Vault contract
The Vault is an fundamental smart contract within the shift ecosystem, primarily designed to enable users to deposit funds and allocate them to various investment strategies, called as DEFIIs. It designed in accordance with the ERC721 non-fungible token standard, granting users an NFT as a record of their deposited funds. This NFT acts as an account ledger, where stored the user’s ERC20 tokens balances.
The Vault offers the capability to automate the process of entering DEFIIs by allowing users to delegate access rights to an operator. This necessitates users granting the operator permission to manage their position within the OperatorRegistry contract, along with covering the transaction fees for entering DEFIIs.
Deposits into DEFIIs must be made with a notion token to ensure correct functionality. Users need to deposit this specific token into the Vault. To support user convenience, a Router smart contract is included as part of the broader ecosystem. This Router allows users to enter the Vault with any ERC20 token supported by a swap router.
View functions
NOTION
Returns the notion of the vault
Returns the address of the OperatorRegistry contract.
calculateDefiiEnterAmount
Returns the amount of tokens for depositing into a specific DEFII from a specific position. During the deposit into the Vault, the number of notion tokens available for deposit from a specific position is specified. Each DEFII in the Vault has a predefined weight, which determines the share of the position that will be deposited into a specific DEFII.
calculateDefiiExitShares
Returns the amount of DEFII LP tokens to be withdrawn from a specific DEFII for a given position. Before the withdrawal, the user or operator specifies the percentage of shares they intend to withdraw. The weight of DEFII is set during the deployment of the Vault and remains unchanged thereafter.
getDefiis
Returns a list of all DEFIIs in the Vault.
getPositionStatus
Write functions
deposit
token
address
Token address
amount
uint256
Amount of deposited tokens
operatorFeeAmount
uint256
Operator fee. User pays fee for transaction processing
depositToPosition
Deposits tokens into existing position in Vault.
positionId
uint256
Position Id for deposit.
token
address
Deposited token
amount
uint256
Amount of deposited tokens
operatorFeeAmount
uint256
Operator fee. User pays fee for transaction processing.
depositWithPermit
token
address
Deposited token
amount
uint256
Amount of deposited tokens
operatorFeeAmount
uint256
Operator fee. User pays fee for transaction processing.
deadline
uint256
Permit deadline
permitV
uint8
Permit V parameter
permitR
bytes32
Permit R paramter
permitS
bytes32
Permit S parameter
enterCallback
The function increases the DEFII LP balance for a position and changes the DEFII's status in the position to PROCESSING after entry into an external protocol. It is called by the DEFII after entering the external protocol. The DEFII's status in the position affects the position's status.
positionId
uint256
Position Id for which enter in DEFII was made.
shares
uint256
Amount for shares were deposited into DEFII
exitCallback
The function changes the DEFII's status to PROCESSED. It is called after exiting from the DEFIl. The DEFII's status in the position affects the position's status.
positionId
uint256
Position Id for which exit in DEFII was made.
enterDefii
Entering a specific DEFII. It can be called by the position owner or an operator with access granted by the owner. The function calculates the amount of notion tokens for entry, changes the DEFII's status within the position, and triggers the entry logic into DEFII.
defii
address
DEFII address
positonId
uint256
Position Id
instructions
Instruction[]
Array of entering instructions. It is can be swap, bridge, slippage protection instructions for enter in DEFII.
exitDefii
Exiting from a specific DEFII. It can be initiated by the position owner or an operator granted access by the position owner. It calculates the amount of DEFII LP tokens for withdrawal, updates the DEFII's status within the position, decreases the user's DEFII LP balance, and triggers the exit logic.
defii
address
Address of DEFII
positonId
uint256
Position Id
instructions
Instruction[]
Array of exit instructions. It is can be swap, bridge, slippage protection instructions for exit from DEFII.
startExit
Sets the percentage of DEFII LP tokens to be withdrawn from DEFII.
percentage
uint256
Percent of user’s funds for exit from vault.
withdraw
Returns the owner of the position an amount of tokens from the position. It can be called by the owner of the position or an operator with access to the position.
token
address
Token for withdraw
amount
uint256
Amount of token for withdraw
positionId
uint256
Position Id from which user want to withdraw. If msg.sender ≠ positionOwner, msg.sender should have approve from positionOwner.
withdrawLiquidity
Burns the user's DEFII LP tokens and directly withdraws liquidity to the owner of the position.
positionId
uint256
Position Id from which user want to withdraw. If msg.sender ≠ positionOwner, msg.sender should have approve from positionOwner.
defii
address
Address of defii to withdraw
instructions
Instruction[]
Set of instructions to withdraw liquidity.
Last updated