Yield Rotation Walkthrough
This walkthrough is based on examples/yield-rotation.
- Fetch rates across providers
- Pick the highest-APY vault
- Execute a dry-run deposit
- Optionally compare Solana and EVM opportunities
pnpm --filter @stendar/example-yield-rotation demoOptional env vars:
SOLANA_RPC_URL,WALLET_PRIVATE_KEYEVM_RPC_URL,EVM_CHAIN_ID(for cross-chain comparison)RUN_YIELD_ROTATION_STRATEGY=true(to loadstrategy.yaml)
Core runtime pattern
Section titled “Core runtime pattern”import { TokenRegistry } from '@stendar/core';
const chainId = 'solana-mainnet';const usdc = new TokenRegistry().resolveToken('USDC', chainId);const rates = await runtime.getYieldRates({ chain: chainId, token: usdc });const bestVault = rates.sort((a, b) => b.apy - a.apy)[0];
if (bestVault) { await runtime.executeDeposit({ token: usdc, amount: 1_000_000n, vault: bestVault.vault, chain: chainId, dryRun: true, });}For full routing-aware optimization, combine this with Best execution and provider-specific risk controls from Security.