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/ledger/helpers/RippleStateHelpers.h>
7#include <xrpl/protocol/STAmount.h>
8#include <xrpl/protocol/STLedgerEntry.h>
9#include <xrpl/protocol/TER.h>
10
11namespace xrpl {
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
65getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account);
66
69STAmount
70ammAccountHolds(ReadView const& view, AccountID const& ammAccountID, Issue const& issue);
71
75TER
76deleteAMMAccount(Sandbox& view, Issue const& asset, Issue const& asset2, beast::Journal j);
77
80void
82 ApplyView& view,
84 AccountID const& account,
85 Issue const& lptIssue,
86 std::uint16_t tfee);
87
92Expected<bool, TER>
93isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID const& lpAccount);
94
99Expected<bool, TER>
101 Sandbox& sb,
102 STAmount const& lpTokens,
103 std::shared_ptr<SLE>& ammSle,
104 AccountID const& account);
105
106} // 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:183
FreezeHandling
Controls the treatment of frozen account balances.
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition AMMUtils.cpp:246
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:350
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:622
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:296
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:153
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:87
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:434