Overview

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](<https://github.com/sol-farm/tulipv2-sdk/blob/68f6d150fcd7f6b06e737ceb727eb8e60e7a4595/vaults/src/instructions/mod.rs#L89>) 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

Redemption Instructions

Lending Optimizers

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:

Example 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