20 #ifndef RIPPLE_PROTOCOL_QUALITYFUNCTION_H_INCLUDED
21 #define RIPPLE_PROTOCOL_QUALITYFUNCTION_H_INCLUDED
23 #include <ripple/basics/Number.h>
24 #include <ripple/protocol/AMMCore.h>
25 #include <ripple/protocol/Quality.h>
59 template <
typename TIn,
typename TOut>
61 TAmounts<TIn, TOut>
const& amounts,
92 template <
typename TIn,
typename TOut>
94 TAmounts<TIn, TOut>
const& amounts,
98 if (amounts.in <= beast::zero || amounts.out <= beast::zero)
99 Throw<std::runtime_error>(
"QualityFunction amounts are 0.");
101 m_ = -cfee / amounts.in;
102 b_ = amounts.out * cfee / amounts.in;
107 #endif // RIPPLE_PROTOCOL_QUALITYFUNCTION_H_INCLUDED
Number feeMult(std::uint16_t tfee)
Get fee multiplier (1 - tfee) @tfee trading fee in basis points.
void combine(QualityFunction const &qf)
Combines QF with the next step QF.
std::optional< Quality > const & quality() const
std::optional< Quality > quality_
bool isConst() const
Return true if the quality function is constant.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Average quality of a path as a function of out: q(out) = m * out + b, where m = -1 / poolGets,...
std::optional< Number > outFromAvgQ(Quality const &quality)
Find output to produce the requested average quality.
QualityFunction(Quality const &quality, CLOBLikeTag)