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

#include <Offer.h>

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

Public Member Functions

 TOffer ()=default
 TOffer (SLE::pointer entry, Quality quality)
Quality quality () const noexcept
 Returns the quality of the offer.
AccountID const & owner () const
 Returns the account id of the offer's owner.
TAmounts< TIn, TOut > const & amount () const
 Returns the in and out amounts.
bool fullyConsumed () const
 Returns true if no more funds can flow through this offer.
void consume (ApplyView &view, TAmounts< TIn, TOut > const &consumed)
 Adjusts the offer to indicate that we consumed some (or all) of it.
std::string id () const
std::optional< uint256key () const
Asset const & assetIn () const
Asset const & assetOut () const
TAmounts< TIn, TOut > limitOut (TAmounts< TIn, TOut > const &offerAmount, TOut const &limit, bool roundUp) const
TAmounts< TIn, TOut > limitIn (TAmounts< TIn, TOut > const &offerAmount, TIn const &limit, bool roundUp) const
bool isFunded () const
bool checkInvariant (TAmounts< TIn, TOut > const &consumed, beast::Journal j) const
 Check any required invariant.

Static Public Member Functions

template<typename... Args>
static TER send (Args &&... args)
static std::pair< std::uint32_t, std::uint32_tadjustRates (std::uint32_t ofrInRate, std::uint32_t ofrOutRate)

Private Member Functions

void setFieldAmounts ()

Private Attributes

SLE::pointer entry_
Quality quality_ {}
AccountID accountID_
Asset assetIn_
Asset assetOut_
TAmounts< TIn, TOut > amounts_ {}

Detailed Description

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

Definition at line 29 of file tx/paths/Offer.h.

Constructor & Destructor Documentation

◆ TOffer() [1/2]

template<StepAmount TIn, StepAmount TOut>
xrpl::TOffer< TIn, TOut >::TOffer ( )
default

◆ TOffer() [2/2]

template<StepAmount TIn, StepAmount TOut>
xrpl::TOffer< TIn, TOut >::TOffer ( SLE::pointer entry,
Quality quality )

Definition at line 180 of file tx/paths/Offer.h.

Member Function Documentation

◆ setFieldAmounts()

template<StepAmount TIn, StepAmount TOut>
void xrpl::TOffer< TIn, TOut >::setFieldAmounts ( )
private

Definition at line 193 of file tx/paths/Offer.h.

◆ quality()

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

Returns the quality of the offer.

Conceptually, the quality is the ratio of output to input currency. The implementation calculates it as the ratio of input to output currency (so it sorts ascending). The quality is computed at the time the offer is placed, and never changes for the lifetime of the offer. This is an important business rule that maintains accuracy when an offer is partially filled; Subsequent partial fills will use the original quality.

Definition at line 58 of file tx/paths/Offer.h.

◆ owner()

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

Returns the account id of the offer's owner.

Definition at line 67 of file tx/paths/Offer.h.

◆ amount()

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

Returns the in and out amounts.

Some or all of the out amount may be unfunded.

Definition at line 77 of file tx/paths/Offer.h.

◆ fullyConsumed()

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

Returns true if no more funds can flow through this offer.

Definition at line 86 of file tx/paths/Offer.h.

◆ consume()

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

Adjusts the offer to indicate that we consumed some (or all) of it.

Definition at line 99 of file tx/paths/Offer.h.

◆ id()

template<StepAmount TIn, StepAmount TOut>
std::string xrpl::TOffer< TIn, TOut >::id ( ) const
nodiscard

Definition at line 113 of file tx/paths/Offer.h.

◆ key()

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

Definition at line 119 of file tx/paths/Offer.h.

◆ assetIn()

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

Definition at line 252 of file tx/paths/Offer.h.

◆ assetOut()

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

Definition at line 259 of file tx/paths/Offer.h.

◆ limitOut()

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

Definition at line 216 of file tx/paths/Offer.h.

◆ limitIn()

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

Definition at line 226 of file tx/paths/Offer.h.

◆ send()

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

Definition at line 244 of file tx/paths/Offer.h.

◆ isFunded()

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

Definition at line 140 of file tx/paths/Offer.h.

◆ adjustRates()

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

Definition at line 147 of file tx/paths/Offer.h.

◆ checkInvariant()

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

Check any required invariant.

Limit order book offer always returns true.

Definition at line 158 of file tx/paths/Offer.h.

Member Data Documentation

◆ entry_

template<StepAmount TIn, StepAmount TOut>
SLE::pointer xrpl::TOffer< TIn, TOut >::entry_
private

Definition at line 32 of file tx/paths/Offer.h.

◆ quality_

template<StepAmount TIn, StepAmount TOut>
Quality xrpl::TOffer< TIn, TOut >::quality_ {}
private

Definition at line 33 of file tx/paths/Offer.h.

◆ accountID_

template<StepAmount TIn, StepAmount TOut>
AccountID xrpl::TOffer< TIn, TOut >::accountID_
private

Definition at line 34 of file tx/paths/Offer.h.

◆ assetIn_

template<StepAmount TIn, StepAmount TOut>
Asset xrpl::TOffer< TIn, TOut >::assetIn_
private

Definition at line 35 of file tx/paths/Offer.h.

◆ assetOut_

template<StepAmount TIn, StepAmount TOut>
Asset xrpl::TOffer< TIn, TOut >::assetOut_
private

Definition at line 36 of file tx/paths/Offer.h.

◆ amounts_

template<StepAmount TIn, StepAmount TOut>
TAmounts<TIn, TOut> xrpl::TOffer< TIn, TOut >::amounts_ {}
private

Definition at line 38 of file tx/paths/Offer.h.