xrpld
Loading...
Searching...
No Matches
xrpl::AMMOffer< TIn, TOut > Class Template Reference

Represents synthetic AMM offer in BookStep. More...

#include <AMMOffer.h>

Collaboration diagram for xrpl::AMMOffer< TIn, TOut >:

Public Member Functions

 AMMOffer (AMMLiquidity< TIn, TOut > const &ammLiquidity, TAmounts< TIn, TOut > const &amounts, TAmounts< TIn, TOut > const &balances, Quality const &quality)
Quality quality () const noexcept
Asset const & assetIn () const
Asset const & assetOut () const
AccountID const & owner () const
std::optional< uint256key () const
TAmounts< TIn, TOut > const & amount () const
void consume (ApplyView &view, TAmounts< TIn, TOut > const &consumed)
bool fullyConsumed () const
TAmounts< TIn, TOut > limitOut (TAmounts< TIn, TOut > const &offerAmount, TOut const &limit, bool roundUp) const
 Limit out of the provided offer.
TAmounts< TIn, TOut > limitIn (TAmounts< TIn, TOut > const &offerAmount, TIn const &limit, bool roundUp) const
 Limit in of the provided offer.
QualityFunction getQualityFunc () const
bool isFunded () const
bool checkInvariant (TAmounts< TIn, TOut > const &consumed, beast::Journal j) const
 Check the new pool product is greater or equal to the old pool product or if decreases then within some threshold.

Static Public Member Functions

template<typename... Args>
static TER send (Args &&... args)
 Send funds without incurring the transfer fee.
static std::pair< std::uint32_t, std::uint32_tadjustRates (std::uint32_t ofrInRate, std::uint32_t ofrOutRate)

Private Attributes

AMMLiquidity< TIn, TOut > const & ammLiquidity_
TAmounts< TIn, TOut > const amounts_
TAmounts< TIn, TOut > const balances_
Quality const quality_
bool consumed_ {false}

Detailed Description

template<StepAmount TIn, StepAmount TOut>
class xrpl::AMMOffer< TIn, TOut >

Represents synthetic AMM offer in BookStep.

AMMOffer mirrors TOffer methods for use in generic BookStep methods. AMMOffer amounts are changed indirectly in BookStep limiting steps.

Definition at line 21 of file AMMOffer.h.

Constructor & Destructor Documentation

◆ AMMOffer()

template<StepAmount TIn, StepAmount TOut>
xrpl::AMMOffer< TIn, TOut >::AMMOffer ( AMMLiquidity< TIn, TOut > const & ammLiquidity,
TAmounts< TIn, TOut > const & amounts,
TAmounts< TIn, TOut > const & balances,
Quality const & quality )

Definition at line 26 of file AMMOffer.cpp.

Member Function Documentation

◆ quality()

template<StepAmount TIn, StepAmount TOut>
Quality xrpl::AMMOffer< TIn, TOut >::quality ( ) const
nodiscardnoexcept

Definition at line 51 of file AMMOffer.h.

◆ assetIn()

template<StepAmount TIn, StepAmount TOut>
Asset const & xrpl::AMMOffer< TIn, TOut >::assetIn ( ) const
nodiscard

Definition at line 38 of file AMMOffer.cpp.

◆ assetOut()

template<StepAmount TIn, StepAmount TOut>
Asset const & xrpl::AMMOffer< TIn, TOut >::assetOut ( ) const
nodiscard

Definition at line 45 of file AMMOffer.cpp.

◆ owner()

template<StepAmount TIn, StepAmount TOut>
AccountID const & xrpl::AMMOffer< TIn, TOut >::owner ( ) const
nodiscard

Definition at line 52 of file AMMOffer.cpp.

◆ key()

template<StepAmount TIn, StepAmount TOut>
std::optional< uint256 > xrpl::AMMOffer< TIn, TOut >::key ( ) const
nodiscard

Definition at line 66 of file AMMOffer.h.

◆ amount()

template<StepAmount TIn, StepAmount TOut>
TAmounts< TIn, TOut > const & xrpl::AMMOffer< TIn, TOut >::amount ( ) const
nodiscard

Definition at line 59 of file AMMOffer.cpp.

◆ consume()

template<StepAmount TIn, StepAmount TOut>
void xrpl::AMMOffer< TIn, TOut >::consume ( ApplyView & view,
TAmounts< TIn, TOut > const & consumed )

Definition at line 66 of file AMMOffer.cpp.

◆ fullyConsumed()

template<StepAmount TIn, StepAmount TOut>
bool xrpl::AMMOffer< TIn, TOut >::fullyConsumed ( ) const
nodiscard

Definition at line 78 of file AMMOffer.h.

◆ limitOut()

template<StepAmount TIn, StepAmount TOut>
TAmounts< TIn, TOut > xrpl::AMMOffer< TIn, TOut >::limitOut ( TAmounts< TIn, TOut > const & offerAmount,
TOut const & limit,
bool roundUp ) const
nodiscard

Limit out of the provided offer.

If one-path then swapOut using current balances. If multi-path then ceil_out using current quality.

Definition at line 82 of file AMMOffer.cpp.

◆ limitIn()

template<StepAmount TIn, StepAmount TOut>
TAmounts< TIn, TOut > xrpl::AMMOffer< TIn, TOut >::limitIn ( TAmounts< TIn, TOut > const & offerAmount,
TIn const & limit,
bool roundUp ) const
nodiscard

Limit in of the provided offer.

If one-path then swapIn using current balances. If multi-path then ceil_in using current quality.

Definition at line 107 of file AMMOffer.cpp.

◆ getQualityFunc()

template<StepAmount TIn, StepAmount TOut>
QualityFunction xrpl::AMMOffer< TIn, TOut >::getQualityFunc ( ) const
nodiscard

Definition at line 124 of file AMMOffer.cpp.

◆ send()

template<StepAmount TIn, StepAmount TOut>
template<typename... Args>
TER xrpl::AMMOffer< TIn, TOut >::send ( Args &&... args)
static

Send funds without incurring the transfer fee.

Definition at line 104 of file AMMOffer.h.

◆ isFunded()

template<StepAmount TIn, StepAmount TOut>
bool xrpl::AMMOffer< TIn, TOut >::isFunded ( ) const
nodiscard

Definition at line 111 of file AMMOffer.h.

◆ adjustRates()

template<StepAmount TIn, StepAmount TOut>
std::pair< std::uint32_t, std::uint32_t > xrpl::AMMOffer< TIn, TOut >::adjustRates ( std::uint32_t ofrInRate,
std::uint32_t ofrOutRate )
static

Definition at line 118 of file AMMOffer.h.

◆ checkInvariant()

template<StepAmount TIn, StepAmount TOut>
bool xrpl::AMMOffer< TIn, TOut >::checkInvariant ( TAmounts< TIn, TOut > const & consumed,
beast::Journal j ) const
nodiscard

Check the new pool product is greater or equal to the old pool product or if decreases then within some threshold.

Definition at line 133 of file AMMOffer.cpp.

Member Data Documentation

◆ ammLiquidity_

template<StepAmount TIn, StepAmount TOut>
AMMLiquidity<TIn, TOut> const& xrpl::AMMOffer< TIn, TOut >::ammLiquidity_
private

Definition at line 24 of file AMMOffer.h.

◆ amounts_

template<StepAmount TIn, StepAmount TOut>
TAmounts<TIn, TOut> const xrpl::AMMOffer< TIn, TOut >::amounts_
private

Definition at line 34 of file AMMOffer.h.

◆ balances_

template<StepAmount TIn, StepAmount TOut>
TAmounts<TIn, TOut> const xrpl::AMMOffer< TIn, TOut >::balances_
private

Definition at line 36 of file AMMOffer.h.

◆ quality_

template<StepAmount TIn, StepAmount TOut>
Quality const xrpl::AMMOffer< TIn, TOut >::quality_
private

Definition at line 39 of file AMMOffer.h.

◆ consumed_

template<StepAmount TIn, StepAmount TOut>
bool xrpl::AMMOffer< TIn, TOut >::consumed_ {false}
private

Definition at line 41 of file AMMOffer.h.