3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/contract.h>
5#include <xrpl/ledger/View.h>
6#include <xrpl/ledger/helpers/TokenHelpers.h>
7#include <xrpl/protocol/Concepts.h>
8#include <xrpl/protocol/Quality.h>
9#include <xrpl/protocol/Rules.h>
10#include <xrpl/protocol/SField.h>
11#include <xrpl/protocol/STLedgerEntry.h>
18template <StepAmount TIn, StepAmount TOut>
106 [[nodiscard]]
Asset const&
108 [[nodiscard]]
Asset const&
117 template <
typename... Args>
119 send(Args&&... args);
132 return {ofrInRate, ofrOutRate};
147 JLOG(j.
error()) <<
"AMMOffer::checkInvariant failed: consumed "
160template <StepAmount TIn, StepAmount TOut>
164 auto const tp =
entry_->getFieldAmount(sfTakerPays);
165 auto const tg =
entry_->getFieldAmount(sfTakerGets);
172template <StepAmount TIn, StepAmount TOut>
195template <StepAmount TIn, StepAmount TOut>
202 return quality().ceilOutStrict(offerAmount, limit, roundUp);
205template <StepAmount TIn, StepAmount TOut>
211 rules && rules->enabled(fixReducedOffersV2))
217 return quality().ceilInStrict(offerAmount, limit, roundUp);
219 return quality_.ceilIn(offerAmount, limit);
222template <StepAmount TIn, StepAmount TOut>
223template <
typename... Args>
230template <StepAmount TIn, StepAmount TOut>
237template <StepAmount TIn, StepAmount TOut>
244template <StepAmount TIn, StepAmount TOut>
248 return os << offer.id();
A generic endpoint for log messages.
Writeable view to a ledger, for applying a transaction.
virtual void update(SLE::ref sle)=0
Indicate changes to a peeked SLE.
A currency issued by an account.
Represents the logical ratio of output currency to input currency.
std::shared_ptr< STLedgerEntry > pointer
static TER send(Args &&... args)
TAmounts< TIn, TOut > amounts_
AccountID const & owner() const
Returns the account id of the offer's owner.
void consume(ApplyView &view, TAmounts< TIn, TOut > const &consumed)
Adjusts the offer to indicate that we consumed some (or all) of it.
Asset const & assetIn() const
static std::pair< std::uint32_t, std::uint32_t > adjustRates(std::uint32_t ofrInRate, std::uint32_t ofrOutRate)
std::optional< uint256 > key() const
Quality quality() const noexcept
Returns the quality of the offer.
bool fullyConsumed() const
Returns true if no more funds can flow through this offer.
TAmounts< TIn, TOut > limitOut(TAmounts< TIn, TOut > const &offerAmount, TOut const &limit, bool roundUp) const
bool checkInvariant(TAmounts< TIn, TOut > const &consumed, beast::Journal j) const
Check any required invariant.
TAmounts< TIn, TOut > const & amount() const
Returns the in and out amounts.
Asset const & assetOut() const
TAmounts< TIn, TOut > limitIn(TAmounts< TIn, TOut > const &offerAmount, TIn const &limit, bool roundUp) const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool isFeatureEnabled(uint256 const &feature, bool resultIfNoRules)
Check whether a feature is enabled in the current ledger rules.
std::optional< Rules > const & getCurrentTransactionRules()
std::ostream & operator<<(std::ostream &out, BaseUInt< Bits, Tag > const &u)
std::string to_string(BaseUInt< Bits, Tag > const &a)
T toAmount(STAmount const &amt)=delete
TER accountSend(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee=WaiveTransferFee::No, AllowMPTOverflow allowOverflow=AllowMPTOverflow::No)
Calls static accountSendIOU if saAmount represents Issue.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
TERSubset< CanCvtToTER > TER
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
STAmount toSTAmount(IOUAmount const &iou, Asset const &asset)
Represents a pair of input and output currencies.