rippled
Loading...
Searching...
No Matches
AMMCore.h
1#pragma once
2
3#include <xrpl/basics/Number.h>
4#include <xrpl/protocol/AccountID.h>
5#include <xrpl/protocol/Issue.h>
6#include <xrpl/protocol/TER.h>
7#include <xrpl/protocol/UintTypes.h>
8
9namespace xrpl {
10
11std::uint16_t constexpr TRADING_FEE_THRESHOLD = 1000; // 1%
12
13// Auction slot
14std::uint32_t constexpr TOTAL_TIME_SLOT_SECS = 24 * 3600;
21
22// Votes
25
26class STObject;
27class STAmount;
28class Rules;
29
33ammLPTCurrency(Currency const& cur1, Currency const& cur2);
34
38ammLPTIssue(Currency const& cur1, Currency const& cur2, AccountID const& ammAccountID);
39
47 STAmount const& amount,
49 bool validZero = false);
50
53
56 Issue const& issue1,
57 Issue const& issue2,
59
64
67bool
68ammEnabled(Rules const&);
69
74inline Number
79
83inline Number
85{
86 return 1 - getFee(tfee);
87}
88
92inline Number
94{
95 return 1 - getFee(tfee) / 2;
96}
97
98} // namespace xrpl
A currency issued by an account.
Definition Issue.h:13
Number is a floating point type that can represent a wide range of values.
Definition Number.h:207
Rules controlling protocol behavior.
Definition Rules.h:18
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::uint32_t constexpr AUCTION_SLOT_MIN_FEE_FRACTION
Definition AMMCore.h:19
std::uint32_t constexpr AUCTION_SLOT_INTERVAL_DURATION
Definition AMMCore.h:20
std::uint16_t constexpr AUCTION_SLOT_TIME_INTERVALS
Definition AMMCore.h:15
std::uint16_t constexpr TRADING_FEE_THRESHOLD
Definition AMMCore.h:11
Number feeMultHalf(std::uint16_t tfee)
Get fee multiplier (1 - tfee / 2) @tfee trading fee in basis points.
Definition AMMCore.h:93
bool ammEnabled(Rules const &)
Return true if required AMM amendments are enabled.
Definition AMMCore.cpp:95
std::uint32_t constexpr VOTE_WEIGHT_SCALE_FACTOR
Definition AMMCore.h:24
std::uint32_t constexpr TOTAL_TIME_SLOT_SECS
Definition AMMCore.h:14
NotTEC invalidAMMAssetPair(Issue const &issue1, Issue const &issue2, std::optional< std::pair< Issue, Issue > > const &pair=std::nullopt)
Definition AMMCore.cpp:55
std::uint16_t constexpr AUCTION_SLOT_MAX_AUTH_ACCOUNTS
Definition AMMCore.h:16
std::uint32_t constexpr AUCTION_SLOT_DISCOUNTED_FEE_FRACTION
Definition AMMCore.h:18
@ current
This was a new validation and was added.
std::uint32_t constexpr AUCTION_SLOT_FEE_SCALE_FACTOR
Definition AMMCore.h:17
Number feeMult(std::uint16_t tfee)
Get fee multiplier (1 - tfee) @tfee trading fee in basis points.
Definition AMMCore.h:84
std::uint16_t constexpr VOTE_MAX_SLOTS
Definition AMMCore.h:23
NotTEC invalidAMMAmount(STAmount const &amount, std::optional< std::pair< Issue, Issue > > const &pair=std::nullopt, bool validZero=false)
Validate the amount.
Definition AMMCore.cpp:67
Number getFee(std::uint16_t tfee)
Convert to the fee from the basis points.
Definition AMMCore.h:75
std::optional< std::uint8_t > ammAuctionTimeSlot(std::uint64_t current, STObject const &auctionSlot)
Get time slot of the auction slot.
Definition AMMCore.cpp:77
Issue ammLPTIssue(Currency const &cur1, Currency const &cur2, AccountID const &ammAccountID)
Calculate LPT Issue from AMM asset pair.
Definition AMMCore.cpp:37
NotTEC invalidAMMAsset(Issue const &issue, std::optional< std::pair< Issue, Issue > > const &pair=std::nullopt)
Definition AMMCore.cpp:43
Currency ammLPTCurrency(Currency const &cur1, Currency const &cur2)
Calculate Liquidity Provider Token (LPT) Currency.
Definition AMMCore.cpp:24