19 #include <ripple/app/paths/AMMOffer.h>
21 #include <ripple/app/paths/AMMLiquidity.h>
22 #include <ripple/protocol/QualityFunction.h>
26 template <
typename TIn,
typename TOut>
29 TAmounts<TIn, TOut>
const& amounts,
31 Quality
const& quality)
32 : ammLiquidity_(ammLiquidity)
40 template <
typename TIn,
typename TOut>
44 return ammLiquidity_.issueIn();
47 template <
typename TIn,
typename TOut>
51 return ammLiquidity_.issueOut();
54 template <
typename TIn,
typename TOut>
58 return ammLiquidity_.ammAccount();
61 template <
typename TIn,
typename TOut>
62 TAmounts<TIn, TOut>
const&
68 template <
typename TIn,
typename TOut>
72 TAmounts<TIn, TOut>
const& consumed)
75 if (consumed.in > amounts_.in || consumed.out > amounts_.out)
76 Throw<std::logic_error>(
"Invalid consumed AMM offer.");
83 ammLiquidity_.context().setAMMUsed();
86 template <
typename TIn,
typename TOut>
89 TAmounts<TIn, TOut>
const& offrAmt,
91 bool fixReducedOffers,
100 if (ammLiquidity_.multiPath())
102 if (fixReducedOffers)
107 return quality().ceil_out_strict(offrAmt, limit, roundUp);
108 return quality().ceil_out(offrAmt, limit);
113 return {swapAssetOut(*balances_, limit, ammLiquidity_.tradingFee()), limit};
116 template <
typename TIn,
typename TOut>
119 TAmounts<TIn, TOut>
const& offrAmt,
120 TIn
const& limit)
const
123 if (ammLiquidity_.multiPath())
124 return quality().ceil_in(offrAmt, limit);
125 return {limit, swapAssetIn(*balances_, limit, ammLiquidity_.tradingFee())};
128 template <
typename TIn,
typename TOut>
132 if (ammLiquidity_.multiPath())
TAmounts< TIn, TOut > const & amount() const
TAmounts< TIn, TOut > limitOut(TAmounts< TIn, TOut > const &offrAmt, TOut const &limit, bool fixReducedOffers, bool roundUp) const
Limit out of the provided offer.
A currency issued by an account.
QualityFunction getQualityFunc() const
Issue const & issueIn() const
TAmounts< TIn, TOut > limitIn(TAmounts< TIn, TOut > const &offrAmt, TIn const &limit) const
Limit in of the provided offer.
Writeable view to a ledger, for applying a transaction.
Integers of any length that is a multiple of 32-bits.
void consume(ApplyView &view, TAmounts< TIn, TOut > const &consumed)
Represents synthetic AMM offer in BookStep.
AMMOffer(AMMLiquidity< TIn, TOut > const &ammLiquidity, TAmounts< TIn, TOut > const &amounts, std::optional< TAmounts< TIn, TOut >> const &balances, Quality const &quality)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
AMMLiquidity class provides AMM offers to BookStep class.
Average quality of a path as a function of out: q(out) = m * out + b, where m = -1 / poolGets,...
Issue const & issueOut() const
AccountID const & owner() const