Last updated
Edit

AMM

[Source]

(Added by the AMM amendment)

An AMM ledger entry describes a single Automated Market Maker (AMM) instance. This is always paired with a special AccountRoot entry.

Example AMM JSON

{
    "Account": "rBp3UDRuEteeJqp4rEk5kxMe7BGWNYrF9A",
    "Asset": {
      "currency": "XRP"
    },
    "Asset2": {
      "currency": "NEX",
      "issuer": "rQGiPFWhaTDdue1xHX7cVpxGqPQK54zng1"
    },
    "AuctionSlot": {
      "Account": "r3ZGQZw1NCbBp5AEGkMDE9NgNpzw91aofD",
      "Expiration": 778576560,
      "Price": {
        "currency": "03DC324562A8915B7C65E9D31B93D62D02BC491C",
        "issuer": "rBp3UDRuEteeJqp4rEk5kxMe7BGWNYrF9A",
        "value": "0"
      }
    },
    "Flags": 0,
    "LPTokenBalance": {
      "currency": "03DC324562A8915B7C65E9D31B93D62D02BC491C",
      "issuer": "rBp3UDRuEteeJqp4rEk5kxMe7BGWNYrF9A",
      "value": "5509581.299648495"
    },
    "LedgerEntryType": "AMM",
    "OwnerNode": "0",
    "PreviousTxnID": "9E8E9B8FD27391C818525BFF6A29452F7A9888F31622BEF6FC36064D05CF6436",
    "PreviousTxnLgrSeq": 91448830,
    "TradingFee": 1,
    "VoteSlots": [
      {
        "VoteEntry": {
          "Account": "r3ZGQZw1NCbBp5AEGkMDE9NgNpzw91aofD",
          "TradingFee": 1,
          "VoteWeight": 100000
        }
      }
    ],
    "index": "F490627BACE2D0AA744514A640B4999D50E495DD1677550D8B10E2D20FBB15C3"
}

AMM Fields

In addition to the common fields, AMM entries have 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.
AccountStringAccountIDYesThe 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.
PreviousTxnIDStringHash256NoThe identifying hash of the transaction that most recently modified this entry. (Added by the fixPreviousTxnID amendment.)
PreviousTxnLgrSeqNumberUInt32NoThe index of the ledger that contains the transaction that most recently modified this entry. (Added by the fixPreviousTxnID amendment.)
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. Normally, this is 1/10 of the normal 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 Reserve

AMM entries do not require a reserve.

AMM Flags

There are no flags defined for AMM entries.

AMM ID Format

The ID of an AMM entry 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.