|
xrpld
|
AMMLiquidity class provides AMM offers to BookStep class. More...
#include <AMMLiquidity.h>

Public Member Functions | |
| AMMLiquidity (ReadView const &view, AccountID const &ammAccountID, std::uint32_t tradingFee, Asset const &in, Asset const &out, AMMContext &ammContext, beast::Journal j) | |
| ~AMMLiquidity ()=default | |
| AMMLiquidity (AMMLiquidity const &)=delete | |
| AMMLiquidity & | operator= (AMMLiquidity const &)=delete |
| std::optional< AMMOffer< TIn, TOut > > | getOffer (ReadView const &view, std::optional< Quality > const &clobQuality) const |
| Generate AMM offer. | |
| AccountID const & | ammAccount () const |
| bool | multiPath () const |
| std::uint32_t | tradingFee () const |
| AMMContext & | context () const |
| Asset const & | assetIn () const |
| Asset const & | assetOut () const |
Private Member Functions | |
| TAmounts< TIn, TOut > | fetchBalances (ReadView const &view) const |
| Fetches current AMM balances. | |
| TAmounts< TIn, TOut > | generateFibSeqOffer (TAmounts< TIn, TOut > const &balances) const |
| Generate AMM offers with the offer size based on Fibonacci sequence. | |
| std::optional< AMMOffer< TIn, TOut > > | maxOffer (TAmounts< TIn, TOut > const &balances) const |
| Generate max offer. | |
Private Attributes | |
| AMMContext & | ammContext_ |
| AccountID const | ammAccountID_ |
| std::uint32_t const | tradingFee_ |
| Asset const | assetIn_ |
| Asset const | assetOut_ |
| TAmounts< TIn, TOut > const | initialBalances_ |
| beast::Journal const | j_ |
Static Private Attributes | |
| static Number const | kInitialFibSeqPct = Number(5) / 20000 |
AMMLiquidity class provides AMM offers to BookStep class.
The offers are generated in two ways. If there are multiple paths specified to the payment transaction then the offers are generated based on the Fibonacci sequence with a limited number of payment engine iterations consuming AMM offers. These offers behave the same way as CLOB offers in that if there is a limiting step, then the offers are adjusted based on their quality. If there is only one path specified in the payment transaction then the offers are generated based on the competing CLOB offer quality. In this case the offer's size is set in such a way that the new AMM's pool spot price quality is equal to the CLOB's offer quality.
Definition at line 35 of file AMMLiquidity.h.
| xrpl::AMMLiquidity< TIn, TOut >::AMMLiquidity | ( | ReadView const & | view, |
| AccountID const & | ammAccountID, | ||
| std::uint32_t | tradingFee, | ||
| Asset const & | in, | ||
| Asset const & | out, | ||
| AMMContext & | ammContext, | ||
| beast::Journal | j ) |
Definition at line 32 of file AMMLiquidity.cpp.
|
default |
|
delete |
|
delete |
|
nodiscard |
Generate AMM offer.
Returns nullopt if clobQuality is provided and it is better than AMM offer quality. Otherwise returns AMM offer. If clobQuality is provided then AMM offer size is set based on the quality.
Definition at line 147 of file AMMLiquidity.cpp.
|
nodiscard |
Definition at line 72 of file AMMLiquidity.h.
|
nodiscard |
Definition at line 78 of file AMMLiquidity.h.
|
nodiscard |
Definition at line 84 of file AMMLiquidity.h.
|
nodiscard |
Definition at line 90 of file AMMLiquidity.h.
|
nodiscard |
Definition at line 96 of file AMMLiquidity.h.
|
nodiscard |
Definition at line 102 of file AMMLiquidity.h.
|
nodiscardprivate |
Fetches current AMM balances.
Definition at line 52 of file AMMLiquidity.cpp.
|
nodiscardprivate |
Generate AMM offers with the offer size based on Fibonacci sequence.
The sequence corresponds to the payment engine iterations with AMM liquidity. Iterations that don't consume AMM offers don't count. The number of iterations with AMM offers is limited. If the generated offer exceeds the pool balance then the function throws overflow exception.
Definition at line 65 of file AMMLiquidity.cpp.
|
nodiscardprivate |
Generate max offer.
The offer is generated as: takerGets = 99% * balances.out takerPays = swapOut(takerGets). Return nullopt if takerGets is 0 or takerGets == balances.out.
Definition at line 136 of file AMMLiquidity.cpp.
|
staticprivate |
Definition at line 38 of file AMMLiquidity.h.
|
private |
Definition at line 39 of file AMMLiquidity.h.
|
private |
Definition at line 40 of file AMMLiquidity.h.
|
private |
Definition at line 41 of file AMMLiquidity.h.
|
private |
Definition at line 42 of file AMMLiquidity.h.
|
private |
Definition at line 43 of file AMMLiquidity.h.
|
private |
Definition at line 45 of file AMMLiquidity.h.
|
private |
Definition at line 46 of file AMMLiquidity.h.