rippled
Loading...
Searching...
No Matches
Rate.h
1#ifndef XRPL_PROTOCOL_RATE_H_INCLUDED
2#define XRPL_PROTOCOL_RATE_H_INCLUDED
3
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/protocol/STAmount.h>
6
7#include <boost/operators.hpp>
8
9#include <cstdint>
10#include <ostream>
11
12namespace ripple {
13
20struct Rate : private boost::totally_ordered<Rate>
21{
23
24 Rate() = delete;
25
26 explicit Rate(std::uint32_t rate) : value(rate)
27 {
28 }
29};
30
31inline bool
32operator==(Rate const& lhs, Rate const& rhs) noexcept
33{
34 return lhs.value == rhs.value;
35}
36
37inline bool
38operator<(Rate const& lhs, Rate const& rhs) noexcept
39{
40 return lhs.value < rhs.value;
41}
42
44operator<<(std::ostream& os, Rate const& rate)
45{
46 os << rate.value;
47 return os;
48}
49
50STAmount
51multiply(STAmount const& amount, Rate const& rate);
52
53STAmount
54multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp);
55
56STAmount
58 STAmount const& amount,
59 Rate const& rate,
60 Asset const& asset,
61 bool roundUp);
62
63STAmount
64divide(STAmount const& amount, Rate const& rate);
65
66STAmount
67divideRound(STAmount const& amount, Rate const& rate, bool roundUp);
68
69STAmount
71 STAmount const& amount,
72 Rate const& rate,
73 Asset const& asset,
74 bool roundUp);
75
76namespace nft {
78Rate
80
81} // namespace nft
82
84extern Rate const parityRate;
85
86} // namespace ripple
87
88#endif
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:6
STAmount divide(STAmount const &amount, Rate const &rate)
Definition Rate2.cpp:74
STAmount multiply(STAmount const &amount, Rate const &rate)
Definition Rate2.cpp:34
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
Definition base_uint.h:628
STAmount divideRound(STAmount const &amount, Rate const &rate, bool roundUp)
Definition Rate2.cpp:85
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition Slice.h:204
STAmount multiplyRound(STAmount const &amount, Rate const &rate, bool roundUp)
Definition Rate2.cpp:45
constexpr bool operator==(base_uint< Bits, Tag > const &lhs, base_uint< Bits, Tag > const &rhs)
Definition base_uint.h:566
Rate const parityRate
A transfer rate signifying a 1:1 exchange.
Represents a transfer rate.
Definition Rate.h:21
Rate(std::uint32_t rate)
Definition Rate.h:26
std::uint32_t value
Definition Rate.h:22
Rate()=delete