1#ifndef XRPL_PROTOCOL_QUALITYFUNCTION_H_INCLUDED
2#define XRPL_PROTOCOL_QUALITYFUNCTION_H_INCLUDED
4#include <xrpl/basics/Number.h>
5#include <xrpl/protocol/AMMCore.h>
6#include <xrpl/protocol/Quality.h>
40 template <
typename TIn,
typename TOut>
42 TAmounts<TIn, TOut>
const& amounts,
73template <
typename TIn,
typename TOut>
75 TAmounts<TIn, TOut>
const& amounts,
79 if (amounts.in <= beast::zero || amounts.out <= beast::zero)
80 Throw<std::runtime_error>(
"QualityFunction amounts are 0.");
82 m_ = -cfee / amounts.in;
83 b_ = amounts.out * cfee / amounts.in;
Average quality of a path as a function of out: q(out) = m * out + b, where m = -1 / poolGets,...
QualityFunction(Quality const &quality, CLOBLikeTag)
void combine(QualityFunction const &qf)
Combines QF with the next step QF.
std::optional< Number > outFromAvgQ(Quality const &quality)
Find output to produce the requested average quality.
std::optional< Quality > const & quality() const
bool isConst() const
Return true if the quality function is constant.
std::optional< Quality > quality_
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.