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