Smart Contracts

Following are the smart contracts used by Lucidity:

  • Safe + Lucidity Module

  • Lucidity Registry

  • Flashloan Handler

Safe + Lucidity Module

The smart contracts for Lucidity uses the Safe Core protocol as a base.

Why Safe Core?

  • To be compatible with Account abstraction (AA) and ever-evolving ethereum development landscape.

  • Using the de-facto industry standard for the Smart contracts Wallet ( SCW),

  • Instead of developing SCW-based system from scratch, Safe Core allows to use the Base SCW with customisations via Modules and Guards.

Learn more about the Safe Core protocol here.

The smart contracts for Lucidity are “modules” or “plugins" that extend the functionality of the standard “Safe” (SCW). In v1, there are two main features:

  • Granular Loans

  • Import Positions ( from outside to be part of Lucidity protocol )

These features are implemented in the Lucidity module, which is installed on the Safe wallet of a user.

Upgradable Module

Lucidity Module is an upgradable contract, with plans to support multiple new features like:

  • Cross Chain transactions

  • Fund routing

  • Automation strategies

  • Fee sponsoring mechanisms

The upgradability of the Lucidity module is to support incremental improvements/features in the existing module user Safes, instead of requiring new Safe deployments for each new feature.

Proxy Upgrade Pattern

Proxy is an abstract contract implementing the core delegation functionality.

Our proxy is built on an abstract base contract by Openzeppelin, and we are currently using the Transparent Upgradable Pattern.

Upgrades Via TimeLock

Even though Lucidity module is expected to undergo modifications to support the said features, each upgrade will be deployed through a TimeLock Contract.

  • TimeLocks will be “Admins” for our Proxies

  • Allowd for "scheduling" upgrading implementations

  • Users and all the stakeholders will be notified via all the channels and will be able to analyze the new implementation and verify the upgrade

How does the Lucidity Module work?

Lucidity Module extends the Safe’s existing functionality to support the following:

  • Batch transaction execution

  • Custom transaction verification via Lucidity Registry

  • Initiate flashloan from different flashloan providers, use such funds to execute operations via safe and repay the flashloan at the end.

  • Safe + Wormhole and other bridging infra provider integration for “Cross-chain safe management”.

  • Enable whitelisted handlers in Lucidity Registry to execute transactions on behalf of the user when the user grants the permission. This is required to allow users to subscribe to automation strategies like auto-refinance, auto liquidation protection, etc.

The entire setup of the Lucidity module & Safe ensures, only the owner / whitelisted handler of the safe can send the transactions to the safe. So except the owner and whitelisted handlers, other addresses cannot access the funds / take actions on behalf of the user. Not even the owner of the contracts.

The provision for whitelisted handlers to take actions on behalf of the user is kept to facilitate automation strategies in future.

Lucidity Registry

The protocol uses a central registry inspired from furuCombo architecture. This registry allows the protocol:

  • To whitelist valid handlers.

    • Handlers are the authorised addresses that can execute transaction via Safe on behalf of a Safe’s owner. Safe’s owner is by default a valid handler.

  • To whitelist valid targets.

    • Targets are the authorised addresses that Lucidity Safe’s can interact with.

    • So any contract that is not a valid target cannot be used with Lucidity’s Safe and modules. This allows the protocol to safeguard against malicious contracts and attackers.

  • Interact with Lucidity Module to authorise the transaction to be sent to Safe.

  • Register a safe against an EOA / Owner. This helps the protocol to keep track of Lucidity Safe for an address. An address can have multiple safes associated with it. Lucidity Registry makes it very easy to keep track of which Lucidity’s safe

FlashLoan Handler

Flashloan handlers connects lucidity contracts with Flashloan providers. Lucidity integrates with multiple flashloan handlers:

  • Aave V2 Flashloan Handler

  • Balancer Flashloan Handler ( Coming soon )

  • Morpho Blue Flashloan Handler ( Coming soon )

Users can either allow Lucidity to choose the most effective flashloan handler or they can select the one they prefer to use.

Last updated