Restore previous AMM docs

This commit is contained in:
mDuo13
2023-09-06 18:17:30 -07:00
parent e94472b333
commit 6a52167b9d
23 changed files with 2080 additions and 42 deletions

View File

@@ -194,25 +194,25 @@ Request('ledger_entry - AccountRoot', {
}
})
// Request('ledger_entry - AMM', {
// description: "Returns a single Automated Market Maker object in its raw ledger format.",
// link: "ledger_entry.html#get-amm-object",
// status: "not_enabled",
// body: {
// "id": "example_get_amm",
// "command": "ledger_entry",
// "amm": {
// "asset": {
// "currency": "XRP"
// },
// "asset2": {
// "currency" : "TST",
// "issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
// }
// },
// "ledger_index": "validated"
// }
// })
Request('ledger_entry - AMM', {
description: "Returns a single Automated Market Maker object in its raw ledger format.",
link: "ledger_entry.html#get-amm-object",
status: "not_enabled",
body: {
"id": "example_get_amm",
"command": "ledger_entry",
"amm": {
"asset": {
"currency": "XRP"
},
"asset2": {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
}
},
"ledger_index": "validated"
}
})
Request('ledger_entry - DirectoryNode', {
description: "Returns a directory object in its raw ledger format.",

View File

@@ -1 +0,0 @@
_自動マーケットメーカーAMM機能は、XRP Ledger プロトコルに提案されている [XLS-30d](https://github.com/XRPLF/XRPL-Standards/discussions/78)の拡張機能 :not_enabled: に含まれるものです。これらの機能は AMM テストネットワークで使用することができますが、公式の修正案がなく、本番のメインネットでは使用することができません。修正案が出るまでは、このページに記載されている内容は変更される可能性があります。_

View File

@@ -1 +0,0 @@
_Automated Market Maker (AMM) functionality is part of the proposed [XLS-30d](https://github.com/XRPLF/XRPL-Standards/discussions/78) extension :not_enabled: to the XRP Ledger protocol. You can use these functions on AMM test networks, but there isn't an official amendment and they aren't available on the production Mainnet. Until there is an amendment, the details documented on these pages are subject to change._ <!-- SPELLING_IGNORE: 30d -->

View File

@@ -0,0 +1,87 @@
---
html: automated-market-makers.html
parent: decentralized-exchange.html
blurb: 自動マーケットメーカーAMMは、資産ペア間の流動性を提供し、分散型取引所のオーダーブックを補完すると同時に、流動性提供者に利益を提供します。
status: not_enabled
labels:
- XRP
- 分散型取引所
- AMM
---
# 自動マーケットメーカー
_([AMM amendment][] :not_enabled:が必要。)_
自動マーケットメーカー(AMM)は、XRP Ledgerの分散型取引所において流動性を提供するスマートコントラクトです。個々のAMMは2つの資産のプールを保有し、数式で定められた取引レートでユーザーがその2つの資産間でスワップを可能とします。
_([AMM amendment][] :not_enabled:が必要。)_
任意の資産ペアに対して、最大1つのAMMが元帳に存在することができます。AMMはそのペアが存在しない場合、誰でも作成することができ、また既存のAMMに預けることもできます。AMMに資産を預ける人は、流動性供給者(LP/Liquidity Provider)と呼ばれ、AMMから「LPトークン」を受け取ります。LPトークンによって、流動性供給者は以下のことが可能になります。
- LPトークンを、AMMのプール内の資産の一部手数料を含むと交換する。
- AMMの手数料設定を変更するために投票する。票は、投票者が保有するLPトークンの数に基づいて重み付けされます。
- AMMの取引手数料の一時的な割引を得るために、LPトークンの一部を入札する。
プール内の2つの資産の取引が比較的活発で均衡している場合、手数料は流動性供給者の収益になります。しかし、資産間の相対価格が変動すると、流動性供給者は[為替リスク](https://www.investopedia.com/terms/c/currencyrisk.asp)により損失を被る可能性があります。
## AMMの仕組み
AMMは2つの異なる資産を保有します。このうち最大でも片方がXRPであり、もう片方または両方は[トークン](tokens.html)となります。この場合、発行者の異なるトークンは異なる資産とみなされます。つまり、通貨コードは同じだが発行者が異なる2つのトークン(「WayGateが発行したFOO」と「StableFooが発行したFOO」は異なる)や、発行者は同じだが通貨コードが異なるトークンに対してAMMが存在する可能性があるということです。また、順番は関係なく、FOO.WayGateからXRPへのAMMは、XRPからFOO.WayGateへのAMMと同一になります。
ユーザーが分散型取引所で取引を行う場合、[オファー](offers.html)と[クロスカレンシー決済](cross-currency-payments.html)は自動的にAMMを使用してトランザクションを成立させることが出来ます。トランザクションは低コストで取引を行えるように、オファー、AMM、またはその両方の組み合わせで実行されます。
AMMは、プール内の資産残高に基づき取引レートを設定します。AMMに対して取引を行うと、AMMが保有する資産残高の変動に応じて、取引レートが調整されます。一方の資産の量が減れば、その資産の価格が上がり、他方の資産の量が増えれば、その資産の価格が下がります。AMMは、プール内の残高が多いほど、一般的により良い取引レートを提供します。同一取引であればプール内の残高が大きい方がAMMの資産バランスに生じる変化は小さくなるからです。AMMの2つの資産のバランスが崩れれば崩れるほど、交換レートは極端に悪化します。
また、AMMは交換レートに加え、一定割合の取引手数料を徴収しています。
XRP Ledgerの実装は、重みパラメータを0.5とした _幾何平均_ AMMですので、_定積_ マーケットメーカーのように機能します。 _定積_ AMMの公式や一般的なAMMの経済学についての詳しい説明は、[Kris Machowski's Introduction to Automated Market Makers](https://www.machow.ski/posts/an_introduction_to_automated_market_makers/)をご覧ください。
## LPトークン
<!-- TODO: add diagrams showcasing flow of funds -->
AMMの作成者は、最初の流動性供給者となり、AMMのプール内の資産の100の所有権を表すLPトークンを受け取ります。LPトークンの一部または全部を交換して、現在のプール残高に比例した資産をAMMから引き出せます。(この比率は、人々がAMMに対して取引を行うにつれて変化しますAMMは、同時に両方の資産を引き出す際に手数料はかかりません。
例えば、5ETHと5USDでAMMを作成し、その後誰かが1.26USDを1ETHに交換したとすると、現在プールには4ETHと6.26USDが入っています。LPトークンの半分を使用して、2ETHと3.13USDを引き出すことができます。
誰でも既存のAMMに資産を預けることができます。預け入れると、その金額に応じて新しいLPトークンを受け取ります。流動性供給者がAMMから引き出すことができる金額は、発行済みのLPトークンの総数に対する流動性提供者のLPトークンの保有割合に基づきます。
LPトークンはXRP Ledgerの他のトークンと同様に、様々な[種類の支払い](payment-types.html)で使用したり、分散型取引所で取引したり、新しいAMMの資産として預けることも可能です。(LPトークンを支払い(Payment)として受け取るには、AMMアカウントを発行元として、限度額が0でない[トラストライン](trust-lines-and-issuing.html)を設定する必要があります)。ただし、LPトークンをAMMに直接送る(換金する)には[AMMWithdraw][]トランザクションタイプを使用し、他のタイプの支払いは使用できません。同様に、AMMのプールに資産を送るには、[AMMDeposit][]トランザクションタイプを使用する必要があります。
AMMは、発行済のLPトークンがない場合に限り、AMMの資産プールが空になるように設計されています。こうした状況は、[AMMWithdraw][]トランザクションの結果としてのみ発生し、発生した時点でAMMは自動的に削除されます。
### LPトークンの通貨コード
LPトークンは、160ビットの16進法["非標準"フォーマット](currency-formats.html#非標準通貨コード)の特別なタイプの通貨コードを使用します。これらのコードの最初の8ビットは`0x03`です。残りのコードは、2つの資産の通貨コードとその発行者のSHA-512ハッシュで、最初の152ビットまで切り捨てたものです。(資産は、数値の低い通貨と発行者のペアを最初にする「正規化された順序」で配置されます。)その結果、LPトークンは、通貨と発行者のペアを最初にする「正規化された順序」で配置されます。その結果、ある資産ペアのAMMのLPトークンは、予測可能で一貫した通貨コードを持っています。
## 取引手数料
取引手数料は流動性供給者の収益源であり、プールの資産に対して他者に取引をさせることによる為替リスクを相殺するものです。取引手数料は流動性提供者に直接支払われずにAMMに支払われますが、流動性供給者は自分のLPトークンをAMMのプールの一定割合と交換することができるため、利益を得ることができます。
流動性供給者は、投票によって取引手数料を0から1まで、0.001刻みで設定することが出来ます。流動性供給者は取引手数料を適切に設定するインセンティブがあり、手数料が高すぎる場合、トレーダーはより良いレートを得るために代わりにオーダーブックを使用することになります。手数料が低すぎる場合、流動性供給者はこのプールへの貢献に対してメリットが得られなくなります。AMMの各流動性供給者は、その保有するLPトークンの量に比例して、取引手数料への投票権を有します。
投票するには、流動性供給者が[AMMVoteトランザクション][]を送信します。誰かが新しい票を入れるたびに、AMMは手数料を再計算し、直近の票の平均を、それらの投票者が保有するLPトークンの数で重み付けしたものにします。この方法では、最大8つの流動性供給者の投票がカウントされます。それ以上の流動性供給者が投票しようとすると、上位8つの投票保有LPトークンの多い順だけがカウントされます。流動性供給者のLPトークンのシェアは、様々な理由(例えば[オファー](offers.html)を使ったトークンの取引)で急速に変化しますが、取引手数料は誰かが新しい票を入れるたびに再計算されますその票がトップ8に入っていない場合でも計算されます)。
### オークションスロット
これまでの自動マーケットメーカーとは異なり、XRP LedgerのAMMのデザインには、流動性供給者が24時間の取引手数料の割引を得るために入札することができる _オークションスロット_ 機能があります。入札はLPトークンで支払う必要があり、落札に使用したLPトークンはAMMに返還されます。一度に複数のアカウントがオークションスロットを保持することはできませんが、落札者は割引を得るために追加で最大4つのアカウントを指定することができます。最低落札価格は設定されていませんが、もしその枠が埋まっている場合は、現在の枠の所有者に競り勝たなければなりません。もし誰かがあなたの入札を退けた場合、残り時間に応じて、落札額の一部が返金されます。アクティブなオークションスロットを保持している限り、そのAMMに対しては取引手数料なしで取引を行うことができます。
どのようなAMMであっても、その資産の価格が外部市場で大きく変動すると、トレーダーは裁定取引によってAMMから利益を得ることができ、その結果、流動性供給者は損失を被ることになります。オークションの仕組みは、より多くの価値を流動性供給者に還元し、AMMの価格をより迅速に外部市場とのバランスに戻すことを意図しています。
## 台帳上の表示
台帳の状態データでは、AMMは複数の[レジャーオブジェクトのタイプ](ledger-object-types.html)で構成されています。
- 自動マーケットメーカー自体を記述した[AMMオブジェクト][]
- AMMのLPトークンを発行し、AMMのXRP保有している場合を保有する特別な[AccountRootオブジェクト][]
このAccountRootのアドレスは、AMMの作成時にランダムに選ばれ、AMMを削除して再作成した場合にも異なるアドレスが選ばれます。これは、AMMのアカウントにユーザーが事前にXRPで資金を供給することを防止するためです。
- AMMのプールにあるトークンのAMM専用アカウントへの[トラストライン](trust-lines-and-issuing.html)
これらのオブジェクトはどのアカウントにも所有されていないため、[準備金要件](reserves.html)は適用されません。ただし、スパムを防ぐため、AMMを作成するための取引には特別な[トランザクションコスト](transaction-cost.html)があり、通常よりも多くのXRPを消費する必要があります。
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,88 @@
---
html: automated-market-makers.html
parent: decentralized-exchange.html
blurb: Automated Market Makers (AMMs) provide liquidity between asset pairs, complemeting the order books in the decentralized exchange while providing passive income for their liquidity providers.
status: not_enabled
labels:
- XRP
- Decentralized Exchange
- AMM
---
# Automated Market Makers
_(Requires the [AMM amendment][] :not_enabled:)_
Automated Market Makers (AMMs) are smart contracts that provide liquidity in the XRP Ledger's decentralized exchange. Each AMM holds a pool of two assets and enables users to swap between them at an exchange rate set by a formula.
For any given pair of assets, there can be up to one AMM in the ledger. Anyone can create the AMM for an asset pair if it doesn't exist yet, or deposit to an existing AMM. Those who deposit assets into an AMM are called _liquidity providers_ (LPs) and receive "LP Tokens" from the AMM. LP Tokens enable liquidity providers to:
- Redeem their LP Tokens for a share of the assets in the AMM's pool, including fees collected.
- Vote to change the AMM's fee settings. The votes are weighted based on how many LP Tokens the voters hold.
- Bid some of their LP Tokens to receive a temporary discount on the AMM's trading fees.
When the flow of funds between the two assets in a pool is relatively active and balanced, the fees provide a source of passive income for liquidity providers. However, when the relative price between the assets shifts, the liquidity providers can take a loss on the [currency risk](https://www.investopedia.com/terms/c/currencyrisk.asp).
## How the AMM Works
An AMM holds two different assets: at most one of these can be XRP, and one or both of them can be [tokens](tokens.html). Tokens with different issuers are considered different assets for this purpose. This means that there can be an AMM for two tokens with the same currency code but different issuers ("FOO issued by WayGate" is different than "FOO issued by StableFoo"), or the same issuer but different currency codes. The order does not matter; the AMM for FOO.WayGate to XRP is the same as for XRP to FOO.WayGate.
When users want to trade in the decentralized exchange, their [Offers](offers.html) and [Cross-Currency Payments](cross-currency-payments.html) can automatically use AMMs to complete the trade. A single transaction might execute by matching Offers, AMMs, or a mix of both, depending on what's cheaper.
An AMM sets its exchange rate based on the balance of assets in the pool. When you trade against an AMM, the exchange rate adjusts based on how much your trade shifts the balance of assets the AMM holds. As its supply of one asset goes down, the price of that asset goes up; as its supply of an asset goes up, the price of that asset goes down. An AMM gives generally better exchange rates when it has larger overall amounts in its pool. This is because any given trade causes a smaller shift in the balance of the AMM's assets. The more a trade unbalances the AMM's supply of the two assets, the more extreme the exchange rate becomes.
The AMM also charges a percentage trading fee on top of the exchange rate.
The XRP Ledger's implements a _geometric mean_ AMM with a weight parameter of 0.5, so it functions like a _constant product_ market maker. For a detailed explanation of the _constant product_ AMM formula and the economics of AMMs in general, see [Kris Machowski's Introduction to Automated Market Makers](https://www.machow.ski/posts/an_introduction_to_automated_market_makers/).
## LP Tokens
<!-- TODO: add diagrams showcasing flow of funds -->
Whoever creates the AMM becomes the first liquidity provider, and receives LP Tokens that represent 100% ownership of assets in the AMM's pool. They can redeem some or all of those LP Tokens to withdraw assets from the AMM in proportion to the amounts currently there. (The proportions shift over time as people trade against the AMM.) The AMM does not charge a fee when withdrawing both assets.
For example, if you created an AMM with 5 ETH and 5 USD, and then someone exchanged 1.26 USD for 1 ETH, the pool now has 4 ETH and 6.26 USD in it. You can spend half your LP Tokens to withdraw 2 ETH and 3.13 USD.
Anyone can deposit assets to an existing AMM. When they do, they receive new LP Tokens based on how much they deposited. The amount that a liquidity provider can withdraw from an AMM is based on the proportion of the AMM's LP Tokens they hold compared to the total number of LP Tokens outstanding.
LP Tokens are like other tokens in the XRP Ledger, so you can use them in many [types of payments](payment-types.html), trade them in the decentralized exchange, or even deposit them as assets for new AMMs. (To receive LP Tokens as payment, you must set up a [trust line](trust-lines-and-issuing.html) with a nonzero limit with the AMM Account as the issuer.) However, you can _only_ send LP Tokens directly to the AMM (redeeming them) using the [AMMWithdraw][] transaction type, not through other types of payments. Similarly, you can only send assets to the AMM's pool through the [AMMDeposit][] transaction type.
The AMM is designed so that an AMM's asset pool is empty if and only if the AMM has no outstanding LP Tokens. This situation can only occur as the result of an [AMMWithdraw][] transaction; when it does, the AMM is automatically deleted.
### LP Token Currency Codes
LP Tokens use a special type of currency code in the 160-bit hexadecimal ["non-standard" format](currency-formats.html#nonstandard-currency-codes). These codes have the first 8 bits `0x03`. The remainder of the code is a SHA-512 hash, truncated to the first 152 bits, of the two assets' currency codes and their issuers. (The assets are placed in a "canonical order" with the numerically lower currency+issuer pair first.) As a result, the LP Tokens for a given asset pair's AMM have a predictable, consistent currency code.
## Trading Fees
Trading fees are a source of passive income for liquidity providers, and they offset the currency risk of letting others trade against the pool's assets. Trading fees are paid to the AMM, not directly to liquidity providers, but liquidity providers benefit because their LP Tokens can be redeemed for a percentage of the AMM's pool.
Liquidity providers can vote to set the fee from 0% to 1%, in increments of 0.001%. Liquidity providers have an incentive to set trading fees at an appropriate rate: if fees are too high, trades will use order books to get a better rate instead; if fees are too low, liquidity providers don't get any benefit for contributing to the pool. <!-- STYLE_OVERRIDE: will --> Each AMM gives its liquidity providers the power to vote on its fees, in proportion to the amount of LP Tokens those liquidity providers hold.
To vote, a liquidity provider sends an [AMMVote transaction][]. Whenever anyone places a new vote, the AMM recalculates its fee to be an average of the latest votes weighted by how many LP Tokens those voters hold. Up to 8 liquidity providers' votes can be counted this way; if more liquidity providers try to vote then only the top 8 votes (by most LP Tokens held) are counted. Even though liquidity providers' share of LP Tokens can shift rapidly for many reasons (such as trading those tokens using [Offers](offers.html)), the trading fees are only recalculated whenever someone places a new vote (even if that vote is not one of the top 8).
### Auction Slot
Unlike any previous Automated Market Makers, the XRP Ledger's AMM design has an _auction slot_ that a liquidity provider can bid on to get a discount on the trading fee for a 24-hour period. The bid must be paid in LP Tokens, which are returned to the AMM. No more than one account can hold the auction slot at a time, but the bidder can name up to 4 more accounts to also receive the discount. There is no minimum bid, but if the slot is currently occupied then you must outbid the current slot holder to displace them. If someone displaces you, you get part of your bid back depending on how much time remains. As long as you hold an active auction slot, you pay a discounted trading fee of 0% when making trades against that AMM.
With any AMM, when the price of its assets shifts significantly in external markets, traders can use arbitrage to profit off the AMM, which results in a loss for liquidity providers. The auction mechanism is intended to return more of that value to liquidity providers and more quickly bring the AMM's prices back into balance with external markets.
## Representation in the Ledger
In the ledger's state data, an AMM consists of multiple [ledger entries](ledger-object-types.html):
- An [AMM object][] describing the automated market maker itself.
- A special [AccountRoot object][] that issues the AMM's LP Tokens, and holds the AMM's XRP (if it has any).
The address of this AccountRoot is chosen somewhat randomly when the AMM is created, and it is different if the AMM is deleted and re-created. This is to prevent people from funding the AMM account with excess XRP in advance.
- [Trust lines](trust-lines-and-issuing.html) to the special AMM Account for the tokens in the AMM's pool.
These objects are not owned by any account, so the [reserve requirement](reserves.html) does not apply to them. However, to prevent spam, the transaction to create an AMM has a special [transaction cost](transaction-cost.html) that requires the sender to burn a larger than usual amount of XRP.
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -7,7 +7,7 @@ labels:
- Data Retention
---
# ledger_entry
[[Source]](https://github.com/xrplf/rippled/blob/master/src/ripple/rpc/handlers/LedgerEntry.cpp "Source")
[[Source]](https://github.com/ripple/rippled/blob/master/src/ripple/rpc/handlers/LedgerEntry.cpp "Source")
The `ledger_entry` method returns a single ledger object from the XRP Ledger in its raw format. See [ledger format][] for information on the different types of objects you can retrieve.
@@ -31,6 +31,7 @@ In addition to the general fields above, you must specify *exactly 1* of the fol
- [`index`](#get-ledger-object-by-id)
- [`account_root`](#get-accountroot-object)
- [`amm`](#get-amm-object) :not_enabled:
- [`directory`](#get-directorynode-object)
- [`offer`](#get-offer-object)
- [`ripple_state`](#get-ripplestate-object)
@@ -144,6 +145,73 @@ rippled json ledger_entry '{ "account_root": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59
### Get AMM Object
_(Automated Market Maker (AMM) functionality is part of the proposed [XLS-30d](https://github.com/XRPLF/XRPL-Standards/discussions/78) extension :not_enabled: to the XRP Ledger protocol. You can use these features on AMM test networks, but there isn't an official amendment and they aren't available on the production Mainnet.)_
Retrieve an Automated Market-Maker (AMM) object from the ledger. This is similar to [amm_info method][], but the `ledger_entry` version returns only the ledger entry as stored.
| Field | Type | Description |
|:-------------|:-----------------|:----------------------|
| `amm` | Object or String | The [AMM](amm.html) to retrieve. If you specify a string, it must be the [object ID](ledger-object-ids.html) of the AMM, as hexadecimal. If you specify an object, it must contain `asset` and `asset2` sub-fields. |
| `amm.asset` | Object | One of the two assets in this AMM's pool, as a [currency object without an amount](currency-formats.html#specifying-without-amounts). |
| `amm.asset2` | Object | The other of the two assets in this AMM's pool, as a [currency object without an amount](currency-formats.html#specifying-without-amounts). |
<!-- MULTICODE_BLOCK_START -->
*WebSocket*
```json
{
"id": 3,
"command": "ledger_entry",
"amm": {
"asset": {
"currency": "XRP"
},
"asset2": {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
}
}
"ledger_index": "validated"
}
```
*JSON-RPC*
```json
{
"method": "ledger_entry",
"params": [
{
"amm": {
"asset": {
"currency": "XRP"
},
"asset2": {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
}
},
"ledger_index": "validated"
}
]
}
```
*Commandline*
```sh
rippled json ledger_entry '{ "amm": { "asset": { "currency": "XRP" }, "asset2": { "currency" : "TST", "issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd" } }, "ledger_index": "validated" }'
```
<!-- MULTICODE_BLOCK_END -->
[Try it! >](websocket-api-tool.html?server=wss%3A%2F%2Famm.devnet.rippletest.net%3A51233%2F#ledger_entry-amm)
### Get DirectoryNode Object
Retrieve a [DirectoryNode](directorynode.html), which contains a list of other ledger objects. Can be provided as string (object ID of the Directory) or as an object.
@@ -206,9 +274,9 @@ Retrieve an [Offer object](offer.html), which defines an offer to exchange curre
| Field | Type | Description |
|:------------------------|:---------------------------|:----------------------|
| `offer` | Object or String | The [Offer object](offer.html) to retrieve. If a string, interpret as the Offer's [ledger entry ID](ledger-object-ids.html). If an object, requires the sub-fields `account` and `seq` to uniquely identify the offer. |
| `offer` | Object or String | The [Offer object](offer.html) to retrieve. If a string, interpret as the [unique object ID](ledgers.html#tree-format) to the Offer. If an object, requires the sub-fields `account` and `seq` to uniquely identify the offer. |
| `offer.account` | String - [Address][] | _(Required if `offer` is specified as an object)_ The account that placed the offer. |
| `offer.seq` | Unsigned Integer | _(Required if `offer` is specified as an object)_ The [Sequence Number][] of the transaction that created the Offer entry. |
| `offer.seq` | Unsigned Integer | _(Required if `offer` is specified as an object)_ The [Sequence Number][] of the transaction that created the Offer object. |
<!-- MULTICODE_BLOCK_START -->
@@ -564,7 +632,7 @@ rippled json ledger_entry '{ "ticket": { "account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJ
Return an NFT Page in its raw ledger format.
| Field | Type | Description |
| `Field` | Type | Description |
|:------------------------|:---------------------------|:----------------------|
| `nft_page` | String | The [object ID](ledger-object-ids.html) of an [NFT Page](nftokenpage.html) to retrieve. |

View File

@@ -0,0 +1,260 @@
---
html: amm_info.html
parent: path-and-order-book-methods.html
blurb: Get info about an Automted Market Maker (AMM) instance.
status: not_enabled
labels:
- 分散型取引所
- クロスカレンシー
- AMM
---
# amm_info
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/AMMInfo.cpp "Source")
`{{currentpage.name}}` メソッドは、自動マーケットメーカーAMMインスタンスに関する情報を取得します。
_([AMM amendment][] :not_enabled:が必要。)_
### リクエストのフォーマット
リクエストの例
{% include '_snippets/no-cli-syntax.ja.md' %}
<!-- MULTICODE_BLOCK_START -->
*WebSocket*
```json
{
"command": "{{currentpage.name}}",
"asset": {
"currency": "XRP"
},
"asset2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
}
}
```
*JSON-RPC*
```json
{
"method": "{{currentpage.name}}",
"params": [{
"asset": {
"currency": "XRP"
},
"asset2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
}
}]
}
```
<!-- MULTICODE_BLOCK_END -->
[試してみる>](websocket-api-tool.html?server=wss%3A%2F%2Famm.devnet.rippletest.net%3A51233%2F#amm_info)
リクエストには以下のパラメーターが含まれます。
| `フィールド` | 型 | 説明 |
|:-----------|:-----------------------|:-----------------------------------|
| `asset` | オブジェクト または 文字列 | [通貨額][Currency Amount]のように、`currency``issuer`フィールドを持つオブジェクトとしてXRPの場合は`issuer`を省略、検索するAMMの資産の一つを指定します。XRPの場合は、オブジェクトではなく文字列`XRP`として指定することができます。 |
| `asset2` | オブジェクト または 文字列 | AMMの資産のもう一方を、`currency``issuer`フィールドXRPの場合は`issuer`を省略)を持つオブジェクトとして、[通貨額][Currency Amount]のように指定することが可能です。 |
### レスポンスのフォーマット
処理が成功したレスポンスの例:
<!-- MULTICODE_BLOCK_START -->
*WebSocket*
```json
{
"result": {
"amm": {
"amm_account": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"amount": "296890496",
"amount2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value": "25.81656470648473"
},
"asset2_frozen": false,
"auction_slot": {
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"auth_accounts": [
{
"account": "r3f2WpQMsAd8k4Zoijv2PZ78EYFJ2EdvgV"
},
{
"account": "rnW8FAPgpQgA6VoESnVrUVJHBdq9QAtRZs"
}
],
"discounted_fee": 0,
"expiration": "2023-Jan-26 00:28:40.000000000 UTC",
"price": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "0"
},
"time_interval": 0
},
"lp_token": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "87533.41976112682"
},
"trading_fee": 600,
"vote_slots": [
{
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"trading_fee": 600,
"vote_weight": 9684
}
]
},
"ledger_current_index": 316725,
"validated": false
},
"status": "success",
"type": "response"
}
```
*JSON-RPC*
```json
200 OK
{
"result": {
"amm": {
"amm_account": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"amount": "296890496",
"amount2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value": "25.81656470648473"
},
"asset2_frozen": false,
"auction_slot": {
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"auth_accounts": [
{
"account": "r3f2WpQMsAd8k4Zoijv2PZ78EYFJ2EdvgV"
},
{
"account": "rnW8FAPgpQgA6VoESnVrUVJHBdq9QAtRZs"
}
],
"discounted_fee": 0,
"expiration": "2023-Jan-26 00:28:40.000000000 UTC",
"price": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "0"
},
"time_interval": 0
},
"lp_token": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "87533.41976112682"
},
"trading_fee": 600,
"vote_slots": [
{
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"trading_fee": 600,
"vote_weight": 9684
}
]
},
"ledger_current_index": 316745,
"status": "success",
"validated": false
}
}
```
<!-- MULTICODE_BLOCK_END -->
レスポンスは[標準フォーマット][]に従っており、成功した場合は以下のフィールドを含みます。
| フィールド | 型 | 説明 |
|:-----------------------|:---------------------|:----------------------------------------------------------|
| `amm` | オブジェクト | リクエストに含まれる資産ペアの[**AMM詳細オブジェクト**](#amm詳細オブジェクト)です。 |
| `ledger_current_index` | [レジャーインデックス][] | _(`ledger_index`の指定がある場合は省略)_ この情報を取得する際に使用された、現在の進行中の台帳の[レジャーインデックス][]。 |
| `ledger_hash` | [ハッシュ][] | _(`ledger_current_index`の指定がある場合は省略)_ この情報を取得する際に使用された台帳のバージョンの識別ハッシュ。 |
| `ledger_index` | [レジャーインデックス][] | _(`ledger_current_index`の指定がある場合は省略_ この情報を取得する際に使用した台帳のバージョンの[レジャーインデックス][]。 |
| `validated` | 真偽値 | もし`true`なら、このリクエストに使用された台帳は検証済みで、これらの結果は最終的なものです。もし省略されるか `false` に設定されると、データは未確定で変更される可能性があります。 |
### AMM詳細オブジェクト
フィールド `amm` は、台帳上の自動マーケットメーカーAMMの現在の状態を記述するオブジェクトであり、以下のフィールドを含みます。
| フィールド | 型 | 説明 |
|-----------------|------------|-------------|
| `amm_account` | 文字列 | AMMアカウントの[アドレス][]です。 |
| `amount` | [通貨額][] | AMMのプールにある1つの資産の合計額。(注記:リクエストに指定した`asset` _または_ `asset2`になります。) |
| `amount2` | [通貨額][] | AMMのプール内の他の資産の合計額。(注意:リクエストに指定した`asset` _または_ `asset2`になります。) |
| `asset_frozen` | 真偽値 | _(XRPの場合、省略)_ `true`の場合、`amount`の通貨は現在[凍結](freezes.html)されています。 |
| `asset2_frozen` | 真偽値 | _(XRPの場合、省略)_ `true`の場合、`amount2`の通貨は現在[凍結](freezes.html)されています。 |
| `auction_slot` | オブジェクト | _(省略される場合があります)_ 存在する場合、現在のオークションスロットの所有者を記述した[オークションスロットオブジェクト](#オークションスロットオブジェクト)です。 |
| `lp_token` | [通貨額][] | このAMMのLPトークンの発行残高の合計。 |
| `trading_fee` | 数値 | AMMの現在の取引手数料。単位は1/100,000で、1は0.001%の手数料に相当します。 |
| `vote_slots` | 配列 | _(省略される場合があります)_ AMMの取引手数料に対する現在の投票数。[投票スロットオブジェクト](#投票スロットオブジェクト)として表示されます。 |
### オークションスロットオブジェクト
`AMM` オブジェクトの `auction_slot` フィールドは、AMMの現在のオークションスロット保持者を表し、以下のフィールドを含みます。
| フィールド | 型 | 説明 |
|------------------|-----------|-------------|
| `account` | 文字列 | オークションスロットを所有するアカウントの[アドレス][]です。 |
| `auth_accounts` | 配列 | オークションスロットの所有者が、取引手数料の割引の対象として指定した追加アカウントのリスト。この配列の各メンバーは、1つのフィールド `account` を持つオブジェクトで、指定したアカウントのアドレスが含まれています。 |
| `discounted_fee` | 数値 | このAMMに対して取引を行う際に、オークションスロットの保有者、および対象となるアカウントに適用される割引後の取引手数料です。これは常に0です。 |
| `expiration` | 文字列 | このオークションスロットが期限切れとなるISO8601 UTCタイムスタンプ。期限切れになると、オークションスロットは適用されません (ただし、別のトランザクションで置き換えられるかクリーンアップされるまで、データは台帳に残ります)。 |
| `price` | [通貨額][] | オークションスロット所有者がオークションスロットを獲得するために支払った金額LPトークン単位です。これは、現在のスロット所有者を競り落とすための価格に影響します。 |
| `time_interval` | 数値 | このオークションスロットが現在入っている72分の時間間隔を0から19までで指定します。オークションスロットは24時間後72分間隔で20回に失効し、現在の保有者を競り落とすためのコストと、誰かが競り落とした場合に現在の保有者が払い戻される金額に影響します。 |
### 投票スロットオブジェクト
`vote_slots`配列の各項目は、取引手数料を設定するための流動性供給者の投票権を表し、以下のフィールドを含みます。
| フィールド | 型 | 説明 |
|---------------|-------|-------------|
| `account` | 文字列 | この流動性供給者の[アドレス][]。 |
| `trading_fee` | 数値 | この流動性供給者が投票した取引手数料。単位は1/100,000です。 |
| `vote_weight` | 数値 | この流動性供給者の投票が、最終的な取引手数料にどれだけカウントさ れるかを表します。これは、この流動性供給者がAMMのLPトークンをどれだけ保有しているかに比例します。値は、この流動性供給者が保有するこのLPトークンの数の100,000倍を、発行済LPトークンの総数で割ったものになります。例えば、値が1000の場合、流動性供給者はこのAMMのLPトークンの1%を保有していることを意味します。 |
### 考えられるエラー
- [汎用エラータイプ][]のすべて。
- `actNotFound` - この資産ペアのAMMが存在しないか、リクエストで指定された発行アカウントが存在しません。
- `invalidParams` - 1つまたは複数のフィールドの指定に誤りがあるか、1つまたは複数の必須フィールドが欠落しています。
## 関連項目
- [AMMオブジェクト](amm.html) - AMMオブジェクトの正規の保存形式
- [AMMBid][] - オークションスロットと入札の仕組みについての詳細はこちら
- [AMMVote][] - 取引手数料の投票メカニズムの詳細はこちら
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,259 @@
---
html: amm_info.html
parent: path-and-order-book-methods.html
blurb: Get info about an Automted Market Maker (AMM) instance.
status: not_enabled
labels:
- Decentralized Exchange
- Cross-Currency
- AMM
---
# amm_info
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/rpc/handlers/AMMInfo.cpp "Source")
The `{{currentpage.name}}` method gets information about an Automated Market Maker (AMM) instance.
{% include '_snippets/amm-disclaimer.md' %}
### Request Format
An example of the request format:
{% include '_snippets/no-cli-syntax.md' %}
<!-- MULTICODE_BLOCK_START -->
*WebSocket*
```json
{
"command": "{{currentpage.name}}",
"asset": {
"currency": "XRP"
},
"asset2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
}
}
```
*JSON-RPC*
```json
{
"method": "{{currentpage.name}}",
"params": [{
"asset": {
"currency": "XRP"
},
"asset2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
}
}]
}
```
<!-- MULTICODE_BLOCK_END -->
[Try it! >](websocket-api-tool.html?server=wss%3A%2F%2Famm.devnet.rippletest.net%3A51233%2F#amm_info)
The request includes the following parameters:
| `Field` | Type | Description |
|:---------|:-----------------|:-----------------------------------|
| `asset` | Object or String | One of the assets of the AMM to look up, as an object with `currency` and `issuer` fields (omit `issuer` for XRP), like [currency amounts][Currency Amount]. For XRP, you can specify as the string `XRP` instead of as an object. |
| `asset2` | Object or String | The other of the assets of the AMM, as an object with `currency` and `issuer` fields (omit `issuer` for XRP), like [currency amounts][Currency Amount]. |
### Response Format
An example of a successful response:
<!-- MULTICODE_BLOCK_START -->
*WebSocket*
```json
{
"result": {
"amm": {
"amm_account": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"amount": "296890496",
"amount2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value": "25.81656470648473"
},
"asset2_frozen": false,
"auction_slot": {
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"auth_accounts": [
{
"account": "r3f2WpQMsAd8k4Zoijv2PZ78EYFJ2EdvgV"
},
{
"account": "rnW8FAPgpQgA6VoESnVrUVJHBdq9QAtRZs"
}
],
"discounted_fee": 0,
"expiration": "2023-Jan-26 00:28:40.000000000 UTC",
"price": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "0"
},
"time_interval": 0
},
"lp_token": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "87533.41976112682"
},
"trading_fee": 600,
"vote_slots": [
{
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"trading_fee": 600,
"vote_weight": 9684
}
]
},
"ledger_current_index": 316725,
"validated": false
},
"status": "success",
"type": "response"
}
```
*JSON-RPC*
```json
200 OK
{
"result": {
"amm": {
"amm_account": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"amount": "296890496",
"amount2": {
"currency": "TST",
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value": "25.81656470648473"
},
"asset2_frozen": false,
"auction_slot": {
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"auth_accounts": [
{
"account": "r3f2WpQMsAd8k4Zoijv2PZ78EYFJ2EdvgV"
},
{
"account": "rnW8FAPgpQgA6VoESnVrUVJHBdq9QAtRZs"
}
],
"discounted_fee": 0,
"expiration": "2023-Jan-26 00:28:40.000000000 UTC",
"price": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "0"
},
"time_interval": 0
},
"lp_token": {
"currency": "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer": "rp9E3FN3gNmvePGhYnf414T2TkUuoxu8vM",
"value": "87533.41976112682"
},
"trading_fee": 600,
"vote_slots": [
{
"account": "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"trading_fee": 600,
"vote_weight": 9684
}
]
},
"ledger_current_index": 316745,
"status": "success",
"validated": false
}
}
```
<!-- MULTICODE_BLOCK_END -->
The response follows the [standard format][], with a successful result containing the following fields:
| Field | Type | Description |
|:-----------------------|:-----------------|:----------------------------------------------------------|
| `amm` | Object | An [**AMM Description Object**](#amm-description-object) for the requested asset pair. |
| `ledger_current_index` | [Ledger Index][] | _(Omitted if `ledger_index` is provided instead)_ The [ledger index][] of the current in-progress ledger, which was used when retrieving this information. |
| `ledger_hash` | [Hash][] | _(Omitted if `ledger_current_index` is provided instead)_ The identifying hash of the ledger version that was used when retrieving this data. |
| `ledger_index` | [Ledger Index][] | _(Omitted if `ledger_current_index` is provided instead)_ The [ledger index][] of the ledger version used when retrieving this information. |
| `validated` | Boolean | If `true`, the ledger used for this request is validated and these results are final; if omitted or set to `false`, the data is pending and may change. |
### AMM Description Object
The `amm` field is an object describing the current status of an Automated Market Maker (AMM) in the ledger, and contains the following fields:
| Field | Type | Description |
|-----------------|---------------------|-------------|
| `amm_account` | String | The [Address][] of the AMM Account. |
| `amount` | [Currency Amount][] | The total amount of one asset in the AMM's pool. (Note: This could be `asset` _or_ `asset2` from the request.) |
| `amount2` | [Currency Amount][] | The total amount of the other asset in the AMM's pool. (Note: This could be `asset` _or_ `asset2` from the request.) |
| `asset_frozen` | Boolean | _(Omitted for XRP)_ If `true`, the `amount` currency is currently [frozen](freezes.html). |
| `asset2_frozen` | Boolean | _(Omitted for XRP)_ If `true`, the `amount2` currency is currently [frozen](freezes.html). |
| `auction_slot` | Object | _(May be omitted)_ An [Auction Slot Object](#auction-slot-object) describing the current auction slot holder, if there is one. |
| `lp_token` | [Currency Amount][] | The total amount of this AMM's LP Tokens outstanding. |
| `trading_fee` | Number | The AMM's current trading fee, in units of 1/100,000; a value of 1 is equivalent to a 0.001% fee. |
| `vote_slots` | Array | _(May be omitted)_ The current votes for the AMM's trading fee, as [Vote Slot Objects](#vote-slot-objects). |
### Auction Slot Object
The `auction_slot` field of the `amm` object describes the current auction slot holder of the AMM, and contains the following fields:
| Field | Type | Description |
|------------------|---------------------|-------------|
| `account` | String | The [Address][] of the account that owns the auction slot. |
| `auth_accounts` | Array | A list of additional accounts that the auction slot holder has designated as being eligible of the discounted trading fee. Each member of this array is an object with one field, `account`, containing the address of the designated account. |
| `discounted_fee` | Number | The discounted trading fee that applies to the auction slot holder, and any eligible accounts, when trading against this AMM. This is always 0. |
| `expiration` | String | The ISO 8601 UTC timestamp after which this auction slot expires. After expired, the auction slot does not apply (but the data can remain in the ledger until another transaction replaces it or cleans it up). |
| `price` | [Currency Amount][] | The amount, in LP Tokens, that the auction slot holder paid to win the auction slot. This affects the price to outbid the current slot holder. |
| `time_interval` | Number | The current 72-minute time interval this auction slot is in, from 0 to 19. The auction slot expires after 24 hours (20 intervals of 72 minutes) and affects the cost to outbid the current holder and how much the current holder is refunded if someone outbids them. |
### Vote Slot Objects
Each entry in the `vote_slots` array represents one liquidity provider's vote to set the trading fee, and contains the following fields:
| Field | Type | Description |
|---------------|--------|-------------|
| `account` | String | The [Address][] of this liquidity provider. |
| `trading_fee` | Number | The trading fee this liquidity provider voted for, in units of 1/100,000. |
| `vote_weight` | Number | How much this liquidity provider's vote counts towards the final trading fee. This is proportional to how much of the AMM's LP Tokens this liquidity provider holds. The value is equal to 100,000 times the number of this LP Tokens this liquidity provider holds, divided by the total number of LP Tokens outstanding. For example, a value of 1000 means that the liquidity provider holds 1% of this AMM's LP Tokens. |
### Possible Errors
- Any of the [universal error types][].
- `actNotFound` - The AMM for this asset pair does not exist, or an issuing account specified in the request does not exist.
- `invalidParams` - One or more fields are specified incorrectly, or one or more required fields are missing.
## See Also
- [AMM object](amm.html) - The canonical storage format of the AMM object
- [AMMBid][] - More info on the auction slot and bidding mechanism
- [AMMVote][] - More info on the trading fee voting mechanism
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -5,9 +5,9 @@ blurb: パブリックAPIメソッドを使用して、rippledサーバーと直
labels:
- コアサーバー
top_nav_grouping: 人気ページ
top_nav_name: パブリックAPIのメソッド
top_nav_name: APIのメソッド
---
# パブリックAPIのメソッド
# rippledのパブリックメソッド
以下のパブリックAPIメソッドを使用して、[XRP Ledgerサーバー](xrpl-servers.html)と直接通信します。パブリックメソッドは必ずしも一般大衆向けに設計されたのではありませんが、サーバーに接続されたあらゆるクライアントが使用します。パブリックメソッドは、サーバーを運用している組織のメンバーまたは顧客向けのものと考えてください。
@@ -43,9 +43,9 @@ XRP Ledgerのアカウントとは、XRPの保有者と取引の送信者を意
トランザクションだけが、XRP Ledgerの共有されている状態を変更できます。XRP Ledgerに対するすべてのビジネスはトランザクションの形態をとります。以下のメソッドを使用して、トランザクションを処理します。
* **[`sign`](sign.html)** - トランザクションに暗号で署名します。
* **[`sign_for`](sign_for.html)** - マルチシグに署名を提供します。
* **[`sign_for`](sign_for.html)** - マルチ署名に署名を提供します。
* **[`submit`](submit.html)** - トランザクションをネットワークに送信します。
* **[`submit_multisigned`](submit_multisigned.html)** - マルチシグトランザクションをネットワークに送信します。
* **[`submit_multisigned`](submit_multisigned.html)** - マルチ署名済みトランザクションをネットワークに送信します。
* **[`transaction_entry`](transaction_entry.html)** - レジャーの特定のバージョンからトランザクションについての情報を取得します。
* **[`tx`](tx.html)** - 手元にあるすべてのレジャーからトランザクションについての情報を取得します。
* **[`tx_history`](tx_history.html)** - 最新の全トランザクションについての情報を取得します。
@@ -55,6 +55,7 @@ XRP Ledgerのアカウントとは、XRPの保有者と取引の送信者を意
パスは、支払いが送信者から受信者に届くまでに中間ステップでたどる道筋を定義します。パスは、送信者と受信者をオーダーブックを介してつなぐことで、複数通貨間の支払いを可能にします。パスと他のオーダーブックに関しては、以下のメソッドを使用します。
* **[`amm_info`](amm_info.html)** :not_enabled: - 自動マーケットメイカー(AMM)についての情報を取得します。
* **[`book_offers`](book_offers.html)** - 2つの通貨を交換するオファーに関する情報を取得します。
* **[`deposit_authorized`](deposit_authorized.html)** - あるアカウントが別のアカウントへの支払いの直接送信について承認されているかどうかを調べます。
* **[`nft_buy_offers`](nft_buy_offers.html)** - Retrieve a list of buy offers for a specified NFToken object.

View File

@@ -59,6 +59,7 @@ By default, the following methods are [admin-only](admin-api-methods.html). They
Paths define a way for payments to flow through intermediary steps on their way from sender to receiver. Paths enable cross-currency payments by connecting sender and receiver through order books. Use these methods to work with paths and other books.
* **[`amm_info`](amm_info.html)** :not_enabled: - Get info about an Automated Market Maker (AMM).
* **[`book_offers`](book_offers.html)** - Get info about offers to exchange two currencies.
* **[`deposit_authorized`](deposit_authorized.html)** - Look up whether one account is authorized to send payments directly to another. <!-- STYLE_OVERRIDE: is authorized to -->
* **[`nft_buy_offers`](nft_buy_offers.html)** - Retrieve a list of buy offers for a specified NFToken object.
@@ -98,7 +99,6 @@ Use these methods to retrieve information using Clio server APIs.
* **[`server_info`](server_info-clio.html)** - Retrieve status of the Clio server.
* **[`ledger`](ledger-clio.html)** - Get info about a ledger version using Clio server's `ledger` API.
* **[`nft_history`](nft_history.html)** - Retrieve transaction history for the specified NFT using Clio server's `nft_history` API.
* **[`nft_info`](nft_info.html)** - Retrieve information about the specified NFT using Clio server's `nft_info` API.
## [Utility Methods](utility-methods.html)

View File

@@ -0,0 +1,115 @@
---
html: amm.html
parent: ledger-object-types.html
blurb: 自動マーケットメーカーAMMインスタンスの定義と詳細。
labels:
- AMM
status: not_enabled
---
# AMM
[[Source]](https://github.com/xrplf/rippled/blob/c1e4bfb08bcc9f187d794a71d653003a6148dc68/src/ripple/protocol/impl/LedgerFormats.cpp#L265-L275 "Source")
_([AMM amendment][] :not_enabled:が必要。)_
`AMM`オブジェクトは、単一の[自動マーケットメーカー](automated-market-makers.html)(AMM)インスタンスを表します。
## AMM JSONの例
```json
{
"AMMAccount" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"Asset" : {
"currency" : "XRP"
},
"Asset2" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"AuctionSlot" : {
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"AuthAccounts" : [
{
"AuthAccount" : {
"Account" : "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"
}
},
{
"AuthAccount" : {
"Account" : "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"
}
}
],
"DiscountedFee" : 0,
"Expiration" : 721870180,
"Price" : {
"currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"value" : "0.8696263565463045"
}
},
"Flags" : 0,
"LPTokenBalance" : {
"currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"value" : "71150.53584131501"
},
"TradingFee" : 600,
"VoteSlots" : [
{
"VoteEntry" : {
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"TradingFee" : 600,
"VoteWeight" : 100000
}
}
]
}
```
## AMM フィールド
`AMM`オブジェクトは以下のフィールドを持ちます。
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:-----------------|:--------------------|:------------------|:----------|--------------|
| `Asset` | オブジェクト | STIssue | はい | このAMMが保有する2つのアセットのうちの1つの定義。JSONでは、`currency``issuer`フィールドを持つオブジェクトになります。 |
| `Asset2` | オブジェクト | STIssue | はい | このAMMが保有するもう一つの資産の定義。JSONでは、`currency``issuer`フィールドを持つオブジェクトになります。 |
| `AMMAccount` | 文字列 | AccountID | はい | このAMMの資産を保有する[特殊なアカウント](accountroot.html#ammの特殊なaccountrootオブジェクト)のアドレス。 |
| `AuctionSlot` | オブジェクト | STObject | いいえ | オークションスロットの現在の所有者の詳細。[オークションスロットオブジェクト](#オークションスロットオブジェクト)形式です。|
| `LPTokenBalance` | [通貨額][] | Amount | はい | AMMインスタンスの流動性供給者トークンの発行残高の合計。このトークンの保有者は、保有量に比例してAMMの取引手数料に投票したり、取引手数料の徴収とともに増えていくAMMの資産の一部とトークンを交換したりすることができます。 |
| `TradingFee` | 数値 | UInt16 | はい | AMMインスタンスに対する取引に課される手数料のパーセンテージを1/100,000の単位で指定します。最大値は1000で、これは1%の手数料となります。 |
| `VoteSlots` | 配列 | STArray | いいえ | プールの取引手数料に関する投票を表す、投票オブジェクトのリスト。|
### オークションスロットオブジェクト
`AuctionSlot`フィールドは、以下のネストしたフィールドを持つオブジェクトを含んでいます。
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:----------------|:--------------------|:------------------|:----------|:--|
| `Account` | 文字列 - アドレス | AccountID | はい | このオークションスロットの現在の所有者。 |
| `AuthAccounts` | 配列 | STArray | いいえ | AMMインスタンスに対して取引手数料を割引した価格で取引することを許可された、最大4つの追加アカウントのリスト。 |
| `DiscountedFee` | 文字列 | UInt32 | はい | オークションの所有者に請求される取引手数料で、`TradingFee`と同じフォーマットです。デフォルトでは0で、オークションスロットの所有者はAMMの標準的な手数料の代わりに、手数料なしで取引できることを意味します。 |
| `Price` | [通貨額][] | Amount | はい | オークションスロットの所有者がこのスロットを落札するために支払った金額LPトークン。 |
| `Expiration` | 文字列 | UInt32 | はい | このスロットの有効期限が切れる[Rippleエポック以降の経過秒数][]で指定した時刻。 |
## AMM フラグ
現在、`AMM`オブジェクトに定義されているフラグはありません。
## AMM ID フォーマット
`AMM`オブジェクトのIIは、以下の値の[SHA-512Half][]を順に繋げたものです。
1. `AMM`のスペースキー(`0x0041`)
0. 第1アセットの発行者のAccountID。
0. 第1トークンの160ビットの通貨コード。
0. 第2アセットの発行者のAccountID。
0. 第2トークンの160ビットの通貨コード。
XRPの場合、トークン・発行者ともに全て0を使用します。
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,115 @@
---
html: amm.html
parent: ledger-object-types.html
blurb: The definition and details of an Automated Market Maker (AMM) instance.
labels:
- AMM
status: not_enabled
---
# AMM
[[Source]](https://github.com/XRPLF/rippled/blob/89780c8e4fd4d140fcb912cf2d0c01c1b260539e/src/ripple/protocol/impl/LedgerFormats.cpp#L272-L284 "Source")
_(Requires the [AMM amendment][] :not_enabled:)_
The `AMM` object type describes a single [Automated Market Maker](automated-market-makers.html) (AMM) instance.
## Example AMM JSON
```json
{
"AMMAccount" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"Asset" : {
"currency" : "XRP"
},
"Asset2" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"AuctionSlot" : {
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"AuthAccounts" : [
{
"AuthAccount" : {
"Account" : "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"
}
},
{
"AuthAccount" : {
"Account" : "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"
}
}
],
"DiscountedFee" : 0,
"Expiration" : 721870180,
"Price" : {
"currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"value" : "0.8696263565463045"
}
},
"Flags" : 0,
"LPTokenBalance" : {
"currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"value" : "71150.53584131501"
},
"TradingFee" : 600,
"VoteSlots" : [
{
"VoteEntry" : {
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"TradingFee" : 600,
"VoteWeight" : 100000
}
}
]
}
```
## AMM Fields
The `AMM` object has the following fields:
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:-----------------|:--------------------|:------------------|:----------|--------------|
| `Asset` | Object | STIssue | Yes | The definition for one of the two assets this AMM holds. In JSON, this is an object with `currency` and `issuer` fields. |
| `Asset2` | Object | STIssue | Yes | The definition for the other asset this AMM holds. In JSON, this is an object with `currency` and `issuer` fields. |
| `AMMAccount` | String | AccountID | Yes | The address of the [special account](accountroot.html#special-amm-accountroot-objects) that holds this AMM's assets. |
| `AuctionSlot` | Object | STObject | No | Details of the current owner of the auction slot, as an [Auction Slot object](#auction-slot-object). |
| `LPTokenBalance` | [Currency Amount][] | Amount | Yes | The 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. |
| `TradingFee` | Number | UInt16 | Yes | The 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. |
| `VoteSlots` | Array | STArray | No | A 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:
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:----------------|:--------------------|:------------------|:----------|:--|
| `Account` | String - Address | AccountID | Yes | The current owner of this auction slot. |
| `AuthAccounts` | Array | STArray | No | A list of at most 4 additional accounts that are authorized to trade at the discounted fee for this AMM instance. |
| `DiscountedFee` | String | UInt32 | Yes | The trading fee to be charged to the auction owner, in the same format as `TradingFee`. By default this is 0, meaning that the auction owner can trade at no fee instead of the standard fee for this AMM. |
| `Price` | [Currency Amount][] | Amount | Yes | The amount the auction owner paid to win this slot, in LP Tokens. |
| `Expiration` | String | UInt32 | Yes | The time when this slot expires, in [seconds since the Ripple Epoch][]. |
## AMM Flags
There are currently no flags defined for `AMM` objects.
## AMM ID Format
The ID of an `AMM` object is the [SHA-512Half][] of the following values, concatenated in order:
1. The `AMM` space key (`0x0041`)
0. The AccountID of the first asset's issuer.
0. The 160-bit currency code of the first token.
0. The AccountID of the second asset's issuer.
0. The 160-bit currency code of the second token.
For XRP, use all 0's for both the token and the issuer.
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -184,6 +184,7 @@ Transaction instructions may contain fields of any of the following types:
| [Hash256][] | 5 | 256 | No | A 256-bit arbitrary binary value. This usually represents the "SHA-512Half" hash of a transaction, ledger version, or ledger data object. |
| [PathSet][] | 18 | Variable | No | A set of possible [payment paths](paths.html) for a [cross-currency payment](cross-currency-payments.html). |
| [STArray][] | 15 | Variable | No | An array containing a variable number of members, which can be different types depending on the field. Two cases of this include [memos](transaction-common-fields.html#memos-field) and lists of signers used in [multi-signing](multi-signing.html). |
| [STIssue][] | 24 | 160 or 320 | No | An asset definition, XRP or a token, with no quantity. |
| [STObject][] | 14 | Variable | No | An object containing one or more nested fields. |
| [UInt8][] | 16 | 8 | No | An 8-bit unsigned integer. |
| [UInt16][] | 1 | 16 | No | A 16-bit unsigned integer. The `TransactionType` is a special case of this type, with specific strings mapping to integer values. |
@@ -191,8 +192,6 @@ Transaction instructions may contain fields of any of the following types:
[Length-prefixed]: #length-prefixing
<!-- | [STIssue][] | 24 | 160 or 320 | No | :not_enabled: An asset definition, XRP or a token, with no quantity. | -->
In addition to all of the above field types, the following types may appear in other contexts, such as [ledger objects](ledger-object-types.html) and [transaction metadata](transaction-metadata.html):
@@ -303,20 +302,13 @@ The XRP Ledger has several "hash" types: Hash128, Hash160, and Hash256. These fi
All such fields are serialized as the specific number of bits, with no length indicator, in big-endian byte order.
<!-- Issue Fields is still under development -->
<!--
### Issue Fields
[STIssue]: #issue-fields
_(The "Issue" or "STIssue" type is part of multiple proposed extensions to the XRP Ledger protocol, including [XLS-30d: Automated Market Maker](https://github.com/XRPLF/XRPL-Standards/discussions/78) :not_enabled: and [Federated Sidechains](federated-sidechains.html) :not_enabled:)_ -->
<!-- SPELLING_IGNORE: 30d -->
<!--
Some fields specify a _type_ of asset, which could be XRP or a fungible [token](tokens.html), without an amount. These fields have consist of one or two 160-bit segments in order:
1. The first 160 bits are the [currency code](#currency-codes) of the asset. For XRP, this is all 0's.
2. If the first 160 bits are all 0's (the asset is XRP), the field ends there. Otherwise, the asset is a token and the next 160 bits are the [AccountID of the token issuer](#accountid-fields). -->
2. If the first 160 bits are all 0's (the asset is XRP), the field ends there. Otherwise, the asset is a token and the next 160 bits are the [AccountID of the token issuer](#accountid-fields).
### Object Fields
@@ -378,6 +370,6 @@ Another special case is the `TransactionType` field. In JSON, this field is conv
<!-- SPELLING_IGNORE: pathset, stobject, starray, ledgerentry, vector256, accountids, uint -->
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,138 @@
---
html: ammbid.html
parent: transaction-types.html
blurb: 自動マーケットメーカーのオークションスロットに入札することで、手数料の割引を受けることができます。
labels:
- AMM
status: not_enabled
---
# AMMBid
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMBid.cpp "Source")
_([AMM amendment][] :not_enabled:が必要。)_
[自動マーケットメーカー](automated-market-makers.html)のオークションスロットに入札することができます。落札されると、競り落とされるか24時間が経過するまで、割引料金でAMMと取引することができます。24時間が経過する前に競り落とされた場合、残り時間に応じて落札価格の一部が払い戻されます。
AMMのLPトークンを使って落札すると、落札額はAMMに返金され、LPトークンの残高が減ります。
## {{currentpage.name}} JSONの例
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Asset" : {
"currency" : "XRP"
},
"Asset2" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"AuthAccounts" : [
{
"AuthAccount" : {
"Account" : "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"
}
},
{
"AuthAccount" : {
"Account" : "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"
}
}
],
"BidMax" : {
"currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"value" : "100"
},
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 9,
"TransactionType" : "AMMBid"
}
```
{% include '_snippets/tx-fields-intro.ja.md' %}
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:---------------|:-----------|:- ----------|:----- |:------------|
| `Asset` | オブジェクト | STIssue | はい | AMMのプールにある資産の一つを定義します。JSONでは、`currency``issuer`フィールドを持つオブジェクトになりますXRPの場合は`issuer`を省略します)。 |
| `Asset2` | オブジェクト | STIssue | はい | AMM のプールにあるもう一つのアセットの定義です。JSONでは、`currency``issuer`フィールドを持つオブジェクトになりますXRPの場合は`issuer`を省略します)。 |
| `BidMin` | [通貨額][] | Amount | いいえ | スロットに支払う最小の金額。この値を高く設定すると、他の人から競り落とされにくくなります。省略された場合は、落札に必要な最低額を支払います。 |
| `BidMax` | [通貨額][] | Amount | いいえ | スロットに支払う最大の金額。落札するためのコストがこの金額より高い場合、取引は失敗します。省略された場合は、落札に必要な金額を支払います。 |
| `AuthAccounts` | 配列 | STArray | いいえ | 割引料金で取引を許可する最大4つの追加のアカウントのリスト。これには、トランザクション送信者のアドレスは含めることはできません。これらのオブジェクトはそれぞれ[Auth Accountオブジェクト](#auth-accountオブジェクト)である必要があります。. |
`BidMin``BidMax` の両方を指定することはできません。
### Auth Accountオブジェクト
`AuthAccounts` 配列の各メンバーは、以下のフィールドを持つオブジェクトである必要があります。
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:---------------|:----------|:-------------|:-----|:------------|
| `Account` | 文字列 | AccountID | はい | 認可するアカウントのアドレス。 |
配列に現れる他の「内部オブジェクト」と同様に、これらのオブジェクトのJSON表現は、オブジェクトタイプ`AuthAccount`のみをキーとするオブジェクトにラップされています。
## オークションスロットの価格
落札された場合、トランザクションは自動的に前のスロット所有者を競り落とし、送信者のLPトークンから落札価格が引き落とされます。落札価格は、72分ずつ20回に区切られた時間経過とともに減少します。もし送信者が落札するのに十分なLPトークンを持っていなかったり、入札価格がトランザクションの`BidMax`値より高い場合、トランザクションは`tecAMM_FAILED_BID`という結果で失敗します。
- オークションスロットが現在空であったり、期限切れ、または最後のインターバルである場合、**最低入札価格**はAMMの総LPトークン残高の**0.001%**です。
**注意:** この最小値は暫定値であり、AMM機能が最終的に完成する前に変更される可能性があります。
- それ以外の場合、現在の保有者に競り勝つための価格は、以下の式で計算されます。
P = B × 1.05 × (1 - t⁶⁰) + M
- `P`: 競り落とすための価格。単位はLPトークン。
- `B`: 現在の入札価格。単位はLPトークン。
- `t`: 現在の24時間枠で経過した時間の割合。0.05の倍数に切り捨てられる。
- `M`: M`は上記で定義された**最低入札価格**。
競り落とすためのコストには、2つの特殊なケースがあります。誰かが落札してから**最初の時間枠**では、その人を競り落とすための価格は、最低入札価格+既存の入札価格の5%アップとなります。
P = B × 1.05 + M
スロットの**最後の時間枠**では、誰かを競り落とすためのコストは最低入札額のみです。
P = M
**注記:** 台帳を作成する際に、ネットワーク上のすべてのサーバーが同じ結果になるように、時間の計測は前回の台帳の[正規の終了時刻](ledgers.html#ledger-close-times) に基づいており、これはおおよその目安の時間です。
## 払い戻し
アクティブなオークションスロットを競り落とした場合、AMMは以下の計算式で前ホルダーに価格の一部を払い戻します。
```text
R = B × (1 - t)
```
- `R`: は返金する金額。単位はLPトークン。
- `B`: 払い戻しの対象となる前回の入札の価格。単位はLPトークン。
- `t`: 現在の24時間枠で経過した時間の割合。0.05の倍数に切り捨てられる。
特殊なケースとして、オークションスロットの最終20番目区間では、払い戻し額は0となる。
**注記:** XRP Ledgerの時刻と同様に、トランザクション処理では _前回の_ 台帳の[正規の終了時刻](ledgers.html#ledger-close-times)を使用するため、実時間と最大で約10秒の差が生じる場合があります。
## エラーケース
すべてのトランザクションで発生する可能性のあるエラーに加えて、{{currentpage.name}}トランザクションでは、次の[トランザクション結果コード](transaction-results.html)が発生する可能性があります。
| エラーコード | 説明 |
|:------------------------|:---------------------------------------------|
| `tecAMM_FAILED_BID` | このトランザクションでは、送信者が必要な入札額を支払うために十分なLPトークンを保有していないか、落札価格がトランザクションで指定された`BidMax`値より高いため、落札できませんでした。 |
| `tecAMM_INVALID_TOKENS` | このトランザクションの送信者は、スロット価格に見合うだけのLPトークンを保有していません。 |
| `temBAD_AMM_TOKENS` | 指定された`BidMin`または`BidMax`は、このAMMの正しいLPトークンとして指定されていません。 |
| `temBAD_AMM_OPTIONS` | トランザクションが無効なオプションを指定しました。例えば、`AuthAccounts`のリストが長すぎるか、`BidMin`とBidMax` の両方を指定しています。 |
| `temDISABLED` | このネットワークでは、AMM機能 :not_enabled: は有効ではありません。 |
| `terNO_ACCOUNT` | このリクエストで指定されたアカウントのいずれかが存在しません。 |
| `terNO_AMM` | このトランザクションの資産ペアの自動マーケットメーカーのインスタンスが存在しません。 |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,138 @@
---
html: ammbid.html
parent: transaction-types.html
blurb: Bid on an Automated Market Maker's auction slot, which grants a discounted fee.
labels:
- AMM
status: not_enabled
---
# AMMBid
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMBid.cpp "Source")
_(Requires the [AMM amendment][] :not_enabled:)_
Bid on an [Automated Market Maker](automated-market-makers.html)'s (AMM's) auction slot. If you win, you can trade against the AMM at a discounted fee until you are outbid or 24 hours have passed. If you are outbid before 24 hours have passed, you are refunded part of the cost of your bid based on how much time remains.
You bid using the AMM's LP Tokens; the amount of a winning bid is returned to the AMM, decreasing the outstanding balance of LP Tokens.
## Example {{currentpage.name}} JSON
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Asset" : {
"currency" : "XRP"
},
"Asset2" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"AuthAccounts" : [
{
"AuthAccount" : {
"Account" : "rMKXGCbJ5d8LbrqthdG46q3f969MVK2Qeg"
}
},
{
"AuthAccount" : {
"Account" : "rBepJuTLFJt3WmtLXYAxSjtBWAeQxVbncv"
}
}
],
"BidMax" : {
"currency" : "039C99CD9AB0B70B32ECDA51EAAE471625608EA2",
"issuer" : "rE54zDvgnghAoPopCgvtiqWNq3dU5y836S",
"value" : "100"
},
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 9,
"TransactionType" : "AMMBid"
}
```
{% include '_snippets/tx-fields-intro.md' %}
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:---------------|:--------------------|:------------------|:----------|:------------|
| `Asset` | Object | STIssue | Yes | The definition for one of the assets in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `Asset2` | Object | STIssue | Yes | The definition for the other asset in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `BidMin` | [Currency Amount][] | Amount | No | Pay at least this amount for the slot. Setting this value higher makes it harder for others to outbid you. If omitted, pay the minimum necessary to win the bid. |
| `BidMax` | [Currency Amount][] | Amount | No | Pay at most this amount for the slot. If the cost to win the bid is higher than this amount, the transaction fails. If omitted, pay as much as necessary to win the bid. |
| `AuthAccounts` | Array | STArray | No | A list of up to 4 additional accounts that you allow to trade at the discounted fee. This cannot include the address of the transaction sender. Each of these objects should be an [Auth Account object](#auth-account-objects). |
You cannot specify both `BidMin` and `BidMax`.
### Auth Account Objects
Each member of the `AuthAccounts` array must be an object with the following field:
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:---------------|:----------|:------------------|:----------|:------------|
| `Account` | String | AccountID | Yes | The address of the account to authorize. |
Like other "inner objects" that can appear in arrays, the JSON representation of each of these objects is wrapped in an object whose only key is the object type, `AuthAccount`.
## Auction Slot Price
If successful, the transaction automatically outbids the previous slot owner and debits the bid price from the sender's LP Tokens. The price to win the auction decreases over time, divided into 20 intervals of 72 minutes each. If the sender does not have enough LP Tokens to win the bid, or the price of the bid is higher than the transaction's `BidMax` value, the transaction fails with a `tecAMM_FAILED_BID` result.
- If the auction slot is currently empty, expired, or in its last interval, the **minimum bid** is **0.001% of the AMM's total LP Tokens balance**.
**Caution:** This minimum value is a placeholder and may change before the AMM feature becomes finalized.
- Otherwise, the price to outbid the current holder is calculated using the following formula:
P = B × 1.05 × (1 - t⁶⁰) + M
- `P` is the price to outbid, in LP Tokens.
- `B` is the price of the current bid, in LP Tokens.
- `t` is the fraction of time elapsed in the current 24-hour slot, rounded down to a multiple of 0.05.
- `M` is the **minimum bid** as defined above.
There are two special cases for the cost to outbid someone. In the **first interval** after someone wins the bid, the price to outbid them is the minimum bid plus 5% more than the existing bid:
P = B × 1.05 + M
In the **last interval** of someone's slot, the cost to outbid someone is only the minimum bid:
P = M
**Note:** To make sure all servers in the network reach the same results when building a ledger, time measurements are based on the [official close time](ledgers.html#ledger-close-times) of the previous ledger, which is approximate.
## Bid Refunds
When you outbid an active auction slot, the AMM refunds the previous holder part of the price, using this formula:
```text
R = B × (1 - t)
```
- `R` is the amount to refund, in LP Tokens.
- `B` is the price of the previous bid to be refunded, in LP Tokens.
- `t` is the fraction of time elapsed in the current 24-hour slot, rounded down to a multiple of 0.05.
As a special case, during the final (20th) interval of the auction slot, the refunded amount is zero.
**Note:** As with all XRP Ledger times, transaction processing uses the [official close time](ledgers.html#ledger-close-times) of the _previous_ ledger, which can result in a difference of up to about 10 seconds from real time.
## Error Cases
Besides errors that can occur for all transactions, {{currentpage.name}} transactions can result in the following [transaction result codes](transaction-results.html):
| Error Code | Description |
|:------------------------|:---------------------------------------------|
| `tecAMM_FAILED_BID` | This transaction could not win the auction, either because the sender does not hold enough LP Tokens to pay the necessary bid or because the price to win the auction was higher than the transaction's specified `BidMax` value. |
| `tecAMM_INVALID_TOKENS` | The sender of this transaction does not hold enough LP Tokens to meet the slot price. |
| `temBAD_AMM_TOKENS` | The specified `BidMin` or `BidMax` were not specified as the correct LP Tokens for this AMM. |
| `temBAD_AMM_OPTIONS` | The transaction specified invalid options, such as a list of `AuthAccounts` that is too long, or specifying both `BidMin` and `BidMax`. |
| `temDISABLED` | The AMM feature :not_enabled: is not enabled on this network. |
| `terNO_ACCOUNT` | One of the accounts specified in this request do not exist. |
| `terNO_AMM` | The Automated Market Maker instance for the asset pair in this transaction does not exist. |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,70 @@
---
html: ammcreate.html
parent: transaction-types.html
blurb: 指定された資産ペアを取引するための新しい自動マーケットメーカーを作成します。
labels:
- AMM
status: not_enabled
---
# AMMCreate
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMCreate.cpp "Source")
_([AMM amendment][] :not_enabled:が必要。)_
資産([代替可能トークン](tokens.html)または[XRP](xrp.html))のペアを取引するための新しい[自動マーケットメーカー](automated-market-makers.html)(AMM)インスタンスを作成します。
AMMを表す[AMMオブジェクト][]と[特殊なAccountRootオブジェクト](accountroot.html#ammの特殊なaccountrootオブジェクト)を作成します。また、両資産の開始残高の所有権を送信者から、作成された`AccountRoot`に移し、初期残高の流動性プロバイダトークンLPトークンをAMMアカウントから送信者に発行します。
**注意:** AMMを作成する際には、各資産をほぼ同額ずつ投入する必要があります。そうしないと、他のユーザーがあなたの負担において、このAMMを使った取引で利益を得ることができます[アービトラージの実行](https://www.machow.ski/posts/an_introduction_to_automated_market_makers/#price-arbitrage))。流動性供給者が負う通貨リスクは、資産ペアのボラティリティ(不均衡の可能性)が高ければ高いほど、大きくなります。取引手数料が高いほど、このリスクを相殺することになりますので、資産ペアのボラティリティに応じて取引手数料を設定するとよいでしょう。
## {{currentpage.name}} JSONの例
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Amount" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value" : "25"
},
"Amount2" : "250000000",
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 6,
"TradingFee" : 500,
"TransactionType" : "AMMCreate"
}
```
{% include '_snippets/tx-fields-intro.md' %}
<!--{# fix md highlighting_ #}-->
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:-------------|:---- -----|:-----------|:------|:------------|
| `Amount` | [通貨額][] | Amount | はい | このAMMの最初の資金となる2つの資産のうち、1つ目の資産です。これは正数である必要があります。 |
| `Amount2` | [通貨額][] | Amount | はい | このAMMの最初の資金となる2つの資産のうち、2つ目の資産です。これは正数である必要があります。 |
| `TradingFee` | 数値 | UInt16 | はい | このAMMインスタンスに対する取引に課される手数料を1/100,000単位で指定します値1は0.001%に相当)。最大値は`1000`で、1%の手数料を意味します。最小値は `0`です。 |
`Amount``Amount2`の一方または両方は[tokens](tokens.html)であり、最大でどちらか一方を[XRP](xrp.html)にすることが可能です。通貨コードと発行者が同じものは使用できません。AMMのLPトークンは、別のAMMの資産の1つとして使用することができます。
## エラーケース
すべてのトランザクションで発生する可能性のあるエラーに加えて、{{currentpage.name}}トランザクションでは、次の[トランザクション結果コード](transaction-results.html)が発生する可能性があります。
| エラーコード | 説明 |
|:--------------------|:---------------------------------------------|
| `temDISABLED` | このネットワークでは、AMM機能 :not_enabled: は有効ではありません。 |
| `temINVALID_FLAG` | トランザクションに無効な`Flags`値が指定されています。現在、このトランザクションタイプに定義されたフラグはないので、[グローバルフラグ](transaction-common-fields.html#グローバルフラグ)のみが許可されます。 |
| `temBAD_AMM_TOKENS` | `Amount``Amount2`値が正しくありません。例えば、両方とも同じトークンを参照している場合です。 |
| `temBAD_FEE` | `TradingFee`の値が不正です。ゼロまたは正の整数でなければならず、1000を超えることはできません。 |
| `terNO_ACCOUNT` | リクエストで参照されたいずれかのアカウントが存在しません。|
| `tecNO_AUTH` | 送信者は資産(`Amount`または`Amount2`)のいずれかを保有する権限がありません。 |
| `tecNO_LINE` | 送信者は資産(`Amount`または`Amount2`のうちいずれか1つに対するトラストラインを保有していません。 |
| `tecFROZEN` | 資産(`Amount`または`Amount2`の少なくとも1つが現在[凍結](freezes.html)されています。 |
| `tecUNFUNDED_AMM` | 送信者は`Amount``Amount2`で指定された金額をAMMに入金するための十分な資金を保有していません。 |
| `tecAMM_EXISTS` | この通貨ペアを扱っているAMMが既に存在しています。 |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,70 @@
---
html: ammcreate.html
parent: transaction-types.html
blurb: Create a new Automated Market Maker for trading a given pair of assets.
labels:
- AMM
status: not_enabled
---
# AMMCreate
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMCreate.cpp "Source")
_(Requires the [AMM amendment][] :not_enabled:)_
Create a new [Automated Market Maker](automated-market-makers.html) (AMM) instance for trading a pair of assets ([fungible tokens](tokens.html) or [XRP](xrp.html)).
Creates both an [AMM object][] and a [special AccountRoot object](accountroot.html#special-amm-accountroot-objects) to represent the AMM. Also transfers ownership of the starting balance of both assets from the sender to the created `AccountRoot` and issues an initial balance of liquidity provider tokens (LP Tokens) from the AMM account to the sender.
**Caution:** When you create the AMM, you should fund it with (approximately) equal-value amounts of each asset. Otherwise, other users can profit at your expense by trading with this AMM ([performing arbitrage](https://www.machow.ski/posts/an_introduction_to_automated_market_makers/#price-arbitrage)). The currency risk that liquidity providers take on increases with the volatility (potential for imbalance) of the asset pair. The higher the trading fee, the more it offsets this risk, so it's best to set the trading fee based on the volatility of the asset pair.
## Example {{currentpage.name}} JSON
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Amount" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value" : "25"
},
"Amount2" : "250000000",
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 6,
"TradingFee" : 500,
"TransactionType" : "AMMCreate"
}
```
{% include '_snippets/tx-fields-intro.md' %}
<!--{# fix md highlighting_ #}-->
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:-------------|:--------------------|:------------------|:----------|:------------|
| `Amount` | [Currency Amount][] | Amount | Yes | The first of the two assets to fund this AMM with. This must be a positive amount. |
| `Amount2` | [Currency Amount][] | Amount | Yes | The second of the two assets to fund this AMM with. This must be a positive amount. |
| `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`. |
One or both of `Amount` and `Amount2` can be [tokens](tokens.html); at most one of them can be [XRP](xrp.html). They cannot both have the same currency code and issuer. An AMM's LP tokens _can_ be used as one of the assets for another AMM.
## Error Cases
Besides errors that can occur for all transactions, {{currentpage.name}} transactions can result in the following [transaction result codes](transaction-results.html):
| Error Code | Description |
|:--------------------|:---------------------------------------------|
| `temDISABLED` | The AMM feature :not_enabled: is not enabled on this network. |
| `temINVALID_FLAG` | The transaction specified an invalid `Flags` value. Since there are currently no flags defined for this transaction type, only [Global Flags](transaction-common-fields.html#global-flags) are allowed. |
| `temBAD_AMM_TOKENS` | The values of `Amount` and `Amount2` are not valid: for example, both refer to the same token. |
| `temBAD_FEE` | The `TradingFee` value is invalid. It must be zero or a positive integer and cannot be over 1000. |
| `terNO_ACCOUNT` | One of the accounts referenced in the request does not exist. |
| `tecNO_AUTH` | The sender is not authorized to hold one of the deposit assets (`Amount` or `Amount2`). |
| `tecNO_LINE` | The sender does not have a trust line for one of the deposit assets (`Amount` or `Amount2`). |
| `tecFROZEN` | At least one of the deposit assets (`Amount` or `Amount2`) is currently [frozen](freezes.html). |
| `tecUNFUNDED_AMM` | The sender does not hold enough money to fund the AMM with the amounts specified in `Amount` and `Amount2`. |
| `tecAMM_EXISTS` | There is already another AMM trading this currency pair. |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,135 @@
---
html: ammdeposit.html
parent: transaction-types.html
blurb: LPTokenと引き換えに、自動マーケットメーカーに資金を預けます。
labels:
- AMM
status: not_enabled
---
# AMMDeposit
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMDeposit.cpp "Source")
_([AMM amendment][] :not_enabled:が必要。)_
[自動マーケットメーカー](automated-market-makers.html)AMMインスタンスに資金を預け、引き換えにAMMの流動性プロバイダートークン _LPトークン_ を受け取ります。AMMのプールにある資産の一方または両方を預けることができます。
トランザクションが成功すると、LPトークンを保持するためにAMMアカウント(リミット0)に[トラストライン](trust-lines-and-issuing.html)が作成されます。
## {{currentpage.name}} JSONの例
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Amount" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value" : "2.5"
},
"Amount2" : "30000000",
"Asset" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"Asset2" : {
"currency" : "XRP"
},
"Fee" : "10",
"Flags" : 1048576,
"Sequence" : 7,
"TransactionType" : "AMMDeposit"
}
```
{% include '_snippets/tx-fields-intro.ja.md' %}
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:--------------|:-----------|:-----------|:------|:------------|
| `Asset` | オブジェクト | STIssue | はい | AMMのプールにある資産の一つを定義します。JSONでは、`currency``issuer`フィールドを持つオブジェクトになりますXRPの場合は`issuer`を省略します)。 |
| `Asset2` | オブジェクト | STIssue | はい | AMMのプールにあるもう一つの資産を定義します。JSONでは、`currency``issuer`フィールドを持つオブジェクトになりますXRPの場合は`issuer`を省略します)。 |
| `Amount` | [通貨額][] | Amount | いいえ | AMMに預ける1つの資産の量を指定します。存在する場合、これはAMMのプールにある資産の一つトークンまたはXRPと一致する必要があります。 |
| `Amount2` | [通貨額][] | Amount | いいえ | AMMに追加する別の資産の量を指定します。存在する場合、これはAMMのプール内の他の資産と一致する必要があり、`Amount`と同じ資産にすることはできません。 |
| `EPrice` | [通貨額][] | Amount | いいえ | 受け取った各LPトークンに支払う、預け入れ資産の最大有効価格です。 |
| `LPTokenOut` | [通貨額][] | Amount | いいえ | AMMのLPトークンの購入数量。 |
### AMMDepositモード
このトランザクションには5つのモードがあり、どのフラグを指定するかで定義されます。それぞれのモードは、特定のフィールドの組み合わせを必要とし、次の2つのカテゴリーに分類されます。
- **ダブルアセット入金**: AMMのプールにある両方(2つ)の資産を、既存の資産の残高に比例して預けます。この預け入れは手数料の対象外です。
- **シングルアセット入金**, AMMの2つの資産のうち1つだけを預けます。AMMは、この預け入れによってプール内の資産残高がどれだけ変化したかによって、対価として支払われるLPトークンから差し引く手数料を設定します。
以下の項目の組み合わせは、**ダブルアセット入金**について示しています。
| フラグ名 | フラグ値 | 指定フィールド | 意味 |
|--------------|--------------|------------------------|---------|
| `tfLPToken` | `0x00010000` | `LPTokenOut`のみ | 指定された量のLPトークンを受け取るように計算された金額の、このAMMの両資産を預けます。預ける金額は、AMMの保有する2つの資産の割合と等しくなります。 |
| `tfTwoAsset` | `0x00100000` | `Amount``Amount2` | このAMMの両資産を指定された金額まで預けます。実際に預ける金額は、AMMがすでに保有している資産と同じ割合を維持する必要があるため、どちらか一方の預け入れ金額が指定金額より少なくてもかまいません。引き換えに得られるLPトークンの金額は、預けた金額の合計に基づきます。 |
以下の項目の組み合わせは、**シングルアセット入金**について示しています。
| フラグ名 | フラグ値 | 指定フィールド | 意味 |
|---------------------|--------------|------------------------|---------|
| `tfSingleAsset` | `0x00080000` | `Amount`のみ | 指定の資産を指定の量だけ預け、その結果得られたプールのシェアに応じた量のLPトークンを受け取ります。手数料を差し引いた金額 |
| `tfOneAssetLPToken` | `0x00200000` | `Amount``LPTokenOut` | 1つの資産を指定された上限額まで預け、対価として指定金額分のLPトークンを受け取ります。手数料を差し引いた金額 |
| `tfLimitLPToken` | `0x00400000` | `Amount``EPrice` | 1つの資産を指定された金額まで預けますが、LPトークン1つにつき指定された有効価格手数料差引後を超えて預けることはありません。 |
これ以外のフィールドとフラグの組み合わせは無効です。
### シングルアセット入金手数料
シングルアセット入金の手数料は、AMMを使って預け入れ金額の一部を他の資産と交換し、ダブルアセット入金を行った場合と同じになるように計算されます。AMMの取引手数料は、取引に必要な金額には適用されますが、残りの預け入れ金額には適用されません。 _例えば、AMMの資産プールがUSDとEURで完全に均等に分割されている場合、100USDを預けようとすると、受け取るLPトークンの量は、50EUR+50USDを預けた場合よりもわずかに少なくなります。_
ダブルアセット入金の場合、LPトークンを受け取る数は、以下の計算式で算出できます。
{{ include_svg("img/amm-single-asset-deposit-formula.svg", "L = T × ( (( 1 + (B - (F × (1 - W) × B)) ÷ P)^W) - 1)") }}
<!-- TODO: improve graphic -->
- `L`: 受け取るLPトークンの量
- `T`: 預け入れ前のLPトークンの残高合計
- `B`: 預け入れ資産の額
- `F`: 取引手数料
- `W`: プール内の預金資産の重みです。これはすべてのAMMプールで0.5と定義されています50/50の分割を意味しますので、Wによる累乗は平方根を取ることと同一です。
- `P`: 預け入れ前のプール内の預金資産の合計額
### AMMDepositフラグ
AMMDepositタイプのトランザクションは、以下のように[`Flags`フィールド](transaction-common-fields.html#flagsフィールド)の値を追加でサポートしています。
| フラグ名 | 16進数値 | 10進数値 | 説明 |
|:--------------------|:-------------|:--------------|:----------------------|
| `tfLPToken` | `0x00010000` | 65536 | ダブルアセット入金を行い、指定された額のLPトークンを受け取ります。 |
| `tfSingleAsset` | `0x00080000` | 524288 | 預け入れる資産を指定して、シングルアセット入金を行います。 |
| `tfTwoAsset` | `0x00100000` | 1048576 | 両資産を指定金額で預けるダブルアセット入金を行います。 |
| `tfOneAssetLPToken` | `0x00200000` | 2097152 | シングルアセット入金を行い、指定された額のLPトークンを受け取ります。 |
| `tfLimitLPToken` | `0x00400000` | 4194304 | 有効価格を指定して、シングルアセット入金を行います。 |
これらのフラグのうちの **1つのみ** と、任意の[グローバルフラグ](transaction-common-fields.html#グローバルフラグ)を指定する必要があります。
## エラーケース
すべてのトランザクションで発生する可能性のあるエラーに加えて、{{currentpage.name}}トランザクションでは、次の[トランザクション結果コード](transaction-results.html)が発生する可能性があります。
| エラーコード | 説明 |
|:------------------------|:---------------------------------------------|
| `temBAD_AMM_OPTIONS` | トランザクションで無効なフィールドの組み合わせが指定されました。詳細は、[AMMDepositモード](#ammdepositモード)を参照してください。 |
| `tecFROZEN` | トランザクションは[凍結](freezes.html)されているトークンを預けようとしました。 |
| `tecAMM_BALANCE` | AMMが預け入れを行うのに十分な量の資産を保有していないたとえば、シングルアセット入金に必要な残高を保有していない、または送信者が指定されたトークンを十分に保有していない場合など。 |
| `temBAD_AMM_TOKENS` | トランザクションでLPトークンが正しく指定されています。例えば、`issuer`がAMMのAccountRootアドレスでない、`currency`がこのAMMのLPトークンの通貨コードでない、またはトランザクションがAssetフィールドのいずれかにこのAMMのLPトークンを指定した、など。 |
| `tecAMM_FAILED_DEPOSIT` | 預け入れの条件が成立しませんでした。例えば、`EPrice`フィールドに指定された実効価格が低すぎる場合など。 |
| `tecAMM_INVALID_TOKENS` | このトークンペアのAMMが存在しないか、計算の結果、預け入れ金額がゼロに丸められました。 |
| `tecINSUF_RESERVE_LINE` | このトランザクションの送信者は、この処理による[準備金要件](reserves.html)の増加の対象であり、LPトークンを保持するための新しいトラストラインが必要で、そのための追加の所有者準備金分のXRPを保有していないためと思われます。 |
| `tecNO_AUTH` | 送信者は、預け入れ資産のいずれかを保有する権限を持っ ていません。 |
| `tecNO_LINE` | 送信者が預け入れ資産のうち1つに対し、トラストラインを保有していません。 |
| `tecUNFUNDED_AMM` | 送信者の残高が、指定された預け入れを行うのに十分な量ではありません。 |
| `terNO_ACCOUNT` | リクエストで参照されたいずれかのアカウントが存在しません。 |
| `terNO_AMM` | このトランザクションの資産ペアの自動マーケットメーカーインスタンスが存在しません。 |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,136 @@
---
html: ammdeposit.html
parent: transaction-types.html
blurb: Deposit funds into an Automated Market Maker in exchange for LPTokens.
labels:
- AMM
status: not_enabled
---
# AMMDeposit
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMDeposit.cpp "Source")
_(Requires the [AMM amendment][] :not_enabled:)_
Deposit funds into an [Automated Market Maker](automated-market-makers.html) (AMM) instance and receive the AMM's liquidity provider tokens (_LP Tokens_) in exchange. You can deposit one or both of the assets in the AMM's pool.
If successful, this transaction creates a [trust line](trust-lines-and-issuing.html) to the AMM Account (limit 0) to hold the LP Tokens.
## Example {{currentpage.name}} JSON
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Amount" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value" : "2.5"
},
"Amount2" : "30000000",
"Asset" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"Asset2" : {
"currency" : "XRP"
},
"Fee" : "10",
"Flags" : 1048576,
"Sequence" : 7,
"TransactionType" : "AMMDeposit"
}
```
{% include '_snippets/tx-fields-intro.md' %}
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:--------------|:--------------------|:------------------|:----------|:------------|
| `Asset` | Object | STIssue | Yes | The definition for one of the assets in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `Asset2` | Object | STIssue | Yes | The definition for the other asset in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `Amount` | [Currency Amount][] | Amount | No | The amount of one asset to deposit to the AMM. If present, this must match the type of one of the assets (tokens or XRP) in the AMM's pool. |
| `Amount2` | [Currency Amount][] | Amount | No | The amount of another asset to add to the AMM. If present, this must match the type of the other asset in the AMM's pool and cannot be the same asset as `Amount`. |
| `EPrice` | [Currency Amount][] | Amount | No | The maximum effective price, in the deposit asset, to pay for each LP Token received. |
| `LPTokenOut` | [Currency Amount][] | Amount | No | How many of the AMM's LP Tokens to buy. |
### AMMDeposit Modes
This transaction has five modes, defined by which flag you specify. Each mode expects a specific combination of fields. The modes fall into two categories:
- **Double-asset deposits**, in which you provide both assets in the AMM's pool, proportional to the balance of the assets already there. These deposits are not subject to a fee.
- **Single-asset deposits**, in which you provide only one of the AMM's two assets. The AMM charges a fee, debited from the LP Tokens paid out, based on how much your deposit shifts the balance of assets in the pool.
The following combinations of fields indicate a **double-asset deposit**:
| Flag Name | Flag Value | Fields Specified | Meaning |
|--------------|--------------|------------------------|---------|
| `tfLPToken` | `0x00010000` | `LPTokenOut` only | Deposit both of this AMM's assets, in amounts calculated so that you receive the specified amount of LP Tokens in return. The amounts deposited maintain the relative proportions of the two assets the AMM already holds. |
| `tfTwoAsset` | `0x00100000` | `Amount` and `Amount2` | Deposit both of this AMM's assets, up to the specified amounts. The actual amounts deposited must maintain the same balance of assets as the AMM already holds, so the amount of either one deposited MAY be less than specified. The amount of LP Tokens you get in return is based on the total value deposited. |
The following combinations of fields indicate a **single asset deposit**:
| Flag Name | Flag Value | Fields Specified | Meaning |
|---------------------|--------------|----------------------------|---------|
| `tfSingleAsset` | `0x00080000` | `Amount` only | Deposit exactly the specified amount of one asset, and receive an amount of LP Tokens based on the resulting share of the pool (minus fees). |
| `tfOneAssetLPToken` | `0x00200000` | `Amount` and `LPTokenOut` | Deposit up to the specified amount of one asset, so that you receive exactly the specified amount of LP Tokens in return (after fees). |
| `tfLimitLPToken` | `0x00400000` | `Amount` and `EPrice` | Deposit up to the specified amount of one asset, but pay no more than the specified effective price per LP Token (after fees). |
Any other combination of these fields and flags is invalid.
### Single Asset Deposit Fee
The fee for a single asset deposit is calculated to be the same as if you had used the AMM to trade part of the deposit amount for the other asset, then done a double-asset deposit. The AMM's trading fee applies to the amount you would need to trade for, but not to the rest of the deposit. _For example, if the AMM's asset pool is split perfectly evenly between USD and EUR, and you try to deposit 100 USD, the amount of LP Tokens you receive is slightly less than if you had deposited 50 EUR + 50 USD, because you pay the trading fee to convert some of your USD to an equal amount of EUR._
The formula for how many LP Tokens you receive for a double-asset deposit is:
{{ include_svg("img/amm-single-asset-deposit-formula.svg", "L = T × ( (( 1 + (B - (F × (1 - W) × B)) ÷ P)^W) - 1)") }}
<!-- TODO: improve graphic -->
Where:
- `L` is the amount of LP Tokens returned
- `T` is the total outstanding LP Tokens before the deposit
- `B` is the amount of the asset being deposited
- `F` is the trading fee, as a decimal
- `W` is the weight of the deposit asset in the pool. This is defined as 0.5 for all AMM pools (meaning a 50/50 split), so exponentiation by W is equivalent to taking the square root.
- `P` is the total amount of the deposit asset in the pool before the deposit
### AMMDeposit Flags
Transactions of the AMMDeposit type support additional values in the [`Flags` field](transaction-common-fields.html#flags-field), as follows:
| Flag Name | Hex Value | Decimal Value | Description |
|:--------------------|:-------------|:--------------|:----------------------|
| `tfLPToken` | `0x00010000` | 65536 | Perform a double-asset deposit and receive the specified amount of LP Tokens. |
| `tfSingleAsset` | `0x00080000` | 524288 | Perform a single-asset deposit with a specified amount of the asset to deposit. |
| `tfTwoAsset` | `0x00100000` | 1048576 | Perform a double-asset deposit with specified amounts of both assets. |
| `tfOneAssetLPToken` | `0x00200000` | 2097152 | Perform a single-asset deposit and receive the specified amount of LP Tokens. |
| `tfLimitLPToken` | `0x00400000` | 4194304 | Perform a single-asset deposit with a specified effective price. |
You must specify **exactly one** of these flags, plus any [global flags](transaction-common-fields.html#global-flags).
## Error Cases
Besides errors that can occur for all transactions, {{currentpage.name}} transactions can result in the following [transaction result codes](transaction-results.html):
| Error Code | Description |
|:------------------------|:---------------------------------------------|
| `temBAD_AMM_OPTIONS` | The transaction specified an invalid combination of fields. See [AMMDeposit Modes](#ammdeposit-modes). |
| `tecFROZEN` | The transaction tried to deposit a [frozen](freezes.html) token. |
| `tecAMM_BALANCE` | The AMM does not have enough of one of the assets to accept the deposit (for example, to satisfy the trade part of a single-asset deposit) or the sender does not have enough of a given token. |
| `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. |
| `tecAMM_FAILED_DEPOSIT` | The conditions on the deposit could not be satisfied; for example, the requested effective price in the `EPrice` field is too low. |
| `tecAMM_INVALID_TOKENS` | The AMM for this token pair does not exist, or one of the calculations resulted in a deposit amount rounding to zero. |
| `tecINSUF_RESERVE_LINE` | The sender of this transaction does meet the increased [reserve requirement](reserves.html) 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. |
| `tecNO_AUTH` | The sender is not authorized to hold one of the deposit assets. |
| `tecNO_LINE` | The sender does not have a trust line for one of the deposit assets. |
| `tecUNFUNDED_AMM` | The sender does not have a high enough balance to make the specified deposit. |
| `terNO_ACCOUNT` | An account specified in the request does not exist. |
| `terNO_AMM` | The Automated Market Maker instance for the asset pair in this transaction does not exist. |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,60 @@
---
html: ammvote.html
parent: transaction-types.html
blurb: 自動マーケットメーカーインスタンスの取引手数料を投票する。
labels:
- AMM
status: not_enabled
---
# AMMVote
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMVote.cpp "Source")
_([AMM amendment][] :not_enabled:が必要。)_
[自動マーケットメーカー](automated-market-makers.html)インスタンスの取引手数料を投票します。最大8つのアカウントが、保有するAMMのLPトークンの量に比例して投票することができます。各新規投票では、投票の加重平均に基づいてAMMの取引手数料が再計算されます。
## {{currentpage.name}} JSONの例
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Asset" : {
"currency" : "XRP"
},
"Asset2" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 8,
"TradingFee" : 600,
"TransactionType" : "AMMVote"
}
```
{% include '_snippets/tx-fields-intro.ja.md' %}
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:-------------|:----------|:-----------|:-----|:------------|
| `Asset` | Object | STIssue | はい | AMMのプールにある資産の一つを定義します。JSONでは、`currency``issuer` フィールドを持つオブジェクトになりますXRPの場合は`issuer`を省略します)。 |
| `Asset2` | Object | STIssue | はい | AMMのプールにあるもう一つの資産を定義します。JSONでは、`currency``issuer` フィールドを持つオブジェクトになりますXRPの場合は`issuer`を省略します)。|
| `TradingFee` | Number | UInt16 | はい | 投票に必要な手数料を100000の1の単位で指定します。最大値は1000で、1の手数料を表します。 |
## エラーケース
すべてのトランザクションで発生する可能性のあるエラーに加えて、{{currentpage.name}}トランザクションでは、次の[トランザクション結果コード](transaction-results.html)が発生する可能性があります。
| エラーコード | 説明 |
|:------------------------|:---------------------------------------------|
| `tecAMM_INVALID_TOKENS` | 送信者は、このAMMのLPトークンを保有していないため、投票することができません。 |
| `tecAMM_FAILED_VOTE` | このトランザクションの送信者よりも多くのLPトークンを保有しているアカウントからの投票が既に8件存在しています。 |
| `terNO_ACCOUNT` | このトランザクションで指定されたアカウントが存在しません。 |
| `temBAD_FEE` | このトランザクションの`TradingFee`は正しくありません。 |
| `terNO_AMM` | このトランザクションの資産ペアの自動マーケットメーカー インスタンスが存在しません。 |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,60 @@
---
html: ammvote.html
parent: transaction-types.html
blurb: Vote on the trading fee for an Automated Market Maker instance.
labels:
- AMM
status: not_enabled
---
# AMMVote
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMVote.cpp "Source")
_(Requires the [AMM amendment][] :not_enabled:)_
Vote on the trading fee for an [Automated Market Maker](automated-market-makers.html) 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.
## Example {{currentpage.name}} JSON
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Asset" : {
"currency" : "XRP"
},
"Asset2" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 8,
"TradingFee" : 600,
"TransactionType" : "AMMVote"
}
```
{% include '_snippets/tx-fields-intro.md' %}
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:-------------|:----------|:------------------|:----------|:------------|
| `Asset` | Object | STIssue | Yes | The definition for one of the assets in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `Asset2` | Object | STIssue | Yes | The definition for the other asset in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `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, {{currentpage.name}} transactions can result in the following [transaction result codes](transaction-results.html):
| Error Code | Description |
|:------------------------|:---------------------------------------------|
| `tecAMM_INVALID_TOKENS` | The sender cannot vote because they do not hold any of this AMM's LP Tokens. |
| `tecAMM_FAILED_VOTE` | There are already 8 votes from accounts that hold more LP Tokens than the sender of this transaction. |
| `terNO_ACCOUNT` | An account specified in this transaction does not exist. |
| `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. |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,124 @@
---
html: ammwithdraw.html
parent: transaction-types.html
blurb: LPTokenを自動マーケットメーカーに返却し、プールが保有する資産の一部と引き換える。
labels:
- AMM
status: not_enabled
---
# AMMWithdraw
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMWithdraw.cpp "Source")
_([AMM amendment][] :not_enabled:が必要。)_
AMMの流動性プロバイダトークンLPトークンを返すことで、[自動マーケットメーカー](automated-market-makers.html)(AMM)インスタンスから資産を引き出します。
## {{currentpage.name}} JSONの例
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Amount" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value" : "5"
},
"Amount2" : "50000000",
"Asset" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"Asset2" : {
"currency" : "XRP"
},
"Fee" : "10",
"Flags" : 1048576,
"Sequence" : 10,
"TransactionType" : "AMMWithdraw"
}
```
{% include '_snippets/tx-fields-intro.md' %}
| フィールド | JSONの型 | [内部の型][] | 必須? | 説明 |
|:-------------|:-----------|:-----------|:------|:------------|
| `Asset` | オブジェクト | STIssue | はい | AMMのプールにある資産の一つを定義します。JSONでは、`currency``issuer`フィールドを持つオブジェクトになりますXRPの場合は`issuer`を省略します)。 |
| `Asset2` | オブジェクト | STIssue | はい | AMMのプールにあるもう一つの資産を定義します。JSONでは、`currency``issuer`フィールドを持つオブジェクトです(XRPの場合は`issuer`を省略)。|
| `Amount` | [通貨額][] | Amount | いいえ | AMMから引き出す1つの資産の量。これは、AMMのプールにある資産の1つトークンまたはXRPと一致する必要があります。 |
| `Amount2` | [通貨額][] | Amount | いいえ | AMMから引き出す他の資産の量。存在する場合、これはAMMのプール内の他の資産と一致する必要があり、`Amount`と同じにすることはできません。 |
| `EPrice` | [通貨額][] | Amount | いいえ | 引き出しに必要な、資産の1単位あたりに支払う最低有効価格LPトークンの返却単位。 |
| `LPTokenIn` | [通貨額][] | Amount | いいえ | AMMのLPトークンの引き替え数。 |
**注記:** ダブルアセット出金の場合、`Asset1``Amount1`または`Amount2`が対応していれば、`Asset2`はもう一方に対応することが可能です。しかし、両者を一致させることをお勧めします(つまり、`Amount2``Asset2`で定義されたアセットの金額です)。その方が混乱を招きにくくなります。
### AMMWithdrawモード
このトランザクションには、指定するフラグによって、いくつかのモードがあります。それぞれのモードは、特定のフィールドの組み合わせを必要とし、以下の2つのカテゴリーに分類されます。
- **ダブルアセット出金**: AMMのプールから両方の資産を、その残高と同じ割合で受け取ります。これらの引き出しには手数料はかかりません。
- **シングルアセット出金**: AMMのプールから1つの資産を受け取ります。AMMは、あなたの引き出しによってプール内の資産残高がどれだけ変動するかによって手数料を設定します。引き出しのモードによって、手数料の額は、支払われたLPトークンの量から差し引かれるか、引き出される資産の量から差し引かれるか決まります。
以下の項目の組み合わせは、**ダブルアセット出金**について示しています。
| フラグ名 | フラグ値 | 指定フィール | 意味 |
|-----------------|--------------|---------------- ----|---------|
| `tfLPToken` | `0x00010000` | `LPTokenIn`のみ | 指定された量のLPトークンを返還し、AMMのプールから、LPトークンの発行総数に対する返還されたトークンの割合に基づく金額の両資産を受 け取ります。 |
| `tfWithdrawAll` | `0x00020000` | なし | LPトークンを _全て_ 返還し、AMMのプールにある両資産を最大限受け取ります。 |
| `tfTwoAsset` | `0x00100000` | `Amount``Amount2` | AMMの資産を、指定した金額を上限として、両方とも引き出します。実際に受け取る金額は、AMMのプールの資産残高の割合と同じになります。 |
以下の項目の組み合わせは、**シングルアセット出金**について示しています。
| フラグ名 | フラグ値 | 指定フィールド | 意味 |
|-------------------------|--------------|-----------------------|---------|
| `tfSingleAsset` | `0x00080000` | `Amount`のみ | LPトークンを必要な数だけ返還し、1つの資産を指定した量だけ出金する。 |
| `tfOneAssetWithdrawAll` | `0x00040000` | `Amount`のみ | LPトークンを全て返還することで、1つの資産を指定した金額以上引き出します。指定された金額以上を受け取ることができない場合は失敗します。指定する金額は0でもかまいません。この場合、少しでも正の金額を引き出せば成功します。 |
| `tfOneAssetLPToken` | `0x00200000` | `Amount``LPTokenIn` | 指定した量のLPトークンを返還することで、1つの資産を指定した量まで引き出します。 |
| `tfLimitLPToken` | `0x00400000` | `Amount``EPrice` | 指定した1つの資産の量を上限として出金しますが、受け取る資産の一単位あたりのLPトークンで指定した有効価格より高い金額を支払うことはありません。 |
これら以外のフィールドとフラグの組み合わせは無効です。
### シングルアセット出金手数料
シングルアセット出金にかかる手数料は、ダブルアセット出金を行い、AMMを使用してもう一方の資産を全て引き出しにかかる資産と交換した場合と同じになるように計算されます。取引手数料は、取引に必要な金額に適用されますが、残りの引き出し分には適用されません。
<!-- TODO: add a formula and example calculation(s) of single-asset withdrawal fees -->
### AMMWithdrawフラグ
AMMWithdrawタイプのトランザクションは、以下のように[`Flags`フィールド](transaction-common-fields.html#flagsフィールド)の値を追加でサポートしています。
| フラグ名 | 16進数値 | 10進数値 | 説明 |
|:------------------------|:-------------|:--------------|:----------------------|
| `tfLPToken` | `0x00010000` | 65536 | 指定された額のLPトークンを返還する、ダブルアセット出金を行います。 |
| `tfWithdrawAll` | `0x00020000` | 131072 | LPトークンをすべて返還する、ダブルアセット出金を行います。 |
| `tfOneAssetWithdrawAll` | `0x00040000` | 262144 | 全てのLPトークンを返還する、シングルアセット出金を行います。 |
| `tfSingleAsset` | `0x00080000` | 524288 | 引き出す資産を指定して、シングルアセット出金を行います。|
| `tfTwoAsset` | `0x00100000` | 1048576 | 両資産の金額を指定して、ダブルアセット出金を行います。 |
| `tfOneAssetLPToken` | `0x00200000` | 2097152 | シングルアセット出金を行い、指定された額のLPトークンを受け取ります。 |
| `tfLimitLPToken` | `0x00400000` | 4194304 | 有効価格を指定して、シングルアセット出金を行います。 |
これらのフラグのうちの **1つのみ** と、任意の[グローバルフラグ](transaction-common-fields.html#グローバルフラグ)を指定する必要があります。
## エラーケース
すべてのトランザクションで発生する可能性のあるエラーに加えて、{{currentpage.name}}トランザクションでは、次の[トランザクション結果コード](transaction-results.html)が発生する可能性があります。
| エラーコード | 説明 |
|:-------------------------|:---------------------------------------------|
| `tecFROZEN` | トランザクションは[凍結](freezes.html)されたトークンを引き出そうとしました。 |
| `tecAMM_BALANCE` | トランザクションによって、プールから1つの資産をすべて引き出そうとしている、もしくは`tfWithdrawAll`の場合に端数処理によって0以外の金額が残ってしまっています。 |
| `tecAMM_FAILED_WITHDRAW` | 例えば、`EPrice`フィールドに指定された有効価格が低過ぎる場合など、引き出しに関する条件が成立しませんでした。 |
| `tecAMM_INVALID_TOKENS` | トークンペアのAMMが存在しないか、計算の結果、引き出し額がゼロに丸められました。 |
| `tecINSUF_RESERVE_LINE` | トランザクションの送信者は、このトランザクションを処理するための[準備金要件](reserves.html)の増加に対応できません。おそらく、引き出される資産の1つを保持するために少なくとも1つの新しいトラストラインが必要ですが、新しいトラストラインのための追加の所有者準備金分のXRPを持っていないためでしょう。 |
| `tecNO_AUTH` | 送信者は、引き出し資産のいずれかを保有する権限を有していません。 |
| `temBAD_AMM_OPTIONS` | トランザクションで無効なフィールドの組み合わせが指定されました。[AMMWithdrawモード](#ammwithdrawモード)を参照してください。 |
| `temBAD_AMM_TOKENS` | 例えば、`issuer`がAMMの関連するAccountRootアドレスでない、`currency`がこのAMMのLPトークンの通貨コードでない、またはトランザクションがこのAMMのLPトークンをAssetフィールドの1つに指定した、などです。 |
| `terNO_AMM` | トランザクションで指定した資産ペアの自動マーケットメーカーインスタンスが存在しません。 |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}

View File

@@ -0,0 +1,124 @@
---
html: ammwithdraw.html
parent: transaction-types.html
blurb: Return LPTokens into an Automated Market Maker in exchange for a share of the assets the pool holds.
labels:
- AMM
status: not_enabled
---
# AMMWithdraw
[[Source]](https://github.com/XRPLF/rippled/blob/master/src/ripple/app/tx/impl/AMMWithdraw.cpp "Source")
_(Requires the [AMM amendment][] :not_enabled:)_
Withdraw assets from an [Automated Market Maker](automated-market-makers.html) (AMM) instance by returning the AMM's liquidity provider tokens (LP Tokens).
## Example {{currentpage.name}} JSON
```json
{
"Account" : "rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm",
"Amount" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
"value" : "5"
},
"Amount2" : "50000000",
"Asset" : {
"currency" : "TST",
"issuer" : "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd"
},
"Asset2" : {
"currency" : "XRP"
},
"Fee" : "10",
"Flags" : 1048576,
"Sequence" : 10,
"TransactionType" : "AMMWithdraw"
}
```
{% include '_snippets/tx-fields-intro.md' %}
| Field | JSON Type | [Internal Type][] | Required? | Description |
|:-------------|:--------------------|:------------------|:----------|:------------|
| `Asset` | Object | STIssue | Yes | The definition for one of the assets in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `Asset2` | Object | STIssue | Yes | The definition for the other asset in the AMM's pool. In JSON, this is an object with `currency` and `issuer` fields (omit `issuer` for XRP). |
| `Amount` | [Currency Amount][] | Amount | No | The amount of one asset to withdraw from the AMM. This must match the type of one of the assets (tokens or XRP) in the AMM's pool. |
| `Amount2` | [Currency Amount][] | Amount | No | The amount of another asset to withdraw from the AMM. If present, this must match the type of the other asset in the AMM's pool and cannot be the same type as `Amount`. |
| `EPrice` | [Currency Amount][] | Amount | No | The minimum effective price, in LP Token returned, to pay per unit of the asset to withdraw. |
| `LPTokenIn` | [Currency Amount][] | Amount | No | How many of the AMM's LP Tokens to redeem. |
**Note:** For a double-asset withdrawal, it is possible for `Asset` to correspond to _either_ `Amount` or `Amount2` as long as `Asset2` corresponds to the other one. It is recommended to match them (that is, `Amount2` is an amount of the asset defined in `Asset2`) because it is less confusing that way.
### AMMWithdraw Modes
This transaction has several modes, depending on which flags you specify. Each mode expects a specific combination of fields. The modes fall into two categories:
- **Double-asset withdrawals**, in which you receive both assets from the AMM's pool in proportions that match their balances there. These withdrawals are not subject to a fee.
- **Single-asset withdrawals**, in which you receive one asset from the AMM's pool. The AMM charges a fee based on how much your deposit shifts the balance of assets in the pool. Depending on the withdraw mode, the amount of the fee can be added to the amount of LP Tokens paid in, or debited from the amount of the asset paid out.
The following combinations of fields indicate a **double-asset withdrawal**:
| Flag Name(s) | Flag Value | Fields Specified | Meaning |
|-----------------|--------------|------------------------|---------|
| `tfLPToken` | `0x00010000` | `LPTokenIn` only | Return the specified amount of LP Tokens and receive both assets from the AMM's pool in amounts based on the returned LP Tokens' share of the total LP Tokens issued. |
| `tfWithdrawAll` | `0x00020000` | No Fields | Return _all_ of your LP Tokens and receive as much as you can of both assets in the AMM's pool. |
| `tfTwoAsset` | `0x00100000` | `Amount` and `Amount2` | Withdraw both of this AMM's assets, in up to the specified amounts. The actual amounts received maintains the balance of assets in the AMM's pool. |
The following combinations of fields indicate a **single asset withdrawal**:
| Flag Name(s) | Flag Value | Fields Specified | Meaning |
|-------------------------|--------------|--------------------------|---------|
| `tfSingleAsset` | `0x00080000` | `Amount` only | Withdraw exactly the specified amount of one asset, by returning as many LP Tokens as necessary. |
| `tfOneAssetWithdrawAll` | `0x00040000` | `Amount` only | Withdraw at least the specified amount of one asset, by returning _all_ of your LP Tokens. Fails if you can't receive at least the specified amount. The specified amount can be 0, meaning the transaction succeeds if it withdraws any positive amount. |
| `tfOneAssetLPToken` | `0x00200000` | `Amount` and `LPTokenIn` | Withdraw up to the specified amount of one asset, by returning up to the specified amount of LP Tokens. |
| `tfLimitLPToken` | `0x00400000` | `Amount` and `EPrice` | Withdraw up to the specified amount of one asset, but pay no more than the specified effective price in LP Tokens per unit of the asset received. |
Any other combination of these fields is invalid.
### Single Asset Withdrawal Fee
The fee for a single asset withdrawal is calculated to be the same as if you had done a double-asset withdrawal and then used the AMM to trade all of the other asset for the one you are withdrawing. The trading fee applies to the amount you would need to trade for, but not to the rest of the withdrawal.
<!-- TODO: add a formula and example calculation(s) of single-asset withdrawal fees -->
### AMMWithdraw Flags
Transactions of the AMMWithdraw type support additional values in the [`Flags` field](transaction-common-fields.html#flags-field), as follows:
| Flag Name | Hex Value | Decimal Value | Description |
|:------------------------|:-------------|:--------------|:----------------------|
| `tfLPToken` | `0x00010000` | 65536 | Perform a double-asset withdrawal and receive the specified amount of LP Tokens. |
| `tfWithdrawAll` | `0x00020000` | 131072 | Perform a double-asset withdrawal returning all your LP Tokens. |
| `tfOneAssetWithdrawAll` | `0x00040000` | 262144 | Perform a single-asset withdrawal returning all of your LP Tokens. |
| `tfSingleAsset` | `0x00080000` | 524288 | Perform a single-asset withdrawal with a specified amount of the asset to withdrawal. |
| `tfTwoAsset` | `0x00100000` | 1048576 | Perform a double-asset withdrawal with specified amounts of both assets. |
| `tfOneAssetLPToken` | `0x00200000` | 2097152 | Perform a single-asset withdrawal and receive the specified amount of LP Tokens. |
| `tfLimitLPToken` | `0x00400000` | 4194304 | Perform a single-asset withdrawal with a specified effective price. |
You must specify **exactly one** of these flags, plus any [global flags](transaction-common-fields.html#global-flags).
## Error Cases
Besides errors that can occur for all transactions, {{currentpage.name}} transactions can result in the following [transaction result codes](transaction-results.html):
| Error Code | Description |
|:-------------------------|:---------------------------------------------|
| `tecFROZEN` | The transaction tried to deposit a [frozen](freezes.html) token. |
| `tecAMM_BALANCE` | The transaction would withdraw all of one asset from the pool, or rounding would cause a "withdraw all" to leave a nonzero amount behind. |
| `tecAMM_FAILED_WITHDRAW` | The conditions on the withdrawal could not be satisfied; for example, the requested effective price in the `EPrice` field is too low. |
| `tecAMM_INVALID_TOKENS` | The AMM for this token pair does not exist, or one of the calculations resulted in a withdrawal amount rounding to zero. |
| `tecINSUF_RESERVE_LINE` | The sender of this transaction does not meet the increased [reserve requirement](reserves.html) of processing this transaction, probably because they need at least one new trust line to hold one of the assets to be withdrawn, and they don't have enough XRP to meet the additional owner reserve for a new trust line. |
| `tecNO_AUTH` | The sender is not authorized to hold one of the deposit assets. |
| `temBAD_AMM_OPTIONS` | The transaction specified an invalid combination of fields. See [AMMWithdraw Modes](#ammwithdraw-modes). |
| `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. |
| `terNO_AMM` | The Automated Market Maker instance for the asset pair in this transaction does not exist. |
<!--{# common link defs #}-->
{% include '_snippets/rippled-api-links.md' %}
{% include '_snippets/tx-type-links.md' %}
{% include '_snippets/rippled_versions.md' %}