Prerequisites
Before this page: a connected or embedded EVM wallet (see Connecting external wallets). Earn vault actions are EVM-only today.
What you’ll build
An Earn flow has four parts:
- List vaults and show their APY and curator.
- Show a wallet’s position (shares and asset value) in a vault.
- Deposit / withdraw — sign and submit from the user’s wallet.
- Rewards — show accrued rewards and claim them.
Amounts you pass to depositToYieldVault and withdrawFromYieldVault are human-readable ('10.5' for 10.5 USDC). Amounts the SDK returns (shares, assets, accrued) are raw on-chain units — divide by assetDecimals from getYieldDetails before displaying them.
Listing vaults
listYieldVaults returns every vault the current environment can see, each with a best-effort netApy and tvlUsd.
Showing a wallet’s position
getYieldPosition reads on-chain, so it always reflects current state. Pair it with getYieldDetails to format shares/assets — both are raw units, scaled by assetDecimals.
useGetYieldPosition stays disabled until walletAccount is defined — safe to render before a wallet is connected.
Depositing
depositToYieldVault takes a human-readable amount and does everything else itself: it requests the signing payload, signs it, and broadcasts it. If the wallet’s allowance is short of amount, it signs an ERC-20 approval first — onStepChange tells you which step is running.
Withdrawing
withdrawFromYieldVault is the mirror of deposit, minus the approval step — the wallet is redeeming shares it already holds, so it’s always a single transaction.
Rewards
Read accrued rewards with getYieldRewards, and only show a claim action once at least one entry has a non-zero accrued amount — claimYieldRewards rejects when nothing is claimable.
Handling errors
See also
Last modified on August 26, 2026