rippled
Loading...
Searching...
No Matches
Rate.h
1#pragma once
2
3#include <xrpl/beast/utility/instrumentation.h>
4#include <xrpl/protocol/STAmount.h>
5
6#include <boost/operators.hpp>
7
8#include <cstdint>
9#include <ostream>
10
11namespace xrpl {
12
19struct Rate : private boost::totally_ordered<Rate>
20{
22
23 Rate() = delete;
24
25 explicit Rate(std::uint32_t rate) : value(rate)
26 {
27 }
28};
29
30inline bool
31operator==(Rate const& lhs, Rate const& rhs) noexcept
32{
33 return lhs.value == rhs.value;
34}
35
36inline bool
37operator<(Rate const& lhs, Rate const& rhs) noexcept
38{
39 return lhs.value < rhs.value;
40}
41
43operator<<(std::ostream& os, Rate const& rate)
44{
45 os << rate.value;
46 return os;
47}
48
49STAmount
50multiply(STAmount const& amount, Rate const& rate);
51
52STAmount
53multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp);
54
55STAmount
56multiplyRound(STAmount const& amount, Rate const& rate, Asset const& asset, bool roundUp);
57
58STAmount
59divide(STAmount const& amount, Rate const& rate);
60
61STAmount
62divideRound(STAmount const& amount, Rate const& rate, bool roundUp);
63
64STAmount
65divideRound(STAmount const& amount, Rate const& rate, Asset const& asset, bool roundUp);
66
67namespace nft {
69Rate
71
72} // namespace nft
73
75extern Rate const parityRate;
76
77} // namespace xrpl
Rate transferFeeAsRate(std::uint16_t fee)
Given a transfer fee (in basis points) convert it to a transfer rate.
Definition Rate2.cpp:26
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
STAmount divide(STAmount const &amount, Rate const &rate)
Definition Rate2.cpp:69
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition Slice.h:198
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
Definition base_uint.h:612
STAmount multiply(STAmount const &amount, Rate const &rate)
Definition Rate2.cpp:34
constexpr bool operator==(base_uint< Bits, Tag > const &lhs, base_uint< Bits, Tag > const &rhs)
Definition base_uint.h:552
STAmount multiplyRound(STAmount const &amount, Rate const &rate, bool roundUp)
Definition Rate2.cpp:45
STAmount divideRound(STAmount const &amount, Rate const &rate, bool roundUp)
Definition Rate2.cpp:80
Rate const parityRate
A transfer rate signifying a 1:1 exchange.
Represents a transfer rate.
Definition Rate.h:20
std::uint32_t value
Definition Rate.h:21
Rate()=delete
Rate(std::uint32_t rate)
Definition Rate.h:25