0065 XLS - 65d: Single Asset Vault #192
Replies: 3 comments 10 replies
-
For the CUD operations, i wonder, why is the I would expect that the AccountID creating the |
Beta Was this translation helpful? Give feedback.
-
Can the |
Beta Was this translation helpful? Give feedback.
-
Closing the discussion as the specification is in a good spot. The pull request can be found here: #239 |
Beta Was this translation helpful? Give feedback.
-
Single Asset Vault
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 Asst Vault uses Multi-Purpose-Token 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.
1. Introduction
1.1 Overview
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, can access these assets via the vault, whether or not they generate yield. Currently, other protocols must be created by the same Account as 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 vault value, and other relevant information.The vault specification includes the following transactions:
Vault Management:
VaultSet
: Creates a new or updates an existing vault object.VaultDelete
: Deletes an existing vault object.Asset Management:
VaultDeposit
: Deposits a specified number of assets into the vault in exchange for shares.VaultWithdraw
: Withdraws a specified number of assets from the vault in exchange for shares.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.1.1.1 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
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, which use on-chain Credentials 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 share holder can withdraw funds.
1.1.3 Yield Bearing Shares
The shares represent the ownership of the portion of the vault's assets. On-chain shares are represented by a Multi-Purpose Token. 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, the shares can be transferred and used in other DeFi protocols as long as the 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
Protocol Instance: A separate XRP Ledger protocol requiring access to aggregated liquidity.
1.3 Actors
1.4 Connecting to the Vault
A protocol connecting to a Vault must track it's 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 specification.
2. Ledger Entries
2.1
Vault
Ledger EntryThe
Vault
ledger entry describes the state of the tokenized vault.2.1.1 Object Identifier
The key of the
Vault
object is the result ofSHA512-Half
of the following values concatenated in order:Vault
space key0x0056
(capital V)AccountID
(https://xrpl.org/docs/references/protocol/binary-format/#accountid-fields) of the account submitting theVaultSet
transaction, i.e.VaultOwner
.Sequence
number. If the transaction used a Ticket, use theTicketSequence
value.2.1.2 Fields
A vault has the following fields:
LedgerEntryType
N/A
string
UINT16
LedgerIndex
N/A
string
UINT16
N/A
Flags
Yes
string
UINT32
PreviousTxnID
N/A
string
HASH256
N/A
PreviousTxnLgrSeq
N/A
number
UINT32
N/A
Sequence
N/A
number
UINT32
N/A
OwnerNode
N/A
number
UINT64
N/A
Owner
No
string
AccountID
N/A
Account
N/A
string
ACCOUNTID
N/A
Data
Yes
string
BLOB
Asset
No
string or object
ISSUE
N/A
XRP
,Fungible Token
andMulti-Purpose Token
.AssetsTotal
N/A
number
NUMBER
AssetsAvailable
N/A
number
NUMBER
AssetsMaximum
Yes
number
NUMBER
0
indicates there is no cap.Share
N/A
object
MPT
SharesTotal
N/A
number
UINT64
WithdrawalPolicy
No
string
UINT8
N/A
PermissionedDomainID
No
string
HASH256
2.1.2.1 Flags
The
Vault
object supports the following flags:lsfFrozen
0x0001
Yes
lsfPrivate
0x0002
No
2.1.3 Vault
_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 LP Tokens. The pseudo-account follows the XLS-64d specification for pseudo accounts. The
AccountRoot
object is created when creating theVault
object.2.1.4 Ownership
The
Vault
objects are stored in the ledger and tracked in an Owner Directory owned by the account submitting theVaultSet
transaction. Furthermore, to facilitateVault
object lookup from the vault shares, the object is also tracked in theOwnerDirectory
of thepseudo-account
.2.1.5 Owner Reserve
The
Vault
object costs one owner reserve for the account creating it.2.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. The MPT is issued by the vault's pseudo-account.
2.1.6.1
MPTokenIssuance
The
MPTokenIssuance
object represents the share on the ledger. It is created and deleted together with theVault
object.2.1.6.1.1
MPTokenIssuance
ValuesHere’s the table with the headings "Field," "Description," and "Value":
Issuer
AssetScale
MaximumAmount
0xFFFFFFFFFFFFFFFF
TransferFee
MPTokenMetadata
Flags
The following flags are set based on whether the shares are transferable and if the vault is public or private.
lsfMPTCanEscrow
lsfMPTCanTrade
lsfMPTCanTransfer
lsfMPTCanEscrow
lsfMPTCanTrade
lsfMPTCanTransfer
lsfMPTRequireAuth
lsfMPTRequireAuth
2.1.6.2
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.2.1
MPToken
ValuesThe
MPToken
values should be set as per theMPT
specification.lsfMPTAuthorized
lsfMPTAuthorized
lsfMPTAuthorized
2.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 Computing shares
Variables
The following variables define the Vault balance:
2.1.7.1.1 Deposit
We compute the number of shares ($\Delta_{share}$ ) a depositor will receive as follows:
The following equations govern the updated vault composition after a successful deposit:
2.1.7.1.2 Redeem
We compute the number of assets ($\Delta_{asset}$ ) returned by burning $\Delta_{share}$ as follows:
The following equations govern the updated vault composition after a successful redemption:
2.1.7.1.3 Withdraw
We compute the number of shares to burn to withdraw$\Delta_{asset}$ as follows:
$$\Delta_{share} = \frac{\Delta_{asset} \times (\Gamma_{share} + 0^{\Gamma_{share}})}{\Gamma_{asset} + 0^{\Gamma_{asset}}} $$
The following equations govern the updated vault composition after a successful withdrawal:
2.1.7.2 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.2.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.7 Frozen Assets
The issuer of the Vaults asset may enact a freeze either through a Global Freeze for IOUs or locking MPT. When the vaults asset is frozen, it can only be withdrawn by specifying the
Destination
account as theIssuer
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.3. Transactions
All transactions introduced by this proposal incorporate the common transaction 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
VaultSet
,VaultDelete
transactionsThe Vault object is managed with
VaultSet
andVaultDelete
transactions.3.1.1
VaultSet
TransactionThe
VaultSet
transaction creates a newVault
object or updates an existing one.TransactionType
string
Uint16
VaultID
string
Hash256
N/A
Flags
string
Uint32
Data
string
Blob
Asset
string or object
Issue
N/A
MPT
) of the Vault. This value is non-modifiable.AssetMaximum
number
Uint64
AssetsTotal
of the Vault unless the value is0
.MPTokenMetadata
string
Blob
WithdrawalPolicy
string
UINT8
N/A
PermissionedDomainID
string
Hash256
PermissionedDomain
associated with this Vault object.3.1.1.1 Flags
tfFreeze
0x0001
tfUnfreeze
0x0002
tfPrivate
0x0003
tfShareNonTransferable
0x0004
3.1.1.2 WithdrawalPolicy
The type indicates the withdrawal strategy supported by the vault. The following values are supported:
strFirstComeFirstServe
0x0001
3.1.1.3 Failure Conditions
The
VaultID
is not specified AND:Asset
isMPT
, andlsfMPTCanTransfer
is not set (the asset is not transferable).The
Asset
isMPT
, and thelsfMPTLocked
flag is set (the asset is frozen).The
Asset
is anIOU
, and thelsfGlobalFreeze
flag is set on the issuing account (the asset is frozen).The
VaultID
is specified AND:Owner
of the vault.AssetMaximum
value is lower than the currentAssetsTotal
.3.1.1.4 State Changes
The
VaultID
is not specified:Vault
ledger object.MPTokenIssuance
ledger object for the vault shares.AccountRoot
object withVaultID
in the ledger entries field.The
VaultID
is specified:3.1.2
VaultDelete
TransactionThe
VaultDelete
transaction deletes an existing vault object.TransactionType
string
Uint16
VaultID
string
Hash256
N/A
3.1.2.1 Failure Conditions
VaultID
does not exist on the ledger.AssetsTotal
,AssetsAvailable
, andSharesTotal
are greater than zero.3.1.2.2 State Changes
MPTokenIssuance
and any remainingMPToken
objects for the vault shares.DirectoryNode
object.AccountRoot
object of the pseudo-account.Vault
object.3.2
VaultDeposit
andVaultWithdraw
transactionsDepositors call the
VaultDeposit
andVaultWithdraw
transactions to add or remove assets from the Tokenized Vault.3.2.1
VaultDeposit
transactionThe
VaultDeposit
transaction adds Liqudity in exchange for vault shares.TransactionType
string
UINT16
VaultID
string
HASH256
N/A
Amount
string
orobject
AMOUNT
N/A
3.2.1.1 Failure conditions
VaultID
does not exist.Amount
to theAssetsTotal
of the vault would exceed theAssetsMaximum
.Private
and theAccount
depositing the assets does not have permission to deposit the asset.lsfFrozen
flag is set.3.2.1.2 State Changes
If no
MPToken
object exists for the depositor, create one. For object details, see 3.4.2MPToken
.Increment the$\Delta_{share}$ .
MPToken
MPTAmount
field byIf the deposited Asset is XRP, it is transferred from the depositor account to the
AccountRoot
of theVault
, updating theBalance
field of both accounts.If the deposited asset is an
IOU
, the balance between theVault
pseudo-account and theissuer
account is adjusted.If the deposited asset is an
MPT
, the balance of theVault
pseudo-accountMPToken
is incremented, and the balance of the depositor is decremented byAmount
.Increase the$\Delta_{share}$ .
SharesTotal
byIncrease the$\Delta_{asset}$ .
AssetsTotal
andAssetsAvailable
by3.2.2
VaultWithdraw
transactionThe
VaultWithdraw
transaction withdraws Tokens in exchange for the vault's shares.TransactionType
string
UINT16
VaultID
string
HASH256
N/A
AssetAmount
number
UINT64
ShareAmount
number
UINT64
Destination
string
AccountID
3.2.2.1 Failure conditions
ID
does not exist.AssetAmount
andShareAmount
are specified.Destination
account is specified, the account does not have permission to hold the asset.lsfFrozen
flag is set.3.2.2.2 State Changes
If the withdrawn Asset is XRP, it is transferred from the
Vault
pseudo-accoount to the redeemer, updating each account'sBalance
field.If the withdrawn asset is an
IOU
, the balance between theVault
pseudo-account and theissuer
account is adjusted.If the deposited asset is an$\Delta_{asset}$ .
MPT
, the balance of theVault
pseudo-accountMPToken
is decremented, and the redeemer's balance is decremented byChanges to the
MPToken
object of the share.MPTAmount
value byMPTAmount
is zero, delete the object.Decrease the$\Delta_{share}$ .
SharesTotal
of the Vault byDecrease the$\Delta_{asset}$
AssetsTotal
andAssetsAvailable
by3.3 VaultClawback Transaction
3.3.1
VaultClawback
transactionThe
VaultClawback
transaction performs a Clawback from the Vault, exchanging the Shares of an account. Conceptually, the transaction performsVaultWithdraw
on behalf of theHolder
, sending the funds to theIssuer
account of the asset. In case there are insufficient funds for the entireAmount
the transaction will perform a partial Clawback, up to theVault.AssetsAvailable
. The Clawback transaction MUST respect any future fees or penalties.TransactionType
string
UINT16
VaultID
string
HASH256
N/A
Holder
string
AccountID
N/A
Amount
number
NUMBER
0
clawback all funds, up to the total Shares theHolder
owns.3.3.1.1 Failure conditions
ID
does not exist.Holder
account does not hold any Vault Shares.3.3.1.2 State Changes
If the Clawback asset is an
IOU
, the balance between theVault
pseudo-account and theIssuer
account is decreased by up toAmount
.If the deposited asset is an
MPT
, the balance of theVault
pseudo-accountMPToken
is decreased by up toAmount
.Changes to the
MPToken
object of the share:MPTAmount
value byMPTAmount
is zero, delete the object.Decrease the$\Delta_{share}$ .
SharesTotal
of the Vault byDecrease the$\Delta_{asset}$
AssetsTotal
andAssetsAvailable
byAppendix
A-1 F.A.Q.
A-1.1 What is the difference between a
Withdraw
andRedeem
configuration in theVaultWithdraw
transaction?The depositor uses the
VaultWithdraw
transaction to convert their shares for the assets held in the Vault. The depositor does so by specifying eitherAssetAmount
orShareAmount
field. These work as aWithdraw
orRedeem
.A
Withdraw
is performed when the depositor provides theAssetAmount
field. The depositor specifies the amount of assets they want to withdraw, and the Vault calculates the cost in terms of Shares.In contrast, a
Redeem
is performed when the depositor provides theShareAmount
field. The depositor specifies the mount of share they are willing to burn, and the Vault calculates the Assets amount that will return.A-1.2 Why does the specification allow both
Withdraw
andRedeem
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
Beta Was this translation helpful? Give feedback.
All reactions