Skip to content

Commit 9a8d705

Browse files
authored
Merge pull request #2969 from XRPLF/migrate-ammclawbackdocs
Add AMMClawback reference docs
2 parents dc73f90 + 3f33bbd commit 9a8d705

File tree

5 files changed

+82
-3
lines changed

5 files changed

+82
-3
lines changed

docs/_snippets/common-links.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
[AMM amendment]: /resources/known-amendments.md#amm
22
[AMM entry]: /docs/references/protocol/ledger-data/ledger-entry-types/amm.md
3+
[AMMClawback amendment]: /resources/known-amendments.md#ammclawback
34
[AMM object]: /docs/references/protocol/ledger-data/ledger-entry-types/amm.md
45
[AMMエントリ]: /docs/references/protocol/ledger-data/ledger-entry-types/amm.md
56
[AMMオブジェクト]: /docs/references/protocol/ledger-data/ledger-entry-types/amm.md
67
[AMMBid transaction]: /docs/references/protocol/transactions/types/ammbid.md
78
[AMMBid transactions]: /docs/references/protocol/transactions/types/ammbid.md
89
[AMMBid]: /docs/references/protocol/transactions/types/ammbid.md
910
[AMMBidトランザクション]: /docs/references/protocol/transactions/types/ammbid.md
11+
[AMMClawback transaction]: /docs/references/protocol/transactions/types/ammclawback.md
1012
[AMMCreate transaction]: /docs/references/protocol/transactions/types/ammcreate.md
1113
[AMMCreate transactions]: /docs/references/protocol/transactions/types/ammcreate.md
1214
[AMMCreate]: /docs/references/protocol/transactions/types/ammcreate.md
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# AMMClawback
2+
3+
<!--> Add link to github source after feature is merged into devnet. <-->
4+
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/app/tx/detail/AMMClawback.cpp "Source")
5+
6+
_(Added by the [AMM amendment][])_
7+
8+
Claw back tokens from a holder who has deposited your issued tokens into an AMM pool.
9+
10+
Clawback is disabled by default. To use clawback, you must send an [AccountSet transaction](https://xrpl.org/docs/references/protocol/transactions/types/accountset) to enable the **Allow Trust Line Clawback** setting. An issuer with any existing tokens cannot enable clawback. You can only enable **Allow Trust Line Clawback** if you have a completely empty owner directory, meaning you must do so before you set up any trust lines, offers, escrows, payment channels, checks, or signer lists. After you enable clawback, it cannot reverted: the account permanently gains the ability to claw back issued assets on trust lines.
11+
12+
13+
## Example {% $frontmatter.seo.title %} JSON
14+
15+
```json
16+
{
17+
"TransactionType": "AMMClawback",
18+
"Account": "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
19+
"Holder": "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
20+
"Asset": {
21+
"currency" : "FOO",
22+
"issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL"
23+
},
24+
"Asset2" : {
25+
"currency" : "BAR",
26+
"issuer" : "rHtptZx1yHf6Yv43s1RWffM3XnEYv3XhRg"
27+
},
28+
"Amount": {
29+
"currency" : "FOO",
30+
"issuer" : "rPdYxU9dNkbzC5Y2h4jLbVJ3rMRrk7WVRL",
31+
"value" : "1000"
32+
}
33+
}
34+
```
35+
36+
37+
{% raw-partial file="/docs/_snippets/tx-fields-intro.md" /%}
38+
39+
40+
| Field | JSON Type | [Internal Type][] | Required | Description |
41+
|:-------------------|:----------|:------------------|:---------|:------------------|
42+
| `Account` | String | AccountID | Yes | The issuer of the asset being clawed back. Only the issuer can submit this transaction. |
43+
| `Asset` | Object | STIssue | Yes | Specifies the asset that the issuer wants to claw back from the AMM pool. In JSON, this is an object with `currency` and `issuer` fields. The `issuer` field must match with `Account`. |
44+
| `Asset2` | Object | STIssue | Yes | Specifies the other asset in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
45+
| `Amount` | [Currency Amount](https://xrpl.org/docs/references/protocol/data-types/basic-data-types#specifying-currency-amounts) | Amount | No | The maximum amount to claw back from the AMM account. The `currency` and `issuer` subfields should match the `Asset` subfields. If this field isn't specified, or the `value` subfield exceeds the holder's available tokens in the AMM, all of the holder's tokens are clawed back. |
46+
| `Holder` | String | AccountID | Yes | The account holding the asset to be clawed back. |
47+
48+
49+
## AMMClawback Flags
50+
51+
| Flag Name | Hex Value | Decimal Value | Description |
52+
|----------|------------|---------------|-------------|
53+
| `tfClawTwoAssets` | `0x00000001` | 1 | Claw back the specified amount of `Asset`, and a corresponding amount of `Asset2` based on the AMM pool's asset proportion; both assets must be issued by the issuer in the `Account` field. If this flag isn't enabled, the issuer claws back the specified amount of `Asset`, while a corresponding proportion of `Asset2` goes back to the `Holder`. |
54+
55+
56+
## Error Cases
57+
58+
Besides errors that can occur for all transactions, `AMMClawback` transactions can result in the following [transaction result codes](https://xrpl.org/docs/references/protocol/transactions/transaction-results):
59+
60+
| Error Code | Description |
61+
|:-------------------|:------------|
62+
| `tecNO_PERMISSION` | Occurs if you attempt to claw back tokens from an AMM without the `lsfAllowTrustlineClawback` flag enabled, or the `tfClawTwoAssets` flag is enabled when you didn't issue both assets in the AMM. Also occurs if the `Asset` issuer doesn't match `Account`. |
63+
| `tecAMM_BALANCE` | Occurs if the `Holder` doesn't hold any LP tokens from the AMM pool. |
64+
| `temDISABLED` | Occurs if the [AMMClawback amendment](#) is not enabled. |
65+
| `temBAD_AMOUNT` | Occurs if the `Amount` field in the `AMMClawback` transaction is less than or equal to 0, or the `currency` and `issuer` subfields don't match between `Amount` and `Asset`. |
66+
| `temINVALID_FLAG` | Occurs if you try enabling flags besides `tfClawTwoAssets`. |
67+
| `temMALFORMED` | Occurs if the `issuer` subfield doesn't match between `Asset` and `Account`, `Account` is the same as the `Holder`, or `Asset` is XRP. |
68+
| `terNO_AMM` | Occurs if the AMM pool specified by `Asset` and `Asset2` doesn't exist. |
69+
70+
{% raw-partial file="/docs/_snippets/common-links.md" /%}

docs/references/protocol/transactions/types/ammcreate.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Creates both an [AMM entry][] and a [special AccountRoot entry](../../ledger-dat
4444
| `Amount2` | [Currency Amount][] | Amount | Yes | The second of the two assets to fund this AMM with. This must be a positive amount. |
4545
| `TradingFee` | Number | UInt16 | Yes | The fee to charge for trades against this AMM instance, in units of 1/100,000; a value of 1 is equivalent to 0.001%. The maximum value is `1000`, indicating a 1% fee. The minimum value is `0`. |
4646

47-
One or both of `Amount` and `Amount2` can be [tokens](../../../../concepts/tokens/index.md); at most one of them can be [XRP](../../../../introduction/what-is-xrp.md). They cannot both have the same currency code and issuer. The tokens' issuers must have [Default Ripple](../../../../concepts/tokens/fungible-tokens/rippling.md#the-default-ripple-flag) enabled. If the [Clawback amendment][] is enabled, those issuers must not have enabled the Allow Clawback flag. The assets _cannot_ be LP tokens for another AMM.
47+
One or both of `Amount` and `Amount2` can be [tokens](../../../../concepts/tokens/index.md); at most one of them can be [XRP](../../../../introduction/what-is-xrp.md). They cannot both have the same currency code and issuer. The tokens' issuers must have [Default Ripple](../../../../concepts/tokens/fungible-tokens/rippling.md#the-default-ripple-flag) enabled. The assets _cannot_ be LP tokens for another AMM.
4848

4949
## Special Transaction Cost
5050

@@ -62,7 +62,7 @@ Besides errors that can occur for all transactions, {% $frontmatter.seo.title %}
6262
| `tecINSUF_RESERVE_LINE` | The sender of this transaction does meet the increased [reserve requirement](../../../../concepts/accounts/reserves.md) of processing this transaction, probably because they need a new trust line to hold the LP Tokens, and they don't have enough XRP to meet the additional owner reserve for a new trust line. |
6363
| `tecNO_AUTH` | At least one of the deposit assets uses [authorized trust lines](../../../../concepts/tokens/fungible-tokens/authorized-trust-lines.md) and the sender does not have authorization to hold that asset. |
6464
| `tecNO_LINE` | The sender does not have a trust line for at least one of the deposit assets. |
65-
| `tecNO_PERMISSION` | At least one of the deposit assets cannot be used in an AMM. For example, the issuer has enabled Clawback support. |
65+
| `tecNO_PERMISSION` | At least one of the deposit assets cannot be used in an AMM. |
6666
| `tecUNFUNDED_AMM` | The sender does not hold enough of the assets specified in `Amount` and `Amount2` to fund the AMM. |
6767
| `terNO_RIPPLE` | The issuer of at least one of the assets has not enabled the [Default Ripple flag](../../../../concepts/tokens/fungible-tokens/rippling.md#the-default-ripple-flag). |
6868
| `temAMM_BAD_TOKENS` | The values of `Amount` and `Amount2` are not valid: for example, both refer to the same token. |

docs/references/protocol/transactions/types/ammdeposit.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ Deposit funds into an [Automated Market Maker](../../../../concepts/tokens/decen
1515

1616
If successful, this transaction creates a [trust line](../../../../concepts/tokens/fungible-tokens/index.md) to the AMM Account (limit 0) to hold the LP Tokens.
1717

18+
{% admonition type="info" name="Note" %}
19+
You can't deposit either asset into an AMM if:
20+
- At least one of the pooled assets is frozen by the token issuer.
21+
- You aren't authorized to hold at least one of the pooled assets.
22+
{% /admonition %}
23+
1824
## Example {% $frontmatter.seo.title %} JSON
1925

2026
```json
@@ -129,7 +135,7 @@ Besides errors that can occur for all transactions, {% $frontmatter.seo.title %}
129135
| `tecAMM_EMPTY` | The AMM currently holds no assets, so you cannot do a normal deposit. You must use the Empty AMM Special Case deposit instead. |
130136
| `tecAMM_NOT_EMPTY` | The transaction specified `tfTwoAssetIfEmpty`, but the AMM was not empty. |
131137
| `tecAMM_FAILED` | The conditions on the deposit could not be satisfied. For example, the requested effective price in the `EPrice` field is too low. |
132-
| `tecFROZEN` | The transaction tried to deposit a [frozen](../../../../concepts/tokens/fungible-tokens/freezes.md) token. |
138+
| `tecFROZEN` | The transaction tried to deposit a [frozen](../../../../concepts/tokens/fungible-tokens/freezes.md) token, or at least one of the paired tokens is frozen. |
133139
| `tecINSUF_RESERVE_LINE` | The sender of this transaction does meet the increased [reserve requirement](../../../../concepts/accounts/reserves.md) of processing this transaction, probably because they need a new trust line to hold the LP Tokens, and they don't have enough XRP to meet the additional owner reserve for a new trust line. |
134140
| `tecUNFUNDED_AMM` | The sender does not have a high enough balance to make the specified deposit. |
135141
| `temBAD_AMM_TOKENS` | The transaction specified the LP Tokens incorrectly. For example, the `issuer` is not the AMM's associated AccountRoot address or the `currency` is not the currency code for this AMM's LP Tokens, or the transaction specified this AMM's LP Tokens in one of the asset fields. |

sidebars.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@
358358
- page: docs/references/protocol/transactions/types/accountset.md
359359
- page: docs/references/protocol/transactions/types/accountdelete.md
360360
- page: docs/references/protocol/transactions/types/ammbid.md
361+
- page: docs/references/protocol/transactions/types/ammclawback.md
361362
- page: docs/references/protocol/transactions/types/ammcreate.md
362363
- page: docs/references/protocol/transactions/types/ammdelete.md
363364
- page: docs/references/protocol/transactions/types/ammdeposit.md

0 commit comments

Comments
 (0)