depositToYieldVault
Deposits assets into an Earn vault, then signs and sends the resulting transaction. Unlike a swap, this is a single call — Dynamic resolves the vault’s contract address and the underlying asset’s decimals server-side, so you pass avaultId and a human-readable amount rather than fetching a quote and executing it yourself.
When the wallet’s current allowance for the vault is short of amount, an ERC-20 approval is signed and sent first. onStepChange reports which step is in flight so you can reflect it in the UI.
Usage
Parameters
Returns
Promise<{ transactionHash: string }> - The hash of the deposit transaction.
Step Lifecycle
Examples
With progress UI
This example uses React; the JavaScript SDK is framework-agnostic and can be used with any frontend or in Node.
Supported Chains
depositToYieldVault only supports EVM wallet accounts — vault actions are EVM-only today. Calling it with a non-EVM walletAccount throws a WalletProviderMethodUnavailableError, since only EVM wallet providers implement the underlying executeYieldTransaction method.
React
useDepositToYieldVault invalidates useGetYieldPosition on success — treat that refetch as a nudge, since the deposit is only broadcast (not necessarily mined) when the mutation resolves.
Related
withdrawFromYieldVault- Withdraw from a vaultgetYieldPosition- Read the resulting positionlistYieldVaults- Find a vault to deposit into