OptyFi's smart contracts can execute generalized multi-step yield strategies while enforcing risk constraints.
Each vault calls upon the Strategy Manager contract to execute the optimal strategy. The Risk Manager contract ensures that only strategies matching the vault's risk profile can be executed. DeFi Adapters provide interfaces to the various DeFi protocols.
OptyFi implements a "hub-and-spoke" architecture with the core contracts (Registry, Strategy Manager, Risk Manager) forming the central hub and vaults and DeFi Adapters forming the spokes. This design makes OptyFi easily extensible by adding vaults for new assets or adding DeFi adapters for new protocols and integrated liquidity pools.
The Strategy Manager contract is able to generate code for any generalized multi-step strategy (including strategies with a borrow step). However, the Strategy Manager does not execute this code but rather returns this code to the vault which then executes the strategy. This security feature ensures that at each strategy step, assets (input tokens and output tokens of the strategy) always remain in the vault and are not transferred between OptyFi contracts.
The Strategy Manager does not know how to interact with the various DeFi pools. For this purpose, it calls upon OptyFi's DeFi Adapters. The Strategy Manager also calls upon the Risk Manager to enforce risk constraints.
Prior to returning the strategy execution code to a vault, the Strategy Manager calls upon the Risk Manager contract to check that the strategy about to be executed:
- only includes liquidity pools approved by governance.
- matches the vault's risk profile.
If these checks fail, the strategy will not be executed.
The Risk Manager enables OptyFi to enforce risk constraints in real time. For example, consider the case where pool ratings are being provided by a credit risk oracle service and a given pool is downgraded from Invest to Earn. In such a case, the Risk Manager will "block" in real time any Earn strategies.