diff --git a/XLS-0065-single-asset-vault/README.md b/XLS-0065-single-asset-vault/README.md index 4f8c39d6..d2bb6043 100644 --- a/XLS-0065-single-asset-vault/README.md +++ b/XLS-0065-single-asset-vault/README.md @@ -8,54 +8,23 @@ category: Amendment requires: [XLS-33](../XLS-0033-multi-purpose-tokens/README.md) created: 2024-04-12 - updated: 2025-11-17 + updated: 2026-04-27 # Single Asset Vault -## _Abstract_ +## 1. Abstract A Single Asset Vault is a new on-chain primitive for aggregating assets from one or more depositors, and making the assets available for other on-chain protocols. The Single Asset Vault uses [Multi-Purpose-Token](../XLS-0033-multi-purpose-tokens/README.md) to represent ownership shares of the Vault. The Vault serves diverse purposes, such as lending markets, aggregators, yield-bearing tokens, asset management, etc. The Single Asset Vault decouples the liquidity provision functionality from the specific protocol logic. -## Index - -- [**1. Introduction**](#1-introduction) - - [**1.1. Feature Overview**](#11-overview) - - [**1.2. Terminology**](#12-terminology) - - [**1.3. Actors**](#13-actors) - - [**1.4 Connecting to the Vault**](#14-connecting-to-the-vault) -- [**2. Ledger Entries**](#2-ledger-entries) - - [**2.1. `Vault` Ledger Entry**](#21-vault-ledger-entry) - - [**2.1.1. Object Identifier**](#211-object-identifier) - - [**2.1.2. Fields**](#212-fields) - - [**2.1.3. Vault _pseudo-account_**](#213-vault-_pseudo-account_) - - [**2.1.4. Ownership**](#214-ownership) - - [**2.1.5. Owner Reserve**](#215-owner-reserve) - - [**2.1.6. Vault Shares**](#216-vault-shares) - - [**2.1.7. Exchange Algorithm**](#217-exchange-algorithm) -- [**3. Transactions**](#3-transactions) - - [**3.1. VaultCreate, VaultSet & VaultDelete Transactions**](#31-vaultcreate-vaultset-vaultdelete-transactions) - - [**3.1.1. VaultCreate Transaction**](#311-vaultcreate-transaction) - - [**3.1.2. VaultSet Transaction**](#312-vaultset-transaction) - - [**3.1.3. VaultDelete Transaction**](#313-vaultdelete-transaction) - - [**3.2. VaultDeposit & VaultWithdraw Transactions**](#32-vaultdeposit-and-vaultwithdraw-transactions) - - [**3.2.1. VaultDeposit Transaction**](#321-vaultdeposit-transaction) - - [**3.2.2. VaultWithdraw Transaction**](#322-vaultwithdraw-transaction) - - [**3.3. VaultClawback Transaction**](#33-vaultclawback-transaction) - - [**3.4. Payment Transaction**](#34-payment-transaction) -- [**4. API**](#4-api) - - [**4.1. RPC `vault_info`**](#41-rpc-vault_info) - - [**4.2. RPC `vault_list`**](#42-rpc-vault_list) -- [Appendix](#appendix) - -## 1. Introduction - -### 1.1 Overview +## 2. Introduction The **Single Asset Vault** is an on-chain object that aggregates assets from one or more depositors and represents ownership through shares. Other protocols, such as the [Lending Protocol](../XLS-0066-lending-protocol/README.md), can access these assets via the vault, whether or not they generate yield. Currently, other protocols must be created by the same Account that created the Vault. However, this may change in the future. The specification introduces a new `Vault` ledger entry, which contains key details such as available assets, shares, total value, and other relevant information. +### 2.1. Transactions + The specification includes the following transactions: **Vault Management**: @@ -73,42 +42,40 @@ Additionally, an issuer can perform a **Clawback** operation: - **`VaultClawback`**: Allows the issuer of an IOU or MPT to claw back funds from the vault, as outlined in the [Clawback documentation](https://xrpl.org/docs/use-cases/tokenization/stablecoin-issuer#clawback). -#### 1.1.1 Vault Ownership and Management +### 2.2. Vault Ownership and Management A Single Asset Vault is owned and managed by an account called the **Vault Owner**. The account is reponsible for creating, updating and deleting the Vault object. -#### 1.1.2 Access Control +### 2.3. Access Control A Single Asset Vault can be either public or private. Any depositor can deposit and redeem liquidity from a public vault, provided they own sufficient shares. In contrast, access to private shares is controlled via [Permissioned Domains](../XLS-0080-permissioned-domains/README.md), which use on-chain [Credentials](../XLS-0070-credentials/README.md) to manage access to the vault. Only depositors with the necessary credentials can deposit assets to a private vault. To prevent Vault Owner from locking away depositor funds, any shareholder can withdraw funds. Furthermore, the Vault Owner has an implicit permission to deposit and withdraw assets to and from the Vault. I.e. they do not have to have credentials in the Permissioned Domain. -#### 1.1.3 Yield Bearing Shares +### 2.4. Yield Bearing Shares Shares represent the ownership of a portion of the vault's assets. On-chain shares are represented by a [Multi-Purpose Token](../XLS-0033-multi-purpose-tokens/README.md). When creating the vault, the Vault Owner can configure the shares to be non-transferable. Non-transferable shares cannot be transferred to any other account -- they can only be redeemed. If the vault is private, shares can be transferred and used in other DeFi protocols as long as the receiving account is authorized to hold the shares. The vault's shares may be yield-bearing, depending on the protocol connected to the vault, meaning that a holder may be able to withdraw more (or less) liquidity than they initially deposited. -### 1.2 Terminology +### 2.5. Terminology - **Vault**: A ledger entry for aggregating liquidity and providing this liquidity to one or more accessors. - **Asset**: The currency of a vault. It is either XRP, a [Fungible Token](https://xrpl.org/docs/concepts/tokens/fungible-tokens/) or a [Multi-Purpose Token](../XLS-0033-multi-purpose-tokens/README.md). - **Share**: Shares represent the depositors' portion of the vault's assets. Shares are a [Multi-Purpose Token](../XLS-0033-multi-purpose-tokens/README.md) created by the _pseudo-account_ of the vault. -### 1.3 Actors +### 2.6. Actors - **Vault Owner**: An account responsible for creating and deleting The Vault. - **Depositor**: An entity that deposits and withdraws assets to and from the vault. -### 1.4 Connecting to the Vault +### 2.7. Connecting to the Vault A protocol connecting to a Vault must track its debt. Furthermore, the updates to the Vault state when funds are removed or added back must be handled in the transactors of the protocol. For an example, please refer to the [Lending Protocol](../XLS-0066-lending-protocol/README.md) specification. -[**Return to Index**](#index) - -## 2. Ledger Entries +## 3. Specification -### 2.1 `Vault` Ledger Entry +### 3.1 Ledger Entry: `Vault` The **`Vault`** ledger entry describes the state of the tokenized vault. -#### 2.1.1 Object Identifier +#### 3.1.1 Object Identifier The key of the `Vault` object is the result of [`SHA512-Half`](https://xrpl.org/docs/references/protocol/data-types/basic-data-types/#hashes) of the following values concatenated in order: @@ -116,83 +83,81 @@ The key of the `Vault` object is the result of [`SHA512-Half`](https://xrpl.org/ - The [`AccountID`](https://xrpl.org/docs/references/protocol/binary-format/#accountid-fields) of the account submitting the `VaultSet`transaction, i.e.`VaultOwner`. - The transaction `Sequence` number. If the transaction used a [Ticket](https://xrpl.org/docs/concepts/accounts/tickets/), use the `TicketSequence` value. -#### 2.1.2 Fields +#### 3.1.2 Fields A vault has the following fields: -| Field Name | Modifiable? | Required? | JSON Type | Internal Type | Default Value | Description | -| ------------------- | :---------: | :----------------: | :----------------: | :-----------: | :-----------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- | -| `LedgerEntryType` | `N/A` | :heavy_check_mark: | `string` | `UINT16` | `0x0084` | Ledger object type. | -| `LedgerIndex` | `N/A` | :heavy_check_mark: | `string` | `UINT16` | `N/A` | Ledger object identifier. | -| `Flags` | `Yes` | :heavy_check_mark: | `string` | `UINT32` | 0 | Ledger object flags. | -| `PreviousTxnID` | `N/A` | :heavy_check_mark: | `string` | `HASH256` | `N/A` | Identifies the transaction ID that most recently modified this object. | -| `PreviousTxnLgrSeq` | `N/A` | :heavy_check_mark: | `number` | `UINT32` | `N/A` | The sequence of the ledger that contains the transaction that most recently modified this object. | -| `Sequence` | `N/A` | :heavy_check_mark: | `number` | `UINT32` | `N/A` | The transaction sequence number that created the vault. | -| `OwnerNode` | `N/A` | :heavy_check_mark: | `number` | `UINT64` | `N/A` | Identifies the page where this item is referenced in the owner's directory. | -| `Owner` | `No` | :heavy_check_mark: | `string` | `AccountID` | `N/A` | The account address of the Vault Owner. | -| `Account` | `N/A` | :heavy_check_mark: | `string` | `ACCOUNTID` | `N/A` | The address of the Vaults _pseudo-account_. | -| `Data` | `Yes` | | `string` | `BLOB` | None | Arbitrary metadata about the Vault. Limited to 256 bytes. | -| `Asset` | `No` | :heavy_check_mark: | `string or object` | `ISSUE` | `N/A` | The asset of the vault. The vault supports `XRP`, `IOU` and `MPT`. | -| `AssetsTotal` | `N/A` | :heavy_check_mark: | `number` | `NUMBER` | 0 | The total value of the vault. | -| `AssetsAvailable` | `N/A` | :heavy_check_mark: | `number` | `NUMBER` | 0 | The asset amount that is available in the vault. | -| `LossUnrealized` | `N/A` | :heavy_check_mark: | `number` | `NUMBER` | 0 | The potential loss amount that is not yet realized expressed as the vaults asset. | -| `AssetsMaximum` | `Yes` | | `number` | `NUMBER` | 0 | The maximum asset amount that can be held in the vault. Zero value `0` indicates there is no cap. | -| `ShareMPTID` | `N/A` | :heavy_check_mark: | `number` | `UINT192` | 0 | The identifier of the share MPTokenIssuance object. | -| `WithdrawalPolicy` | `No` | :heavy_check_mark: | `string` | `UINT8` | `N/A` | Indicates the withdrawal strategy used by the Vault. | -| `Scale` | `No` | :heavy_check_mark: | `number` | `UINT8` | 6 | The `Scale` specifies the power of 10 ($10^{\text{scale}}$) to multiply an asset's value by when converting it into an integer-based number of shares. | - -##### 2.1.2.1 Flags +| Field Name | Constant | Required | JSON Type | Internal Type | Default Value | Description | +| ------------------- | :------: | :------: | :----------------: | :-----------: | :-----------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- | +| `LedgerEntryType` | No | Yes | `string` | `UINT16` | `0x0084` | Ledger object type. | +| `LedgerIndex` | No | Yes | `string` | `UINT16` | `N/A` | Ledger object identifier. | +| `Flags` | Yes | Yes | `string` | `UINT32` | 0 | Ledger object flags. | +| `PreviousTxnID` | No | Yes | `string` | `HASH256` | `N/A` | Identifies the transaction ID that most recently modified this object. | +| `PreviousTxnLgrSeq` | No | Yes | `number` | `UINT32` | `N/A` | The sequence of the ledger that contains the transaction that most recently modified this object. | +| `Sequence` | No | Yes | `number` | `UINT32` | `N/A` | The transaction sequence number that created the vault. | +| `OwnerNode` | No | Yes | `number` | `UINT64` | `N/A` | Identifies the page where this item is referenced in the owner's directory. | +| `Owner` | No | Yes | `string` | `AccountID` | `N/A` | The account address of the Vault Owner. | +| `Account` | No | Yes | `string` | `AccountID` | `N/A` | The address of the Vaults _pseudo-account_. | +| `Data` | Yes | No | `string` | `BLOB` | None | Arbitrary metadata about the Vault. Limited to 256 bytes. | +| `Asset` | No | Yes | `string or object` | `ISSUE` | `N/A` | The asset of the vault. The vault supports `XRP`, `IOU` and `MPT`. | +| `AssetsTotal` | No | Yes | `number` | `NUMBER` | 0 | The total value of the vault. | +| `AssetsAvailable` | No | Yes | `number` | `NUMBER` | 0 | The asset amount that is available in the vault. | +| `LossUnrealized` | No | Yes | `number` | `NUMBER` | 0 | The potential loss amount that is not yet realized expressed as the vaults asset. | +| `AssetsMaximum` | Yes | No | `number` | `NUMBER` | 0 | The maximum asset amount that can be held in the vault. Zero value `0` indicates there is no cap. | +| `ShareMPTID` | No | Yes | `number` | `UINT192` | 0 | The identifier of the share MPTokenIssuance object. | +| `WithdrawalPolicy` | No | Yes | `string` | `UINT8` | `N/A` | Indicates the withdrawal strategy used by the Vault. | +| `Scale` | No | Yes | `number` | `UINT8` | 6 | The `Scale` specifies the power of 10 ($10^{\text{scale}}$) to multiply an asset's value by when converting it into an integer-based number of shares. | + +##### 3.1.2.1 Flags The `Vault` object supports the following flags: | Flag Name | Flag Value | Modifiable? | Description | | ----------------- | :----------: | :---------: | :------------------------------------------: | -| `lsfVaultPrivate` | `0x00010000` | `No` | If set, indicates that the vault is private. | +| `lsfVaultPrivate` | `0x00010000` | No | If set, indicates that the vault is private. | -#### 2.1.3 Vault `_pseudo-account_` +#### 3.1.3 Pseudo-Account An AccountRoot entry holds the XRP, IOU or MPT deposited into the vault. It also acts as the issuer of the vault's shares. The _pseudo-account_ follows the XLS-64 specification for pseudo accounts. The `AccountRoot` object is created when creating the `Vault` object. -#### 2.1.4 Ownership +#### 3.1.4 Ownership The `Vault` objects are stored in the ledger and tracked in an [Owner Directory](https://xrpl.org/docs/references/protocol/ledger-data/ledger-entry-types/directorynode) owned by the account submitting the `VaultSet` transaction. Furthermore, to facilitate `Vault` object lookup from the vault shares, the object is also tracked in the `OwnerDirectory` of the _`pseudo-account`_. -#### 2.1.5 Owner Reserve +#### 3.1.5 Owner Reserve The `Vault` object costs one reserve fee per object created: - The `Vault` object itself. - The `MPTokenIssuance` associated with the shares of the Vault. -#### 2.1.6 Vault Shares +#### 3.1.6 Vault Shares Shares represent the portion of the Vault assets a depositor owns. Vault Owners set the currency code of the share and whether the token is transferable during the vault's creation. These two values are immutable. The share is represented by a [Multi-Purpose Token](../XLS-0033-multi-purpose-tokens/README.md). The MPT is issued by the vault's pseudo-account. -##### 2.1.6.1 `Scale` +##### 3.1.6.1 `Scale` 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 $10^{\text{Scale}}$, that converts a decimal asset amount into a corresponding whole number of shares. For example, with a `Scale` of `6`, a deposit of **20.3** assets is multiplied by $10^6$ and credited as **20,300,000** shares. As a general rule, all calculations involving MPTs are executed with a precision of a single MPT, treating them as indivisible units. If a calculation results in a fractional amount, it will be rounded up, down or to the nearest whole number depending on the context. Crucially, the rounding direction is determined by the protocol and is not controlled by the transaction submitter, which may lead to unexpected results. -##### 2.1.6.1.1 `IOU` +###### 3.1.6.1.1 `IOU` When a vault holds an **`IOU`**, the `Scale` is configurable by the Vault Owner at the time of the vault's creation. 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. -##### 2.1.6.1.2 `XRP` +###### 3.1.6.1.2 `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 (the smallest unit of XRP), 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 ($10 \times 10^6$). -##### 2.1.6.1.3 `MPT` +###### 3.1.6.1.3 `MPT` When a vault holds `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. 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. -##### 2.1.6.2 `MPTokenIssuance` +##### 3.1.6.2 `MPTokenIssuance` The `MPTokenIssuance` object represents the share on the ledger. It is created and deleted together with the `Vault` object. -###### 2.1.6.2.1 `MPTokenIssuance` Values - -Here’s the table with the headings "Field," "Description," and "Value": +###### 3.1.6.2.1 `MPTokenIssuance` Values | **Field** | **Description** | **Value** | | ----------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------------- | @@ -211,11 +176,11 @@ The following flags are set based on whether the shares are transferable and if | **Public Vault** | `lsfMPTCanEscrow`
`lsfMPTCanTrade`
`lsfMPTCanTransfer` | No Flags | | **Private Vault** | `lsfMPTCanEscrow`
`lsfMPTCanTrade`
`lsfMPTCanTransfer`
`lsfMPTRequireAuth` | `lsfMPTRequireAuth` | -##### 2.1.6.3 `MPToken` +##### 3.1.6.3 `MPToken` The `MPToken` object represents the amount of shares held by a depositor. It is created when the account deposits liquidity into the vault and is deleted when a depositor redeems (or transfers) all shares. -###### 2.1.6.3.1 `MPToken` Values +###### 3.1.6.3.1 `MPToken` Values The `MPToken` values should be set as per the `MPT` [specification](../XLS-0033-multi-purpose-tokens/README.md#2112-fields). @@ -224,11 +189,11 @@ The `MPToken` values should be set as per the `MPT` [specification](../XLS-0033- | **Public Vault** | No Flags | `lsfMPTAuthorized` | | **Private Vault** | `lsfMPTAuthorized` | `lsfMPTAuthorized` | -#### 2.1.7 Exchange Algorithm +#### 3.1.7 Exchange Algorithm Exchange Algorithm refers to the logic that is used to exchange assets into shares and shares into assets. This logic is executed when depositing or redeeming liquidity. A Vault comes with the default exchange algorithm, which is detailed below. -##### 2.1.7.1 Unrealized Loss +##### 3.1.7.1 Unrealized Loss A well-informed depositor may learn of an incoming loss and redeem their shares early, causing the remaining depositors to bear the full loss. To discourage such behaviour, we introduce a concept of "paper loss," captured by the `Vault` object's `LossUnrealized` attribute. The "paper loss" captures a potential loss the vault may experience and thus temporarily decreases the vault value. Only a protocol connected to the `Vault` may increase or decrease the `LossUnrealized` attribute. @@ -258,11 +223,11 @@ A depositor could deposit $100k assets at a 0.1 exchange rate and get 1.0m share To account for this problem, the Vault must use two different exchange rate models: one for depositing assets and one for withdrawing them. -### 2.1.7.2 Exchange Rate Algorithms +##### 3.1.7.2 Exchange Rate Algorithms This section details the algorithms used to calculate the exchange between assets and shares for deposits, redemptions, and withdrawals. -#### Key Variables +The following are the **key variables** used in the calculations: - **$\Gamma_{assets}$**: The total balance of assets held within the vault. - **$\Gamma_{shares}$**: The total number of shares currently issued by the vault. @@ -271,7 +236,7 @@ This section details the algorithms used to calculate the exchange between asset - **$\iota$**: The vault's total **unrealized loss**. - **$\sigma$**: The scaling factor derived from `Scale`, used to convert fractional assets into integer shares. -### 2.1.7.2.1 Deposit +###### 3.1.7.2.1 Deposit The deposit function calculates the number of shares a user receives for their assets. @@ -289,14 +254,14 @@ Because the share amount is rounded down, the actual assets taken from the depos $$\Delta_{assets'} = \frac{\Delta_{shares} \times \Gamma_{assets}}{\Gamma_{shares}}$$ -#### Vault State Update +###### 3.1.7.2.1.1 Vault State Update The vault's totals are updated with the final calculated amounts. - **New Total Assets**: $\Gamma_{assets} \leftarrow \Gamma_{assets} + \Delta_{assets'}$ - **New Total Shares**: $\Gamma_{shares} \leftarrow \Gamma_{shares} + \Delta_{shares}$ -### 2.1.7.2.2 Redeem +###### 3.1.7.2.2 Redeem The redeem function calculates the asset payout for a user burning a specific number of shares. @@ -313,7 +278,7 @@ The vault's totals are reduced after the redemption. - **New Total Assets**: $\Gamma_{assets} \leftarrow \Gamma_{assets} - \Delta_{assets}$ - **New Total Shares**: $\Gamma_{shares} \leftarrow \Gamma_{shares} - \Delta_{shares}$ -### 2.1.7.2.3 Withdraw +###### 3.1.7.2.3 Withdraw The withdraw function handles a request for a specific amount of assets, which involves a two-step process to determine the final payout. @@ -336,56 +301,52 @@ The vault's totals are reduced by the final calculated amounts. - **New Total Assets**: $\Gamma_{assets} \leftarrow \Gamma_{assets} - \Delta_{assets\_out}$ - **New Total Shares**: $\Gamma_{shares} \leftarrow \Gamma_{shares} - \Delta_{shares}$ -##### 2.1.7.3 Withdrawal Policy +##### 3.1.7.3 Withdrawal Policy Withdrawal policy controls the logic used when removing liquidity from a vault. Each strategy has its own implementation, but it can be used in multiple vaults once implemented. Therefore, different vaults may have different withdrawal policies. The specification introduces the following options: -###### 2.1.7.3.1 `first-come-first-serve` +###### 3.1.7.3.1 `first-come-first-serve` The First Come, First Serve strategy treats all requests equally, allowing a depositor to redeem any amount of assets provided they have a sufficient number of shares. -#### 2.1.8 Frozen Assets +#### 3.1.8 Frozen Assets The issuer of the Vaults asset may enact a freeze either through a [Global Freeze](https://xrpl.org/docs/concepts/tokens/fungible-tokens/freezes/#global-freeze) for IOUs or [locking MPT](../XLS-0033-multi-purpose-tokens/README.md#21122-flags). When the vaults asset is frozen, it can only be withdrawn by specifying the `Destination` account as the `Issuer` of the asset. Similarly, a frozen asset _may not_ be deposited into a vault. Furthermore, when the asset of a vault is frozen, the shares corresponding to the asset may not be transferred. -#### 2.1.9 Transfer Fees +#### 3.1.9 Transfer Fees The Vault does not apply the [Transfer Fee](https://xrpl.org/docs/concepts/tokens/transfer-fees) to `VaultDeposit` and `VaultWithdraw` transactions. Furthermore, whenever a protocol moves assets from or to a Vault, the `Transfer Fee` must not be charged. -[**Return to Index**](#index) - -## 3. Transactions - -All transactions introduced by this proposal incorporate the [common transaction fields](https://xrpl.org/docs/references/protocol/transactions/common-fields) that are shared by all transactions. Standard fields are only documented in this proposal if needed because this proposal introduces new possible values for such fields. - -### 3.1 `VaultCreate`, `VaultSet`, `VaultDelete` transactions +#### 3.1.10 Invariants -The `Vault` object is managed with `VaultCreate`, `VaultSet` and `VaultDelete` transactions. +**TBD** -#### 3.1.1 `VaultCreate` Transaction +### 3.2 Transaction: `VaultCreate` The `VaultCreate` transaction creates a new `Vault` object. -| Field Name | Required? | JSON Type | Internal Type | Default Value | Description | -| ------------------ | :----------------: | :----------------: | :-----------: | :----------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- | -| `TransactionType` | :heavy_check_mark: | `string` | `UINT16` | `58` | The transaction type. | -| `Flags` | :heavy_check_mark: | `number` | `UINT32` | 0 | Specifies the flags for the Vault. | -| `Data` | | `string` | `BLOB` | | Arbitrary Vault metadata, limited to 256 bytes. | -| `Asset` | :heavy_check_mark: | `string or object` | `ISSUE` | `N/A` | The asset (`XRP`, `IOU` or `MPT`) of the Vault. | -| `AssetsMaximum` | | `number` | `NUMBER` | 0 | The maximum asset amount that can be held in a vault. | -| `MPTokenMetadata` | | `string` | `BLOB` | | Arbitrary metadata about the share `MPT`, in hex format, limited to 1024 bytes. | -| `WithdrawalPolicy` | | `number` | `UINT8` | `strFirstComeFirstServe` | Indicates the withdrawal strategy used by the Vault. | -| `DomainID` | | `string` | `HASH256` | | The `PermissionedDomain` object ID associated with the shares of this Vault. | -| `Scale` | | `number` | `UINT8` | 6 | The `Scale` specifies the power of 10 ($10^{\text{scale}}$) to multiply an asset's value by when converting it into an integer-based number of shares. | +#### 3.2.1 Fields + +| Field Name | Required | JSON Type | Internal Type | Default Value | Description | +| ------------------ | :------: | :----------------: | :-----------: | :---------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- | +| `TransactionType` | Yes | `string` | `UINT16` | `58` | The transaction type. | +| `Flags` | Yes | `number` | `UINT32` | 0 | Specifies the flags for the Vault. | +| `Data` | No | `string` | `BLOB` | | Arbitrary Vault metadata, limited to 256 bytes. | +| `Asset` | Yes | `string or object` | `ISSUE` | `N/A` | The asset (`XRP`, `IOU` or `MPT`) of the Vault. | +| `AssetsMaximum` | No | `number` | `NUMBER` | 0 | The maximum asset amount that can be held in a vault. | +| `MPTokenMetadata` | No | `string` | `BLOB` | | Arbitrary metadata about the share `MPT`, in hex format, limited to 1024 bytes. | +| `WithdrawalPolicy` | No | `number` | `UINT8` | `"FirstComeFirstServe"` | Indicates the withdrawal strategy used by the Vault. | +| `DomainID` | No | `string` | `HASH256` | | The `PermissionedDomain` object ID associated with the shares of this Vault. | +| `Scale` | No | `number` | `UINT8` | 6 | The `Scale` specifies the power of 10 ($10^{\text{scale}}$) to multiply an asset's value by when converting it into an integer-based number of shares. | -##### 3.1.1.1 Flags +#### 3.2.2 Flags | Flag Name | Flag Value | Description | | ----------------------------- | :----------: | :--------------------------------------------------------------------------------------- | | `tfVaultPrivate` | `0x00010000` | Indicates that the vault is private. It can only be set during Vault creation. | | `tfVaultShareNonTransferable` | `0x00020000` | Indicates the vault share is non-transferable. It can only be set during Vault creation. | -###### 3.1.1.2 WithdrawalPolicy +##### 3.2.3 WithdrawalPolicy The type indicates the withdrawal strategy supported by the vault. The following values are supported: @@ -393,190 +354,221 @@ The type indicates the withdrawal strategy supported by the vault. The following | ---------------------------------- | :------: | :-------------------------------------------------------: | | `vaultStrategyFirstComeFirstServe` | `0x0001` | Requests are processed on a first-come-first-serve basis. | -##### 3.1.1.3 Transaction Fees +#### 3.2.4 Transaction Fees The transaction creates an `AccountRoot` object for the `_pseudo-account_`. Therefore, the transaction [must destroy](../XLS-0064-pseudo-account/README.md) one incremental owner reserve amount. -##### 3.1.1.4 Failure Conditions +#### 3.2.5 Failure Conditions -- The `Asset` is `XRP`: - - The `Scale` parameter is provided. +##### 3.2.5.1 Data Verification -- The `Asset` is `MPT`: - - The `Scale` parameter is provided. - - The `lsfMPTCanTransfer` is not set in the `MPTokenIssuance` object. (the asset is not transferable). - - The `lsfMPTLocked` flag is set in the `MPTokenIssuance` object. (the asset is locked). +_TBD_ -- The `Asset` is an `IOU`: - - The `lsfGlobalFreeze` flag is set on the issuing account (the asset is frozen). - - The `Scale` parameter is provided, and is less than **0** or greater than **18**. +##### 3.2.5.2 Protocol-Level Failures -- The `tfVaultPrivate` flag is not set and the `DomainID` is provided. (The VaultOwner is attempting to create a public Vault with a PermissionedDomain) +1. The `Asset` is `XRP`: + 1. The `Scale` parameter is provided. -- The `PermissionedDomain` object does not exist with the provided `DomainID`. +2. The `Asset` is `MPT`: + 1. The `Scale` parameter is provided. + 2. The `lsfMPTCanTransfer` is not set in the `MPTokenIssuance` object (the asset is not transferable). + 3. The `lsfMPTLocked` flag is set in the `MPTokenIssuance` object (the asset is locked). -- The `Data` field is larger than 256 bytes. -- The account submiting the transaction has insufficient `AccountRoot.Balance` for the Owner Reserve. +3. The `Asset` is an `IOU`: + 1. The `lsfGlobalFreeze` flag is set on the issuing account (the asset is frozen). + 2. The `Scale` parameter is provided, and is less than **0** or greater than **18**. -##### 3.1.1.5 State Changes +4. The `tfVaultPrivate` flag is not set and the `DomainID` is provided (the Vault Owner is attempting to create a public Vault with a PermissionedDomain) -- Create a new `Vault` ledger object. -- Create a new `MPTokenIssuance` ledger object for the vault shares. - - If the `DomainID` is provided: - - `MPTokenIssuance(Vault.ShareMPTID).DomainID = DomainID` (Set the Permissioned Domain ID). - - Create an `MPToken` object for the Vault Owner to hold Vault Shares. -- Create a new `AccountRoot`[_pseudo-account_](../XLS-0064-pseudo-account/README.md) object setting the `PseudoOwner` to `VaultID`. +5. The `PermissionedDomain` object does not exist with the provided `DomainID`. -- If `Vault.Asset` is an `IOU`: - - Create a `RippleState` object between the _pseudo-account_ `AccountRoot` and `Issuer` `AccountRoot`. +6. The `Data` field is larger than 256 bytes. +7. The account submitting the transaction has insufficient `AccountRoot.Balance` for the Owner Reserve. -- If `Vault.Asset` is an `MPT`: - - Create `MPToken` object for the _pseudo-account_ for the `Asset.MPTokenIssuance`. +#### 3.2.6 State Changes -##### 3.1.1.6 Invariants +1. Create a new `Vault` ledger object. +2. Create a new `MPTokenIssuance` ledger object for the vault shares, and assign its MPTID to `Vault.ShareMPTID`. + 1. If the `DomainID` is provided: + 1. `MPTokenIssuance(Vault.ShareMPTID).DomainID = DomainID` (Set the Permissioned Domain ID). + 2. Create an `MPToken` object for the Vault Owner to hold Vault Shares. +3. Create a new `AccountRoot`[_pseudo-account_](../XLS-0064-pseudo-account/README.md) object setting the `PseudoOwner` to `VaultID`. -**TBD** +4. If `Vault.Asset` is an `IOU`: + 1. Create a `RippleState` object between the _pseudo-account_ `AccountRoot` and `Issuer` `AccountRoot`. + +5. If `Vault.Asset` is an `MPT`: + 1. Create `MPToken` object for the _pseudo-account_ for the `Asset.MPTokenIssuance`. + +#### 3.2.7 Invariants -[**Return to Index**](#index) +**TBD** -#### 3.1.2 `VaultSet` Transaction +### 3.3 Transaction: `VaultSet` The `VaultSet` updates an existing `Vault` ledger object. -| Field Name | Required? | JSON Type | Internal Type | Default Value | Description | -| ----------------- | :----------------: | :-------: | :-----------: | :-----------: | :-------------------------------------------------------------------------------------------------------------------------------------- | -| `TransactionType` | :heavy_check_mark: | `string` | `Uint16` | `59` | The transaction type. | -| `VaultID` | :heavy_check_mark: | `string` | `Hash256` | `N/A` | The ID of the Vault to be modified. Must be included when updating the Vault. | -| `Data` | | `string` | `Blob` | | Arbitrary Vault metadata, limited to 256 bytes. | -| `AssetsMaximum` | | `number` | `Number` | | The maximum asset amount that can be held in a vault. The value cannot be lower than the current `AssetsTotal` unless the value is `0`. | -| `DomainID` | | `string` | `Hash256` | | The `PermissionedDomain` object ID associated with the shares of this Vault. | +#### 3.3.1 Fields -##### 3.1.2.1 Failure Conditions +| Field Name | Required | JSON Type | Internal Type | Default Value | Description | +| ----------------- | :------: | :-------: | :-----------: | :-----------: | :-------------------------------------------------------------------------------------------------------------------------------------- | +| `TransactionType` | Yes | `string` | `UINT16` | `59` | The transaction type. | +| `VaultID` | Yes | `string` | `HASH256` | `N/A` | The ID of the Vault to be modified. Must be included when updating the Vault. | +| `Data` | No | `string` | `BLOB` | | Arbitrary Vault metadata, limited to 256 bytes. | +| `AssetsMaximum` | No | `number` | `NUMBER` | | The maximum asset amount that can be held in a vault. The value cannot be lower than the current `AssetsTotal` unless the value is `0`. | +| `DomainID` | No | `string` | `HASH256` | | The `PermissionedDomain` object ID associated with the shares of this Vault. | -- `Vault` object with the specified `VaultID` does not exist on the ledger. -- The submitting account is not the `Owner` of the vault. -- The `Data` field is larger than 256 bytes. -- If `Vault.AssetsMaximum` > `0` AND `AssetsMaximum` > 0 AND: - - The `AssetsMaximum` < `Vault.AssetsTotal` (new `AssetsMaximum` cannot be lower than the current `AssetsTotal`). -- The `sfVaultPrivate` flag is not set and the `DomainID` is provided (Vault Owner is attempting to set a PermissionedDomain to a public Vault). -- The `PermissionedDomain` object does not exist with the provided `DomainID`. -- The transaction is attempting to modify an immutable field. -- The transaction does not specify any of the modifiable fields. +#### 3.3.2 Failure Conditions -##### 3.1.2.2 State Changes +##### 3.3.2.1 Data Verification -- Update mutable fields in the `Vault` ledger object. -- If `DomainID` is provided: - - Set `MPTokenIssuance(Vault.ShareMPTID).DomainID = DomainID` (Set the Permissioned Domain). +_TBD_ -##### 3.1.2.3 Invariants +##### 3.3.2.2 Protocol-Level Failures -**TBD** +1. `Vault` object with the specified `VaultID` does not exist on the ledger. +2. The submitting account is not the `Owner` of the vault. +3. The `Data` field is larger than 256 bytes. +4. If `Vault.AssetsMaximum` > `0` AND `tx.AssetsMaximum` > 0 AND: + 1. The `tx.AssetsMaximum` < `Vault.AssetsTotal` (new `tx.AssetsMaximum` cannot be lower than the current `AssetsTotal`). +5. The `sfVaultPrivate` flag is not set and the `DomainID` is provided (Vault Owner is attempting to set a PermissionedDomain to a public Vault). +6. The `PermissionedDomain` object does not exist with the provided `DomainID`. +7. The transaction is attempting to modify an immutable field. +8. The transaction does not specify any of the modifiable fields. + +#### 3.3.3 State Changes -[**Return to Index**](#index) +1. Update mutable fields in the `Vault` ledger object. +2. If `DomainID` is provided: + 1. Set `MPTokenIssuance(Vault.ShareMPTID).DomainID = DomainID` (Set the Permissioned Domain). + +#### 3.3.4 Invariants + +**TBD** -#### 3.1.3 `VaultDelete` Transaction +### 3.4 Transaction: `VaultDelete` The `VaultDelete` transaction deletes an existing vault object. -| Field Name | Required? | JSON Type | Internal Type | Default Value | Description | -| ----------------- | :----------------: | :-------: | :-----------: | :-----------: | :--------------------------------: | -| `TransactionType` | :heavy_check_mark: | `string` | `Uint16` | `60` | Transaction type. | -| `VaultID` | :heavy_check_mark: | `string` | `Hash256` | `N/A` | The ID of the vault to be deleted. | +#### 3.4.1 Fields -##### 3.1.3.1 Failure Conditions +| Field Name | Required | JSON Type | Internal Type | Default Value | Description | +| ----------------- | :------: | :-------: | :-----------: | :-----------: | :--------------------------------: | +| `TransactionType` | Yes | `string` | `UINT16` | `60` | Transaction type. | +| `VaultID` | Yes | `string` | `HASH256` | `N/A` | The ID of the vault to be deleted. | -- `Vault` object with the `VaultID` does not exist on the ledger. -- The submitting account is not the `Owner` of the vault. -- `AssetsTotal`, `AssetsAvailable`, or `MPTokenIssuance(Vault.ShareMPTID).OutstandingAmount` are greater than zero. -- The `OwnerDirectory` of the Vault _pseudo-account_ contains pointers to objects other than the `Vault`, the `MPTokenIssuance` for its shares, or an `MPToken` or trust line for its asset. +#### 3.4.2 Failure Conditions -##### 3.1.3.2 State Changes +##### 3.4.2.1 Data Verification -- Delete the `MPTokenIssuance` object for the vault shares. -- Delete the `MPToken` or `RippleState` object corresponding to the vault's holding of the asset, if one exists. -- Delete the `AccountRoot` object of the _pseudo-account_, and its `DirectoryNode` objects. -- Release the Owner Reserve to the `Vault.Owner` account. -- Delete the `Vault` object. +_None._ -##### 3.1.3.3 Invariants +##### 3.4.2.2 Protocol-Level Failures -**TBD** +1. `Vault` object with the `VaultID` does not exist on the ledger. +2. The submitting account is not the `Owner` of the vault. +3. `AssetsTotal`, `AssetsAvailable`, or `MPTokenIssuance(Vault.ShareMPTID).OutstandingAmount` are greater than zero. +4. The `OwnerDirectory` of the Vault _pseudo-account_ contains pointers to objects other than the `Vault`, the `MPTokenIssuance` for its shares, or an `MPToken` or trust line for its asset. -[**Return to Index**](#index) +#### 3.4.3 State Changes -### 3.2 `VaultDeposit` and `VaultWithdraw` transactions +1. Delete the `MPTokenIssuance` object for the vault shares. +2. Delete the `MPToken` or `RippleState` object corresponding to the vault's holding of the asset, if one exists. +3. Delete the `AccountRoot` object of the _pseudo-account_, and its `DirectoryNode` objects. +4. Release the Owner Reserve to the `Vault.Owner` account. +5. Delete the `Vault` object. -Depositors call the `VaultDeposit` and `VaultWithdraw` transactions to add or remove assets from the Tokenized Vault. +#### 3.4.4 Invariants -[**Return to Index**](#index) +**TBD** -#### 3.2.1 `VaultDeposit` transaction +### 3.5 Transaction: `VaultDeposit` The `VaultDeposit` transaction adds Liqudity in exchange for vault shares. -| Field Name | Required? | JSON Type | Internal Type | Default Value | Description | -| ----------------- | :----------------: | :------------------: | :-----------: | :-----------: | :----------------------------------------------------- | -| `TransactionType` | :heavy_check_mark: | `string` | `UINT16` | `61` | Transaction type. | -| `VaultID` | :heavy_check_mark: | `string` | `HASH256` | `N/A` | The ID of the vault to which the assets are deposited. | -| `Amount` | :heavy_check_mark: | `string` or `object` | `STAmount` | `N/A` | Asset amount to deposit. | +#### 3.5.1 Fields -##### 3.2.1.1 Failure conditions +| Field Name | Required | JSON Type | Internal Type | Default Value | Description | +| ----------------- | :------: | :------------------: | :-----------: | :-----------: | :----------------------------------------------------- | +| `TransactionType` | Yes | `string` | `UINT16` | `61` | Transaction type. | +| `VaultID` | Yes | `string` | `HASH256` | `N/A` | The ID of the vault to which the assets are deposited. | +| `Amount` | Yes | `string` or `object` | `STAmount` | `N/A` | Asset amount to deposit. | -- `Vault` object with the `VaultID` does not exist on the ledger. -- The asset type of the vault does not match the asset type the depositor is depositing. -- The depositor does not have sufficient funds to make a deposit. -- Adding the `Amount` to the `AssetsTotal` of the vault would exceed the `AssetsMaximum`. -- The `Vault` `lsfVaultPrivate` flag is set and the `Account` depositing the assets does not have credentials in the permissioned domain of the share. +#### 3.5.2 Failure Conditions -- The `Vault.Asset` is `MPT`: - - `MPTokenIssuance.lsfMPTCanTransfer` is not set (the asset is not transferable). - - `MPTokenIssuance.lsfMPTLocked` flag is set (the asset is globally locked). - - `MPToken(MPTokenIssuanceID, AccountID).lsfMPTLocked` flag is set (the asset is locked for the depositor). - - `MPToken(MPTokenIssuanceID, AccountID).MPTAmount` < `Amount` (insufficient balance). +##### 3.5.2.1 Data Verification -- The `Asset` is an `IOU`: - - The `lsfGlobalFreeze` flag is set on the issuing account (the asset is frozen). - - The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the depositor. - - The `RippleState` object `Balance` < `Amount` (insufficient balance). +1. The `VaultID` field is zero. (`temMALFORMED`) +2. The `Amount` field is zero or negative. (`temBAD_AMOUNT`) -##### 3.2.1.2 State Changes +##### 3.5.2.2 Protocol-Level Failures -If no `MPToken` object exists for the depositor, create one. For object details, see [2.1.6.2 `MPToken`](#2162-mptoken). +1. The `Vault` object with the `VaultID` does not exist on the ledger. (`tecNO_ENTRY`) +2. The `Amount` asset does not match `Vault.Asset`. (`tecWRONG_ASSET`) -- Increase the `MPTAmount` field of the share `MPToken` object of the `Account` by $\Delta_{share}$. -- Increase the `OutstandingAmount` field of the share `MPTokenIssuance` object by $\Delta_{share}$. -- Increase the `AssetsTotal` and `AssetsAvailable` of the `Vault` by `Amount`. +3. If the vault has `lsfVaultPrivate` set and the depositor is not the vault owner: + 1. No `PermissionedDomain` is configured on `MPTokenIssuance(Vault.ShareMPTID)`. (`tecNO_AUTH`) + 2. The depositor is not a valid member of the permissioned domain. (`tecNO_AUTH`) -- If the `Vault.Asset` is `XRP`: - - Increase the `Balance` field of _pseudo-account_ `AccountRoot` by `Amount`. - - Decrease the `Balance` field of the depositor `AccountRoot` by `Amount`. +4. If `Vault.Asset` is an `MPT`: + 1. The `lsfMPTCanTransfer` flag is not set in the `MPTokenIssuance` object (the asset is not transferable). (`tecNO_AUTH`) + 2. The asset is globally or individually locked for the depositor. (`tecLOCKED`) -- If the `Vault.Asset` is an `IOU`: - - Increase the `RippleState` balance between the _pseudo-account_ `AccountRoot` and the `Issuer` `AccountRoot` by `Amount`. - - Decrease the `RippleState` balance between the depositor `AccountRoot` and the `Issuer` `AccountRoot` by `Amount`. +5. If `Vault.Asset` is an `IOU`: + 1. The asset is globally frozen, or the depositor's trust line is frozen. (`tecFROZEN`) -- If the `Vault.Asset` is an `MPT`: - - Increase the `MPToken.MPTAmount` by `Amount` of the _pseudo-account_ `MPToken` object for the `Vault.Asset`. - - Decrease the `MPToken.MPTAmount` by `Amount` of the depositor `MPToken` object for the `Vault.Asset`. +6. The vault shares are locked for the depositor. (`tecLOCKED`) +7. The depositor does not have a required authorized holding for the vault asset (e.g., missing `MPToken` for a restricted `MPT`). (`tecNO_AUTH`) +8. The depositor has insufficient balance to cover the deposit. (`tecINSUFFICIENT_FUNDS`) +9. The `Amount` rounds to zero at the vault's precision scale. (`tecPRECISION_LOSS`) +10. The `Amount` rounds to zero at the depositor's trust line scale (IOU only). (`tecPRECISION_LOSS`) +11. The computed number of shares for the deposit is zero. (`tecPRECISION_LOSS`) +12. Arithmetic overflow during share calculation. (`tecPATH_DRY`) +13. Adding the deposited amount to `Vault.AssetsTotal` would exceed `Vault.AssetsMaximum`. (`tecLIMIT_EXCEEDED`) -##### 3.2.1.3 Invariants +#### 3.5.3 State Changes -**TBD** +1. If no share `MPToken` object exists for the depositor, create one. For private vaults, the `MPToken` is created only after domain authorization is verified. +2. Increase the `MPTAmount` field of the depositor's share `MPToken` by $\Delta_{share}$. +3. Increase the `OutstandingAmount` field of the share `MPTokenIssuance` by $\Delta_{share}$. +4. Increase `Vault.AssetsTotal` and `Vault.AssetsAvailable` by $\Delta_{asset}$. + +5. If `Vault.Asset` is `XRP`: + 1. Increase the `Balance` field of the _pseudo-account_ `AccountRoot` by $\Delta_{asset}$. + 2. Decrease the `Balance` field of the depositor `AccountRoot` by $\Delta_{asset}$. + +6. If `Vault.Asset` is an `IOU`: + 1. Increase the `RippleState` balance between the _pseudo-account_ `AccountRoot` and the `Issuer` `AccountRoot` by $\Delta_{asset}$. + 2. Decrease the `RippleState` balance between the depositor `AccountRoot` and the `Issuer` `AccountRoot` by $\Delta_{asset}$. -[**Return to Index**](#index) +7. If `Vault.Asset` is an `MPT`: + 1. Increase the `MPToken.MPTAmount` of the _pseudo-account_ `MPToken` for `Vault.Asset` by $\Delta_{asset}$. + 2. Decrease the `MPToken.MPTAmount` of the depositor `MPToken` for `Vault.Asset` by $\Delta_{asset}$. -#### 3.2.2 `VaultWithdraw` transaction +> **Note:** $\Delta_{asset}$ is the actual asset amount transferred, which may be slightly less than the requested `Amount` due to scale rounding for IOU assets. + +#### 3.5.4 Invariants + +1. The vault pseudo-account's asset balance must increase by a positive amount not exceeding the transaction `Amount`. +2. Unless the depositor is the asset issuer, the depositor's asset balance must decrease by the same amount as the vault increases. +3. The depositor's share `MPToken.MPTAmount` must increase by a positive amount. +4. The increase in `MPTokenIssuance(Vault.ShareMPTID).OutstandingAmount` must equal the increase in the depositor's share balance. +5. `Vault.AssetsTotal` and `Vault.AssetsAvailable` must each increase by exactly the vault's asset balance increase. +6. If `Vault.AssetsMaximum > 0`: `Vault.AssetsTotal <= Vault.AssetsMaximum`. + +### 3.6 Transaction: `VaultWithdraw` The `VaultWithdraw` transaction withdraws assets in exchange for the vault's shares. -| Field Name | Required? | JSON Type | Internal Type | Default Value | Description | -| ----------------- | :----------------: | :-------: | :-----------: | :-----------: | :-------------------------------------------------------------------------- | -| `TransactionType` | :heavy_check_mark: | `string` | `UINT16` | `62` | Transaction type. | -| `VaultID` | :heavy_check_mark: | `string` | `HASH256` | `N/A` | The ID of the vault from which assets are withdrawn. | -| `Amount` | :heavy_check_mark: | `number` | `STAmount` | 0 | The exact amount of Vault asset to withdraw. | -| `Destination` | | `string` | `AccountID` | Empty | An account to receive the assets. It must be able to receive the asset. | -| `DestinationTag` | | `number` | `UINT32` | Empty | Arbitrary tag identifying the reason for the withdrawal to the destination. | +#### 3.6.1 Fields + +| Field Name | Required | JSON Type | Internal Type | Default Value | Description | +| ----------------- | :------: | :-------: | :-----------: | :-----------: | :-------------------------------------------------------------------------- | +| `TransactionType` | Yes | `string` | `UINT16` | `62` | Transaction type. | +| `VaultID` | Yes | `string` | `HASH256` | `N/A` | The ID of the vault from which assets are withdrawn. | +| `Amount` | Yes | `number` | `STAmount` | 0 | The exact amount of Vault asset to withdraw. | +| `Destination` | No | `string` | `AccountID` | Empty | An account to receive the assets. It must be able to receive the asset. | +| `DestinationTag` | No | `number` | `UINT32` | Empty | Arbitrary tag identifying the reason for the withdrawal to the destination. | - If `Amount` is the Vaults asset, calculate the share cost using the [**Withdraw formula**](#21723-withdraw). - If `Amount` is the Vaults share, calculate the assets amount using the [**Redeem formula**](#21722-redeem). @@ -589,204 +581,219 @@ In sections below assume the following variables: - $\Delta_{asset}$ - the change in the total amount of assets after a deposit, withdrawal, or redemption. - $\Delta_{share}$ - che change in the total amount of shares after a deposit, withdrawal, or redemption. -##### 3.2.2.1 Failure conditions +#### 3.6.2 Failure Conditions + +##### 3.6.2.1 Data Verification -- `Vault` object with the `VaultID` does not exist on the ledger. +_None._ -- The `Vault.Asset` is `MPT`: - - `MPTokenIssuance.lsfMPTCanTransfer` is not set (the asset is not transferable). - - `MPTokenIssuance.lsfMPTLocked` flag is set (the asset is globally locked). - - `MPToken(MPTokenIssuanceID, AccountID | Destination).lsfMPTLocked` flag is set (the asset is locked for the depositor or the destination). +##### 3.6.2.2 Protocol-Level Failures -- The `Asset` is an `IOU`: - - The `lsfGlobalFreeze` flag is set on the issuing account (the asset is frozen). - - The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the `AccountRoot` of the `AccountID` or the `Destination`. +1. The `Vault` object corresponding to the `VaultID` field does not exist on the ledger. -- The unit of `Amount` is not shares of the vault. -- The unit of `Amount` is not asset of the vault. +2. If the `Vault.Asset` is `MPT`: + 1. `MPTokenIssuance.lsfMPTCanTransfer` is not set (the asset is not transferable). + 2. `MPTokenIssuance.lsfMPTLocked` flag is set (the asset is globally locked). + 3. `MPToken(MPTokenIssuanceID, AccountID | Destination).lsfMPTLocked` flag is set (the asset is locked for the depositor or the destination). -- There is insufficient liquidity in the vault to fill the request: - - If `Amount` is the vaults share: - - `MPTokenIssuance(Vault.ShareMPTID).OutstandingAmount` < `Amount` (attempt to withdraw more shares than there are in total). - - The shares `MPToken.MPTAmount` of the `Account` is less than `Amount` (attempt to withdraw more shares than owned). - - `Vault.AssetsAvailable` < $\Delta_{asset}$ (the vault has insufficient assets). +3. If the `Asset` is an `IOU`: + 1. The `lsfGlobalFreeze` flag is set on the issuing account (the asset is frozen). + 2. The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the `AccountRoot` of the `AccountID` or the `Destination`. - - If `Amount` is the vaults asset: - - The shares `MPToken.MPTAmount` of the `Account` is less than $\Delta_{share}$ (attempt to withdraw more shares than owned). - - `Vault.AssetsAvailable` < `Amount` (the vault has insufficient assets). +4. The unit of `Amount` is not shares or the asset of the vault. -- The `Destination` account is specified: - - The account does not have permission to receive the asset. - - The account does not have a `RippleState` or `MPToken` object for the asset. +5. There is insufficient liquidity in the vault to fill the request: + 1. If `Amount` is the vaults share: + 1. `MPTokenIssuance(Vault.ShareMPTID).OutstandingAmount` < `Amount` (attempt to withdraw more shares than there are in total). + 2. The shares `MPToken.MPTAmount` of the `Account` is less than `Amount` (attempt to withdraw more shares than owned). + 3. `Vault.AssetsAvailable` < $\Delta_{asset}$ (the vault has insufficient assets). -##### 3.2.2.2 State Changes + 2. If `Amount` is the vault's asset: + 1. The shares `MPToken.MPTAmount` of the `Account` is less than $\Delta_{share}$ (attempt to withdraw more shares than owned). + 2. `Vault.AssetsAvailable` < `Amount` (the vault has insufficient assets). -- If the `Vault.Asset` is XRP: - - Decrease the `Balance` field of _pseudo-account_ `AccountRoot` by $\Delta_{asset}$. - - Increase the `Balance` field of the depositor `AccountRoot` by $\Delta_{asset}$. +6. The `Destination` account is specified: + 1. The account does not have permission to receive the asset. + 2. The account does not have a `RippleState` or `MPToken` object for the asset. -- If the `Vault.Asset` is an `IOU`: - - If the Depositor account does not have a `RippleState` object for the Vaults Asset, create the `RippleState` object. +#### 3.6.3 State Changes - - Decrease the `RippleState` balance between the _pseudo-account_ `AccountRoot` and the `Issuer` `AccountRoot` by $\Delta_{asset}$. - - Increase the `RippleState` balance between the depositor `AccountRoot` and the `Issuer` `AccountRoot` by $\Delta_{asset}$. +1. If the `Vault.Asset` is XRP: + 1. Decrease the `Balance` field of _pseudo-account_ `AccountRoot` by $\Delta_{asset}$. + 2. Increase the `Balance` field of the depositor `AccountRoot` by $\Delta_{asset}$. -- If the `Vault.Asset` is an `MPT`: - - If the Depositor account does not have a `MPToken` object for the Vaults Asset, create the `MPToken` object. +2. If the `Vault.Asset` is an `IOU`: + 1. If the Depositor account does not have a `RippleState` object for the Vault's Asset, create the `RippleState` object. + 2. Decrease the `RippleState` balance between the _pseudo-account_ `AccountRoot` and the `Issuer` `AccountRoot` by $\Delta_{asset}$. + 3. Increase the `RippleState` balance between the depositor `AccountRoot` and the `Issuer` `AccountRoot` by $\Delta_{asset}$. - - Decrease the `MPToken.MPTAmount` by $\Delta_{asset}$ of the _pseudo-account_ `MPToken` object for the `Vault.Asset`. - - Increase the `MPToken.MPTAmount` by $\Delta_{asset}$ of the depositor `MPToken` object for the `Vault.Asset`. +3. If the `Vault.Asset` is an `MPT`: + 1. If the Depositor account does not have a `MPToken` object for the Vault's Asset, create the `MPToken` object. + 2. Decrease the `MPToken.MPTAmount` by $\Delta_{asset}$ of the _pseudo-account_ `MPToken` object for the `Vault.Asset`. + 3. Increase the `MPToken.MPTAmount` by $\Delta_{asset}$ of the depositor `MPToken` object for the `Vault.Asset`. -- Update the `MPToken` object for the `Vault.ShareMPTID` of the depositor `AccountRoot`: - - Decrease the `MPToken.MPTAmount` by $\Delta_{share}$. - - If `MPToken.MPTAmount == 0`, delete the object. +4. Update the `MPToken` object for the `Vault.ShareMPTID` of the depositor `AccountRoot`: + 1. Decrease the `MPToken.MPTAmount` by $\Delta_{share}$. + 2. If `MPToken.MPTAmount == 0`, delete the object. -- Update the `MPTokenIssuance` object for the `Vault.ShareMPTID`: - - Decrease the `OutstandingAmount` field of the share `MPTokenIssuance` object by $\Delta_{share}$. +5. Update the `MPTokenIssuance` object for the `Vault.ShareMPTID`: + 1. Decrease the `OutstandingAmount` field of the share `MPTokenIssuance` object by $\Delta_{share}$. -- Decrease the `AssetsTotal` and `AssetsAvailable` by $\Delta_{asset}$ +6. Decrease the `AssetsTotal` and `AssetsAvailable` by $\Delta_{asset}$ -##### 3.2.2.3 Invariants +#### 3.6.4 Invariants **TBD** -[**Return to Index**](#index) +### 3.7 Transaction: `VaultClawback` -## 3.3 VaultClawback Transaction +The `VaultClawback` transaction performs a Clawback from the Vault, exchanging the shares of an account. Conceptually, the transaction performs `VaultWithdraw` on behalf of the `Holder`, sending the funds to the `Issuer` account of the asset. In case there are insufficient funds for the entire `Amount` the transaction will perform a partial Clawback, up to the `Vault.AssetsAvailable`. The Clawback transaction must respect any future fees or penalties. -#### 3.3.1 `VaultClawback` Transaction +#### 3.7.1 Fields -The `VaultClawback` transaction performs a Clawback from the Vault, exchanging the shares of an account. Conceptually, the transaction performs `VaultWithdraw` on behalf of the `Holder`, sending the funds to the `Issuer` account of the asset. In case there are insufficient funds for the entire `Amount` the transaction will perform a partial Clawback, up to the `Vault.AssetsAvailable`. The Clawback transaction must respect any future fees or penalties. +| Field Name | Required | JSON Type | Internal Type | Default Value | Description | +| ----------------- | :------: | :-------: | :-----------: | :-----------: | :------------------------------------------------------------------------------------------------------------- | +| `TransactionType` | Yes | `string` | `UINT16` | `63` | Transaction type. | +| `VaultID` | Yes | `string` | `HASH256` | `N/A` | The ID of the vault from which assets are withdrawn. | +| `Holder` | Yes | `string` | `AccountID` | `N/A` | The account ID from which to clawback the assets. | +| `Amount` | No | `number` | `NUMBER` | 0 | The asset amount to clawback. When Amount is `0` clawback all funds, up to the total shares the `Holder` owns. | + +#### 3.7.2 Failure Conditions + +##### 3.7.2.1 Data Verification -| Field Name | Required? | JSON Type | Internal Type | Default Value | Description | -| ----------------- | :----------------: | :-------: | :-----------: | :-----------: | :------------------------------------------------------------------------------------------------------------- | -| `TransactionType` | :heavy_check_mark: | `string` | `UINT16` | `63` | Transaction type. | -| `VaultID` | :heavy_check_mark: | `string` | `HASH256` | `N/A` | The ID of the vault from which assets are withdrawn. | -| `Holder` | :heavy_check_mark: | `string` | `AccountID` | `N/A` | The account ID from which to clawback the assets. | -| `Amount` | | `number` | `NUMBER` | 0 | The asset amount to clawback. When Amount is `0` clawback all funds, up to the total shares the `Holder` owns. | +_None._ -##### 3.3.1.1 Failure conditions +##### 3.7.2.2 Protocol-Level Failures -- `Vault` object with the `VaultID` does not exist on the ledger. +1. `Vault` object with the `VaultID` does not exist on the ledger. -- If `Vault.Asset` is `XRP`. +2. If `Vault.Asset` is `XRP`. -- If `Vault.Asset` is an `IOU` and: - - The `Issuer` account is not the submitter of the transaction. - - If the `AccountRoot(Issuer)` object does not have `lsfAllowTrustLineClawback` flag set (the asset does not support clawback). - - If the `AccountRoot(Issuer)` has the `lsfNoFreeze` flag set (the asset cannot be frozen). +3. If `Vault.Asset` is an `IOU` and: + 1. The `Issuer` account is not the submitter of the transaction. + 2. If the `AccountRoot(Issuer)` object does not have `lsfAllowTrustLineClawback` flag set (the asset does not support clawback). + 3. If the `AccountRoot(Issuer)` has the `lsfNoFreeze` flag set (the asset cannot be frozen). -- If `Vault.Asset` is an `MPT` and: - - `MPTokenIssuance.Issuer` is not the submitter of the transaction. - - `MPTokenIssuance.lsfMPTCanClawback` flag is not set (the asset does not support clawback). - - If the `MPTokenIssuance.lsfMPTCanLock` flag is NOT set (the asset cannot be locked). +4. If `Vault.Asset` is an `MPT` and: + 1. `MPTokenIssuance.Issuer` is not the submitter of the transaction. + 2. `MPTokenIssuance.lsfMPTCanClawback` flag is not set (the asset does not support clawback). + 3. If the `MPTokenIssuance.lsfMPTCanLock` flag is NOT set (the asset cannot be locked). -- The `MPToken` object for the `Vault.ShareMPTID` of the `Holder` `AccountRoot` does not exist OR `MPToken.MPTAmount == 0`. +5. The `MPToken` object for the `Vault.ShareMPTID` of the `Holder` `AccountRoot` does not exist OR `MPToken.MPTAmount == 0`. -##### 3.3.1.2 State Changes +#### 3.7.3 State Changes -- If the `Vault.Asset` is an `IOU`: - - Decrease the `RippleState` balance between the _pseudo-account_ `AccountRoot` and the `Issuer` `AccountRoot` by `min(Vault.AssetsAvailable`, $\Delta_{asset}$`)`. +1. If the `Vault.Asset` is an `IOU`: + 1. Decrease the `RippleState` balance between the _pseudo-account_ `AccountRoot` and the `Issuer` `AccountRoot` by `min(Vault.AssetsAvailable`, $\Delta_{asset}$`)`. -- If the `Vault.Asset` is an `MPT`: - - Decrease the `MPToken.MPTAmount` by `min(Vault.AssetsAvailable`, $\Delta_{asset}$`)` of the _pseudo-account_ `MPToken` object for the `Vault.Asset`. +2. If the `Vault.Asset` is an `MPT`: + 1. Decrease the `MPToken.MPTAmount` by `min(Vault.AssetsAvailable`, $\Delta_{asset}$`)` of the _pseudo-account_ `MPToken` object for the `Vault.Asset`. -- Update the `MPToken` object for the `Vault.ShareMPTID` of the depositor `AccountRoot`: - - Decrease the `MPToken.MPTAmount` by $\Delta_{share}$. - - If `MPToken.MPTAmount == 0`, delete the object. +3. Update the `MPToken` object for the `Vault.ShareMPTID` of the depositor `AccountRoot`: + 1. Decrease the `MPToken.MPTAmount` by $\Delta_{share}$. + 2. If `MPToken.MPTAmount == 0`, delete the object. -- Update the `MPTokenIssuance` object for the `Vault.ShareMPTID`: - - Decrease the `OutstandingAmount` field of the share `MPTokenIssuance` object by $\Delta_{share}$. +4. Update the `MPTokenIssuance` object for the `Vault.ShareMPTID`: + 1. Decrease the `OutstandingAmount` field of the share `MPTokenIssuance` object by $\Delta_{share}$. -- Decrease the `AssetsTotal` and `AssetsAvailable` by `min(Vault.AssetsAvailable`, $\Delta_{asset}$`)` +5. Decrease the `AssetsTotal` and `AssetsAvailable` by `min(Vault.AssetsAvailable`, $\Delta_{asset}$`)` -##### 3.3.1.3 Invariants +#### 3.7.4 Invariants **TBD** -[**Return to Index**](#index) +### 3.8 Transaction: `Payment` -## 3.4 Payment Transaction +The Single Asset Vault does not introduce new `Payment` transaction fields. However, it adds additional failure conditions and state changes when transferring Vault shares. -### 3.4.1 `Payment` transaction +#### 3.8.1 Fields -The Single Asset Vault does not introduce new `Payment` transaction fields. However, it adds additional failure conditions and state changes when transfering Vault shares. +The Single Asset Vault does not introduce or modify any `Payment` transaction fields. Refer to the existing [Payment transaction fields](https://xrpl.org/docs/references/protocol/transactions/types/payment). -#### 3.4.1.1 Failure Conditions +#### 3.8.2 Failure Conditions -- If `Payment.Amount` is a `Vault` share AND: - - The `Vault` `lsfVaultPrivate` flag is set and the `Payment.Destination` account does not have credentials in the permissioned domain of the Vaults Share. - - The `Vault` `tfVaultShareNonTransferable` flag is set. +##### 3.8.2.1 Data Verification - - The `Vault.Asset` is `MPT`: - - `MPTokenIssuance.lsfMPTCanTransfer` is not set (the asset is not transferable). - - `MPTokenIssuance.lsfMPTLocked` flag is set (the asset is globally locked). - - `MPToken(MPTokenIssuanceID, AccountID).lsfMPTLocked` flag is set (the asset is locked for the payer). - - `MPToken(MPTokenIssuanceID, PseudoAccountID).lsfMPTLocked` flag is set (the asset is locked for the `pseudo-account`). - - `MPToken(MPTokenIssuanceID, Destination).lsfMPTLocked` flag is set (the asset is locked for the destination account). +_None._ - - The `Vault.Asset` is an `IOU`: - - The `lsfGlobalFreeze` flag is set on the issuing account (the asset is frozen). - - The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the payer account. - - The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the destination account. - - The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the `pseudo-account`. +##### 3.8.2.2 Protocol-Level Failures -#### 3.4.1.2 State Changes +1. If `Payment.Amount` is a `Vault` share AND: + 1. The `Vault` `lsfVaultPrivate` flag is set and the `Payment.Destination` account is not a member of the permissioned domain specified at `MPTokenIssuance(Vault.ShareMPTID).DomainID`. + 2. The `Vault` `tfVaultShareNonTransferable` flag is set. -- If `MPToken`object for shares does not exist for the destination account, create one. + 3. If the `Vault.Asset` is `MPT`: + 1. `MPTokenIssuance.lsfMPTCanTransfer` is not set (the asset is not transferable). + 2. `MPTokenIssuance.lsfMPTLocked` flag is set (the asset is globally locked). + 3. `MPToken(MPTokenIssuanceID, AccountID).lsfMPTLocked` flag is set (the asset is locked for the payer). + 4. `MPToken(MPTokenIssuanceID, AccountID).lsfMPTLocked` flag is set (the asset is locked for the `pseudo-account`). + 5. `MPToken(MPTokenIssuanceID, Destination).lsfMPTLocked` flag is set (the asset is locked for the destination account). -[**Return to Index**](#index) + 4. If the `Vault.Asset` is an `IOU`: + 1. The `lsfGlobalFreeze` flag is set on the issuing account (the asset is frozen). + 2. The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the payer account. + 3. The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the destination account. + 4. The `lsfHighFreeze` or `lsfLowFreeze` flag is set on the `RippleState` object between the Asset `Issuer` and the `pseudo-account`. -## 4. API +#### 3.8.3 State Changes -### 4.1 RPC `vault_info` +1. If `MPToken`object for shares does not exist for the destination account, create one. + +### 3.9 RPC: `vault_info` This RPC retrieves the Vault ledger entry and the IDs associated with it. -#### 4.1.1 Request Fields - -We propose adding the following fields to the `ledger_entry` method: - -| Field Name | Required? | JSON Type | Description | -| ---------- | :----------------: | :-------: | :----------------------------------------: | -| `vault` | :heavy_check_mark: | `string` | The object ID of the Vault to be returned. | - -#### 4.1.2 Response - -| Field Name | Required? | JSON Type | Description | -| -------------------------------- | --------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `vault` | `yes` | `object` | Root object representing the vault. | -| `vault.Account` | `yes` | `string` | The pseudo-account ID of the vault. | -| `vault.Asset` | `yes` | `object` | Object representing the asset held in the vault. | -| `vault.Asset.currency` | `yes` | `string` | Currency code of the asset stored in the vault. | -| `vault.Asset.issuer` | `no` | `string` | Issuer address of the asset. | -| `vault.AssetsAvailable` | `yes` | `string` | Amount of assets currently available for withdrawal. | -| `vault.AssetsTotal` | `yes` | `string` | Total amount of assets in the vault. | -| `vault.Flags` | `no` | `number` | Bit-field flags associated with the vault. | -| `vault.LedgerEntryType` | `yes` | `string` | Ledger entry type, always "Vault". | -| `vault.LossUnrealized` | `no` | `string` | Unrealized loss associated with the vault. | -| `vault.Owner` | `yes` | `string` | ID of the Vault Owner account. | -| `vault.OwnerNode` | `no` | `string` | Identifier for the owner node in the ledger tree. | -| `vault.PreviousTxnID` | `yes` | `string` | Transaction ID of the last modification to this vault. | -| `vault.PreviousTxnLgrSeq` | `yes` | `number` | Ledger sequence number of the last transaction modifying this vault. | -| `vault.Sequence` | `yes` | `number` | Sequence number of the vault entry. | -| `vault.ShareMPTID` | `no` | `string` | Multi-purpose token ID associated with this vault. | -| `vault.WithdrawalPolicy` | `no` | `number` | Policy defining withdrawal conditions. | -| `vault.index` | `yes` | `string` | Unique index of the vault ledger entry. | -| `vault.shares` | `yes` | `object` | Object containing details about issued shares. | -| `vault.shares.Flags` | `no` | `number` | Bit-field flags associated with the shares issuance. | -| `vault.shares.Issuer` | `yes` | `string` | The ID of the Issuer of the Share. It will always be the pseudo-account ID. | -| `vault.shares.LedgerEntryType` | `yes` | `string` | Ledger entry type, always "MPTokenIssuance". | -| `vault.shares.OutstandingAmount` | `yes` | `string` | Total outstanding shares issued. | -| `vault.shares.OwnerNode` | `no` | `string` | Identifier for the owner node of the shares. | -| `vault.shares.PreviousTxnID` | `yes` | `string` | Transaction ID of the last modification to the shares issuance. | -| `vault.shares.PreviousTxnLgrSeq` | `yes` | `number` | Ledger sequence number of the last transaction modifying the shares issuance. | -| `vault.shares.Sequence` | `yes` | `number` | Sequence number of the shares issuance entry. | -| `vault.shares.index` | `yes` | `string` | Unique index of the shares ledger entry. | -| `vault.shares.mpt_issuance_id` | `no` | `string` | The ID of the `MPTokenIssuance` object. It will always be equal to `vault.ShareMPTID`. | -| `vault.Scale` | `yes` | `number` | The `Scale` specifies the power of 10 ($10^{\text{scale}}$) to multiply an asset's value by when converting it into an integer-based number of shares. | - -#### 4.1.2.1 Example +#### 3.9.1 Request Fields + +| Field Name | Required? | JSON Type | Description | +| ---------- | :-------: | :-------: | :----------------------------------------: | +| `vault` | Yes | `string` | The object ID of the Vault to be returned. | + +#### 3.9.2 Response Fields + +| Field Name | Always Present? | JSON Type | Description | +| -------------------------------- | :-------------: | :-------: | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `vault` | Yes | `object` | Root object representing the vault. | +| `vault.Account` | Yes | `string` | The pseudo-account ID of the vault. | +| `vault.Asset` | Yes | `object` | Object representing the asset held in the vault. | +| `vault.Asset.currency` | Yes | `string` | Currency code of the asset stored in the vault. | +| `vault.Asset.issuer` | No | `string` | Issuer address of the asset. | +| `vault.AssetsAvailable` | Yes | `string` | Amount of assets currently available for withdrawal. | +| `vault.AssetsTotal` | Yes | `string` | Total amount of assets in the vault. | +| `vault.Flags` | No | `number` | Bit-field flags associated with the vault. | +| `vault.LedgerEntryType` | Yes | `string` | Ledger entry type, always "Vault". | +| `vault.LossUnrealized` | No | `string` | Unrealized loss associated with the vault. | +| `vault.Owner` | Yes | `string` | ID of the Vault Owner account. | +| `vault.OwnerNode` | No | `string` | Identifier for the owner node in the ledger tree. | +| `vault.PreviousTxnID` | Yes | `string` | Transaction ID of the last modification to this vault. | +| `vault.PreviousTxnLgrSeq` | Yes | `number` | Ledger sequence number of the last transaction modifying this vault. | +| `vault.Sequence` | Yes | `number` | Sequence number of the vault entry. | +| `vault.ShareMPTID` | No | `string` | Multi-purpose token ID associated with this vault. | +| `vault.WithdrawalPolicy` | No | `number` | Policy defining withdrawal conditions. | +| `vault.index` | Yes | `string` | Unique index of the vault ledger entry. | +| `vault.shares` | Yes | `object` | Object containing details about issued shares. | +| `vault.shares.Flags` | No | `number` | Bit-field flags associated with the shares issuance. | +| `vault.shares.Issuer` | Yes | `string` | The ID of the Issuer of the Share. It will always be the pseudo-account ID. | +| `vault.shares.LedgerEntryType` | Yes | `string` | Ledger entry type, always "MPTokenIssuance". | +| `vault.shares.OutstandingAmount` | Yes | `string` | Total outstanding shares issued. | +| `vault.shares.OwnerNode` | No | `string` | Identifier for the owner node of the shares. | +| `vault.shares.PreviousTxnID` | Yes | `string` | Transaction ID of the last modification to the shares issuance. | +| `vault.shares.PreviousTxnLgrSeq` | Yes | `number` | Ledger sequence number of the last transaction modifying the shares issuance. | +| `vault.shares.Sequence` | Yes | `number` | Sequence number of the shares issuance entry. | +| `vault.shares.index` | Yes | `string` | Unique index of the shares ledger entry. | +| `vault.shares.mpt_issuance_id` | No | `string` | The ID of the `MPTokenIssuance` object. It will always be equal to `vault.ShareMPTID`. | +| `vault.Scale` | Yes | `number` | The `Scale` specifies the power of 10 ($10^{\text{scale}}$) to multiply an asset's value by when converting it into an integer-based number of shares. | + +#### 3.9.3 Failure Conditions + +**TBD** + +#### 3.9.4 Example Request + +**TBD** + +#### 3.9.5 Example Response Vault holding an `IOU`: @@ -833,7 +840,7 @@ Vault holding an `IOU`: }, "Scale": 6, } - } +} ``` Vault holding an `MPT`: @@ -1104,34 +1111,38 @@ The matching strategy depends on the asset type: } ``` -[**Return to Index**](#index) +## 4. Rationale -# Appendix +_TBD_ + +## 5. Security Considerations -[**Return to Index**](#index) +_TBD_ + +# Appendix -## A-1 F.A.Q. +## Appendix A: FAQ -### A-1.1 Why does the specification allow both `Withdraw` and `Redeem` and not just one of them? +### A.1 Why does the specification allow both `Withdraw` and `Redeem` and not just one of them? We chose this design in order to reduce the amount of off-chain math required to be implemented by XRPL users and/or developers -### A-1.2 Why can any account that holds Vaults shares submit a `VaultWithdraw` transaction? +### A.2 Why can any account that holds Vaults shares submit a `VaultWithdraw` transaction? The `VaultWithdraw` transaction does not respect the permissioned domain rules. In other words, any account that holds the shares of the Vault can withdraw them. The decision was made 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 loosing access to their funds. -### A-1.3 How can a depositor transfer shares to another account? +### A.3 How can a depositor transfer shares to another account? Vault shares are a first-class assets, meaning that they can be transfered and used in other on-ledger protocols that support MPTokens. However, the payee (or the receiver) of the shares must have permissions to hold the shares and the assset that the shares represent. For example, if the shares are for a private Vault containing `USDC` the destination account must be in the permissioned domain of the Vault, and have permissions to hold `USDC`. In addion, any compliance mechanisms applied to `USDC` will also apply to the share. For example, if the Issuer of `USDC` freezes the Trustline of the payee, then the payee will not be able to receive any shares representing `USDC`. -### A-1.4 What is the difference between the `VaultOwner` and the `pseudo-account`? +### A.4 What is the difference between the `VaultOwner` and the `pseudo-account`? XRP Ledger is an account based blockchain. That means that assets (XRP, IOU and MPT) must be held by an account. The Vault Object (or any other object, such as the AMM) cannot hold assets directly. Therefore, a pseudo-account is created that holds the assets on behalf of that object. The pseudo-account is a stand-alone account, that cannot receive funds, it cannot send transactions, it is there to only hold assets. So for example, when a depositor deposits assets into a vault, in reality this transaction moves the assets from the depositor account to the pseudo-account. Furthermore, the Vault `pseudo-account` is the Issuer of the Vault shares. -### A-1.5 Do `VaultDeposit` or `VaultWithdraw` transactions charge transfer fees? +### A.5 Do `VaultDeposit` or `VaultWithdraw` transactions charge transfer fees? No, neither of the transactions charge transfer fees when depositing or withdrawing assets to and from the Vault.