rippled
Loading...
Searching...
No Matches
AMMDelete.cpp
1#include <xrpld/app/misc/AMMUtils.h>
2#include <xrpld/app/tx/detail/AMMDelete.h>
3
4#include <xrpl/ledger/Sandbox.h>
5#include <xrpl/protocol/AMMCore.h>
6#include <xrpl/protocol/TER.h>
7#include <xrpl/protocol/TxFlags.h>
8
9namespace ripple {
10
11bool
16
19{
20 return tesSUCCESS;
21}
22
23TER
25{
26 auto const ammSle =
27 ctx.view.read(keylet::amm(ctx.tx[sfAsset], ctx.tx[sfAsset2]));
28 if (!ammSle)
29 {
30 JLOG(ctx.j.debug()) << "AMM Delete: Invalid asset pair.";
31 return terNO_AMM;
32 }
33
34 auto const lpTokensBalance = (*ammSle)[sfLPTokenBalance];
35 if (lpTokensBalance != beast::zero)
36 return tecAMM_NOT_EMPTY;
37
38 return tesSUCCESS;
39}
40
41TER
43{
44 // This is the ledger view that we work against. Transactions are applied
45 // as we go on processing transactions.
46 Sandbox sb(&ctx_.view());
47
48 auto const ter = deleteAMMAccount(
49 sb, ctx_.tx[sfAsset].get<Issue>(), ctx_.tx[sfAsset2].get<Issue>(), j_);
50 if (ter == tesSUCCESS || ter == tecINCOMPLETE)
51 sb.apply(ctx_.rawView());
52
53 return ter;
54}
55
56} // namespace ripple
Stream debug() const
Definition Journal.h:309
static NotTEC preflight(PreflightContext const &ctx)
Definition AMMDelete.cpp:18
TER doApply() override
Definition AMMDelete.cpp:42
static TER preclaim(PreclaimContext const &ctx)
Definition AMMDelete.cpp:24
static bool checkExtraFeatures(PreflightContext const &ctx)
Definition AMMDelete.cpp:12
ApplyView & view()
A currency issued by an account.
Definition Issue.h:14
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
Discardable, editable view to a ledger.
Definition Sandbox.h:16
void apply(RawView &to)
Definition Sandbox.h:36
beast::Journal const j_
Definition Transactor.h:126
ApplyContext & ctx_
Definition Transactor.h:124
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition Indexes.cpp:427
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition AMMUtils.cpp:264
bool ammEnabled(Rules const &)
Return true if required AMM amendments are enabled.
Definition AMMCore.cpp:110
@ tecINCOMPLETE
Definition TER.h:317
@ tecAMM_NOT_EMPTY
Definition TER.h:315
@ tesSUCCESS
Definition TER.h:226
@ terNO_AMM
Definition TER.h:208
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:61
ReadView const & view
Definition Transactor.h:64
beast::Journal const j
Definition Transactor.h:69
State information when preflighting a tx.
Definition Transactor.h:16