xrpld
Loading...
Searching...
No Matches
tx/transactors/dex/AMMClawback.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/core/ServiceRegistry.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/protocol/AccountID.h>
7#include <xrpl/protocol/STAmount.h>
8#include <xrpl/protocol/STTx.h>
9#include <xrpl/protocol/TER.h>
10#include <xrpl/protocol/XRPAmount.h>
11#include <xrpl/tx/ApplyContext.h>
12#include <xrpl/tx/Transactor.h>
13
14#include <cstdint>
15#include <optional>
16#include <tuple>
17
18namespace xrpl {
19class Sandbox;
20class AMMClawback : public Transactor
21{
22public:
24
25 explicit AMMClawback(ApplyContext& ctx) : Transactor(ctx)
26 {
27 }
28
29 static bool
31
32 static std::uint32_t
34
35 static NotTEC
36 preflight(PreflightContext const& ctx);
37
38 static TER
39 preclaim(PreclaimContext const& ctx);
40
41 TER
42 doApply() override;
43
44 void
45 visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override;
46
47 [[nodiscard]] bool
49 STTx const& tx,
50 TER result,
51 XRPAmount fee,
52 ReadView const& view,
53 beast::Journal const& j) override;
54
55private:
56 TER
58
74 SLE const& ammSle,
75 AccountID const& holder,
76 AccountID const& ammAccount,
77 STAmount const& amountBalance,
78 STAmount const& amount2Balance,
79 STAmount const& lptAMMBalance,
80 STAmount const& holdLPtokens,
81 STAmount const& amount);
82};
83
84} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
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.
static bool checkExtraFeatures(PreflightContext const &ctx)
TER applyGuts(Sandbox &view)
std::tuple< TER, STAmount, STAmount, std::optional< STAmount > > equalWithdrawMatchingOneAmount(Sandbox &view, SLE const &ammSle, AccountID const &holder, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount2Balance, STAmount const &lptAMMBalance, STAmount const &holdLPtokens, STAmount const &amount)
Withdraw both assets by providing maximum amount of asset1, asset2's amount will be calculated accord...
TER doApply() override
static constexpr auto kConsequencesFactory
State information when applying a tx.
A view into a ledger.
Definition ReadView.h:41
std::shared_ptr< STLedgerEntry const > const & const_ref
Discardable, editable view to a ledger.
Definition Sandbox.h:18
ApplyView & view()
Definition Transactor.h:175
Transactor(Transactor const &)=delete
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
STLedgerEntry SLE
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:607
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:572
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
TERSubset< CanCvtToTER > TER
Definition TER.h:647
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:83
State information when preflighting a tx.
Definition Transactor.h:38