AMM

[Source]

Attention

Automated Market Maker (AMM) functionality is part of the proposed XLS-30d extension to the XRP Ledger protocol. You can use these functions on test networks for now. Until there is an amendment in a stable release, the details documented on these pages are subject to change.

The AMM object type describes a single Automated Market Maker (AMM) instance.

Example AMM JSON

{
    "AMMAccount" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
    "Asset" : {
      "currency" : "XRP"
    },
    "Asset2" : {
      "currency" : "TST",
      "issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
    },
    "AuctionSlot" : {
      "Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
      "AuthAccounts" : [
          {
            "AuthAccount" : {
                "Account" : "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"
            }
          },
          {
            "AuthAccount" : {
                "Account" : "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"
            }
          }
      ],
      "DiscountedFee" : 0,
      "Expiration" : 721870180,
      "Price" : {
          "currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
          "issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
          "value" : "0.8696263565463045"
      }
    },
    "Flags" : 0,
    "LPTokenBalance" : {
      "currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
      "issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
      "value" : "71150.53584131501"
    },
    "TradingFee" : 600,
    "VoteSlots" : [
      {
          "VoteEntry" : {
            "Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
            "TradingFee" : 600,
            "VoteWeight" : 100000
          }
      }
    ]
}

AMM Fields

The AMM object has the following fields:

FieldJSON TypeInternal TypeRequired?Description
AssetObjectSTIssueYesThe definition for one of the two assets this AMM holds. In JSON, this is an object with currency and issuer fields.
Asset2ObjectSTIssueYesThe definition for the other asset this AMM holds. In JSON, this is an object with currency and issuer fields.
AMMAccountStringAccountIDYesThe address of the special account that holds this AMM's assets.
AuctionSlotObjectSTObjectNoDetails of the current owner of the auction slot, as an Auction Slot object.
LPTokenBalanceCurrency AmountAmountYesThe total outstanding balance of liquidity provider tokens from this AMM instance. The holders of these tokens can vote on the AMM's trading fee in proportion to their holdings, or redeem the tokens for a share of the AMM's assets which grows with the trading fees collected.
TradingFeeNumberUInt16YesThe percentage fee to be charged for trades against this AMM instance, in units of 1/100,000. The maximum value is 1000, for a 1% fee.
VoteSlotsArraySTArrayNoA list of vote objects, representing votes on the pool's trading fee.

Auction Slot Object

The AuctionSlot field contains an object with the following nested fields:

FieldJSON TypeInternal TypeRequired?Description
AccountString - AddressAccountIDYesThe current owner of this auction slot.
AuthAccountsArraySTArrayNoA list of at most 4 additional accounts that are authorized to trade at the discounted fee for this AMM instance.
DiscountedFeeStringUInt32YesThe trading fee to be charged to the auction owner, in the same format as TradingFee. By default this is 0, meaning that the auction owner can trade at no fee instead of the standard fee for this AMM.
PriceCurrency AmountAmountYesThe amount the auction owner paid to win this slot, in LP Tokens.
ExpirationStringUInt32YesThe time when this slot expires, in seconds since the Ripple Epoch.

VoteEntry Object

The VoteSlots field contains an array of VoteEntry objects with the following fields:

FieldJSON TypeInternal TypeRequired?Description
AccountString - AddressAccountIDYesThe account that cast the vote.
TradingFeeNumberUInt16YesThe proposed trading fee, in units of 1/100,000; a value of 1 is equivalent to 0.001%. The maximum value is 1000, indicating a 1% fee.
VoteWeightNumberUInt32YesThe weight of the vote, in units of 1/100,000. For example, a value of 1234 means this vote counts as 1.234% of the weighted total vote. The weight is determined by the percentage of this AMM's LP Tokens the account owns. The maximum value is 100000.

AMM Flags

There are currently no flags defined for AMM objects.

AMM ID Format

The ID of an AMM object is the SHA-512Half of the following values, concatenated in order:

  1. The AMM space key (0x0041)
  2. The AccountID of the first asset's issuer.
  3. The 160-bit currency code of the first token.
  4. The AccountID of the second asset's issuer.
  5. The 160-bit currency code of the second token.

For XRP, use all 0's for both the token and the issuer.