xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
tx
transactors
dex
AMMContext.h
1
#pragma once
2
3
#include <xrpl/protocol/AccountID.h>
4
5
#include <
cstdint
>
6
7
namespace
xrpl
{
8
16
class
AMMContext
17
{
18
public
:
19
// Restrict number of AMM offers. If this restriction is removed
20
// then need to restrict in some other way because AMM offers are
21
// not counted in the BookStep offer counter.
22
static
constexpr
std::uint8_t
kMaxIterations
= 30;
23
24
private
:
25
// Tx account owner is required to get the AMM trading fee in BookStep
26
AccountID
accountID_
;
27
// true if payment has multiple paths
28
bool
multiPath_
{
false
};
29
// Is true if AMM offer is consumed during a payment engine iteration.
30
bool
ammUsed_
{
false
};
31
// Counter of payment engine iterations with consumed AMM
32
std::uint16_t
ammIters_
{0};
33
34
public
:
35
AMMContext
(
AccountID
const
&
account
,
bool
multiPath
)
36
:
accountID_
(
account
),
multiPath_
(
multiPath
)
37
{
38
}
39
~AMMContext
() =
default
;
40
AMMContext
(
AMMContext
const
&) =
delete
;
41
AMMContext
&
42
operator=
(
AMMContext
const
&) =
delete
;
43
44
[[nodiscard]]
bool
45
multiPath
()
const
46
{
47
return
multiPath_
;
48
}
49
50
void
51
setMultiPath
(
bool
fs)
52
{
53
multiPath_
= fs;
54
}
55
56
void
57
setAMMUsed
()
58
{
59
ammUsed_
=
true
;
60
}
61
62
void
63
update
()
64
{
65
if
(
ammUsed_
)
66
++
ammIters_
;
67
ammUsed_
=
false
;
68
}
69
70
[[nodiscard]]
bool
71
maxItersReached
()
const
72
{
73
return
ammIters_
>=
kMaxIterations
;
74
}
75
76
[[nodiscard]]
std::uint16_t
77
curIters
()
const
78
{
79
return
ammIters_
;
80
}
81
82
[[nodiscard]]
AccountID
83
account
()
const
84
{
85
return
accountID_
;
86
}
87
92
void
93
clear
()
94
{
95
ammUsed_
=
false
;
96
}
97
};
98
99
}
// namespace xrpl
xrpl::AMMContext::account
AccountID account() const
Definition
AMMContext.h:83
xrpl::AMMContext::kMaxIterations
static constexpr std::uint8_t kMaxIterations
Definition
AMMContext.h:22
xrpl::AMMContext::AMMContext
AMMContext(AMMContext const &)=delete
xrpl::AMMContext::maxItersReached
bool maxItersReached() const
Definition
AMMContext.h:71
xrpl::AMMContext::setAMMUsed
void setAMMUsed()
Definition
AMMContext.h:57
xrpl::AMMContext::setMultiPath
void setMultiPath(bool fs)
Definition
AMMContext.h:51
xrpl::AMMContext::operator=
AMMContext & operator=(AMMContext const &)=delete
xrpl::AMMContext::update
void update()
Definition
AMMContext.h:63
xrpl::AMMContext::AMMContext
AMMContext(AccountID const &account, bool multiPath)
Definition
AMMContext.h:35
xrpl::AMMContext::clear
void clear()
Strand execution may fail.
Definition
AMMContext.h:93
xrpl::AMMContext::ammUsed_
bool ammUsed_
Definition
AMMContext.h:30
xrpl::AMMContext::accountID_
AccountID accountID_
Definition
AMMContext.h:26
xrpl::AMMContext::ammIters_
std::uint16_t ammIters_
Definition
AMMContext.h:32
xrpl::AMMContext::~AMMContext
~AMMContext()=default
xrpl::AMMContext::multiPath
bool multiPath() const
Definition
AMMContext.h:45
xrpl::AMMContext::curIters
std::uint16_t curIters() const
Definition
AMMContext.h:77
xrpl::AMMContext::multiPath_
bool multiPath_
Definition
AMMContext.h:28
cstdint
std::uint8_t
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
Generated by
1.17.0