To redeem the vault shares token, burning them for the underlying asset the shares must be removed from the deposit tracking account using the withdraw_deposit_tracking
instruction.
For third-party protocols, if you are receiving the vault token directly from another party, then you do not need to withdraw funds from the deposit tracking account, as that will have already been done.
The withdraw_deposit_tracking
is a general instruction used across all V2 vaults, regardless of their type (raydium, orca, atrix, etc…), however the subsequent redemption instructions are “protocol specific” in that each vault type (raydium, orca, atrix, etc…) has a specific set of instructions used to redeem the shares token for the backing underlying assets.
Example anchor program instruction
Example anchor program unit test
When redeeming from the lending optimizer vaults, you must specify the lending protocol which will have the underlying assets removed from. The only restriction is that you may not withdraw more than the currently deposited value from a specific protocol.
For example if the USDC lending optimizer has 500k USDC deposited, with 250k in solend, 200k in tulip, and 50k in mango, you may withdraw up to 250k from solend, up to 200k from tulip, and up to 50k from mango.
The actual withdrawal instruction is the same regardless of which lending protocol you are withdrawing from, however the order of accounts, and the accounts provided will change.
You can see the instruction helper function, as well as comments which explain the order of accounts that must be provided based on the protocol being withdraw from here
Notes:
ProgramType::SplUnmodified
means tulip is being withdrawn fromProgramType::SplModifiedSolend
means solend is being withdrawn fromProgramType::MangoV3
means mango is being withdrawn fromExample anchor unit tests for usdc lending optimizer tulip withdrawal
Example anchor unit tests for usdc lending optimizer mango withdrawal
Example anchor unit tests for usdc lending optimizer solend withdrawal