CIAN
Search
K

Vault Intro

stETH Vault Description

Overview

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.

Contract overview

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.
StrategyDummyImplementation.sol
AdminModule.sol
LeverageModule.sol
MigrateModule.sol
UserModule.sol
ReadModule.sol
LendingLogic.sol
FlashloanHelper.sol
Strategy.sol
VaultImplementation.sol
Vault.sol
ProxyAdmin.sol
VaultStETHWrapper
StrategyDummyImplementation.sol
0x28C24FF607c4dBe51e09D5d2dD738826FE506157
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.
AdminModule.sol
0xf619f356BfB23d4Ea53bB44c21c04d361E3790C6
The management function module of the strategy contract, including the logic of initializing strategy parameters, adjusting strategy parameters, and appointing a rebalancer.
LeverageModule.sol
0xDca3Ab0D05E0B3AD5570f73b754d0530A566eD84
The leverage function module of the strategy contract includes the functions of adjusting position leverage and deleveraging withdrawal from the strategy leverage pool.
MigrateModule.sol
0x67eB8CF6538b056226D86b6CD67a5612D49EF717
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.
UserModule.sol
0xc170b044E40C58b96bAc975f935FD41aa78D8183
The user fund entry and exit function module of the strategy contract, the deposit and withdrawal logic of user funds.
ReadModule.sol
0x300d5B9fc0E89EDC7534369392917f7cec95B3B1
The reading function module of the strategy contract is used to read various parameters and position status of the strategy.
LendingLogic.sol
0xa0aD94AC894Cdc591cF3419a460CD683bf7792C7
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.
FlashloanHelper.sol
0x6e055d5592E41709C3e70539a2B53933455574Df
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.
Strategy.sol
0x3fD49A8F37E2349A29EA701b56F10f03B08F1532
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.
VaultImplementation.sol
0x40C68480d323919D23AbC9b569a2e98b4d2a7B30
The implementation logic of the vault contract uses the erc4626 standard.
Vault.sol
0xcDd374F491fBF3f4FcF6E9023c99043774005137
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.
ProxyAdmin.sol
0xa2B94C8d55403FB7B163E1aB9F5E0C4Ae691945d
Manages upgrades of the Vault.sol contract.
VaultStETHWrapper.sol
0x4E8e60ccDF79EBaA4189D91b5DC9b0F85df9a427
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.

Core contract

###Strategy
AdminModule.sol
The management function module of the strategy contract.
initialize
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.
enterProtocol
Allows interaction with a lending protocol
exitProtocol
Disable interaction with a lending protocol
####setVault
Set the client share management contract of the policy pool
updateFeeReceiver
Update Performance Fee Payee Address
updateLendingLogic
Update the interaction logic of the lending agreement
updateFlashloanHelper
Update flash loan transfer contract
updateRebalancer
Update the address or status of the resizer
updateSafeAggregatedRatio
Update aggregated collateral ratios
updateSafeProtocolRatio
Update the target mortgage rate corresponding to the lending agreement
collectRevenue
Extract the performance fee from the strategy pool
LeverageModule.sol
The leverage management function module of the strategy contract.
leverage
Increase the position in the lending agreement, which can be added collateral or increased leverage or both.
deleverage
Reducing a position in a lending agreement can be by reducing collateral or reducing leverage or both.
####deleverageAndWithdraw
The deleveraging method withdraws funds from the lending agreement to the user, and maintains the collateral ratio basically unchanged after completion.
getDeleverageAmount
The amount of WETH that is flash loaned is required to obtain the deleveraging operation.
MigrateModule.sol
migrate
Transfer a position from one lending agreement to another.
UserModule.sol
deposit
The assets of the vault contract enter the policy management contract, which is called when the user deposits assets.
withdraw
The assets of the policy management contract are entered into the vault contract, which is called when the user withdraws the assets.
basic.sol
Contains the basic logic of the strategy contract.
lendingLogic
Interaction Logic Contract of Lending Protocol
flashloanHelper
Intermediary contracts for flash loans
executor
Flash loan anti-re-entry sign
exchangePrice
Strike Prices for Depositing and Withdrawing Assets
executeLendingLogic
Call the delegatecall of the lending protocol interaction to the LendingLogic contract.
updateExchangePrice
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.
getAvailableBorrowsETH
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.
getAvailableWithdrawsStETH
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.
getProtocolAccountData
Obtain the amount of collateral and borrowing in the lending agreement
getProtocolNetAssets
Get the net assets in the lending agreement
getProtocolRatio
Obtain the loan and collateral ratio in the lending agreement
getProtocolCollateralRatio
Obtain the value ratio of the loan and collateral in the lending agreement in the oracle of the lending agreement
getProtocolLeverageAmount
Get the amount of ETH you need to flash loan when adjusting leverage and whether you should increase or decrease leverage
getNetAssetsInfo
Obtain the asset status of the overall strategy pool
getNetAssets
Obtain the net assets of the strategy pool
getCurrentExchangePrice
Get the current actual exchange rate

Vault

vault.sol
This contract uses the ERC4626 standard
convertToShares
How many share tokens can be obtained by obtaining the specified amount of STETH
convertToAssets
How much STETH can be obtained by obtaining a specified number of share tokens (withdrawal fees also need to be deducted)
getWithdrawFee
Get the withdrawal fee that will be deducted when withdrawing the specified amount of STETH
getDeleverageWithdrawFee
Obtain the amount of STETH that needs to be swapped when de-leverage withdrawal is required
####totalAssets
ERC4626 standard method for obtaining total assets
deposit
ERC4626 standard method of depositing assets, the incoming parameter is the amount of STETH
withdraw
ERC4626 standard asset extraction method, the input parameter is the number of STETH
####mint
ERC4626 standard deposit asset method, the incoming parameter is the number of share tokens
redeem
ERC4626 standard asset extraction method, the input parameter is the number of share tokens
####deleverageWithdraw
Withdraw STETH from a lending agreement to deleverage

Peripheral contract

VaultStETHWrapper

VaultStETHWrapper.sol
deposit
The user consumes ETH or WETH to exchange for STETH and deposits it in the vault, which needs to be exchanged through 1inch
withdraw
The user consumes the share token to take out ETH or WETH to the user, which needs to be exchanged through 1inch
depositWstETH
The user consumes WstETH and deposits it into the vault to get the share token, which needs to be unwrapped through the WstETH contract
withdrawWstETH
The user consumes share tokens to withdraw WstETH from the vault, which needs to be wrapped through the WstETH contract
getWithdrawSwapAmount
The amount of STETH that needs to be exchanged for 1inch to get withdrawal ETH or WETH