Withdraws assets from an Earn vault, then signs and sends the transaction for you. As with depositToYieldVault, you pass a vaultId and a plain amount like '10.5', and Dynamic looks up the vault’s address and decimal places for you.Unlike a deposit, there’s no approval step first: the wallet already owns its position in the vault, so an EVM withdrawal is always a single transaction.A Solana withdrawal is an ordered sequence of up to three transactions. When the wallet’s shares are staked in the vault’s farm, the sequence starts by unstaking them, then withdraws, and then runs any cleanup the vault program needs. withdrawFromYieldVault signs, sends, and confirms each transaction before it starts the next, and onTransactionStepChange reports progress through the sequence.
The wallet account whose position is being withdrawn. Must be an EVM wallet account for an EVM vault, or a Solana wallet account for a Solana vault.
amount
string
How much of the vault’s underlying asset to withdraw, in the asset’s human-readable units ('10.5' USDC, not '10500000'). Rejected when it carries more precision than the asset supports.
receiverAddress
string (optional)
The address that receives the withdrawn assets. Defaults to walletAccount’s own address. Must equal the wallet’s own address for a Solana vault.
Callback invoked as each transaction of a multi-transaction withdrawal begins, which only happens for Solana vaults. progress has ordinal (zero-based position), total (number of transactions), and an optional label such as 'unstake-from-farm', 'withdraw', or 'post-withdraw'.
sponsored
boolean (optional)
Whether the transaction is gas-sponsored. When omitted, an EVM withdrawal is sponsored if EVM gas sponsorship is enabled and the wallet is a Dynamic embedded wallet, and a Solana withdrawal is not sponsored. false never sponsors. true requires sponsorship and rejects when it is unavailable.
client
DynamicClient (optional)
The Dynamic client instance. Only required when using multiple Dynamic clients.
Promise<{ transactionHash: string }> - The hash of the withdraw transaction. For a Solana vault, this is the signature of the last transaction in the sequence.
For an EVM vault, a resolved withdrawFromYieldVault call means the withdrawal was sent, not that it finished. See Waiting for confirmation before showing a success state to the user.
For an EVM vault, transactionHash is returned as soon as the withdrawal is broadcast to the network, and it can still fail or revert after that. Wait for a receipt before telling the user their withdrawal succeeded:
For a Solana vault, withdrawFromYieldVault polls each transaction until it reaches the confirmed commitment level before it starts the next one, and it resolves only after the last transaction has confirmed. A resolved call therefore means every transaction in the sequence landed, although a confirmed transaction is not yet finalized.All of the transactions in the sequence share one blockhash, which stays valid only briefly, so a user who takes too long to approve can leave a later transaction unsendable. When a transaction fails, expires, or is rejected by the user, withdrawFromYieldVault stops and rejects with a SolanaYieldStepError from @dynamic-labs-sdk/solana. Every transaction before the failed one has already confirmed, so the withdrawal may be partially applied, for example with the shares unstaked from the farm but not yet withdrawn. Read the position with getYieldPosition before you retry. See depositToYieldVault for the error’s properties.
withdrawFromYieldVault supports EVM wallet accounts for EVM vaults and Solana wallet accounts for Solana vaults. Pass a wallet account from the same chain family as the vault’s chainName: the API rejects an address from the other family with an HTTP 400 error. Wallet accounts on other chains are not supported, and a wallet provider that does not implement the underlying executeYieldTransaction method throws a WalletProviderMethodUnavailableError.
useWithdrawFromYieldVault accepts the same parameters, including onTransactionStepChange. It invalidates useGetYieldPosition on success, so the position refetches automatically. That refetch can still briefly show the old balance, since the withdrawal transaction may not be mined yet (see Waiting for confirmation).