xrpld
Loading...
Searching...
No Matches
STAmount.h
1#pragma once
2
3#include <xrpl/basics/CountedObject.h>
4#include <xrpl/basics/Number.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/basics/safe_cast.h>
7#include <xrpl/beast/utility/Journal.h>
8#include <xrpl/beast/utility/Zero.h>
9#include <xrpl/beast/utility/instrumentation.h>
10#include <xrpl/json/json_value.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/Asset.h>
13#include <xrpl/protocol/Concepts.h>
14#include <xrpl/protocol/IOUAmount.h>
15#include <xrpl/protocol/Issue.h>
16#include <xrpl/protocol/MPTAmount.h>
17#include <xrpl/protocol/MPTIssue.h>
18#include <xrpl/protocol/Protocol.h>
19#include <xrpl/protocol/SField.h>
20#include <xrpl/protocol/STBase.h>
21#include <xrpl/protocol/Serializer.h>
22#include <xrpl/protocol/XRPAmount.h>
23#include <xrpl/protocol/json_get_or_throw.h>
24
25#include <cstddef>
26#include <cstdint>
27#include <limits>
28#include <memory>
29#include <stdexcept>
30#include <string>
31#include <utility>
32
33namespace xrpl {
34
35// Internal form:
36// 1: If amount is zero, then value is zero and offset is -100
37// 2: Otherwise:
38// legal offset range is -96 to +80 inclusive
39// value range is 10^15 to (10^16 - 1) inclusive
40// amount = value * [10 ^ offset]
41
42// Wire form:
43// High 8 bits are (offset+142), legal range is, 80 to 22 inclusive
44// Low 56 bits are value, legal range is 10^15 to (10^16 - 1) inclusive
45class STAmount final : public STBase, public CountedObject<STAmount>
46{
47public:
49 using exponent_type = int;
51
52private:
57
58public:
60
61 static constexpr int kMinOffset = -96;
62 static constexpr int kMaxOffset = 80;
63
64 // Maximum native value supported by the code
65 static constexpr std::uint64_t kMinValue = 1'000'000'000'000'000ull;
66 static_assert(isPowerOfTen(kMinValue));
67 static constexpr std::uint64_t kMaxValue = (kMinValue * 10) - 1;
68 static_assert(kMaxValue == 9'999'999'999'999'999ull);
69 static constexpr std::uint64_t kMaxNative = 9'000'000'000'000'000'000ull;
70
71 // Max native value on network.
72 static constexpr std::uint64_t kMaxNativeN = 100'000'000'000'000'000ull;
73 static constexpr std::uint64_t kIssuedCurrency = 0x8'000'000'000'000'000ull;
74 static constexpr std::uint64_t kPositive = 0x4'000'000'000'000'000ull;
75 static constexpr std::uint64_t kMpToken = 0x2'000'000'000'000'000ull;
76 static constexpr std::uint64_t kValueMask = ~(kPositive | kMpToken);
77
79
80 //--------------------------------------------------------------------------
81 STAmount(SerialIter& sit, SField const& name);
82
83 struct Unchecked
84 {
85 explicit Unchecked() = default;
86 };
87
88 // Do not call canonicalize
89 template <AssetType A>
91 SField const& name,
92 A const& asset,
95 bool negative,
96 Unchecked);
97
98 template <AssetType A>
100 A const& asset,
103 bool negative,
104 Unchecked);
105
106 // Call canonicalize
107 template <AssetType A>
108 STAmount(
109 SField const& name,
110 A const& asset,
113 bool negative = false);
114
115 STAmount(SField const& name, std::int64_t mantissa);
116
117 STAmount(SField const& name, std::uint64_t mantissa = 0, bool negative = false);
118
119 explicit STAmount(std::uint64_t mantissa = 0, bool negative = false);
120
121 explicit STAmount(SField const& name, STAmount const& amt);
122
123 template <AssetType A>
124 STAmount(A const& asset, std::uint64_t mantissa = 0, int exponent = 0, bool negative = false)
126 {
127 canonicalize();
128 }
129
130 // VFALCO Is this needed when we have the previous signature?
131 template <AssetType A>
132 STAmount(A const& asset, std::uint32_t mantissa, int exponent = 0, bool negative = false);
133
134 template <AssetType A>
135 STAmount(A const& asset, std::int64_t mantissa, int exponent = 0);
136
137 template <AssetType A>
138 STAmount(A const& asset, int mantissa, int exponent = 0);
139
140 template <AssetType A>
141 STAmount(A const& asset, Number const& number) : STAmount(fromNumber(asset, number))
142 {
143 }
144
145 // Legacy support for new-style amounts
146 STAmount(IOUAmount const& amount, Issue const& issue);
147 STAmount(XRPAmount const& amount);
148 STAmount(MPTAmount const& amount, MPTIssue const& mptIssue);
149 operator Number() const;
150
151 //--------------------------------------------------------------------------
152 //
153 // Observers
154 //
155 //--------------------------------------------------------------------------
156
157 [[nodiscard]] int
158 exponent() const noexcept;
159
160 [[nodiscard]] bool
161 integral() const noexcept;
162
163 [[nodiscard]] bool
164 native() const noexcept;
165
166 template <ValidIssueType TIss>
167 [[nodiscard]] constexpr bool
168 holds() const noexcept;
169
170 [[nodiscard]] bool
171 negative() const noexcept;
172
173 [[nodiscard]] std::uint64_t
174 mantissa() const noexcept;
175
176 [[nodiscard]] Asset const&
177 asset() const;
178
179 template <ValidIssueType TIss>
180 constexpr TIss const&
181 get() const;
182
183 template <ValidIssueType TIss>
184 TIss&
185 get();
186
187 [[nodiscard]] AccountID const&
188 getIssuer() const;
189
190 [[nodiscard]] int
191 signum() const noexcept;
192
196 [[nodiscard]] STAmount
197 zeroed() const;
198
199 void
200 setJson(json::Value&) const;
201
202 [[nodiscard]] STAmount const&
203 value() const noexcept;
204
219 [[nodiscard]] bool
220 isZeroAtScale(int scale) const;
221
222 //--------------------------------------------------------------------------
223 //
224 // Operators
225 //
226 //--------------------------------------------------------------------------
227
228 explicit
229 operator bool() const noexcept;
230
231 STAmount&
232 operator+=(STAmount const&);
233 STAmount&
234 operator-=(STAmount const&);
235
236 STAmount& operator=(beast::Zero);
237
238 STAmount&
239 operator=(XRPAmount const& amount);
240
241 STAmount&
242 operator=(Number const&);
243
244 //--------------------------------------------------------------------------
245 //
246 // Modification
247 //
248 //--------------------------------------------------------------------------
249
250 void
251 negate();
252
253 void
254 clear();
255
256 // Zero while copying currency and issuer.
257 void
258 clear(Asset const& asset);
259
263 void
264 setIssue(Asset const& asset);
265
266 //--------------------------------------------------------------------------
267 //
268 // STBase
269 //
270 //--------------------------------------------------------------------------
271
272 [[nodiscard]] SerializedTypeID
273 getSType() const override;
274
275 [[nodiscard]] std::string
276 getFullText() const override;
277
278 [[nodiscard]] std::string
279 getText() const override;
280
281 [[nodiscard]] json::Value getJson(JsonOptions = JsonOptions::Values::None) const override;
282
283 void
284 add(Serializer& s) const override;
285
286 [[nodiscard]] bool
287 isEquivalent(STBase const& t) const override;
288
289 [[nodiscard]] bool
290 isDefault() const override;
291
292 [[nodiscard]] XRPAmount
293 xrp() const;
294 [[nodiscard]] IOUAmount
295 iou() const;
296 [[nodiscard]] MPTAmount
297 mpt() const;
298
299private:
300 template <AssetType A>
301 static STAmount
302 fromNumber(A const& asset, Number const& number);
303
304 static std::unique_ptr<STAmount>
305 construct(SerialIter&, SField const& name);
306
307 void
308 set(std::int64_t v);
309 void
310 canonicalize();
311
312 STBase*
313 copy(std::size_t n, void* buf) const override;
314 STBase*
315 move(std::size_t n, void* buf) override;
316
317 STAmount&
318 operator=(IOUAmount const& iou);
319
320 friend class detail::STVar;
321
322 friend STAmount
323 operator+(STAmount const& v1, STAmount const& v2);
324};
325
326template <AssetType A>
328 SField const& name,
329 A const& asset,
332 bool negative,
333 Unchecked)
335{
336}
337
338template <AssetType A>
348
349template <AssetType A>
351 SField const& name,
352 A const& asset,
354 int exponent,
355 bool negative)
357{
358 // value_ is uint64, but needs to fit in the range of int64
360 {
361 XRPL_ASSERT(
363 "xrpl::STAmount::STAmount(SField, A, std::uint64_t, int, bool) : "
364 "maximum mantissa input");
365 }
366 else
367 {
369 throw std::overflow_error("STAmount mantissa is too large " + std::to_string(mantissa));
370 }
371 canonicalize();
372}
373
374template <AssetType A>
381
382template <AssetType A>
387
388template <AssetType A>
391{
392}
393
394// Legacy support for new-style amounts
395inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue)
396 : asset_(issue), offset_(amount.exponent()), isNegative_(amount < beast::kZero)
397{
398 if (isNegative_)
399 {
401 }
402 else
403 {
405 }
406
407 canonicalize();
408}
409
410inline STAmount::STAmount(MPTAmount const& amount, MPTIssue const& mptIssue)
411 : asset_(mptIssue), offset_(0), isNegative_(amount < beast::kZero)
412{
413 if (isNegative_)
414 {
416 }
417 else
418 {
420 }
421
422 canonicalize();
423}
424
425//------------------------------------------------------------------------------
426//
427// Creation
428//
429//------------------------------------------------------------------------------
430
431// VFALCO TODO The parameter type should be Quality not uint64_t
434
436amountFromString(Asset const& asset, std::string const& amount);
437
439amountFromJson(SField const& name, json::Value const& v);
440
441bool
442amountFromJsonNoThrow(STAmount& result, json::Value const& jvSource);
443
444// IOUAmount and XRPAmount define toSTAmount, defining this
445// trivial conversion here makes writing generic code easier
446inline STAmount const&
448{
449 return a; // NOLINT(bugprone-return-const-ref-from-parameter)
450}
451
452//------------------------------------------------------------------------------
453//
454// Observers
455//
456//------------------------------------------------------------------------------
457
458inline int
459STAmount::exponent() const noexcept
460{
461 return offset_;
462}
463
464inline bool
465STAmount::integral() const noexcept
466{
467 return asset_.integral();
468}
469
470inline bool
471STAmount::native() const noexcept
472{
473 return asset_.native();
474}
475
476template <ValidIssueType TIss>
477constexpr bool
478STAmount::holds() const noexcept
479{
480 return asset_.holds<TIss>();
481}
482
483inline bool
484STAmount::negative() const noexcept
485{
486 return isNegative_;
487}
488
489inline std::uint64_t
490STAmount::mantissa() const noexcept
491{
492 return value_;
493}
494
495inline Asset const&
497{
498 return asset_;
499}
500
501template <ValidIssueType TIss>
502[[nodiscard]] constexpr TIss const&
504{
505 return asset_.get<TIss>();
506}
507
508template <ValidIssueType TIss>
509TIss&
511{
512 return asset_.get<TIss>();
513}
514
515inline AccountID const&
517{
518 return asset_.getIssuer();
519}
520
521inline int
522STAmount::signum() const noexcept
523{
524 if (value_ == 0u)
525 return 0;
526 return isNegative_ ? -1 : 1;
527}
528
529inline STAmount
531{
532 return STAmount(asset_);
533}
534
535inline STAmount::
536operator bool() const noexcept
537{
538 return *this != beast::kZero;
539}
540
541inline STAmount::
542operator Number() const
543{
544 return asset().visit(
545 [&](Issue const& issue) -> Number {
546 if (issue.native())
547 return xrp();
548 return iou();
549 },
550 [&](MPTIssue const&) -> Number { return mpt(); });
551}
552
553inline STAmount&
555{
556 clear();
557 return *this;
558}
559
560inline STAmount&
562{
563 *this = STAmount(amount);
564 return *this;
565}
566
567template <AssetType A>
568inline STAmount
569STAmount::fromNumber(A const& a, Number const& number)
570{
571 bool const negative = number.mantissa() < 0;
572 Number const working{negative ? -number : number};
573 Asset const asset{a};
574 if (asset.integral())
575 {
576 std::uint64_t const intValue = static_cast<std::int64_t>(working);
577 return STAmount{asset, intValue, 0, negative};
578 }
579
580 auto const [mantissa, exponent] = working.normalizeToRange<kMinValue, kMaxValue>();
581
583}
584
585inline void
587{
588 if (*this != beast::kZero)
590}
591
592inline void
594{
595 // The -100 is used to allow 0 to sort less than a small positive values
596 // which have a negative exponent.
597 offset_ = integral() ? 0 : -100;
598 value_ = 0;
599 isNegative_ = false;
600}
601
602inline void
604{
606 clear();
607}
608
609inline STAmount const&
610STAmount::value() const noexcept
611{
612 return *this;
613}
614
615[[nodiscard]] inline bool
616isLegalNet(STAmount const& value)
617{
618 return !value.native() || (value.mantissa() <= STAmount::kMaxNativeN);
619}
620
621[[nodiscard]] inline bool
622isLegalMPT(STAmount const& value)
623{
624 return !value.holds<MPTIssue>() ||
625 (!value.negative() && value.exponent() == 0 && value.mantissa() <= kMaxMpTokenAmount);
626}
627
628/* Check recursively if an object has invalid MPTAmount or XRPAmount in STAmount field.
629 * Calls isLegalNet() and isLegalMPT().
630 */
631[[nodiscard]] bool
632hasInvalidAmount(STBase const& field, beast::Journal j);
633
634//------------------------------------------------------------------------------
635//
636// Operators
637//
638//------------------------------------------------------------------------------
639
640bool
641operator==(STAmount const& lhs, STAmount const& rhs);
642bool
643operator<(STAmount const& lhs, STAmount const& rhs);
644
645inline bool
646operator>(STAmount const& lhs, STAmount const& rhs)
647{
648 return rhs < lhs;
649}
650
651inline bool
652operator<=(STAmount const& lhs, STAmount const& rhs)
653{
654 return !(rhs < lhs);
655}
656
657inline bool
658operator>=(STAmount const& lhs, STAmount const& rhs)
659{
660 return !(lhs < rhs);
661}
662
663STAmount
664operator-(STAmount const& value);
665
666//------------------------------------------------------------------------------
667//
668// Arithmetic
669//
670//------------------------------------------------------------------------------
671
672STAmount
673operator+(STAmount const& v1, STAmount const& v2);
674STAmount
675operator-(STAmount const& v1, STAmount const& v2);
676
677STAmount
678divide(STAmount const& v1, STAmount const& v2, Asset const& asset);
679
680STAmount
681multiply(STAmount const& v1, STAmount const& v2, Asset const& asset);
682
683// multiply rounding result in specified direction
684STAmount
685mulRound(STAmount const& v1, STAmount const& v2, Asset const& asset, bool roundUp);
686
687// multiply following the rounding directions more precisely.
688STAmount
689mulRoundStrict(STAmount const& v1, STAmount const& v2, Asset const& asset, bool roundUp);
690
691// divide rounding result in specified direction
692STAmount
693divRound(STAmount const& v1, STAmount const& v2, Asset const& asset, bool roundUp);
694
695// divide following the rounding directions more precisely.
696STAmount
697divRoundStrict(STAmount const& v1, STAmount const& v2, Asset const& asset, bool roundUp);
698
699// Someone is offering X for Y, what is the rate?
700// Rate: smaller is better, the taker wants the most out: in/out
701// VFALCO TODO Return a Quality object
703getRate(STAmount const& offerOut, STAmount const& offerIn);
704
717[[nodiscard]] STAmount
719 STAmount const& value,
722
733template <AssetType A>
734void
735roundToAsset(A const& asset, Number& value)
736{
737 value = STAmount{asset, value};
738}
739
752template <AssetType A>
753[[nodiscard]] Number
755 A const& asset,
756 Number const& value,
759{
760 NumberRoundModeGuard const mg(rounding);
761 STAmount const ret{asset, value};
762 if (ret.integral())
763 return ret;
764 // Note that the ctor will round integral types (XRP, MPT) via canonicalize,
765 // so no extra work is needed for those.
766 return roundToScale(ret, scale);
767}
768
769//------------------------------------------------------------------------------
770
771inline bool
772isXRP(STAmount const& amount)
773{
774 return amount.native();
775}
776
777bool
778canAdd(STAmount const& amt1, STAmount const& amt2);
779
780bool
781canSubtract(STAmount const& amt1, STAmount const& amt2);
782
793inline int
794scale(Number const& number, Asset const& asset)
795{
796 return STAmount{asset, number}.exponent();
797}
798
799} // namespace xrpl
800
801//------------------------------------------------------------------------------
802namespace json {
803template <>
804inline xrpl::STAmount
805getOrThrow(json::Value const& v, xrpl::SField const& field)
806{
807 using namespace xrpl;
808 json::StaticString const& key = field.getJsonName();
809 if (!v.isMember(key))
811 json::Value const& inner = v[key];
812 return amountFromJson(field, inner);
813}
814} // namespace json
A generic endpoint for log messages.
Definition Journal.h:44
Lightweight wrapper to tag static string.
Definition json_value.h:48
Represents a JSON value.
Definition json_value.h:117
bool isMember(char const *key) const
Return true if the object has a member named key.
Floating point representation of amounts with high dynamic range.
Definition IOUAmount.h:26
mantissa_type mantissa() const noexcept
Definition IOUAmount.h:172
A currency issued by an account.
Definition Issue.h:18
bool native() const
Definition Issue.cpp:54
constexpr value_type value() const
Returns the underlying value.
Definition MPTAmount.h:134
Number is a floating point type that can represent a wide range of values.
Definition Number.h:351
constexpr rep mantissa() const noexcept
Returns the mantissa of the external view of the Number.
Definition Number.h:692
std::pair< T, int > normalizeToRange() const
Definition Number.h:842
static RoundingMode getround()
static MantissaRange::MantissaScale getMantissaScale()
Returns which mantissa scale is currently in use for normalization.
Identifies fields.
Definition SField.h:132
json::StaticString const & getJsonName() const
Definition SField.h:210
void set(std::int64_t v)
Definition STAmount.cpp:878
constexpr bool holds() const noexcept
Definition STAmount.h:478
constexpr TIss const & get() const
void setIssue(Asset const &asset)
Set the Issue for this amount.
Definition STAmount.cpp:407
static constexpr std::uint64_t kIssuedCurrency
Definition STAmount.h:73
std::string getFullText() const override
Definition STAmount.cpp:636
exponent_type offset_
Definition STAmount.h:55
mantissa_type value_
Definition STAmount.h:54
static STAmount fromNumber(A const &asset, Number const &number)
Definition STAmount.h:569
STAmount value_type
Definition STAmount.h:59
void add(Serializer &s) const override
Definition STAmount.cpp:742
bool isNegative_
Definition STAmount.h:56
std::pair< mantissa_type, exponent_type > rep
Definition STAmount.h:50
static std::uint64_t const kURateOne
Definition STAmount.h:78
void negate()
Definition STAmount.h:586
void canonicalize()
Definition STAmount.cpp:821
std::uint64_t mantissa() const noexcept
Definition STAmount.h:490
static constexpr std::uint64_t kPositive
Definition STAmount.h:74
int signum() const noexcept
Definition STAmount.h:522
friend class detail::STVar
Definition STAmount.h:320
bool isEquivalent(STBase const &t) const override
Definition STAmount.cpp:790
STBase * copy(std::size_t n, void *buf) const override
Definition STAmount.cpp:254
std::string getText() const override
Definition STAmount.cpp:646
static constexpr int kMinOffset
Definition STAmount.h:61
std::uint64_t mantissa_type
Definition STAmount.h:48
SerializedTypeID getSType() const override
Definition STAmount.cpp:630
IOUAmount iou() const
Definition STAmount.cpp:286
bool negative() const noexcept
Definition STAmount.h:484
STAmount zeroed() const
Returns a zero value with the same issuer and currency.
Definition STAmount.h:530
static constexpr std::uint64_t kMaxNativeN
Definition STAmount.h:72
bool isDefault() const override
Definition STAmount.cpp:797
bool integral() const noexcept
Definition STAmount.h:465
static constexpr std::uint64_t kValueMask
Definition STAmount.h:76
STAmount & operator=(beast::Zero)
Definition STAmount.h:554
static std::unique_ptr< STAmount > construct(SerialIter &, SField const &name)
Definition STAmount.cpp:248
bool native() const noexcept
Definition STAmount.h:471
Asset const & asset() const
Definition STAmount.h:496
int exponent_type
Definition STAmount.h:49
void setJson(json::Value &) const
Definition STAmount.cpp:606
STAmount(A const &asset, Number const &number)
Definition STAmount.h:141
MPTAmount mpt() const
Definition STAmount.cpp:301
static constexpr std::uint64_t kMpToken
Definition STAmount.h:75
json::Value getJson(JsonOptions=JsonOptions::Values::None) const override
Definition STAmount.cpp:734
int exponent() const noexcept
Definition STAmount.h:459
AccountID const & getIssuer() const
Definition STAmount.h:516
bool isZeroAtScale(int scale) const
Checks if this amount evaluates to zero when constrained to a specific accounting scale.
static constexpr std::uint64_t kMinValue
Definition STAmount.h:65
static constexpr std::uint64_t kMaxValue
Definition STAmount.h:67
STBase * move(std::size_t n, void *buf) override
Definition STAmount.cpp:260
static constexpr std::uint64_t kMaxNative
Definition STAmount.h:69
XRPAmount xrp() const
Definition STAmount.cpp:271
static constexpr int kMaxOffset
Definition STAmount.h:62
STAmount const & value() const noexcept
Definition STAmount.h:610
STAmount(SerialIter &sit, SField const &name)
Definition STAmount.cpp:112
STAmount(A const &asset, std::uint64_t mantissa=0, int exponent=0, bool negative=false)
Definition STAmount.h:124
T max(T... args)
constexpr Zero kZero
Definition Zero.h:30
JSON (JavaScript Object Notation).
Definition json_errors.h:5
xrpl::AccountID getOrThrow(json::Value const &v, xrpl::SField const &field)
Definition AccountID.h:126
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr BaseUInt< Bits, Tag > operator+(BaseUInt< Bits, Tag > const &a, BaseUInt< Bits, Tag > const &b)
Definition base_uint.h:643
STAmount divide(STAmount const &amount, Rate const &rate)
Definition Rate2.cpp:69
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition Slice.h:212
constexpr bool operator==(BaseUInt< Bits, Tag > const &lhs, BaseUInt< Bits, Tag > const &rhs)
Definition base_uint.h:606
bool isLegalMPT(STAmount const &value)
Definition STAmount.h:622
bool operator>=(STAmount const &lhs, STAmount const &rhs)
Definition STAmount.h:658
bool isXRP(AccountID const &c)
Definition AccountID.h:84
Number operator-(Number const &x, Number const &y)
Definition Number.h:789
STAmount mulRoundStrict(STAmount const &v1, STAmount const &v2, Asset const &asset, bool roundUp)
int scale(Number const &number, Asset const &asset)
Get the scale of a Number for a given asset.
Definition STAmount.h:794
bool isLegalNet(STAmount const &value)
Definition STAmount.h:616
STAmount amountFromString(Asset const &asset, std::string const &amount)
Definition STAmount.cpp:907
STAmount divRound(STAmount const &v1, STAmount const &v2, Asset const &asset, bool roundUp)
constexpr Dest safeCast(Src s) noexcept
Definition safe_cast.h:21
constexpr Dest unsafeCast(Src s) noexcept
Definition safe_cast.h:55
STAmount roundToScale(STAmount const &value, std::int32_t scale, Number::RoundingMode rounding=Number::getround())
Round an arbitrary precision Amount to the precision of an STAmount that has a given exponent.
bool canAdd(STAmount const &amt1, STAmount const &amt2)
Safely checks if two STAmount values can be added without overflow, underflow, or precision loss.
Definition STAmount.cpp:464
bool amountFromJsonNoThrow(STAmount &result, json::Value const &jvSource)
STAmount amountFromQuality(std::uint64_t rate)
Definition STAmount.cpp:895
SerializedTypeID
Definition SField.h:94
std::uint64_t getRate(STAmount const &offerOut, STAmount const &offerIn)
Definition STAmount.cpp:422
constexpr bool isPowerOfTen(T value)
Definition Number.h:43
STAmount amountFromJson(SField const &name, json::Value const &v)
Definition STAmount.cpp:916
bool hasInvalidAmount(STBase const &field, beast::Journal j)
void roundToAsset(A const &asset, Number &value)
Round an arbitrary precision Number IN PLACE to the precision of a given Asset.
Definition STAmount.h:735
bool operator<=(STAmount const &lhs, STAmount const &rhs)
Definition STAmount.h:652
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
STAmount mulRound(STAmount const &v1, STAmount const &v2, Asset const &asset, bool roundUp)
bool canSubtract(STAmount const &amt1, STAmount const &amt2)
Determines if it is safe to subtract one STAmount from another.
Definition STAmount.cpp:541
STAmount divRoundStrict(STAmount const &v1, STAmount const &v2, Asset const &asset, bool roundUp)
STAmount multiply(STAmount const &amount, Number const &frac, Number::RoundingMode rm)
constexpr std::uint64_t kMaxMpTokenAmount
The maximum amount of MPTokenIssuance.
Definition Protocol.h:296
bool operator>(STAmount const &lhs, STAmount const &rhs)
Definition STAmount.h:646
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition contract.h:52
STAmount toSTAmount(IOUAmount const &iou, Asset const &asset)
Zero allows classes to offer efficient comparisons to zero.
Definition Zero.h:26
Note, should be treated as flags that can be | and &.
Definition STBase.h:22
T to_string(T... args)