3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/beast/utility/Zero.h>
8#include <xrpl/ledger/ApplyView.h>
9#include <xrpl/ledger/helpers/TokenHelpers.h>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/Concepts.h>
12#include <xrpl/protocol/Feature.h>
13#include <xrpl/protocol/Quality.h>
14#include <xrpl/protocol/Rules.h>
15#include <xrpl/protocol/SField.h>
16#include <xrpl/protocol/STLedgerEntry.h>
17#include <xrpl/protocol/TER.h>
28template <StepAmount TIn, StepAmount TOut>
124 [[nodiscard]]
Asset const&
126 [[nodiscard]]
Asset const&
135 template <
typename... Args>
137 send(Args&&... args);
150 return {ofrInRate, ofrOutRate};
166 JLOG(j.
error()) <<
"AMMOffer::checkInvariant failed: consumed "
179template <StepAmount TIn, StepAmount TOut>
183 auto const tp =
entry_->getFieldAmount(sfTakerPays);
184 auto const tg =
entry_->getFieldAmount(sfTakerGets);
191template <StepAmount TIn, StepAmount TOut>
214template <StepAmount TIn, StepAmount TOut>
221 return quality().ceilOutStrict(offerAmount, limit, roundUp);
224template <StepAmount TIn, StepAmount TOut>
230 rules && rules->enabled(fixReducedOffersV2))
236 return quality().ceilInStrict(offerAmount, limit, roundUp);
238 return quality_.ceilIn(offerAmount, limit);
241template <StepAmount TIn, StepAmount TOut>
242template <
typename... Args>
250template <StepAmount TIn, StepAmount TOut>
257template <StepAmount TIn, StepAmount TOut>
264template <StepAmount TIn, StepAmount TOut>
268 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.
TER accountSend(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &saAmount, beast::Journal j, SLE::ref sponsorSle={}, WaiveTransferFee waiveFee=WaiveTransferFee::No, AllowMPTOverflow allowOverflow=AllowMPTOverflow::No)
Calls static accountSendIOU if saAmount represents Issue.
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
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.