rippled
Loading...
Searching...
No Matches
xrpld
app
tx
detail
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
9
namespace
xrpl
{
10
11
bool
12
AMMDelete::checkExtraFeatures
(
PreflightContext
const
& ctx)
13
{
14
return
ammEnabled
(ctx.
rules
);
15
}
16
17
NotTEC
18
AMMDelete::preflight
(
PreflightContext
const
& ctx)
19
{
20
return
tesSUCCESS
;
21
}
22
23
TER
24
AMMDelete::preclaim
(
PreclaimContext
const
& ctx)
25
{
26
auto
const
ammSle = ctx.
view
.
read
(
keylet::amm
(ctx.
tx
[sfAsset], ctx.
tx
[sfAsset2]));
27
if
(!ammSle)
28
{
29
JLOG(ctx.
j
.
debug
()) <<
"AMM Delete: Invalid asset pair."
;
30
return
terNO_AMM
;
31
}
32
33
auto
const
lpTokensBalance = (*ammSle)[sfLPTokenBalance];
34
if
(lpTokensBalance != beast::zero)
35
return
tecAMM_NOT_EMPTY
;
36
37
return
tesSUCCESS
;
38
}
39
40
TER
41
AMMDelete::doApply
()
42
{
43
// This is the ledger view that we work against. Transactions are applied
44
// as we go on processing transactions.
45
Sandbox
sb(&
ctx_
.
view
());
46
47
auto
const
ter =
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:24
xrpl::AMMDelete::doApply
TER doApply() override
Definition
AMMDelete.cpp:41
xrpl::AMMDelete::checkExtraFeatures
static bool checkExtraFeatures(PreflightContext const &ctx)
Definition
AMMDelete.cpp:12
xrpl::AMMDelete::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
AMMDelete.cpp:18
xrpl::ApplyContext::tx
STTx const & tx
Definition
ApplyContext.h:44
xrpl::ApplyContext::rawView
RawView & rawView()
Definition
ApplyContext.h:63
xrpl::ApplyContext::view
ApplyView & view()
Definition
ApplyContext.h:50
xrpl::Issue
A currency issued by an account.
Definition
Issue.h:14
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:16
xrpl::Sandbox::apply
void apply(RawView &to)
Definition
Sandbox.h:36
xrpl::TERSubset
Definition
TER.h:396
xrpl::Transactor::j_
beast::Journal const j_
Definition
Transactor.h:111
xrpl::Transactor::ctx_
ApplyContext & ctx_
Definition
Transactor.h:109
xrpl::keylet::amm
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition
Indexes.cpp:393
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:6
xrpl::terNO_AMM
@ terNO_AMM
Definition
TER.h:208
xrpl::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition
AMMUtils.cpp:222
xrpl::ammEnabled
bool ammEnabled(Rules const &)
Return true if required AMM amendments are enabled.
Definition
AMMCore.cpp:95
xrpl::tecAMM_NOT_EMPTY
@ tecAMM_NOT_EMPTY
Definition
TER.h:315
xrpl::tecINCOMPLETE
@ tecINCOMPLETE
Definition
TER.h:317
xrpl::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:226
xrpl::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition
Transactor.h:54
xrpl::PreclaimContext::view
ReadView const & view
Definition
Transactor.h:57
xrpl::PreclaimContext::tx
STTx const & tx
Definition
Transactor.h:60
xrpl::PreclaimContext::j
beast::Journal const j
Definition
Transactor.h:62
xrpl::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:16
xrpl::PreflightContext::rules
Rules const rules
Definition
Transactor.h:20
Generated by
1.9.8