Skip to content

AMMVote

[Source]

Vote on the trading fee for an Automated Market Maker instance. Up to 8 accounts can vote in proportion to the amount of the AMM's LP Tokens they hold. Each new vote re-calculates the AMM's trading fee based on a weighted average of the votes.

Requires the AMM amendment. Loading...

Example AMMVote JSON

{
    "Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
    "Asset" : {
        "currency" : "XRP"
    },
    "Asset2" : {
        "currency" : "TST",
        "issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
    },
    "Fee" : "10",
    "Flags" : 2147483648,
    "Sequence" : 8,
    "TradingFee" : 600,
    "TransactionType" : "AMMVote"
}
Query example transaction

AMMVote Fields

In addition to the common fields, AMMVote transactions use the following fields:

FieldJSON TypeInternal TypeRequired?Description
AssetObjectIssueYesThe definition for one of the assets in the AMM's pool. The asset can be XRP, a token, or an MPT (see: Specifying Without Amounts).
Asset2ObjectIssueYesThe definition for the other asset in the AMM's pool. The asset can be XRP, a token, or an MPT (see: Specifying Without Amounts).
TradingFeeNumberUInt16YesThe proposed fee to vote for, in units of 1/100,000; a value of 1 is equivalent to 0.001%. The maximum value is 1000, indicating a 1% fee.

Error Cases

Besides errors that can occur for all transactions, AMMVote transactions can result in the following transaction result codes:

Error CodeDescription
tecAMM_EMPTYThe AMM has no assets in its pool. In this state, you can only delete the AMM or fund it with a new deposit.
tecAMM_INVALID_TOKENSThe sender cannot vote because they do not hold any of this AMM's LP Tokens.
temBAD_FEEThe TradingFee from this transaction is not valid.
terNO_AMMThe Automated Market Maker instance for the asset pair in this transaction does not exist.

If all eight vote slots are taken by accounts that still hold LP Tokens, the transaction succeeds with tesSUCCESS but doesn't record the sender's vote in either of the following cases:

  • The sender holds fewer LP Tokens than the existing voter with the fewest LP Tokens.
  • The sender holds the same amount of LP Tokens as that voter, and votes for a trading fee that is lower than or equal to that voter's fee.

Whether or not the vote is recorded, the transaction still recalculates the weights of the existing votes and the AMM's trading fee based on the voters' current LP Token balances. A vote from an account that no longer holds any LP Tokens is dropped during this recalculation, so its slot becomes available. To find out whether the vote was recorded, check the VoteSlots field of the AMM entry after the transaction is validated.

See Also