Vaults V2 Migration Technical Info
Technical Aspects of the Vaults Update
Migration Smart Contract
Migration Contracts Addresses:
for Locus Yield ETH: 0xd25d0de43579223429c28f2d64183a47a79078C7
for DeFi Core Index: 0xf42402303BCA9d5575A8aC7b90CB18026c80354D
for Arbitrum Yield Index: 0xC7469254416Ad546A5F07e5530a0c3eA468F1FCE
The process works as follows:
1. You need to approve the funds transfer to our migration contract.
2. We will then execute a withdraw
function that moves your approved tokens from the vault to the migration contract
3. Afterward, we execute a deposit
function, transferring the funds to the new vault. From this point on, the migration contract will manage all share tokens and safeguard your portion of these tokens.
Migration Smart Contract
Please note that the final smart contract may differ slightly; before announcing requests, we will attach the final version
Valuable points
1. Before approval you can check yourself in array users, that you are in the list of migrating users
2. We made such architecture, that everyone can easily do this process yourself. We did that to exclude the case in your mind, that we can withdraw but not deposit.
3. There's an emergency withdraw
function that moves all funds to the treasury address. You can check this address before giving your approval
4. We've also included a function to add users in case we unintentionally miss someone. Importantly, we can only add new addresses and cannot remove old ones.
5. There's a single onlyOwner
modifier, which means only we can initiate specific functions such as adding users and initiating emergency withdrawals
6. This contract is not upgradeable, so we canât change logic after deploy
Variables
vaultV1
- Address of the old vault.
vaultV2
- Address of the new vault.
token
- Address of the want token (USDC/USDT/etc).
treasury
- Address of the treasury.
users
- List of users who are intended to be migrated.
userToBalance
- Mapping that tracks users' balances. After calling the withdraw function, you can easily verify your migration status by checking your balance. If it's greater than 0, your money was successfully withdrawn.
notWithdrawnUsers
- List of users who haven't approved their tokens for migration. This list is used to track users who will be withdrawn later using the `withdrawUsersWithDetectedError` function.
Initialization
In this step, we set up all the important addresses: treasury, old vault (vaultV1
), new vault (vaultV2
), the token we're working with, and the list of users who want to migrate their assets. We also handle approvals to save on transaction fees. If there's an emergency, we have extra approval from the treasury.
Functions
addUsers
- This function enables us to add more users to the list of migrating addresses.
withdraw
- This core function allows us to withdraw funds from the old vault. Our vault's security is robust, preventing us from withdrawing funds directly. Instead, we require all users to exit the old vault by providing their share tokens for migration to the new vault. We iterate over all users on the list, verifying if they have a balance. We also check if the user has given us approval. If not, we add them to the list of addresses without approval for later migration when they are approved. Afterward, we transfer the user's share tokens from their account to the migration contract and update the user's balance. Once we've processed all users, we initiate a withdrawal from vault V1 to the migration contract.
withdrawUsersWithDetectedError
- This function allows us to migrate users who didn't provide approval for the initial withdrawal. The logic is similar to the regular withdrawal, but here we iterate over a separate list of users. If a user still hasn't given approval, we skip them for the next round of migration (in waves). This approach helps us optimize the function call's cost, as iterating over the entire list of users can be more expensive, especially on Ethereum.
deposit
- Simply deposit all assets from the migration contract into vault V2. We don't need to make multiple deposit function calls with specific recipients because we're tracking balances and can do this in waves.
emergencyExit
- This function is used when we decide to transfer all assets on the contract to the treasury. This can occur in an emergency situation or in response to an attack attempt.
Last updated