Skip to main content

Overview

Earn lets a user’s EVM wallet deposit into a yield vault, track what the position is worth, claim reward campaigns, and withdraw. The dynamic_sdk_earn package wraps the Earn API and signs and broadcasts the transactions it returns. For how vaults, shares, and yield work, see the Earn overview. Every Earn call returns an unsigned payload. You sign and broadcast it with execute, which sends the ERC-20 approval first and waits for it to confirm whenever the payload carries one.

Prerequisites

  • Dynamic SDK initialized (see Quickstart)
  • User authenticated (see Authentication)
  • An EVM wallet (see Wallet Creation). Earn is EVM only.
  • Earn enabled for your environment in the Dynamic dashboard. Until it is, every call throws an EarnException with statusCode 403.

Install

Earn is available on the SDK instance as DynamicSDK.instance.earn:

Browse vaults

listVaults returns the vaults your environment can access. getVaultDetails adds the on-chain fields you need to display and transact against one, including assetDecimals.
netApy and tvlUsd come from live market data on a best-effort basis, so both are null when that data is unavailable.

Read a position

A position holds shares and assets, both in raw token units. Show assets: it grows as yield accrues, while shares stays flat.

Read rewards

Rewards are a separate bonus some vaults pay in another token. They sit unclaimed until you claim them, unlike base yield, which shows up as assets growing.
The list is empty when the wallet has accrued nothing in the vault.

Deposit

deposit builds the payload, execute sends it. amount is human-readable, so '12.5' deposits 12.5 USDC.
execute returns the vault transaction hash. When the payload carries an evmApproval, it sends that approval first and waits for its receipt, so onStepChange reports approval before transaction. To send the shares to a different wallet, set receiverAddress on the request. It defaults to ownerAddress.

Withdraw

Withdrawals redeem shares the wallet already holds, so they never need an approval.

Claim rewards

Amount units

Amounts cross the wire as strings in two different units:
  • EarnVaultActionRequest.amount is human-readable: '12.5' means 12.5 USDC.
  • EarnVaultPosition, EarnVaultReward, and the amounts inside a signing payload are raw token units. They can exceed a Dart int, so parse them with BigInt.parse.
Mixing the two units up silently transacts the wrong value. Human-readable amounts also need a leading zero: '0.01' works, '.01' is rejected by the API.

Handle errors

Every failed Earn call throws an EarnException carrying the HTTP statusCode:
execute also throws an EarnException when the wallet is not EVM, when the payload carries no transaction, or when the approval reverts or is not confirmed in time.

Next steps

Last modified on September 9, 2026