0082 XLS-82d: Multi-Purpose Tokens (MPTs) integration into XRP Ledger DEX #231
Replies: 4 comments 3 replies
-
|
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.
-
|
Can one use MFT to implement fractional NFT? |
Beta Was this translation helpful? Give feedback.
-
|
Can you migrate old tokens to the MPT? |
Beta Was this translation helpful? Give feedback.
-
|
@gregtatcam what is the status of this specification? Can it be moved to a pull-request? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Title: Multi-Purpose Tokens (MPTs) integration into XRP Ledger DEX Type: draft Author: Gregory Tsipenyuk Affiliation: RippleMPT Integration into DEX
Abstract
This proposal adds Multi-purpose token (MPT) support to the XRPL DEX.. MPT is described in XLS-33. 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).AMMClawback: Enable token issuers to claw back tokens from wallets that have deposited into AMM pools.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:
currencyandissuer, MPT is identified bympt_issuance_id. MPT amountvalueis 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
MPTokenIssuanceCreatetransaction and in most cases, except forAMMCreateandOfferCreate, the token has to be authorized by the holder account withMPTokenAuthorizetransaction 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 ofAMMCreatethe token pair is identified byAmountandAmount2. In case ofAMMDeposit,AMMWithdraw, andAMMDeletethe token pair is identified byAssetandAsset2with the token type corresponding toAmountandAmount2ofAMMCreate.AssetandAsset2areSTIssuetype, which represents a token bycurrencyandissuer. IfSTIssuetype represents MPT thenmpt_issuance_idmust be used instead.AMMDepositandAMMWithdrawhave optional fieldsAmountandAmount2, which if present must match the type ofAssetandAsset2respectively.Create JSON Example
{ "Account": "rffMEZLzDQPNU6VYbWNkgQBtMz6gCYnMAG", "Amount": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308", "value": "1000" }, "Amount2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308", "value": "1000" }, "Fee": "2000000", "Flags": 0, "TradingFee": "0", "TransactionType": "AMMCreate" }For each MPT token
AMMCreatecreates and authorizesMPTokenobject for AMM pseudo-account.In addition to the current failure scenarios
AMMCreatefails if:MPTokenIssuanceobject doesn't existMPTokenobject doesn't exist and AMM creator is not the issuer of MPTMPTLockedflag is set and AMM creator is not the issuer of MPTMPTRequireAuthflag is set and AMM creator is not authorizedMPTCanTransferis not set and AMM creator is not the issuer of MPTMPTCanClawbackis setDeposit JSON Example
{ "Account": "rffMEZLzDQPNU6VYbWNkgQBtMz6gCYnMAG", "Amount": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308", "value": "100" }, "Amount2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308", "value": "100" }, "Asset": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, "Asset2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308" }, "Fee": "10", "Flags": 524288, "TransactionType": "AMMDeposit" }In addition to the current failure scenarios
AMMDepositfails if:MPTokenIssuanceobject doesn't existMPTokenobject doesn't exist and the account is not the issuer of MPTMPTLockedflag is set and the account is not the issuer of MPTMPTRequireAuthflag is set and the account is not authorizedMPTCanTransferis not set and the account is not the issuer of MPTWithdraw JSON Example
{ "Account": "rffMEZLzDQPNU6VYbWNkgQBtMz6gCYnMAG", "Amount": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308", "value": "100" }, "Amount2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308", "value": "100" }, "Asset": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, "Asset2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308" }, "Fee": "10", "Flags": 1048576, "TransactionType": "AMMWithdraw" }AMMWithdrawcreates and authorizesMPTokenobject if Liquidity Provider doesn't ownMPTokenobject for a withdrawn token.In addition to the current failure scenarios
AMMWithdrawfails if:MPTokenIssuanceobject doesn't existMPTLockedflag is set and the account is not the issuer of MPTMPTRequireAuthflag is set and the account is not authorizedMPTCanTransferis not set and the account is not the issuer of MPTDelete JSON Example
{ "Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm", "Asset": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, "Asset2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308" }, "Fee" : "10", "Flags" : 0, "Sequence" : 9, "TransactionType" : "AMMDelete" }In addition to the current failure scenarios
AMMDeletefails if:MPTokenIssuanceobject doesn't existMPTokenobject doesn't exist and the account is not the issuer of MPTClawback JSON Example
{ "TransactionType": "AMMClawback", "Account": "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL", "Holder": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B", "Asset": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, "Asset2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308" }, "Amount": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308", "value" : "1000" }, "Flags": 1 }AMMClawbackcreates and authorizesMPTokenobject if Liquidity Provider doesn't ownMPTokenobject for a withdrawn token.In addition to the current failure scenarios
AMMClawbackfails if:MPTokenIssuanceobject doesn't existMPTLockedflag is set and the account is not the issuer of MPTMPTRequireAuthflag is set and the account is not authorizedMPTCanTransferis not set and the account is not the issuer of MPTCheckCreate JSON Example
{ "TransactionType": "CheckCreate", "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo", "Destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", "SendMax": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308", "value": "100" }, "Expiration": 570113521, "InvoiceID": "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B", "DestinationTag": 1, "Fee": "12" }In addition to the current failure scenarios
CheckCreatefails if:MPTokenIssuanceobject doesn't existMPTokenobject doesn't exist and the account is not the issuer of MPTMPTLockedflag is set and the account is not the issuer of MPTMPTRequireAuthflag is set and the account is not authorizedMPTCanTransferis not set and the account is not the issuer of MPTCheckCash Transaction
{ "Account": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy", "TransactionType": "CheckCash", "Amount": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308", "value": "100" }, "CheckID": "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334", "Fee": "12" }In addition to the current failure scenarios
CheckCashfails if:MPTokenIssuanceobject doesn't existMPTokenobject doesn't exist and the account is not the issuer of MPTMPTLockedflag is set and the account is not the issuer of MPTMPTRequireAuthflag is set and the account is not authorizedMPTCanTransferis not set and the account is not the issuer of MPTOfferCreate Transaction
{ "Account": "rMTysmc799PzTvK228jNaua6w3b6VgYUjw", "Fee": "10", "Flags": 0, "TakerGets": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308", "value": "100" }, "TakerPays": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308", "value": "100"}, "TransactionType": "OfferCreate" }OfferCreatecan have any token combination ofTakerGetsandTakerPays. I.e., in addition to the current combination of XRP/IOU and IOU/IOU tokens,OfferCreatecan have XRP/MPT, IOU/MPT, and MPT/MPT tokens.OfferCreateautomatically creates and authorizesMPTokenobject for the offer's owner account when the offer is consumed andMPTokenobject doesn't exist forTakerPays'smpt_issuance_id.In addition to the current failure scenarios
OfferCreatefails if:MPTokenIssuanceobject doesn't existMPTokenobject doesn't exist and the account is not the issuer of MPTMPTLockedflag is set and the account is not the issuer of MPTMPTRequireAuthflag is set and the account is not authorizedMPTCanTransferis not set and the account is not the issuer of MPTPayment Transaction
{ "Account" : "rJ85Mok8YRNxSo7NnxKGrPuk29uAeZQqwZ", "DeliverMax" : { "mpt_issuance_id" : "00000010A407AF5856CCF3C42619DAA925813FC955C72983", "value" : "100" }, "DeliverMin" : { "mpt_issuance_id" : "00000010A407AF5856CCF3C42619DAA925813FC955C72983", "value" : "90" }, "Destination" : "rHKBGB4vhnnVFmfrj4sUx3F9riz2CiHgCK", "Fee" : "10", "Flags" : 131072, "Paths" : [ [ { "mpt_issuance_id" : "00000004A407AF5856CCF3C42619DAA925813FC955C72983" }, { "mpt_issuance_id" : "0000000AA407AF5856CCF3C42619DAA925813FC955C72983" }, { "mpt_issuance_id" : "00000010A407AF5856CCF3C42619DAA925813FC955C72983" } ] ], "SendMax" : "100000000", }Paymentcan have any cross-token payment combination. I.e., in addition to the current combination of XRP/IOU and IOU/IOU cross-token payment,Paymentcan have XRP/MPT, IOU/MPT, and MPT/MPT cross-token payment. MPT can be used to specifyPaths, in which casempt_issuance_idshould be used instead ofcurrencyandissueras shown in the example above. MPT doesn't support payment rippling.mpt_issuance_ididentifies a unique MPT and it's impossible to reference the same MPT with different issuer.In addition to the current failure scenarios
Paymentfails if:MPTokenIssuanceobject doesn't existMPTokenobject doesn't exist and the account is not the issuer of MPTMPTLockedflag is set and the account is not the issuer of MPTMPTRequireAuthflag is set and the account is not authorizedMPTCanTransferis not set and the account is not the issuer of MPTMPTCanTradeis not setAPI's
To use MPT in API's,
currencyandissuerfields must be replaced withmpt_issuance_idfield as shown in the examples below.path_find
{ "command": "path_find", "subcommand": "create", "source_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "destination_amount": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308", "value": "100" } }ripple_path_find
{ "command": "ripple_path_find", "source_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "source_currencies": [ { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, ], "destination_account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "destination_amount": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308", "value": "100" } }amm_info
{ "command": "amm_info", "Asset": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, "Asset2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308" } }ledger_entry
{ "command": "ledger_entry", "amm": { "Asset": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, "Asset2": { "mpt_issuance_id": "00000003430427B80BD2D09D36B70B969E12801065F22308" } }, "ledger_index": "validated" }book_offers
{ "id": 4, "command": "book_offers", "taker": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "taker_gets": { "mpt_issuance_id": "00000002430427B80BD2D09D36B70B969E12801065F22308" }, "taker_pays": { "currency": "USD", "issuer": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B" }, "limit": 10 }Appendices
STIssueserializationSTIssuetype defines AMM token pair used inAMMDeposit,AMMWithdraw, andAMMDeletetransactions. However, its current serialization format presents a challenge for integrating MPT into the DEX.Currently,
STIssueis serialized as a 160-bitcurrencycode followed by a 160-bitaccountaddress. This format doesn't have spare bits to indicate whether the serializedSTIssuerepresents acurrencyandaccountor anmpt_issuance_id. I.e. reading 320 bits doesn't provide enough information to unequivocally distinguishcurrencyandaccountfrommpt_issuance_id.Proposed Solutions
Splitting
mpt_issuance_idwith black hole account flag:mpt_issuance_idinto its sequence number and account.currencyandaccount. Ifaccountis 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:
USDcurrency code in hex is0000000000000000000000005553440000000000.015841551A748AD2C1F76FF6ECB0CCCD00000000.mpt_issuance_id. The 16-bit value distinguishesmpt_issuance_idfrom both standard and non-standard currency code.currencyand checks for the leading 0x0001 to identify MPT and reads additional 48 bits to assemble thempt_issuance_id.rippledcode 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