Required Instructions
Every adaptor must implement these three core instructions:1. Initialize Instruction
The vault calls this when a strategy is first created. Your adaptor should set up any protocol-specific accounts needed. The vault passes these accounts in order:payer, vault_strategy_auth (signer), strategy, system_program, followed by any remaining accounts.
- Create protocol-specific accounts (e.g. market state, token mints)
- Initialize token accounts (e.g. receipt token ATAs)
- Configure protocol-specific parameters
2. Deposit Instruction
The vault calls this after transferring tokens from idle to thevault_strategy_asset_ata. Your adaptor must deploy those tokens into your protocol and return the current position value as u64.
The vault passes these accounts in order: vault_strategy_auth (signer), strategy, vault_asset_mint, vault_strategy_asset_ata, asset_token_program, followed by any remaining accounts.
u64 is critical — the vault uses it to track the strategy’s position value and calculate P&L.
3. Withdraw Instruction
The vault calls this with the amount of underlying tokens to withdraw. Your adaptor must convert this to the protocol’s units (e.g. receipt tokens), execute the withdrawal, and return the remaining position value asu64.
The vault passes the same account order as deposit: vault_strategy_auth (signer), strategy, vault_asset_mint, vault_strategy_asset_ata, asset_token_program, followed by remaining accounts.
vault_strategy_asset_ata back to idle.
Position Value Calculation
Your adaptor must accurately calculate the position value in underlying token terms. This is theu64 returned by deposit and withdraw. Common patterns:
Additional Instructions
Adaptors are not limited to the three core instructions. Depending on your protocol, you may need:- Multi-step withdrawals — Some protocols (e.g. Drift vaults) require a request/withdraw flow. Add
request_withdrawandcancel_request_withdrawinstructions alongside the corewithdraw. - Reward harvesting — Add
claim_rewardsorharvestinstructions to collect yield, optionally swapping reward tokens back to the vault’s base asset. - Multiple strategy types — A single adaptor can support multiple strategy types within the same protocol. For example, a Drift adaptor can handle vault depositor strategies, spot lending strategies, and curve strategies, each with different instruction sets and seed derivations.
StrategyInitReceipt for position tracking.
Remaining Accounts
Protocol-specific accounts beyond the fixed ones are passed viaremaining_accounts. Common uses:
- Market/oracle data for equity calculations
- Protocol state accounts needed for CPI calls
- Additional token accounts for reward claiming or swaps
ctx.remaining_accounts and can forward them to protocol CPIs or parse them for position calculations.
Error Handling
Define protocol-specific errors for your adaptor:Account Validation Patterns
PDA Verification
Verify protocol accounts using seeds constraints:ATA Verification
Validate associated token accounts:Implementation Checklist
- Implemented core three instructions (Initialize, Deposit, Withdraw)
- Deposit and Withdraw return accurate
u64position values - Strategy account correctly maps to protocol state
- Protocol-specific accounts validated (PDAs, ATAs, ownership)
- Used checked math operations for all arithmetic
- Handled token decimal conversions correctly
- Added any protocol-specific instructions (multi-step withdrawals, reward harvesting, etc.)
- Remaining accounts correctly parsed and forwarded where needed
- Tested deposit, withdraw, and edge cases (zero amount, first deposit)