rippled
Loading...
Searching...
No Matches
AMMUtils.h
1#ifndef XRPL_APP_MISC_AMMUTILS_H_INCLUDED
2#define XRPL_APP_MISC_AMMUTILS_H_INCLUDED
3
4#include <xrpl/basics/Expected.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/ledger/View.h>
7#include <xrpl/protocol/STAmount.h>
8#include <xrpl/protocol/STLedgerEntry.h>
9#include <xrpl/protocol/TER.h>
10
11namespace ripple {
12
13class ReadView;
14class ApplyView;
15class Sandbox;
16class NetClock;
17
22 ReadView const& view,
23 AccountID const& ammAccountID,
24 Issue const& issue1,
25 Issue const& issue2,
26 FreezeHandling freezeHandling,
27 beast::Journal const j);
28
33Expected<std::tuple<STAmount, STAmount, STAmount>, TER>
35 ReadView const& view,
36 SLE const& ammSle,
37 std::optional<Issue> const& optIssue1,
38 std::optional<Issue> const& optIssue2,
39 FreezeHandling freezeHandling,
40 beast::Journal const j);
41
44STAmount
46 ReadView const& view,
47 Currency const& cur1,
48 Currency const& cur2,
49 AccountID const& ammAccount,
50 AccountID const& lpAccount,
51 beast::Journal const j);
52
53STAmount
55 ReadView const& view,
56 SLE const& ammSle,
57 AccountID const& lpAccount,
58 beast::Journal const j);
59
66 ReadView const& view,
67 SLE const& ammSle,
68 AccountID const& account);
69
72STAmount
74 ReadView const& view,
75 AccountID const& ammAccountID,
76 Issue const& issue);
77
81TER
83 Sandbox& view,
84 Issue const& asset,
85 Issue const& asset2,
87
90void
92 ApplyView& view,
94 AccountID const& account,
95 Issue const& lptIssue,
96 std::uint16_t tfee);
97
102Expected<bool, TER>
104 ReadView const& view,
105 Issue const& ammIssue,
106 AccountID const& lpAccount);
107
112Expected<bool, TER>
114 Sandbox& sb,
115 STAmount const& lpTokens,
116 std::shared_ptr<SLE>& ammSle,
117 AccountID const& account);
118
119} // namespace ripple
120
121#endif // XRPL_APP_MISC_AMMUTILS_H_INCLUDED
A generic endpoint for log messages.
Definition Journal.h:41
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:29
FreezeHandling
Controls the treatment of frozen account balances.
Definition View.h:58
std::uint16_t getTradingFee(ReadView const &view, SLE const &ammSle, AccountID const &account)
Get AMM trading fee for the given account.
Definition AMMUtils.cpp:160
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition AMMUtils.cpp:264
Expected< bool, TER > isOnlyLiquidityProvider(ReadView const &view, Issue const &ammIssue, AccountID const &lpAccount)
Return true if the Liquidity Provider is the only AMM provider, false otherwise.
Definition AMMUtils.cpp:368
Expected< bool, TER > verifyAndAdjustLPTokenBalance(Sandbox &sb, STAmount const &lpTokens, std::shared_ptr< SLE > &ammSle, AccountID const &account)
Due to rounding, the LPTokenBalance of the last LP might not match the LP's trustline balance.
Definition AMMUtils.cpp:450
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition AMMUtils.cpp:321
STAmount ammLPHolds(ReadView const &view, Currency const &cur1, Currency const &cur2, AccountID const &ammAccount, AccountID const &lpAccount, beast::Journal const j)
Get the balance of LP tokens.
Definition AMMUtils.cpp:94
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:37
std::pair< STAmount, STAmount > ammPoolHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue1, Issue const &issue2, FreezeHandling freezeHandling, beast::Journal const j)
Get AMM pool balances.
Definition AMMUtils.cpp:12
Expected< std::tuple< STAmount, STAmount, STAmount >, TER > ammHolds(ReadView const &view, SLE const &ammSle, std::optional< Issue > const &optIssue1, std::optional< Issue > const &optIssue2, FreezeHandling freezeHandling, beast::Journal const j)
Get AMM pool and LP token balances.
Definition AMMUtils.cpp:28
STLedgerEntry SLE
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition AMMUtils.cpp:192
TERSubset< CanCvtToTER > TER
Definition TER.h:630