xrpld
Loading...
Searching...
No Matches
tx/transactors/dex/OfferCreate.h
1#pragma once
2
3#include <xrpl/protocol/Quality.h>
4#include <xrpl/tx/Transactor.h>
5
6namespace xrpl {
7
9class Sandbox;
10
12class OfferCreate : public Transactor
13{
14public:
16
18 explicit OfferCreate(ApplyContext& ctx) : Transactor(ctx)
19 {
20 }
21
22 static TxConsequences
24
25 static bool
27
28 static std::uint32_t
30
32 static NotTEC
33 preflight(PreflightContext const& ctx);
34
36 static TER
37 preclaim(PreclaimContext const& ctx);
38
40 TER
41 doApply() override;
42
43 void
44 visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override;
45
46 [[nodiscard]] bool
48 STTx const& tx,
49 TER result,
50 XRPAmount fee,
51 ReadView const& view,
52 beast::Journal const& j) override;
53
54private:
56 applyGuts(Sandbox& view, Sandbox& viewCancel);
57
58 // Determine if we are authorized to hold the asset we want to get.
59 static TER
61 ReadView const& view,
62 ApplyFlags const flags,
63 AccountID const id,
64 beast::Journal const j,
65 Asset const& asset);
66
67 // Use the payment flow code to perform offer crossing.
70 PaymentSandbox& psb,
71 PaymentSandbox& psbCancel,
72 Amounts const& takerAmount,
73 std::optional<uint256> const& domainID);
74
75 static std::string
76 formatAmount(STAmount const& amount);
77
78 TER
80 Sandbox& sb,
82 Keylet const& offerIndex,
83 STAmount const& saTakerPays,
84 STAmount const& saTakerGets,
85 std::uint64_t openRate,
86 std::function<void(SLE::ref, std::optional<uint256>)> const& setDir);
87};
88
89} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:38
State information when applying a tx.
static TER preclaim(PreclaimContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
static TER checkAcceptAsset(ReadView const &view, ApplyFlags const flags, AccountID const id, beast::Journal const j, Asset const &asset)
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.
TER doApply() override
Precondition: fee collection is likely.
static TxConsequences makeTxConsequences(PreflightContext const &ctx)
std::pair< TER, Amounts > flowCross(PaymentSandbox &psb, PaymentSandbox &psbCancel, Amounts const &takerAmount, std::optional< uint256 > const &domainID)
static bool checkExtraFeatures(PreflightContext const &ctx)
OfferCreate(ApplyContext &ctx)
Construct a Transactor subclass that creates an offer in the ledger.
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
static NotTEC preflight(PreflightContext const &ctx)
Enforce constraints beyond those of the Transactor base class.
TER applyHybrid(Sandbox &sb, STLedgerEntry::pointer sleOffer, Keylet const &offerIndex, STAmount const &saTakerPays, STAmount const &saTakerGets, std::uint64_t openRate, std::function< void(SLE::ref, std::optional< uint256 >)> const &setDir)
std::pair< TER, bool > applyGuts(Sandbox &view, Sandbox &viewCancel)
static constexpr auto kConsequencesFactory
static std::string formatAmount(STAmount const &amount)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
A wrapper which makes credits unavailable to balances.
A view into a ledger.
Definition ReadView.h:31
std::shared_ptr< STLedgerEntry > const & ref
std::shared_ptr< STLedgerEntry > pointer
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
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition applySteps.h:38
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
TAmounts< STAmount, STAmount > Amounts
Definition Quality.h:64
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
ApplyFlags
Definition ApplyView.h:12
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
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
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