# AMMVote

[Source](https://github.com/XRPLF/rippled/blob/release/3.4.x/src/libxrpl/tx/transactors/dex/AMMVote.cpp)

Vote on the trading fee for an [Automated Market Maker](/es-es/docs/concepts/tokens/decentralized-exchange/automated-market-makers) 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.

_Added by the [AMM amendment](/resources/known-amendments#amm). (Enabled: 2024-03-22)_

## Example  JSON

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

##  Fields

In addition to the [common fields](/docs/references/protocol/transactions/common-fields),  transactions use the following fields:

| Field | JSON Type | [Internal Type](/docs/references/protocol/binary-format) | Required? | Description |
|  --- | --- | --- | --- | --- |
| `Asset` | Object | Issue | Yes | The 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](/docs/references/protocol/data-types/currency-formats#specifying-without-amounts)). |
| `Asset2` | Object | Issue | Yes | The definition for the other asset in the AMM's pool. The asset can be XRP, a token, or an MPT (see: [Specifying Without Amounts](/docs/references/protocol/data-types/currency-formats#specifying-without-amounts)). |
| `TradingFee` | Number | UInt16 | Yes | The 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,  transactions can result in the following [transaction result codes](/es-es/docs/references/protocol/transactions/transaction-results):

| Error Code | Description |
|  --- | --- |
| `tecAMM_EMPTY` | The 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_TOKENS` | The sender cannot vote because they do not hold any of this AMM's LP Tokens. |
| `temBAD_FEE` | The `TradingFee` from this transaction is not valid. |
| `terNO_AMM` | The 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`](/es-es/docs/references/protocol/transactions/transaction-results/tes-success) 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](/docs/references/protocol/ledger-data/ledger-entry-types/amm) after the transaction is validated.

## See Also

- [AMM entry](/docs/references/protocol/ledger-data/ledger-entry-types/amm)