0065 XLS - 65d: Managed Single Asset Tokenized Pool #192
Tapanito
started this conversation in
Standard Proposals
Replies: 1 comment 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.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Managed Single Asset Tokenized Pool
Abstract
We propose a tokenized Pool object standard to represent ownership shares of XRP or a single Fungible Token. We also propose standard interfaces to interact with the Pool object. Tokenized pools serve diverse purposes, such as lending markets, aggregators, yield-bearing tokens, etc. While the specific protocol design & implementation for each of these use cases may vary, this document establishes a universal framework to enable a unified and common standard that fosters the development and expansion of diverse use cases.
1. Introduction
Tokenized Pools have well-established standards in the broader blockchain ecosystem. To facilitate the adoption of the XRP Ledger in the cryptocurrency ecosystem, we propose following the ERC-4626 standard. The standard introduces a minimal interface implemented by protocols relying on tokenized pools.
An early standard establishes minimum functional requirements for protocols requiring a Tokenized Pool. Furthermore, a single standard lowers the effort required for future protocol design and implementation.
Adopting an already established standard will simplify the integration of XRP Ledger with existing frontends.
Goals
Pool
.Pool
instance.1.1. Terminology
LPTokens
) represent the liquidity providers' share of the pool instance.LPTokens
are Fungible Token issued by the pseudo-account of the Pool. A Trust Line maintains the balance ofLPTokens
between the Liquidity Provider and the pools pseudo-account.1.2. Actors
2. New
Pool
Ledger EntryA
Pool
Ledger Entry represents the state of a tokenized pool. It contains fields necessary to identify a pool and general fielddetails
containing protocol-specific fields.A
Pool
requires a uniqueID
to identify the object. We do not limit the number of pools a single account may create. Therefore, the unique pool `ID' must uniquely identify multiple pools created by the same account for the same Asset.We propose to use a similar technique to generate a
Pool
ID
as is used to create anOffer
Object ID:SHA512-Half
of the following values:Pool
space key0x0050
(capital P)AccountID
of the account creating the pool.Sequence
number of the transaction creating the Pool. If the transaction used a Ticket, use theTicketSequence
value.The
Pool
ledger entry contains the following fields:Account
specifies the ID of theAccountRoot
object associated with thePool
ledger entry.DelegateAccountID
specifies the ID of the account creating the Pool object. Note thatDelegateAccountID
!=Account
.DelegateAccountURI
specifies an URI to an off-chain identifier of the Pool Delegate.PoolSequence
specifies theSequence
number of the transaction that created the Pool.Asset
specifies the Asset of the Pool instance.LPTokenBalance
specifies the balance of the outstanding liquidity provider tokens (LPTokens).AvailableLiquidity
specifies the liquidity available in the Pool.Type
specifies the concrete type of the Pool. For example,LendingPool
,Aggregator
or others.Frozen
indicates whether thePool
is frozen.Details
specifies protocol-specific fields. A protocol that uses aPool
instance specifies the content of this object. The details field allows for a flexible design and reduces the number of unique ledger entry types needed.2.1.
LPTokens
Liquidity Provider Tokens (
LPTokens
) represent a share of the Pool the holder owns. A Trust Line tracks the balance of LPTokens. However, some pools may require LPTokens to be non-transferable. Therefore, configuring whether assets are transferable is left to a specific implementation.LPTokens
are uniquely identified by the following:issuer
thePool
instance Account ID and;currency
the currency code forLPTokens
is formed deterministicallyLPTokenID
=0x03
+ first 19 bytes from the uniquePoolID
. We also leave the option open for the protocol to implement their currency code generation scheme.2.2. AccountRoot Entry
An
AccountRoot
entry tracks the balance of XRP or Token, issued LP Tokens, and other protocol-specific assets, such as collateral.The following rules must apply to the
AccountRoot
ledger entry associated with a pool:Special Considerations for the pseudo-account
lsfDefaultRipple
controls whether users can send pseudo-account issued tokens amongst themselves. It is an implementation-specific flag.3.
CUD
Pool
instance transactionsThis proposal introduces transactions to interact with a
Pool
object. It specifies general fields and rules forCreate
,Update
andDelete
transactions. However, the protocol-specific logic is left to the users of thePool
.3.1.
Create
aPool
instance transactionA transaction creating a
Pool
MUST include the following fields.3.1.1 Common transaction fields
TransactionType
string
UINT16
TransactionType
specifies the new transaction type. The integer value is55
.Fee
string
AMOUNT
Fee
specifies the integer amount of XRP, in drops, to be destroyed as a cost of creating a Pool instance.Asset
string
orobject
ISSUE
Asset
specifies the asset, XRP or Fungible Token, of thePool
instance.Type
string
UINT16
Type
specifies the concrete type of the Pool. This is a protocol-specific value.PoolDelegateURI
string
BLOB
Details
object
BLOB
Details
specifies the protocol-specific values for thePool
.3.1.2. Failure Conditions
The
Create
transaction MUST fail when:Pool
is NOT theissuer
of the Token ANDRequireAuth
flag for the Token is set ANDasfGlobalFreeze
is NOT set for theissuer
account.DefaultRipple
flag disabled.Type
is not supported.3.1.3. State Changes
If the transaction is successful:
Pool
,AccountRoot
,DirectoryNode
] are created.The
regular key
for theAccountRoot
ledger entry is set to account zero, and the master key is disabled. This effectively prevents all ways of signing transactions from this account.3.1.3. Trustlines
A successful
Create
transaction will automatically create at least the following trust lines:Pool
account and the issuer of the Fungible Token.LPTokens
.Specific protocols may create additional Trust Lines.
3.1.4.
Pool
Reserve FundsThe account that creates a
Pool
object incurs one owner reserve (2 XRP at the time of writing this document).3.2.
Update a
Pool
instance transactionA transaction updating a
Pool
MUST include the following fields.3.2.1 Common transaction fields
TransactionType
string
UINT16
TransactionType
specifies the new transaction type. The integer value is56
.Account
string
AccountID
Indicates the account that initiated the transaction.
Account
must equal thePool.DelegateAccountID
field.Fee
string
AMOUNT
Fee
specifies the integer amount of XRP, in drops, to be destroyed as a cost of modifying a Pool instance.PoolSequence
number
UINT32
Sequence
number of thePool
instance.PoolDelegateURI
string
BLOB
Frozen
BOOL
Details
struct
BLOB
Details
is a struct with the protocol-specific fields.3.2.2 Failure Conditions
The transaction MUST fail if the AccountID of the transaction DOES NOT equal
PoolDelegateID
.3.2.3 State Changes
The transaction modifies the
Details
field of the Pool.3.3.
Delete
aPool
instance transaction.3.3.1. Common transaction fields
TransactionType
string
UINT16
TransactionType
specifies the new transaction type. The integer value is57
.Account
string
AccountID
Indicates the account that initiated the transaction.
Account
must equal thePool.DelegateAccountID
field.Fee
string
AMOUNT
Fee
specifies the integer amount of XRP, in drops, to be destroyed as a cost of deleting a Pool instance. TODO: what is the specific fee?PoolSequence
number
UINT32
Sequence
number of thePool
instance.3.3.2 Failure Conditions
The transaction MUST fail if the AccountID of the transaction DOES NOT equal
PoolDelegateID
.The transaction MUST fail if the
LPTokenBalance
of the Pool are NOT zero.3.3.3 State Changes
Delete the
Pool
ledger entry.Delete the
AccountRoot
object.Delete the
DirectoryNode
object.Delete all associated Trust Lines.
Release Owner Funds.
4. LiquidityProvider Transactions
The following transactions add or remove assets to a
Pool
instance. Protocols may constrain who can make the transactions and the amount of tokens that can be deposited or withdrawn.Deposit
: The deposit transaction adds liquidity to thePool
in exchange for shares of the instance in the form ofLPTokens
.Withdraw
: The withdraw transaction removes liquidity from thePool
instance in exchange forLPTokens
issued by theAccountRoot
of the Pool.Redeem
: The redeem transaction exchanges some amount ofLPTokens
for the equivalent amount of assets in thePool
.4.1
Deposit
transactionThe
Deposit
transaction adds Liqudity in exchange forLPTokens
of the Pool.4.1.1 Computing LPToken shares
Assume the following variables that define the pool balance:
We compute the number of shares a liquidity provider will issue as follows:
Following is the updated pool composition after the successful deposit:
LPToken
balance in the pool.4.1.2 Common transaction fields
TransactionType
string
UINT16
TransactionType
specifies the new transaction type. The integer value is58
.Account
string
AccountID
Indicates the account that initiated the transaction.
Fee
string
AMOUNT
Fee
specifies the integer amount of XRP, in drops, to be destroyed as a cost of depositing assets to the Pool.Amount
string
orobject
AMOUNT
Amount
specifies the amount of the pool asset to deposit.Amount
is a string when the Asset of the Pool is XRP. Otherwise, it is anAMOUNT
object
.PoolSequence
number
UINT32
Sequence
number of thePool
instance.PoolDelegateID
String
AccountID
The
PoolDelegateID
of the Pool.4.1.3 Failure Conditions
The transaction MUST fail when:
Pool
is frozen.4.1.4 State Changes
AccountRoot
of thePool
, updating theBalance
field of both accounts.Pool
instance account and theissuer
account is adjusted.Pool
account issuesLPTokensBalance
of the Pool byAvailableLiquidity
of the Pool by4.2.
Withdraw
transactionThe
Withdraw
transaction withdraws Tokens in exchange for an equivalent number ofLPTokens
.4.2.1. Computing LPToken shares
Assume the following variables that define the pool balance:
LPTokens
to burn.We compute the number of$\Delta_{Assets}$ as follows:
$$\Delta_{LPTokens} = \frac{\Delta_{Assets} \times (\Gamma_{LPTokens} + 0^{\Gamma_{LPTokens}})}{\Gamma_{Assets} + 0^{\Gamma_{Assets}}} $$
LPTokens
to burn to withdrawFollowing is the updated pool composition after the successful deposit:
LPToken
balance in the pool.4.2.2 Common transaction fields
TransactionType
string
UINT16
TransactionType
specifies the new transaction type. The integer value is59
.Account
string
AccountID
The
ID
of the account that initiated the transaction and received the funds.Destination
string
AccountID
Destination
is an optional field. It indicates a separate account to receive the assets. The destination account must meet all the requirements to hold the Asset.Fee
string
AMOUNT
Fee
specifies the integer amount of XRP, in drops, to be destroyed as a cost of depositing assets to the Pool.Amount
string
orobject
AMOUNT
Amount
specifies the amount of the pool asset to withdraw.Amount
is a string when the Asset of the Pool is XRP. Otherwise, it is anAMOUNT
object.PoolSequence
number
UINT32
Sequence
number of thePool
instance.PoolDelegateID
String
AccountID
The
PoolDelegateID
of the Pool.4.2.3. Failure Conditions
LPTokens
to withdraw funds from the Pool.Pool
is frozen.4.2.4. State Changes
Pool
instance account to the account initiating the transaction, updating each account'sBalance
field.Pool
instance account and theissuer
account is adjusted.Pool
account burnsLPTokensBalance
of the Pool byAvailableLiquidity
of the Pool by4.2.5. Frozen Assets
An IOU issuer may enact a Global Freeze on issued Fungible Tokens. If a frozen token is in a Pool, it is withdrawable by specifying the
Destination
account as theissuer
of the Asset.4.3.
Redeem
transactionThe
Redeem
transaction burns a specified number ofLPTokens
in exchange for Tokens of the Pool.4.3.1. Computing assets
Assume the following variables that define the pool balance:
LPTokens
the user wants to burn.We compute the number of assets returned by burning$\Delta_{LPTokens}$ as follows:
Following is the updated pool composition after the successful deposit:
LPToken
balance in the pool.4.3.2. Common transaction fields
TransactionType
string
UINT16
TransactionType
specifies the new transaction type. The integer value is60
.Account
string
AccountID
Indicates the account that initiated the transaction.
Fee
string
AMOUNT
Fee
specifies the integer amount of XRP, in drops, to be destroyed as a cost of depositing assets to the Pool.LPTokensOut
string
AMOUNT
LPTokensOut
specifies the maximum amount ofLPTokens
the account instantiating the transaction is willing to exchange.PoolSequence
number
UINT32
Sequence
number of thePool
instance.PoolDelegateID
String
AccountID
The
PoolDelegateID
of the Pool.Destination
string
AccountID
Destination
is an optional field. It indicates a separate account to receive the assets. The destination account must meet all the requirements to hold the Asset.4.3.3. Failure Conditions
LPTokens
to redeem funds from the Pool.LPTokensOut
does not match the pseudo-account of the Pool.Pool
is frozen.4.3.4. State Changes
Pool
instance account to the account initiating the transaction, updating each account'sBalance
field.Pool
instance account and theissuer
account is adjusted.Pool
account burnsLPTokensBalance
of the Pool byAvailableLiquidity
of the Pool by4.2.5 Frozen Assets
An IOU issuer may enact a Global Freeze on issued Fungible Tokens. If a frozen token is in a Pool, it is only redeemable by specifying the
Destination
account as theissuer
of the Asset.5. Read-Only Methods
We introduce the following read-only methods to simplify the interaction with the Pool.
ConvertTo
: methods are rough estimates that do not account for operation-specific details like withdrawal fees, slippage, etc. They are for frontends and applications that need an average value of shares or assets, not an exact value.Preview
: methods are for applications that need an exact value that attempts to account for fees and slippage. We include a preview method to match each mutable transaction. These methods must not account for deposit or withdrawal limits to ensure they are easily composable.Max
: methods provide the maximum asset amount an account may deposit or withdraw from a Pool.5.1.
ConvertToLPTokens
The
ConvertToLPTokens
method returns the amount of LPTokens the Pool would exchange for the Tokens provided.The result:
This calculation MAY NOT reflect the per-user price-per-share. Instead, it should reflect the “average user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.
5.2
ConvertToAssets
The
ConvertToAssets
method returns the amount of Tokens the Pool would exchange for the LPTokens provided.The result:
This calculation MAY NOT reflect the per-user price-per-share. Instead, it should reflect the “average user’s” price-per-share, meaning what the average user should expect to see when exchanging to and from.
5.3
PreviewDeposit
The
PreviewDeposit
method simulates the effects of theDeposit
transaction at the current ledger, given the current XRP Ledger state.The result:
LPTokens
minted by aDeposit
transaction. I.e.Deposit
should return the same or moreLPTokens
asPreviewDeposit
if executed in the same ledger.MaxDeposit
and should always act as though the deposit would be accepted, regardless of whether the user has enough assets.Deposit
to fail.Note that an unfavourable discrepancy between
ConvertToLPTokens
andPreviewDeposit
SHOULD be considered slippage in share price or other conditions, meaning the depositor will lose assets by depositing.5.4
PreviewWithdraw
The
PreviewWithdraw
method simulates the effects of theWithdraw
transaction at the current ledger, given the current XRP Ledger state.The result:
LPTokens
burned by aWithdraw
transaction. I.e.Withdraw
should return the same or moreLPTokens
asPreviewWithdraw
if executed in the same ledger.MaxWithdraw
and should always act as though the withdrawal would be accepted, regardless of whether the user has enoughLPTokens
.Withdraw
to fail.Note that an unfavourable discrepancy between
ConvertToLPTokens
andPreviewWithdraw
SHOULD be considered slippage in share price or other conditions, meaning the withdrawer will lose assets by withdrawing.5.5
PreviewRedeem
The
PreviewRedeem
method simulates the effects of theRedeem
transaction at the current ledger, given the current XRP Ledger state.The result:
PreviewRedeem
transaction. For example,Redeem
should return the same or more assets asPreviewRedeem
if executed in the same ledger.MaxRedeem
and should always act as though the redeem would be accepted, regardless of whether the user has enoughLPTokens
.Redeem
to fail.Note that an unfavourable discrepancy between
ConvertToAssets
andPreviewRedeem
SHOULD be considered slippage in share price or other conditions, meaning the redeemer will lose assets by redeeming.5.6
MaxDeposit
The
MaxDeposit
method returns the maximum asset amount a user can deposit into the Pool with theDeposit
transaction given the current XRP Ledger state.The result:
Deposit
transaction. I.e.,MaxDeposit
must be lower than theDeposit
transaction.5.7
MaxWithdraw
The
MaxWithdraw
method returns the maximum asset amount a user can withdraw from the Pool with theWithdraw
transaction given the current XRP Ledger state.The result:
Withdraw
transaction. For example,MaxWithdraw
must be lower than theWithdraw
transaction.LPTokens
.5.8
MaxRedeem
The
MaxRedeem
method returns the maximumLPToken
amount a user can withdraw from the Pool with theRedeem
transaction given the current XRP Ledger state.The result:
LPTokens
burned by aRedeem
transaction. I.e.MaxRedeem
must be lower than theRedeem
transaction.LPTokens
.Beta Was this translation helpful? Give feedback.
All reactions