rippled
Loading...
Searching...
No Matches
AMMDeposit.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2023 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TX_AMMDEPOSIT_H_INCLUDED
21#define RIPPLE_TX_AMMDEPOSIT_H_INCLUDED
22
23#include <xrpld/app/tx/detail/Transactor.h>
24
25namespace ripple {
26
27class Sandbox;
28
62class AMMDeposit : public Transactor
63{
64public:
66
67 explicit AMMDeposit(ApplyContext& ctx) : Transactor(ctx)
68 {
69 }
70
71 static NotTEC
72 preflight(PreflightContext const& ctx);
73
74 static TER
75 preclaim(PreclaimContext const& ctx);
76
77 TER
78 doApply() override;
79
80private:
83
100 deposit(
101 Sandbox& view,
102 AccountID const& ammAccount,
103 STAmount const& amountBalance,
104 STAmount const& amountDeposit,
105 std::optional<STAmount> const& amount2Deposit,
106 STAmount const& lptAMMBalance,
107 STAmount const& lpTokensDeposit,
108 std::optional<STAmount> const& depositMin,
109 std::optional<STAmount> const& deposit2Min,
110 std::optional<STAmount> const& lpTokensDepositMin,
111 std::uint16_t tfee);
112
128 Sandbox& view,
129 AccountID const& ammAccount,
130 STAmount const& amountBalance,
131 STAmount const& amount2Balance,
132 STAmount const& lptAMMBalance,
133 STAmount const& lpTokensDeposit,
134 std::optional<STAmount> const& depositMin,
135 std::optional<STAmount> const& deposit2Min,
136 std::uint16_t tfee);
137
154 Sandbox& view,
155 AccountID const& ammAccount,
156 STAmount const& amountBalance,
157 STAmount const& amount2Balance,
158 STAmount const& lptAMMBalance,
159 STAmount const& amount,
160 STAmount const& amount2,
161 std::optional<STAmount> const& lpTokensDepositMin,
162 std::uint16_t tfee);
163
177 Sandbox& view,
178 AccountID const& ammAccount,
179 STAmount const& amountBalance,
180 STAmount const& lptAMMBalance,
181 STAmount const& amount,
182 std::optional<STAmount> const& lpTokensDepositMin,
183 std::uint16_t tfee);
184
198 Sandbox& view,
199 AccountID const& ammAccount,
200 STAmount const& amountBalance,
201 STAmount const& amount,
202 STAmount const& lptAMMBalance,
203 STAmount const& lpTokensDeposit,
204 std::uint16_t tfee);
205
219 Sandbox& view,
220 AccountID const& ammAccount,
221 STAmount const& amountBalance,
222 STAmount const& amount,
223 STAmount const& lptAMMBalance,
224 STAmount const& ePrice,
225 std::uint16_t tfee);
226
237 Sandbox& view,
238 AccountID const& ammAccount,
239 STAmount const& amount,
240 STAmount const& amount2,
241 Issue const& lptIssue,
242 std::uint16_t tfee);
243};
244
245} // namespace ripple
246
247#endif // RIPPLE_TX_AMMDEPOSIT_H_INCLUDED
AMMDeposit implements AMM deposit Transactor.
Definition AMMDeposit.h:63
std::pair< TER, bool > applyGuts(Sandbox &view)
std::pair< TER, STAmount > equalDepositLimit(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount2Balance, STAmount const &lptAMMBalance, STAmount const &amount, STAmount const &amount2, std::optional< STAmount > const &lpTokensDepositMin, std::uint16_t tfee)
Equal asset deposit (Asset1In, Asset2In) with the constraint on the maximum amount of both assets tha...
std::pair< TER, STAmount > singleDepositEPrice(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount, STAmount const &lptAMMBalance, STAmount const &ePrice, std::uint16_t tfee)
Single asset deposit (Asset1In, EPrice) with two constraints.
static TER preclaim(PreclaimContext const &ctx)
std::pair< TER, STAmount > singleDeposit(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &lptAMMBalance, STAmount const &amount, std::optional< STAmount > const &lpTokensDepositMin, std::uint16_t tfee)
Single asset deposit (Asset1In) by the amount.
static NotTEC preflight(PreflightContext const &ctx)
std::pair< TER, STAmount > equalDepositTokens(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount2Balance, STAmount const &lptAMMBalance, STAmount const &lpTokensDeposit, std::optional< STAmount > const &depositMin, std::optional< STAmount > const &deposit2Min, std::uint16_t tfee)
Equal asset deposit (LPTokens) for the specified share of the AMM instance pools.
static constexpr ConsequencesFactoryType ConsequencesFactory
Definition AMMDeposit.h:65
TER doApply() override
std::pair< TER, STAmount > equalDepositInEmptyState(Sandbox &view, AccountID const &ammAccount, STAmount const &amount, STAmount const &amount2, Issue const &lptIssue, std::uint16_t tfee)
Equal deposit in empty AMM state (LP tokens balance is 0)
std::pair< TER, STAmount > singleDepositTokens(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amount, STAmount const &lptAMMBalance, STAmount const &lpTokensDeposit, std::uint16_t tfee)
Single asset deposit (Asset1In, LPTokens) by the tokens.
std::pair< TER, STAmount > deposit(Sandbox &view, AccountID const &ammAccount, STAmount const &amountBalance, STAmount const &amountDeposit, std::optional< STAmount > const &amount2Deposit, STAmount const &lptAMMBalance, STAmount const &lpTokensDeposit, std::optional< STAmount > const &depositMin, std::optional< STAmount > const &deposit2Min, std::optional< STAmount > const &lpTokensDepositMin, std::uint16_t tfee)
Deposit requested assets and token amount into LP account.
AMMDeposit(ApplyContext &ctx)
Definition AMMDeposit.h:67
State information when applying a tx.
A currency issued by an account.
Definition Issue.h:33
Discardable, editable view to a ledger.
Definition Sandbox.h:35
ApplyView & view()
Definition Transactor.h:161
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:80
State information when preflighting a tx.
Definition Transactor.h:35