VaultWithdraw

[Source]

Redeem vault shares for assets. The number of shares burned or assets received depends on the exchange rate, which adjusts based on the vault’s total assets and any unrealized losses.

Note

The VaultWithdraw transaction does not respect the Permissioned Domain rules. In other words, any account that holds the shares of the vault can redeem them. This is to avoid a situation where a depositor deposits assets to a private vault to then have their access revoked by invalidating their credentials, and thus losing access to their funds.

(Requires the Single Asset Vault amendment )

Example VaultWithdraw JSON

{
  "TransactionType": "VaultWithdraw",
  "Account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
  "Fee": "12",
  "Flags": 0,
  "LastLedgerSequence": 7108682,
  "Sequence": 8,
  "VaultID": "77D6234D074E505024D39C04C3F262997B773719AB29ACFA83119E4210328776",
  "Amount" : "10000",
  "Destination": "ruazs5h1qEsqpke88pcqnaseXdm6od2xc"
}

VaultWithdraw Fields

In addition to the common fields, VaultWithdraw transactions use the following fields:

Field NameJSON TypeInternal TypeRequired?Description
VaultIDStringHash256YesThe unique identifier of the vault to which the assets are deposited.
AmountNumberSTAmountYesThe exact amount of vault asset to withdraw or vault share to redeem.
DestinationStringAccountIDNoAn account to receive the assets. This account must be able to receive the vault asset or the transaction fails.

There are two ways to specify the transaction Amount field:

Specify AssetsSpecify Shares
  • If the Amount field specifies an asset amount (e.g., 100 XRP), the transaction burns the necessary number of shares to provide the requested amount.
  • If the vault has an unrealized loss, withdrawing the same amount of assets requires burning more shares.
  • If the Amount field specifies a share amount (e.g., 500 vault shares), the transaction converts those shares into the corresponding amount of assets.
  • If the vault has an unrealized loss, each share is worth less, meaning fewer assets are received.

VaultWithdraw Flags

There are no flags defined for VaultWithdraw transactions.

Transfer Fees

A single asset vault does not apply the transfer fee to VaultWithdraw transactions. Additionally, whenever a protocol moves assets from or to a vault, the Transfer Fee must not be charged.

Error Cases

Besides errors that can occur for all transactions, VaultWithdraw transactions can result in the following transaction result codes:

Error CodeDescription
tecOBJECT_NOT_FOUNDOccurs if the Vault object with the provided VaultID does not exist on the ledger.
tecFROZENOccurs if the asset is a Fungible Token and the lsfGlobalFreeze flag is set on the issuing account, meaning the asset is frozen.
tecFROZENOccurs if the asset is a Fungible Token and the lsfHighFreeze or lsfLowFreeze flag is set on the trust line between the asset issuer and AccountRoot of the AccountID or Destination.
tecWRONG_ASSETOccurs if the unit of Amount is not a share of the vault.
tecWRONG_ASSETOccurs if the unit of Amount is not the asset of the vault.
tecINSUFFICIENT_FUNDSOccurs if there is insufficient liquidity in the vault to fill the request.