| 
    rippled
    
   | 
 
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, Issue const &in, Issue 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 | 
| Issue const & | issueIn () const | 
| Issue const & | issueOut () 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, Rules const &rules) const | 
| Generate max offer.   | |
Private Attributes | |
| AMMContext & | ammContext_ | 
| AccountID const | ammAccountID_ | 
| std::uint32_t const | tradingFee_ | 
| Issue const | issueIn_ | 
| Issue const | issueOut_ | 
| TAmounts< TIn, TOut > const | initialBalances_ | 
| beast::Journal const | j_ | 
Static Private Attributes | |
| static Number const | InitialFibSeqPct = 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 52 of file AMMLiquidity.h.
| ripple::AMMLiquidity< TIn, TOut >::AMMLiquidity | ( | ReadView const & | view, | 
| AccountID const & | ammAccountID, | ||
| std::uint32_t | tradingFee, | ||
| Issue const & | in, | ||
| Issue const & | out, | ||
| AMMContext & | ammContext, | ||
| beast::Journal | j | ||
| ) | 
Definition at line 26 of file AMMLiquidity.cpp.
      
  | 
  default | 
      
  | 
  delete | 
      
  | 
  delete | 
| std::optional< AMMOffer< TIn, TOut > > ripple::AMMLiquidity< TIn, TOut >::getOffer | ( | ReadView const & | view, | 
| std::optional< Quality > const & | clobQuality | ||
| ) | const | 
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 150 of file AMMLiquidity.cpp.
| AccountID const & ripple::AMMLiquidity< TIn, TOut >::ammAccount | ( | ) | const | 
Definition at line 89 of file AMMLiquidity.h.
| bool ripple::AMMLiquidity< TIn, TOut >::multiPath | ( | ) | const | 
Definition at line 95 of file AMMLiquidity.h.
| std::uint32_t ripple::AMMLiquidity< TIn, TOut >::tradingFee | ( | ) | const | 
Definition at line 101 of file AMMLiquidity.h.
| AMMContext & ripple::AMMLiquidity< TIn, TOut >::context | ( | ) | const | 
Definition at line 107 of file AMMLiquidity.h.
| Issue const & ripple::AMMLiquidity< TIn, TOut >::issueIn | ( | ) | const | 
Definition at line 113 of file AMMLiquidity.h.
| Issue const & ripple::AMMLiquidity< TIn, TOut >::issueOut | ( | ) | const | 
Definition at line 119 of file AMMLiquidity.h.
      
  | 
  private | 
Fetches current AMM balances.
Definition at line 46 of file AMMLiquidity.cpp.
      
  | 
  private | 
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 59 of file AMMLiquidity.cpp.
      
  | 
  private | 
Generate max offer.
If fixAMMOverflowOffer is active, the offer is generated as: takerGets = 99% * balances.out takerPays = swapOut(takerGets). Return nullopt if takerGets is 0 or takerGets == balances.out.
If fixAMMOverflowOffer is not active, the offer is generated as: takerPays = max input amount; takerGets = swapIn(takerPays). 
Definition at line 122 of file AMMLiquidity.cpp.
      
  | 
  staticprivate | 
Definition at line 55 of file AMMLiquidity.h.
      
  | 
  private | 
Definition at line 56 of file AMMLiquidity.h.
      
  | 
  private | 
Definition at line 57 of file AMMLiquidity.h.
      
  | 
  private | 
Definition at line 58 of file AMMLiquidity.h.
      
  | 
  private | 
Definition at line 59 of file AMMLiquidity.h.
      
  | 
  private | 
Definition at line 60 of file AMMLiquidity.h.
      
  | 
  private | 
Definition at line 62 of file AMMLiquidity.h.
      
  | 
  private | 
Definition at line 63 of file AMMLiquidity.h.