Skip to content

Yield Rotation Walkthrough

This walkthrough is based on examples/yield-rotation.

  1. Fetch rates across providers
  2. Pick the highest-APY vault
  3. Execute a dry-run deposit
  4. Optionally compare Solana and EVM opportunities
Terminal window
pnpm --filter @stendar/example-yield-rotation demo

Optional env vars:

  • SOLANA_RPC_URL, WALLET_PRIVATE_KEY
  • EVM_RPC_URL, EVM_CHAIN_ID (for cross-chain comparison)
  • RUN_YIELD_ROTATION_STRATEGY=true (to load strategy.yaml)
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.