rippled
Loading...
Searching...
No Matches
AMMUtils.h
1#pragma once
2
3#include <xrpl/basics/Expected.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/ledger/View.h>
6#include <xrpl/protocol/STAmount.h>
7#include <xrpl/protocol/STLedgerEntry.h>
8#include <xrpl/protocol/TER.h>
9
10namespace xrpl {
11
12class ReadView;
13class ApplyView;
14class Sandbox;
15class NetClock;
16
21 ReadView const& view,
22 AccountID const& ammAccountID,
23 Issue const& issue1,
24 Issue const& issue2,
25 FreezeHandling freezeHandling,
26 beast::Journal const j);
27
32Expected<std::tuple<STAmount, STAmount, STAmount>, TER>
34 ReadView const& view,
35 SLE const& ammSle,
36 std::optional<Issue> const& optIssue1,
37 std::optional<Issue> const& optIssue2,
38 FreezeHandling freezeHandling,
39 beast::Journal const j);
40
43STAmount
45 ReadView const& view,
46 Currency const& cur1,
47 Currency const& cur2,
48 AccountID const& ammAccount,
49 AccountID const& lpAccount,
50 beast::Journal const j);
51
52STAmount
53ammLPHolds(ReadView const& view, SLE const& ammSle, AccountID const& lpAccount, beast::Journal const j);
54
60getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account);
61
64STAmount
65ammAccountHolds(ReadView const& view, AccountID const& ammAccountID, Issue const& issue);
66
70TER
71deleteAMMAccount(Sandbox& view, Issue const& asset, Issue const& asset2, beast::Journal j);
72
75void
77 ApplyView& view,
79 AccountID const& account,
80 Issue const& lptIssue,
81 std::uint16_t tfee);
82
87Expected<bool, TER>
88isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID const& lpAccount);
89
94Expected<bool, TER>
96 Sandbox& sb,
97 STAmount const& lpTokens,
99 AccountID const& account);
100
101} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:36
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition AMMUtils.cpp:166
FreezeHandling
Controls the treatment of frozen account balances.
Definition View.h:58
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition AMMUtils.cpp:222
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
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:314
STLedgerEntry SLE
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:26
TERSubset< CanCvtToTER > TER
Definition TER.h:620
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:269
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
std::uint16_t getTradingFee(ReadView const &view, SLE const &ammSle, AccountID const &account)
Get AMM trading fee for the given account.
Definition AMMUtils.cpp:139
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:80
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:390