XRP Ledger Standards
XLS-0073 Draft Amendment

AMMClawback

Amendment to enable token issuers to claw back tokens from AMM pools for regulatory compliance

Authors
Shawn Xie, Yinyi Qian
Created
2024-08-02
Updated
2026-11-30
Requires
XLS-39, XLS-30
Discussion
XRPLF/XRPL-Standards/discussions/212

1. Abstract

The AMMClawback amendment enables token issuers to claw back tokens from wallets that have deposited into AMM pools, ensuring regulatory compliance. We introduced a new transaction type AMMClawback in this amendment and the AMMClawback transaction is allowed only when lsfAllowTrustLineClawback is enabled by the issuer. lsfAllowTrustLineClawback can be set only if the account has an empty owner directory through AccountSet.

2. Motivation

This proposal introduces new improvements on how AMM interacts with frozen asset and clawback.

2.1. AMM and Frozen Asset

Currently if an asset in the AMM pool is frozen (either global or individual), we can still deposit the paired token into the AMM pool (if the paired asset is not frozen). This proposal introduces:

  • Prohibit a wallet from depositing new tokens (single-sided and double-sided) into an AMM pool if at least one of the tokens the wallet owns has been frozen (either individually or globally) by the token issuer.

2.2. AMM and Unauthorized Asset

At present, if an account is not authorized to hold a token in the AMM pool, it can still make a single deposit of the other paired token, provided it is authorized for that token. This proposal introduces:

  • Prevent a wallet from depositing new tokens (either single-sided or double-sided) into an AMM pool if it is not authorized to hold one or both of the tokens in the pool.

2.3. AMM and Clawback

Currently, accounts that have enabled clawback cannot create AMM pools. This proposal introduces the following:

  • Allow an account to create AMM pool even if one of the tokens has enabled lsfAllowTrustLineClawback. However, token issuers will not be allowed to claw back from the AMM account using the Clawback transaction.
  • Introduce a new AMMClawback transaction to allow token issuers to exclusively claw back from AMM pools that has one of their tokens, according to the current proportion in the pool.

3. Specification

3.1. Transaction: AMMDeposit

This proposal introduces changes to the behavior of the AMMDeposit transaction when tokens in trustlines interact with Automated Market Maker (AMM) pools. Assume we have created an Automated Market Maker (AMM) pool with two assets: A and B. Double-asset deposits and single-asset deposits of either asset are prohibited in the cases below.

3.1.1. Fields

The fields of this transaction do not change.

3.1.2. Transaction Fee

The fee for this transaction does not change.

3.1.3. Failure Conditions

3.1.3.1. Protocol-Level Failures
  1. Asset A is frozen (either individually or globally). Deposits are prohibited for the non-frozen asset B when its paired asset A is frozen. (TODO: content pass — result code.)
  2. The issuer of A has set lsfRequireAuth and the holder is not authorized to hold A. When the holder is not allowed to hold one of the tokens in the AMM pool, depositing the other asset is prohibited. (TODO: content pass — result code.)

3.1.4. State Changes

The state changes of this transaction do not change.

3.1.5. Example JSON

The JSON format of this transaction does not change.

3.2. Transaction: AMMCreate

3.2.1. Fields

The fields of this transaction do not change.

3.2.2. Transaction Fee

The fee for this transaction does not change.

3.2.3. Failure Conditions

After the AMMClawback amendment, AMMCreate is allowed for a clawback-enabled issuer, one that has set the lsfAllowTrustLineClawback flag. Before it, AMMCreate is prohibited against this issuer.

3.2.4. State Changes

The state changes of this transaction do not change.

3.2.5. Example JSON

The JSON format of this transaction does not change.

3.3. Transaction: AMMClawback

This proposal introduces a new transaction type AMMClawback to allow asset issuers to claw back their assets from the AMM pool.

3.3.1. Fields

Field Name Required JSON Type Internal Type Default Value Description
TransactionType Yes string UINT16 AMMClawback Specifies the new transaction type AMMClawback. The integer value is 31.
Account Yes string ACCOUNT N/A Designates the issuer of the asset being clawed back, and must match the account submitting the transaction.
Holder Yes string ACCOUNT N/A Specifies the holder account of the asset to be clawed back.
Asset Yes object ISSUE N/A Specifies the token that the issuer wants to claw back from the AMM pool.
Asset2 Yes object ISSUE N/A Specifies the other asset in the AMM pool.
Amount No object AMOUNT N/A Specifies the amount of token to be clawed back from the AMM account. It should match the Asset field.
3.3.1.1. Asset

Always put the token to be clawed back in Asset instead of Asset2. It has the following subfields:

Field Name Required Description
issuer Yes Specifies the issuer of the token being clawed back. This should be the same as the Account field.
currency Yes Specifies the currency to be clawed back.
3.3.1.2. Asset2

It has the following subfields:

Field Name Required Description
issuer Conditional Specifies the paired token's issuer. Omit for XRP.
currency Yes Specifies the paired token's currency.
3.3.1.3. Amount

It has the following subfields:

Field Name Required Description
issuer Yes Specifies the issuer of the token being clawed back. This should be the same as the Account field.
currency Yes Specifies the currency to be clawed back.
value Yes Specifies the maximum amount of this currency to be clawed back.

3.3.2. Flags

Flag Name Flag Value Description
tfClawTwoAssets 0x00000001 Indicates if the issuer wants to claw back both tokens in the pool. The two assets must both be issued by the issuer.

3.3.3. Transaction Fee

TODO: content pass.

3.3.4. Failure Conditions

3.3.4.1. Data Verification
  1. The provided Asset's issuer does not match Account (temMALFORMED).
3.3.4.2. Protocol-Level Failures
  1. The issuer does not have the lsfAllowTrustLineClawback flag enabled. Issuers can only claw back issued tokens in the AMM pool if this flag is enabled (tecNO_PERMISSION).
  2. The tfClawTwoAssets flag is set, but the issuer does not issue both assets in the AMM pool. tfClawTwoAssets can only be set if the issuer issues both assets in the AMM pool (tecNO_PERMISSION).

3.3.5. State Changes

By designating the holder account, asset, asset2 and amount, this transaction will:

  1. Claw back the specified amount of asset held by the specified holder account that are in the specified AMM account.
  2. Initiate a two-asset withdrawal of the specified amount of tokens on the current proportion from the AMM pool.
  3. Return the issuer's Asset to the issuer's account.
  4. If the issuer only issues one token in the AMM pool, transfer the paired Asset2, which is not issued by the issuer, back to the holder's account.
  5. If the two assets in the AMM pool are both issued by the issuer:
    1. If the tfClawTwoAssets flag is set, return the paired Asset2, which is also issued by the issuer, to the issuer as well. Both the Asset token and the paired token Asset2 are clawed back.
    2. If the tfClawTwoAssets flag is not set, only the Asset token is clawed back, and the paired Asset2 goes back to the holder.
  6. If the requested amount of tokens (Amount) exceeds the holder's available balance in the AMM pool, claw back all the tokens owned by the specified holder.
  7. If Amount is not given in the request, claw back all the tokens owned by the specified holder from the pool.

3.3.6. Example JSON

3.3.6.1. Only one token is issued by the issuer

Assume we have an AMM pool consisting two tokens FOO and Bar. And the proportion of FOO and BAR is 1:2. And the issuer rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL only issues FOO, BAR is issued by some other account.

{
  "TransactionType": "AMMClawback",
  "Account": "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
  "Holder": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
  "Asset": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
  },
  "Asset2" : {
      "currency" : "BAR",
      "issuer" : "rHtptZx1yHf6Yv43s1RWffM3XnEYv3XhRg"
  },
  "Amount": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
      "value" : "1000"
  }
}
  • Upon execution, this transaction enables the issuer rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL to claw back at most 1000 FOO owned by holder rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B from AMM pool FOO/BAR.
  • The transaction will result in the withdrawal of two corresponding assets from the AMM account on the current proportion:
    • The asset issued by the Account will be returned to the issuer Account. So 1000 FOO will be returned to the issuer rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL.
    • The other asset will be transferred back to the holder's wallet. Since the proportion of FOO and BAR is 1:2, 2000 BAR will be transferred back to the holder's wallet.
    • If Amount is not given or its subfield value exceeds the holder's available balance, then all the holder's FOO will be clawed back from the AMM pool.
  • tfClawTwoAssets can not be set because BAR is not issued by the issuer.
3.3.6.2. Both tokens are issued by the same issuer

Assume we have an AMM pool consisting two tokens FOO and Bar. And the proportion of FOO and BAR is 1:2. And the issuer rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL issues both FOO and BAR.

{
  "TransactionType": "AMMClawback",
  "Account": "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
  "Holder": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
  "Asset": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
  },
  "Asset2": {
      "currency" : "BAR",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
  },
  "Amount": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
      "value" : "1000"
  },
  "Flags": 1
}
  • In this example, tfClawTwoAssets is set in the Flags, so 1000 FOO and 2000 BAR will both go back to the issuer. (If tfClawTwoAssets is not set in the Flags, 1000 FOO will go back to the issuer and 2000 BAR will be transferred back to the holder.)
  • If Amount is not given or its subfield value exceeds the holder's available balance, then we will claw back the holder's existing balance of FOO in the AMM pool. And whether BAR will be clawed back or go back to the holder is still determined by the flag tfClawTwoAssets.
3.3.6.3. Clawback all the tokens
{
  "TransactionType": "AMMClawback",
  "Account": "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
  "Holder": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
  "Asset": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
  },
  "Asset2" : {
      "currency" : "BAR",
      "issuer" : "rHtptZx1yHf6Yv43s1RWffM3XnEYv3XhRg"
  }
}
  • Issuer will clawback all of the holder's FOO token balance in the AMM pool by omitting the Amount field.
  • In this example, since BAR is issued by a different issuer, then tfClawTwoAssets is not allowed to be set. All holder's FOO in the AMM pool will be clawed back. And the corresponding BAR will go back to the holder.
3.3.6.4. Clawback all the tokens issued by the same issuer
{
  "TransactionType": "AMMClawback",
  "Account": "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
  "Holder": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
  "Asset": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
  },
  "Asset2" : {
      "currency" : "BAR",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
  },
  Flags: 1
}
  • In this example, both FOO and BAR are issued by the same issuer. So tfClawTwoAssets is allowed to be set.
  • Since Amount is not given and tfClawTwoAssets is set, the issuer will clawback all the holder's FOO and the corresponding BAR from the AMM pool. (FOO and BAR clawed back amounts reflect the two-asset withdrawal amounts from redeeming all holder's LPtokens in the AMM pool.)
  • tfClawTwoAssets is used to determine if BAR will be clawed back or goes back to the holder.
3.3.6.5. Clawback token from a pool containing XRP
{
  "TransactionType": "AMMClawback",
  "Account": "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
  "Holder": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
  "Asset": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
  },
  "Asset2" : {
      "currency" : "XRP",
  },
  "Amount": {
      "currency" : "FOO",
      "issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
      "value" : "1000"
  }
}
  • In this example, the issuer will clawback 1000 FOO from the AMM pool FOO/XRP. And the corresponding proportion of XRP will go back to the holder.
  • Notice XRP can not be clawed back.

3.4. Transaction: Clawback

After the AMMClawback amendment, the issuer can not claw back from the AMM account using the Clawback transaction. The AMMClawback transaction is needed for the issuer to claw back from an AMM account.

3.4.1. Fields

The fields of this transaction do not change.

3.4.2. Transaction Fee

The fee for this transaction does not change.

3.4.3. Failure Conditions

3.4.3.1. Protocol-Level Failures
  1. The issuer uses the Clawback transaction to claw back from an AMM account. (TODO: content pass — result code.)

3.4.4. State Changes

The state changes of this transaction do not change.

3.4.5. Example JSON

The JSON format of this transaction does not change.

4. Rationale

This change allows for the creation of AMM pools with clawback-enabled issuers while introducing a new transaction type (AMMClawback) for issuers to claw back assets from AMM accounts.

TODO: content pass.

5. Backwards Compatibility

5.1. AMMDeposit for Frozen Asset

Assume we have created an Automated Market Maker (AMM) pool with two assets: A and B. Currently, asset A is frozen (either individually or globally). The following table outlines whether specific scenarios are allowed or prohibited for the current behavior and proposed behavior:

Scenario Current Behavior Proposed Behavior
Double-Asset Deposit Prohibited Prohibited
Only Deposit A (frozen) Prohibited Prohibited
Only Deposit B Allowed Prohibited

As illustrated in the table above, the primary change is that when one asset in the AMM pool is frozen, depositing the other asset is no longer allowed.

5.2. AMMDeposit for Unauthorized Asset

Assume we have created an Automated Market Maker (AMM) pool with two assets: A and B. The issuer of A has set lsfRequireAuth and the holder is not authorized to hold A. The table below summarizes the allowed and prohibited scenarios under the current and proposed behavior:

Scenario Current Behavior Proposed Behavior
Double-Asset Deposit Prohibited Prohibited
Only Deposit A (Unauthorized) Prohibited Prohibited
Only Deposit B Allowed Prohibited

The primary change is that when the holder is not allowed to hold one of the tokens in the AMM pool, depositing the other asset is no longer allowed.

5.3. AMMCreate with a Clawback-Enabled Issuer

Suppose an issuer has enabled clawback by setting the lsfAllowTrustLineClawback flag through an AccountSet transaction. Additionally, two trustlines have been established between the holder and the issuer for currencies A and B.

  • Pre-Amendment Behavior:

    • If the holder attempts to create an AMM pool (AMMCreate) using the pair of trustline assets A and B associated with the issuer, the transaction will fail with a tecNO_PERMISSION error.
  • Post-Amendment Behavior:

    • After the AMMClawback amendment, if the holder submits an AMMCreate transaction to create an AMM pool with assets A and B, the transaction will be successful.
    • However, if the issuer wants to claw back assets from the AMM account, they must use the AMMClawback transaction instead of the regular Clawback transaction.

8. Security Considerations

TODO: content pass.

Appendix

Appendix A: rippled Names

The recommended name for the AMMClawback transaction type in rippled is ttAMM_CLAWBACK.