0082 XLS-82d: Multi-Purpose Tokens (MPTs) integration into XRP Ledger DEX #231
gregtatcam
started this conversation in
Standard Proposals
Replies: 2 comments
-
My preference would be strongly for the blackhole account flag for serializing the mpt_issuance_id. Having a white/blacklist of non-standard currencies is ugly and would add a hash map lookup for every Offer and AMM ledger entry in whole ledger operations. typo: "then additional 32 bits have to be red and deserialized into a sequence number." |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can one use MFT to implement fractional NFT? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
MPT Integration into DEX
Abstract
This proposal adds Multi-purpose token (MPT) support to the XRPL DEX.. MPT is described in XLS-33d. Current XRPL transactions that interact with the DEX are:
AMMCreate
: Create a new Automated Market Maker (AMM) instance for trading a pair of assets (fungible tokens or XRP).AMMDeposit
: Deposit funds into an AMM instance and receive the AMM's liquidity provider tokens (LP Tokens) in exchange.AMMWithdraw
: Withdraw assets from an AMM instance by returning the AMM's liquidity provider tokens (LP Tokens).CheckCreate
: Create a Check object in the ledger, which is a deferred payment that can be cashed by its intended destination.CheckCash
: Attempts to redeem a Check object in the ledger to receive up to the amount authorized by the corresponding CheckCreate transaction.OfferCreate
: An OfferCreate transaction places an Offer in the decentralized exchange.Payment
: A Payment transaction represents a transfer of value from one account to another.MPT will support all of the above transactions. MPT can be combined with IOU and XRP tokens in the transactions. For instance, a Payment could be a cross-token payment from MPT token to IOU token; AMM can be created for XRP and MPT token-pair; an order book offer can be created to buy some MPT token and to sell another MPT token. MPT doesn't modify the transactions fields, flags, and functionality. However, the JSON of the MPT amount field differs from the JSON of the IOU amount field. Instead of$63^2$ . Below is an example of JSON MPT amount:
currency
andissuer
, MPT is identified bympt_issuance_id
. MPT amountvalue
is INT or UINT, which must be less or equal toAny transaction with MPT Amount has to use JSON format as described above. For any transaction, which uses MPT token, the token has to be created first by an issuer with
MPTokenIssuanceCreate
transaction and in most cases, except forAMMCreate
andOfferCreate
, the token has to be authorized by the holder account withMPTokenAuthorize
transaction as described in XLS-33d.This proposal provides JSON request examples for MPT-supported transactions and relevant API's. It highlights any differences compared to existing transaction functionality. For a comprehensive description of all transactions refer to XRPL documentation
MPT Supported Transactions
AMM
AMM is identified by a token pair. Any token or both tokens in AMM transactions can be MPT. I.e., in addition to the current combination of XRP/IOU and IOU/IOU token pair, AMM can have XRP/MPT, IOU/MPT, and MPT/MPT token pair. Each MPT in the pair is identified by
mpt_issuance_id
. If both tokens are MPT then each token must have a uniquempt_issuance_id
. In case ofAMMCreate
the token pair is identified byAmount
andAmount2
. In case ofAMMDeposit
,AMMWithdraw
, andAMMDelete
the token pair is identified byAsset
andAsset2
with the token type corresponding toAmount
andAmount2
ofAMMCreate
.Asset
andAsset2
areSTIssue
type, which represents a token bycurrency
andissuer
. IfSTIssue
type represents MPT thenmpt_issuance_id
must be used instead.AMMDeposit
andAMMWithdraw
have optional fieldsAmount
andAmount2
, which if present must match the type ofAsset
andAsset2
respectively.Create JSON Example
For each MPT token
AMMCreate
creates and authorizesMPToken
object for AMM pseudo-account.In addition to the current failure scenarios
AMMCreate
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and AMM creator is not the issuer of MPTMPTLocked
flag is set and AMM creator is not the issuer of MPTMPTRequireAuth
flag is set and AMM creator is not authorizedMPTCanTransfer
is not set and AMM creator is not the issuer of MPTMPTCanClawback
is setDeposit JSON Example
In addition to the current failure scenarios
AMMDeposit
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and AMM creator is not the issuer of MPTMPTLocked
flag is set and AMM creator is not the issuer of MPTMPTRequireAuth
flag is set and AMM creator is not authorizedMPTCanTransfer
is not set and AMM creator is not the issuer of MPTWithdraw JSON Example
In addition to the current failure scenarios
AMMWithdraw
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and AMM creator is not the issuer of MPTMPTLocked
flag is set and AMM creator is not the issuer of MPTMPTRequireAuth
flag is set and AMM creator is not authorizedMPTCanTransfer
is not set and AMM creator is not the issuer of MPTDelete JSON Example
In addition to the current failure scenarios
AMMDelete
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and AMM creator is not the issuer of MPTCheckCreate JSON Example
In addition to the current failure scenarios
CheckCreate
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and the account is not the issuer of MPTMPTLocked
flag is set and the account is not the issuer of MPTMPTRequireAuth
flag is set and the account is not authorizedMPTCanTransfer
is not set and the account is not the issuer of MPTCheckCash Transaction
In addition to the current failure scenarios
CheckCash
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and the account is not the issuer of MPTMPTLocked
flag is set and the account is not the issuer of MPTMPTRequireAuth
flag is set and the account is not authorizedMPTCanTransfer
is not set and the account is not the issuer of MPTOfferCreate Transaction
OfferCreate
can have any token combination ofTakerGets
andTakerPays
. I.e., in addition to the current combination of XRP/IOU and IOU/IOU tokens,OfferCreate
can have XRP/MPT, IOU/MPT, and MPT/MPT tokens.OfferCreate
automatically creates and authorizesMPToken
object for the offer's owner account when the offer is consumed andMPToken
object doesn't exist forTakerPays
'smpt_issuance_id
.In addition to the current failure scenarios
OfferCreate
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and the account is not the issuer of MPTMPTLocked
flag is set and the account is not the issuer of MPTMPTRequireAuth
flag is set and the account is not authorizedMPTCanTransfer
is not set and the account is not the issuer of MPTPayment Transaction
Payment
can have any cross-token payment combination. I.e., in addition to the current combination of XRP/IOU and IOU/IOU cross-token payment,Payment
can have XRP/MPT, IOU/MPT, and MPT/MPT cross-token payment. MPT can be used to specifyPaths
, in which casempt_issuance_id
should be used instead ofcurrency
andissuer
as shown in the example above. MPT doesn't support payment rippling.mpt_issuance_id
identifies a unique MPT and it's impossible to reference the same MPT with different issuer.In addition to the current failure scenarios
Payment
fails if:MPTokenIssuance
object doesn't existMPToken
object doesn't exist and the account is not the issuer of MPTMPTLocked
flag is set and the account is not the issuer of MPTMPTRequireAuth
flag is set and the account is not authorizedMPTCanTransfer
is not set and the account is not the issuer of MPTMPTCanTrade
is not setAPI's
To use MPT in API's,
currency
andissuer
fields must be replaced withmpt_issuance_id
field as shown in the examples below.path_find
ripple_path_find
amm_info
ledger_entry
book_offers
Appendices
STIssue
serializationSTIssue
type defines AMM token pair used inAMMDeposit
,AMMWithdraw
, andAMMDelete
transactions. However, its current serialization format presents a challenge for integrating MPT into the DEX.Currently,
STIssue
is serialized as a 160-bitcurrency
code followed by a 160-bitaccount
address. This format doesn't have spare bits to indicate whether the serializedSTIssue
represents acurrency
andaccount
or anmpt_issuance_id
. I.e. reading 320 bits doesn't provide enough information to unequivocally distinguishcurrency
andaccount
frommpt_issuance_id
.Proposed Solutions
Splitting
mpt_issuance_id
with black hole account flag:mpt_issuance_id
into its sequence number and account.currency
andaccount
. Ifaccount
is the black hole account then additional 32 bits have to be read and deserialized into a sequence number.mpt_issuance_id
.Leveraging standard vs. non-standard currency code distinction:
USD
currency code in hex is0000000000000000000000005553440000000000
.015841551A748AD2C1F76FF6ECB0CCCD00000000
.mpt_issuance_id
. The 16-bit value distinguishesmpt_issuance_id
from both standard and non-standard currency code.currency
and checks for the leading 0x0001 to identify MPT and reads additional 48 bits to assemble thempt_issuance_id
.rippled
code doesn't enforce the non-standard code rule.As of 8/19/24, an entire ledger with index 90166625, has in total 140,602 currencies. Of which 4,782 are standard currencies, 135,889 are non-standard currencies. 22 of non-standard currencies start with eight zero bits. There are 28 Offers with non-standard currency, which start with eight zero bits. There are no AMMs or Checks with non-standard currency. While these non-standard currencies start with eight zero bits, none of them have 88 reserve zero bits followed by non-zero bits. None of the non-standard currencies start with 0x0001.
Beta Was this translation helpful? Give feedback.
All reactions