3#include <xrpl/basics/Number.h>
4#include <xrpl/protocol/AMMCore.h>
5#include <xrpl/protocol/Quality.h>
39 template <
typename TIn,
typename TOut>
69template <
typename TIn,
typename TOut>
72 if (amounts.in <= beast::zero || amounts.out <= beast::zero)
73 Throw<std::runtime_error>(
"QualityFunction amounts are 0.");
75 m_ = -cfee / amounts.in;
76 b_ = amounts.out * cfee / amounts.in;
Number is a floating point type that can represent a wide range of values.
Average quality of a path as a function of out: q(out) = m * out + b, where m = -1 / poolGets,...
std::optional< Quality > const & quality() const
QualityFunction(Quality const &quality, CLOBLikeTag)
void combine(QualityFunction const &qf)
Combines QF with the next step QF.
std::optional< Quality > quality_
std::optional< Number > outFromAvgQ(Quality const &quality)
Find output to produce the requested average 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.
Number feeMult(std::uint16_t tfee)
Get fee multiplier (1 - tfee) @tfee trading fee in basis points.