xrpld
Loading...
Searching...
No Matches
tx/transactors/dex/AMMDeposit.h
1#pragma once
2
3#include <xrpl/tx/Transactor.h>
4
5namespace xrpl {
6
7class Sandbox;
8
42class AMMDeposit : public Transactor
43{
44public:
46
47 explicit AMMDeposit(ApplyContext& ctx) : Transactor(ctx)
48 {
49 }
50
51 static bool
53
54 static std::uint32_t
56
57 static NotTEC
58 preflight(PreflightContext const& ctx);
59
60 static TER
61 preclaim(PreclaimContext const& ctx);
62
63 TER
64 doApply() override;
65
66 void
67 visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override;
68
69 [[nodiscard]] bool
71 STTx const& tx,
72 TER result,
73 XRPAmount fee,
74 ReadView const& view,
75 beast::Journal const& j) override;
76
77private:
80
97 deposit(
99 AccountID const& ammAccount,
100 STAmount const& amountBalance,
101 STAmount const& amountDeposit,
102 std::optional<STAmount> const& amount2Deposit,
103 STAmount const& lptAMMBalance,
104 STAmount const& lpTokensDeposit,
105 std::optional<STAmount> const& depositMin,
106 std::optional<STAmount> const& deposit2Min,
107 std::optional<STAmount> const& lpTokensDepositMin,
108 std::uint16_t tfee);
109
125 Sandbox& view,
126 AccountID const& ammAccount,
127 STAmount const& amountBalance,
128 STAmount const& amount2Balance,
129 STAmount const& lptAMMBalance,
130 STAmount const& lpTokensDeposit,
131 std::optional<STAmount> const& depositMin,
132 std::optional<STAmount> const& deposit2Min,
133 std::uint16_t tfee);
134
151 Sandbox& view,
152 AccountID const& ammAccount,
153 STAmount const& amountBalance,
154 STAmount const& amount2Balance,
155 STAmount const& lptAMMBalance,
156 STAmount const& amount,
157 STAmount const& amount2,
158 std::optional<STAmount> const& lpTokensDepositMin,
159 std::uint16_t tfee);
160
174 Sandbox& view,
175 AccountID const& ammAccount,
176 STAmount const& amountBalance,
177 STAmount const& lptAMMBalance,
178 STAmount const& amount,
179 std::optional<STAmount> const& lpTokensDepositMin,
180 std::uint16_t tfee);
181
195 Sandbox& view,
196 AccountID const& ammAccount,
197 STAmount const& amountBalance,
198 STAmount const& amount,
199 STAmount const& lptAMMBalance,
200 STAmount const& lpTokensDeposit,
201 std::uint16_t tfee);
202
216 Sandbox& view,
217 AccountID const& ammAccount,
218 STAmount const& amountBalance,
219 STAmount const& amount,
220 STAmount const& lptAMMBalance,
221 STAmount const& ePrice,
222 std::uint16_t tfee);
223
234 Sandbox& view,
235 AccountID const& ammAccount,
236 STAmount const& amount,
237 STAmount const& amount2,
238 Asset const& lptIssue,
239 std::uint16_t tfee);
240};
241
242} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:38
static TER preclaim(PreclaimContext const &ctx)
static bool checkExtraFeatures(PreflightContext const &ctx)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static constexpr auto kConsequencesFactory
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
std::pair< TER, STAmount > singleDepositTokens(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount, STAmount const &lptAMMBalance, STAmount const &lpTokensDeposit, std::uint16_t tfee)
Single asset deposit (Asset1In, LPTokens) by the tokens.
std::pair< TER, STAmount > equalDepositInEmptyState(Sandbox &view, AccountID const &ammAccount, STAmount const &amount, STAmount const &amount2, Asset const &lptIssue, std::uint16_t tfee)
Equal deposit in empty AMM state (LP tokens balance is 0).
std::pair< TER, STAmount > equalDepositTokens(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount2Balance, STAmount const &lptAMMBalance, STAmount const &lpTokensDeposit, std::optional< STAmount > const &depositMin, std::optional< STAmount > const &deposit2Min, std::uint16_t tfee)
Equal asset deposit (LPTokens) for the specified share of the AMM instance pools.
std::pair< TER, STAmount > singleDepositEPrice(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount, STAmount const &lptAMMBalance, STAmount const &ePrice, std::uint16_t tfee)
Single asset deposit (Asset1In, EPrice) with two constraints.
std::pair< TER, bool > applyGuts(Sandbox &view)
std::pair< TER, STAmount > singleDeposit(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &lptAMMBalance, STAmount const &amount, std::optional< STAmount > const &lpTokensDepositMin, std::uint16_t tfee)
Single asset deposit (Asset1In) by the amount.
static NotTEC preflight(PreflightContext const &ctx)
TER doApply() override
bool finalizeInvariants(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j) override
Check transaction-specific post-conditions after all entries have been visited.
std::pair< TER, STAmount > equalDepositLimit(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount2Balance, STAmount const &lptAMMBalance, STAmount const &amount, STAmount const &amount2, std::optional< STAmount > const &lpTokensDepositMin, std::uint16_t tfee)
Equal asset deposit (Asset1In, Asset2In) with the constraint on the maximum amount of both assets tha...
std::pair< TER, STAmount > deposit(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amountDeposit, std::optional< STAmount > const &amount2Deposit, STAmount const &lptAMMBalance, STAmount const &lpTokensDeposit, std::optional< STAmount > const &depositMin, std::optional< STAmount > const &deposit2Min, std::optional< STAmount > const &lpTokensDepositMin, std::uint16_t tfee)
Deposit requested assets and token amount into LP account.
State information when applying a tx.
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry const > const & const_ref
Discardable, editable view to a ledger.
Definition Sandbox.h:15
ApplyView & view()
Definition Transactor.h:136
Transactor(Transactor const &)=delete
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:594
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:554
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
TERSubset< CanCvtToTER > TER
Definition TER.h:634
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:61
State information when preflighting a tx.
Definition Transactor.h:18