rippled
Loading...
Searching...
No Matches
AMMCore.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2023 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_PROTOCOL_AMMCORE_H_INCLUDED
21#define RIPPLE_PROTOCOL_AMMCORE_H_INCLUDED
22
23#include <xrpl/basics/Number.h>
24#include <xrpl/protocol/AccountID.h>
25#include <xrpl/protocol/Issue.h>
26#include <xrpl/protocol/TER.h>
27#include <xrpl/protocol/UintTypes.h>
28
29namespace ripple {
30
31std::uint16_t constexpr TRADING_FEE_THRESHOLD = 1000; // 1%
32
33// Auction slot
34std::uint32_t constexpr TOTAL_TIME_SLOT_SECS = 24 * 3600;
42
43// Votes
46
47class STObject;
48class STAmount;
49class Rules;
50
54ammLPTCurrency(Currency const& cur1, Currency const& cur2);
55
60 Currency const& cur1,
61 Currency const& cur2,
62 AccountID const& ammAccountID);
63
71 STAmount const& amount,
73 bool validZero = false);
74
77 Issue const& issue,
79
82 Issue const& issue1,
83 Issue const& issue2,
85
90
93bool
94ammEnabled(Rules const&);
95
100inline Number
102{
104}
105
109inline Number
111{
112 return 1 - getFee(tfee);
113}
114
118inline Number
120{
121 return 1 - getFee(tfee) / 2;
122}
123
124} // namespace ripple
125
126#endif // RIPPLE_PROTOCOL_AMMCORE_H_INCLUDED
A currency issued by an account.
Definition Issue.h:33
Rules controlling protocol behavior.
Definition Rules.h:38
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
NotTEC invalidAMMAmount(STAmount const &amount, std::optional< std::pair< Issue, Issue > > const &pair=std::nullopt, bool validZero=false)
Validate the amount.
Definition AMMCore.cpp:95
std::uint32_t constexpr TOTAL_TIME_SLOT_SECS
Definition AMMCore.h:34
std::uint16_t constexpr AUCTION_SLOT_TIME_INTERVALS
Definition AMMCore.h:35
std::optional< std::uint8_t > ammAuctionTimeSlot(std::uint64_t current, STObject const &auctionSlot)
Get time slot of the auction slot.
Definition AMMCore.cpp:108
NotTEC invalidAMMAsset(Issue const &issue, std::optional< std::pair< Issue, Issue > > const &pair=std::nullopt)
Definition AMMCore.cpp:66
Currency ammLPTCurrency(Currency const &cur1, Currency const &cur2)
Calculate Liquidity Provider Token (LPT) Currency.
Definition AMMCore.cpp:43
bool ammEnabled(Rules const &)
Return true if required AMM amendments are enabled.
Definition AMMCore.cpp:129
Issue ammLPTIssue(Currency const &cur1, Currency const &cur2, AccountID const &ammAccountID)
Calculate LPT Issue from AMM asset pair.
Definition AMMCore.cpp:57
@ current
This was a new validation and was added.
std::uint32_t constexpr AUCTION_SLOT_MIN_FEE_FRACTION
Definition AMMCore.h:39
Number feeMult(std::uint16_t tfee)
Get fee multiplier (1 - tfee) @tfee trading fee in basis points.
Definition AMMCore.h:110
std::uint32_t constexpr AUCTION_SLOT_FEE_SCALE_FACTOR
Definition AMMCore.h:37
Number getFee(std::uint16_t tfee)
Convert to the fee from the basis points.
Definition AMMCore.h:101
std::uint32_t constexpr VOTE_WEIGHT_SCALE_FACTOR
Definition AMMCore.h:45
NotTEC invalidAMMAssetPair(Issue const &issue1, Issue const &issue2, std::optional< std::pair< Issue, Issue > > const &pair=std::nullopt)
Definition AMMCore.cpp:80
std::uint32_t constexpr AUCTION_SLOT_INTERVAL_DURATION
Definition AMMCore.h:40
Number feeMultHalf(std::uint16_t tfee)
Get fee multiplier (1 - tfee / 2) @tfee trading fee in basis points.
Definition AMMCore.h:119
std::uint16_t constexpr VOTE_MAX_SLOTS
Definition AMMCore.h:44
std::uint16_t constexpr TRADING_FEE_THRESHOLD
Definition AMMCore.h:31
std::uint16_t constexpr AUCTION_SLOT_MAX_AUTH_ACCOUNTS
Definition AMMCore.h:36
std::uint32_t constexpr AUCTION_SLOT_DISCOUNTED_FEE_FRACTION
Definition AMMCore.h:38