Skip to content

Vault

[Source]

Attention

Lending Protocol and Single Asset Vaults are disabled on Devnet. You have two options for testing these features:

  1. Run rippled in stand-alone mode and enable LendingProtocol and SingleAssetVault in the rippled.cfg file.
  2. Connect to the Lending Protocol-specific Devnet at https://lend.devnet.rippletest.net:51234/.

A Vault object defines the state of a tokenized vault. It contains key details such as available assets, shares, total value, and other relevant information. You can create a Vault object with the VaultCreate transaction.

The Vault object is tracked in an Owner Directory owned by the Vault Owner account. Additionally, to facilitate Vault object lookup, the object is tracked in the owner directory of the vault's pseudo-account.

(Requires the Single Asset Vault amendment )

Example Vault JSON

{
  "LedgerEntryType": "Vault",
  "Account": "rwCNM7SeUHTajEBQDiNqxDG8p1Mreizw85",
  "Asset": {
      "currency": "USD",
      "issuer": "rXJSJiZMxaLuH3kQBUV5DLipnYtrE6iVb"
  },
  "AssetsAvailable": "0",
  "AssetsMaximum": "1000000",
  "AssetsTotal": "0",
  "Data": "5661756C74206D65746164617461",
  "Flags": 0,
  "LossUnrealized": "0",
  "Owner": "rNGHoQwNG753zyfDrib4qDvvswbrtmV8Es",
  "OwnerNode": "0",
  "Scale": 6,
  "Sequence": 200370,
  "ShareMPTID": "0000000169F415C9F1AB6796AB9224CE635818AFD74F8175",
  "WithdrawalPolicy": 1,
}

Vault Fields

In addition to the common ledger entry fields, Vault entries have the following fields:

NameJSON TypeInternal TypeRequired?Description
LedgerEntryTypeStringUInt16YesLedger object type. The default value is 0x0081.
LedgerIndexStringUInt16YesThe unique identifier of the ledger object.
FlagsStringUInt32YesSet of bit-flags for this ledger object.
PreviousTxnIDStringHash256YesIdentifies the transaction ID that most recently modified this object.
PreviousTxnLgrSeqNumberUInt32YesThe sequence of the ledger that contains the transaction that most recently modified this object.
SequenceNumberUInt32YesThe transaction sequence number that created the vault.
OwnerNodeNumberUInt64YesIdentifies the page where this item is referenced in the owner's directory.
OwnerStringAccountIDYesThe account address of the Vault Owner.
AccountStringAccountIDYesThe address of the vault's pseudo-account.
DataStringBlobNoArbitrary metadata about the vault. Limited to 256 bytes.
AssetObjectIssueYesThe asset of the vault. The vault supports XRP, trust line tokens, and MPTs.
AssetsTotalNumberNumberYesThe total value of the vault.
AssetsAvailableNumberNumberYesThe asset amount that is available in the vault.
AssetsMaximumNumberNumberNoThe maximum asset amount that can be held in the vault. If set to 0, this indicates there is no cap.
LossUnrealizedNumberNumberYesThe potential loss amount that is not yet realized, expressed as the vault's asset. Only a protocol connected to the vault can modify this attribute.
ShareMPTIDStringUInt192YesThe identifier of the share MPTokenIssuance object.
WithdrawalPolicyStringUInt8YesIndicates the withdrawal strategy used by the vault.
ScaleNumberUInt8NoSpecifies decimal precision for share calculations. Assets are multiplied by 10Scale to convert fractional amounts into whole number shares. For example, with a Scale of 6, depositing 20.3 units creates 20,300,000 shares (20.3 × 10Scale). For trust line tokens this can be configured at vault creation, and valid values are between 0-18, with the default being 6. For XRP and MPTs, this is fixed at 0.

Scaling Factor

The Scale field enables the vault to accurately represent fractional asset values using integer-only MPT shares, which prevents the loss of value from decimal truncation. It defines a scaling factor, calculated as 10Scale, that converts a decimal asset amount into a corresponding whole number of shares.

The scaling factor behavior varies by asset type:

  • Trust line token: When a vault holds a trust line token, the Scale is configurable by the Vault Owner when creating the vault. The value can range from 0 to a maximum of 18, with a default of 6. This flexibility allows issuers to set a level of precision appropriate for their specific token.

  • XRP: When a vault holds XRP, the Scale is fixed at 0. This aligns with XRP's native structure, where one share represents one drop, and one XRP equals 1,000,000 drops. Therefore, a deposit of 10 XRP to an empty vault will result in the issuance of 10,000,000 shares.

  • MPT: When a vault holds an MPT, its Scale is fixed at 0. This creates a 1-to-1 relationship between deposited MPT units and the shares issued. For example, depositing 10 MPTs to an empty vault issues 10 shares. The value of a single MPT is determined at the issuer's discretion.

    Warning

    If an MPT is set to represent a large value, the vault owner and the depositor must be cautious. Since only whole MPT units are used in calculations, any value that is not a multiple of a single MPT's value may be lost due to rounding during a transaction.

Vault Flags

Vault entries can have the following flags:

Flag NameFlag ValueDescription
lsfVaultPrivate0x00010000If set, indicates that the vault is private. This flag can only be set when creating the vault.

Vault ID Format

The ID of a Vault entry is the SHA512-Half of the following values, concatenated in order:

  • The Vault space key 0x0056 (capital V).
  • The AccountID of the account submitting the transaction (for example, the vault owner) .
  • The transaction Sequence number. If the transaction used a Ticket, use the TicketSequence value.