Core Components Implementation
Core Components Guide
This guide details the essential components and instructions required to implement a Voltr adaptor. Each adaptor must implement these core components to maintain compatibility with the Voltr vault system.
Required Instructions
Every adaptor must implement these three core instructions:
1. Initialize Instruction
pub struct Initialize<'info> {
/// The payer for account creation
#[account(mut)]
pub payer: Signer<'info>,
/// Vault's strategy authority
#[account(mut)]
pub vault_strategy_auth: Signer<'info>,
/// The strategy account
#[account(
seeds = [constants::STRATEGY_SEED, strategy.load()?.counterparty_asset_ta.key().as_ref()],
bump = strategy.load()?.bump
)]
pub strategy: AccountLoader<'info, Strategy>,
pub system_program: Program<'info, System>,
/// The protocol's program ID
/// CHECK: Validated in handler
#[account(constraint = protocol_program.key() == strategy.load()?.protocol_program)]
pub protocol_program: AccountInfo<'info>,
}Key responsibilities:
Create protocol-specific accounts
Initialize state tracking
Setup token accounts if needed
Configure protocol-specific parameters
2. Deposit Instruction
Required functionality:
Validate deposit amount
Handle token transfers
Interact with protocol
Track position value
Return final position amount
3. Withdraw Instruction
Required functionality:
Validate withdrawal amount
Handle protocol withdrawal
Transfer tokens back to vault
Update position tracking
Return final position amount
State Management
Strategy Account
Strategy Type Definition
Position Value Calculation
Your adaptor must implement accurate position value calculations:
Error Handling
Implement comprehensive error handling:
Account Validation Patterns
Token Account Validation
Protocol Account Validation
Implementation Checklist
Before deploying your adaptor, ensure you have:
Security Requirements
Account Validation
Always validate account ownership
Check PDA derivation
Verify token account authorities
Validate protocol accounts
Amount Validation
Use checked math operations
Handle decimal conversions safely
Validate against protocol limits
Check for overflows
State Updates
Update position values atomically
Maintain consistent state
Handle failed transactions
Track version numbers
Last updated