steth vault is a decentralized ETH leveraged pledge strategy pool. Users can deposit ETH, STETH, and WSETH into the vault to obtain share tokens. The funds in the vault are determined by the cian platform to be allocated to decentralized lending agreements such as AAVE, COMPOUND, and MORPHO, and the leverage strategy of lending ETH to exchange for more STETH increases the holdings of STETH. As time increases, share tokens will be able to redeem more STETH from the vault, thereby realizing user profitability.
Due to the large amount of logic in the vault strategy, a single contract is not enough to meet the required code capacity, so the logic is divided into different functional modules in a way similar to diamond agents. When the strategy contract is called, it will delegate call to different module contracts according to different situations.
The empty contract of the Diamond Proxy integrates the abi of all methods called externally by the strategy, and is compatible with the block browser verification of the EIP-1967 Transparent Proxy contract. When actually calling, it will delegatecall to the corresponding module contract.
The management function module of the strategy contract, including the logic of initializing strategy parameters, adjusting strategy parameters, and appointing a rebalancer.
The leverage function module of the strategy contract includes the functions of adjusting position leverage and deleveraging withdrawal from the strategy leverage pool.
The position migration function module of the strategy contract includes the function of migrating deposits and loans in one lending agreement to another lending agreement at one time.
The user fund entry and exit function module of the strategy contract, the deposit and withdrawal logic of user funds.
The reading function module of the strategy contract is used to read various parameters and position status of the strategy.
Since the abi of each lending agreement is too different, the abi call is unified by writing independent logic that interacts with the lending agreement, and LendingLogic is designed as a replaceable contract to facilitate functional upgrades.
Currently, the most widely used flash loans on the Ethereum mainnet are balancer and aave. Balancer has no flash loan fee, so we will give priority to using it. However, in some cases, there will be a need to complete 1inch exchange and flash loan at the same time in one transaction. If there is a balancer protocol path in the exchange and the balancer flash loan is also used, it will be rejected by the balancer as a reentrant call. Therefore, when a transaction needs to be exchanged with a balancer, the transaction must not use the balancer flash loan. At this time, you can only choose to use aave. The flash loan abi interface of aave and balancer is very different. For the flexibility of contract interaction, FlashloanHelper is used as the transfer contract of flash loan, and the flash loan of which protocol to use is determined by selecting the id.
The entity of the strategy contract, the contract for asset storage and management, when this contract is called, the call logic will delegatecall to each logic contract module.
The implementation logic of the vault contract uses the erc4626 standard.
Entities of the vault contract, use EIP-1967 Transparent Proxy fallback to VaultImplementation.sol In , the user's assets enter and exit through this contract. Provides the function of depositing assets to obtain share tokens and burning share tokens to obtain assets.
Manages upgrades of the Vault.sol contract.
Since the core asset of this vault is STETH, when users need to use other assets to deposit, they need to convert it to STETH first, and the same goes for withdrawing. This contract provides the function of converting ETH, WETH, WSTETH into STETH and depositing them into the vault, and can also be withdrawn as required assets.
The management function module of the strategy contract.
Initialize the performance fee rate, the aggregated steth and debt eth ratio, the mortgage ratio of each lending agreement, the address of the rebalancing executor, the flashloanHelper address, the lendingLogic address, and the address of the performance fee payee.
Allows interaction with a lending protocol
Disable interaction with a lending protocol
Set the client share management contract of the policy pool
Update Performance Fee Payee Address
Update the interaction logic of the lending agreement
Update flash loan transfer contract
Update the address or status of the resizer
Update aggregated collateral ratios
Update the target mortgage rate corresponding to the lending agreement
Extract the performance fee from the strategy pool
The leverage management function module of the strategy contract.
Increase the position in the lending agreement, which can be added collateral or increased leverage or both.
Reducing a position in a lending agreement can be by reducing collateral or reducing leverage or both.
The deleveraging method withdraws funds from the lending agreement to the user, and maintains the collateral ratio basically unchanged after completion.
The amount of WETH that is flash loaned is required to obtain the deleveraging operation.
Transfer a position from one lending agreement to another.
The assets of the vault contract enter the policy management contract, which is called when the user deposits assets.
The assets of the policy management contract are entered into the vault contract, which is called when the user withdraws the assets.
Contains the basic logic of the strategy contract.
Interaction Logic Contract of Lending Protocol
Intermediary contracts for flash loans
Flash loan anti-re-entry sign
Strike Prices for Depositing and Withdrawing Assets
Call the delegatecall of the lending protocol interaction to the LendingLogic contract.
Update the exercise price when users perform asset deposits and withdrawals. The exercise price is used to complete the exchange of core assets and share tokens.
Obtain how much ETH can be lent in a loan agreement without exceeding the ltv. If it is less than this amount, you can avoid using flash loans in the operation to cause additional expenses.
Obtain how much STETH can be withdrawn under the condition that the ltv is not exceeded in a certain loan agreement. If it is less than this amount, the extra overhead caused by the use of flash loans can be avoided in the operation.
Obtain the amount of collateral and borrowing in the lending agreement
Get the net assets in the lending agreement
Obtain the loan and collateral ratio in the lending agreement
Obtain the value ratio of the loan and collateral in the lending agreement in the oracle of the lending agreement
Get the amount of ETH you need to flash loan when adjusting leverage and whether you should increase or decrease leverage
Obtain the asset status of the overall strategy pool
Obtain the net assets of the strategy pool
Get the current actual exchange rate
This contract uses the ERC4626 standard
How many share tokens can be obtained by obtaining the specified amount of STETH
How much STETH can be obtained by obtaining a specified number of share tokens (withdrawal fees also need to be deducted)
Get the withdrawal fee that will be deducted when withdrawing the specified amount of STETH
Obtain the amount of STETH that needs to be swapped when de-leverage withdrawal is required
ERC4626 standard method for obtaining total assets
ERC4626 standard method of depositing assets, the incoming parameter is the amount of STETH
ERC4626 standard asset extraction method, the input parameter is the number of STETH
ERC4626 standard deposit asset method, the incoming parameter is the number of share tokens
ERC4626 standard asset extraction method, the input parameter is the number of share tokens
Withdraw STETH from a lending agreement to deleverage
The user consumes ETH or WETH to exchange for STETH and deposits it in the vault, which needs to be exchanged through 1inch
The user consumes the share token to take out ETH or WETH to the user, which needs to be exchanged through 1inch
The user consumes WstETH and deposits it into the vault to get the share token, which needs to be unwrapped through the WstETH contract
The user consumes share tokens to withdraw WstETH from the vault, which needs to be wrapped through the WstETH contract
The amount of STETH that needs to be exchanged for 1inch to get withdrawal ETH or WETH