Yield Source Adapters
Each yield source (Blend, Kamino, Aave) has a standardized adapter contract that the vault uses to deposit, withdraw, and check balances.
Adapter Interface
rust
/// Standard interface all yield adapters must implement
pub trait YieldAdapter {
/// Deposit assets into the yield source
fn deposit(env: Env, amount: i128) -> i128;
/// Withdraw assets from the yield source
fn withdraw(env: Env, amount: i128) -> i128;
/// Check current balance in the yield source
fn balance_of(env: Env) -> i128;
/// Get current APY (in basis points, e.g., 950 = 9.50%)
fn current_apy(env: Env) -> u32;
}Blend Adapter (Native Stellar)
rust
#[contract]
pub struct BlendAdapter;
#[contractimpl]
impl BlendAdapter {
pub fn deposit(env: Env, amount: i128) -> i128 {
let blend_pool = Self::get_pool_address(&env);
// Call Blend's lending pool deposit
blend_pool::supply(&env, &env.current_contract_address(), amount);
amount
}
pub fn withdraw(env: Env, amount: i128) -> i128 {
let blend_pool = Self::get_pool_address(&env);
blend_pool::withdraw(&env, &env.current_contract_address(), amount);
amount
}
pub fn balance_of(env: Env) -> i128 {
let blend_pool = Self::get_pool_address(&env);
blend_pool::get_balance(&env, &env.current_contract_address())
}
pub fn current_apy(env: Env) -> u32 {
// Fetch from Blend's rate oracle
850 // 8.50% example
}
}Yield Source Registry
The registry contract tracks which adapters are approved, their risk scores, and maximum allocation limits.
rust
pub struct YieldSource {
pub adapter: Address, // Adapter contract address
pub name: String, // "Blend", "Kamino", etc.
pub risk_score: u32, // 1-10 (1 = lowest risk)
pub max_allocation: u32, // Max % of vault this source can hold
pub is_active: bool,
}