diff --git a/AMMBid_8cpp_source.html b/AMMBid_8cpp_source.html index 89984d7fc3..ea15b8937f 100644 --- a/AMMBid_8cpp_source.html +++ b/AMMBid_8cpp_source.html @@ -244,195 +244,205 @@ $(function() {
173  return {tecINTERNAL, false};
174  STAmount const lptAMMBalance = (*ammSle)[sfLPTokenBalance];
175  auto const lpTokens = ammLPHolds(sb, *ammSle, account_, ctx_.journal);
-
176  if (!ammSle->isFieldPresent(sfAuctionSlot))
-
177  ammSle->makeFieldPresent(sfAuctionSlot);
-
178  auto& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot);
-
179  auto const current =
-
180  duration_cast<seconds>(
-
181  ctx_.view().info().parentCloseTime.time_since_epoch())
-
182  .count();
-
183  // Auction slot discounted fee
-
184  auto const discountedFee =
-
185  (*ammSle)[sfTradingFee] / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION;
-
186  auto const tradingFee = getFee((*ammSle)[sfTradingFee]);
-
187  // Min price
-
188  auto const minSlotPrice =
-
189  lptAMMBalance * tradingFee / AUCTION_SLOT_MIN_FEE_FRACTION;
-
190 
-
191  std::uint32_t constexpr tailingSlot = AUCTION_SLOT_TIME_INTERVALS - 1;
-
192 
-
193  // If seated then it is the current slot-holder time slot, otherwise
-
194  // the auction slot is not owned. Slot range is in {0-19}
-
195  auto const timeSlot = ammAuctionTimeSlot(current, auctionSlot);
-
196 
-
197  // Account must exist and the slot not expired.
-
198  auto validOwner = [&](AccountID const& account) {
-
199  // Valid range is 0-19 but the tailing slot pays MinSlotPrice
-
200  // and doesn't refund so the check is < instead of <= to optimize.
-
201  return timeSlot && *timeSlot < tailingSlot &&
-
202  sb.read(keylet::account(account));
-
203  };
-
204 
-
205  auto updateSlot = [&](std::uint32_t fee,
-
206  Number const& minPrice,
-
207  Number const& burn) -> TER {
-
208  auctionSlot.setAccountID(sfAccount, account_);
-
209  auctionSlot.setFieldU32(sfExpiration, current + TOTAL_TIME_SLOT_SECS);
-
210  if (fee != 0)
-
211  auctionSlot.setFieldU16(sfDiscountedFee, fee);
-
212  else if (auctionSlot.isFieldPresent(sfDiscountedFee))
-
213  auctionSlot.makeFieldAbsent(sfDiscountedFee);
-
214  auctionSlot.setFieldAmount(
-
215  sfPrice, toSTAmount(lpTokens.issue(), minPrice));
-
216  if (ctx_.tx.isFieldPresent(sfAuthAccounts))
-
217  auctionSlot.setFieldArray(
-
218  sfAuthAccounts, ctx_.tx.getFieldArray(sfAuthAccounts));
-
219  else
-
220  auctionSlot.makeFieldAbsent(sfAuthAccounts);
-
221  // Burn the remaining bid amount
-
222  auto const saBurn = adjustLPTokens(
-
223  lptAMMBalance, toSTAmount(lptAMMBalance.issue(), burn), false);
-
224  if (saBurn >= lptAMMBalance)
-
225  {
-
226  // This error case should never occur.
-
227  JLOG(ctx_.journal.fatal())
-
228  << "AMM Bid: LP Token burn exceeds AMM balance " << burn << " "
-
229  << lptAMMBalance;
-
230  return tecINTERNAL;
-
231  }
-
232  auto res =
-
233  redeemIOU(sb, account_, saBurn, lpTokens.issue(), ctx_.journal);
-
234  if (res != tesSUCCESS)
+
176  auto const& rules = ctx_.view().rules();
+
177  if (!rules.enabled(fixInnerObjTemplate))
+
178  {
+
179  if (!ammSle->isFieldPresent(sfAuctionSlot))
+
180  ammSle->makeFieldPresent(sfAuctionSlot);
+
181  }
+
182  else
+
183  {
+
184  assert(ammSle->isFieldPresent(sfAuctionSlot));
+
185  if (!ammSle->isFieldPresent(sfAuctionSlot))
+
186  return {tecINTERNAL, false};
+
187  }
+
188  auto& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot);
+
189  auto const current =
+
190  duration_cast<seconds>(
+
191  ctx_.view().info().parentCloseTime.time_since_epoch())
+
192  .count();
+
193  // Auction slot discounted fee
+
194  auto const discountedFee =
+
195  (*ammSle)[sfTradingFee] / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION;
+
196  auto const tradingFee = getFee((*ammSle)[sfTradingFee]);
+
197  // Min price
+
198  auto const minSlotPrice =
+
199  lptAMMBalance * tradingFee / AUCTION_SLOT_MIN_FEE_FRACTION;
+
200 
+
201  std::uint32_t constexpr tailingSlot = AUCTION_SLOT_TIME_INTERVALS - 1;
+
202 
+
203  // If seated then it is the current slot-holder time slot, otherwise
+
204  // the auction slot is not owned. Slot range is in {0-19}
+
205  auto const timeSlot = ammAuctionTimeSlot(current, auctionSlot);
+
206 
+
207  // Account must exist and the slot not expired.
+
208  auto validOwner = [&](AccountID const& account) {
+
209  // Valid range is 0-19 but the tailing slot pays MinSlotPrice
+
210  // and doesn't refund so the check is < instead of <= to optimize.
+
211  return timeSlot && *timeSlot < tailingSlot &&
+
212  sb.read(keylet::account(account));
+
213  };
+
214 
+
215  auto updateSlot = [&](std::uint32_t fee,
+
216  Number const& minPrice,
+
217  Number const& burn) -> TER {
+
218  auctionSlot.setAccountID(sfAccount, account_);
+
219  auctionSlot.setFieldU32(sfExpiration, current + TOTAL_TIME_SLOT_SECS);
+
220  if (fee != 0)
+
221  auctionSlot.setFieldU16(sfDiscountedFee, fee);
+
222  else if (auctionSlot.isFieldPresent(sfDiscountedFee))
+
223  auctionSlot.makeFieldAbsent(sfDiscountedFee);
+
224  auctionSlot.setFieldAmount(
+
225  sfPrice, toSTAmount(lpTokens.issue(), minPrice));
+
226  if (ctx_.tx.isFieldPresent(sfAuthAccounts))
+
227  auctionSlot.setFieldArray(
+
228  sfAuthAccounts, ctx_.tx.getFieldArray(sfAuthAccounts));
+
229  else
+
230  auctionSlot.makeFieldAbsent(sfAuthAccounts);
+
231  // Burn the remaining bid amount
+
232  auto const saBurn = adjustLPTokens(
+
233  lptAMMBalance, toSTAmount(lptAMMBalance.issue(), burn), false);
+
234  if (saBurn >= lptAMMBalance)
235  {
-
236  JLOG(ctx_.journal.debug()) << "AMM Bid: failed to redeem.";
-
237  return res;
-
238  }
-
239  ammSle->setFieldAmount(sfLPTokenBalance, lptAMMBalance - saBurn);
-
240  sb.update(ammSle);
-
241  return tesSUCCESS;
-
242  };
-
243 
-
244  TER res = tesSUCCESS;
-
245 
-
246  auto const bidMin = ctx_.tx[~sfBidMin];
-
247  auto const bidMax = ctx_.tx[~sfBidMax];
-
248 
-
249  auto getPayPrice =
-
250  [&](Number const& computedPrice) -> Expected<Number, TER> {
-
251  auto const payPrice = [&]() -> std::optional<Number> {
-
252  // Both min/max bid price are defined
-
253  if (bidMin && bidMax)
-
254  {
-
255  if (computedPrice <= *bidMax)
-
256  return std::max(computedPrice, Number(*bidMin));
-
257  JLOG(ctx_.journal.debug())
-
258  << "AMM Bid: not in range " << computedPrice << " "
-
259  << *bidMin << " " << *bidMax;
-
260  return std::nullopt;
-
261  }
-
262  // Bidder pays max(bidPrice, computedPrice)
-
263  if (bidMin)
+
236  // This error case should never occur.
+
237  JLOG(ctx_.journal.fatal())
+
238  << "AMM Bid: LP Token burn exceeds AMM balance " << burn << " "
+
239  << lptAMMBalance;
+
240  return tecINTERNAL;
+
241  }
+
242  auto res =
+
243  redeemIOU(sb, account_, saBurn, lpTokens.issue(), ctx_.journal);
+
244  if (res != tesSUCCESS)
+
245  {
+
246  JLOG(ctx_.journal.debug()) << "AMM Bid: failed to redeem.";
+
247  return res;
+
248  }
+
249  ammSle->setFieldAmount(sfLPTokenBalance, lptAMMBalance - saBurn);
+
250  sb.update(ammSle);
+
251  return tesSUCCESS;
+
252  };
+
253 
+
254  TER res = tesSUCCESS;
+
255 
+
256  auto const bidMin = ctx_.tx[~sfBidMin];
+
257  auto const bidMax = ctx_.tx[~sfBidMax];
+
258 
+
259  auto getPayPrice =
+
260  [&](Number const& computedPrice) -> Expected<Number, TER> {
+
261  auto const payPrice = [&]() -> std::optional<Number> {
+
262  // Both min/max bid price are defined
+
263  if (bidMin && bidMax)
264  {
-
265  return std::max(computedPrice, Number(*bidMin));
-
266  }
-
267  else if (bidMax)
-
268  {
-
269  if (computedPrice <= *bidMax)
-
270  return computedPrice;
-
271  JLOG(ctx_.journal.debug()) << "AMM Bid: not in range "
-
272  << computedPrice << " " << *bidMax;
-
273  return std::nullopt;
-
274  }
-
275  else
-
276  return computedPrice;
-
277  }();
-
278  if (!payPrice)
-
279  return Unexpected(tecAMM_FAILED);
-
280  else if (payPrice > lpTokens)
-
281  return Unexpected(tecAMM_INVALID_TOKENS);
-
282  return *payPrice;
-
283  };
-
284 
-
285  // No one owns the slot or expired slot.
-
286  if (auto const acct = auctionSlot[~sfAccount]; !acct || !validOwner(*acct))
-
287  {
-
288  if (auto const payPrice = getPayPrice(minSlotPrice); !payPrice)
-
289  return {payPrice.error(), false};
-
290  else
-
291  res = updateSlot(discountedFee, *payPrice, *payPrice);
-
292  }
-
293  else
-
294  {
-
295  // Price the slot was purchased at.
-
296  STAmount const pricePurchased = auctionSlot[sfPrice];
-
297  assert(timeSlot);
-
298  auto const fractionUsed =
-
299  (Number(*timeSlot) + 1) / AUCTION_SLOT_TIME_INTERVALS;
-
300  auto const fractionRemaining = Number(1) - fractionUsed;
-
301  auto const computedPrice = [&]() -> Number {
-
302  auto const p1_05 = Number(105, -2);
-
303  // First interval slot price
-
304  if (*timeSlot == 0)
-
305  return pricePurchased * p1_05 + minSlotPrice;
-
306  // Other intervals slot price
-
307  return pricePurchased * p1_05 * (1 - power(fractionUsed, 60)) +
-
308  minSlotPrice;
-
309  }();
-
310 
-
311  auto const payPrice = getPayPrice(computedPrice);
-
312 
-
313  if (!payPrice)
-
314  return {payPrice.error(), false};
-
315 
-
316  // Refund the previous owner. If the time slot is 0 then
-
317  // the owner is refunded 95% of the amount.
-
318  auto const refund = fractionRemaining * pricePurchased;
-
319  if (refund > *payPrice)
-
320  {
-
321  // This error case should never occur.
-
322  JLOG(ctx_.journal.fatal()) << "AMM Bid: refund exceeds payPrice "
-
323  << refund << " " << *payPrice;
-
324  return {tecINTERNAL, false};
-
325  }
-
326  res = accountSend(
-
327  sb,
-
328  account_,
-
329  auctionSlot[sfAccount],
-
330  toSTAmount(lpTokens.issue(), refund),
-
331  ctx_.journal);
-
332  if (res != tesSUCCESS)
-
333  {
-
334  JLOG(ctx_.journal.debug()) << "AMM Bid: failed to refund.";
-
335  return {res, false};
-
336  }
-
337 
-
338  auto const burn = *payPrice - refund;
-
339  res = updateSlot(discountedFee, *payPrice, burn);
-
340  }
-
341 
-
342  return {res, res == tesSUCCESS};
-
343 }
-
344 
-
345 TER
-
346 AMMBid::doApply()
-
347 {
-
348  // This is the ledger view that we work against. Transactions are applied
-
349  // as we go on processing transactions.
-
350  Sandbox sb(&ctx_.view());
+
265  if (computedPrice <= *bidMax)
+
266  return std::max(computedPrice, Number(*bidMin));
+
267  JLOG(ctx_.journal.debug())
+
268  << "AMM Bid: not in range " << computedPrice << " "
+
269  << *bidMin << " " << *bidMax;
+
270  return std::nullopt;
+
271  }
+
272  // Bidder pays max(bidPrice, computedPrice)
+
273  if (bidMin)
+
274  {
+
275  return std::max(computedPrice, Number(*bidMin));
+
276  }
+
277  else if (bidMax)
+
278  {
+
279  if (computedPrice <= *bidMax)
+
280  return computedPrice;
+
281  JLOG(ctx_.journal.debug()) << "AMM Bid: not in range "
+
282  << computedPrice << " " << *bidMax;
+
283  return std::nullopt;
+
284  }
+
285  else
+
286  return computedPrice;
+
287  }();
+
288  if (!payPrice)
+
289  return Unexpected(tecAMM_FAILED);
+
290  else if (payPrice > lpTokens)
+
291  return Unexpected(tecAMM_INVALID_TOKENS);
+
292  return *payPrice;
+
293  };
+
294 
+
295  // No one owns the slot or expired slot.
+
296  if (auto const acct = auctionSlot[~sfAccount]; !acct || !validOwner(*acct))
+
297  {
+
298  if (auto const payPrice = getPayPrice(minSlotPrice); !payPrice)
+
299  return {payPrice.error(), false};
+
300  else
+
301  res = updateSlot(discountedFee, *payPrice, *payPrice);
+
302  }
+
303  else
+
304  {
+
305  // Price the slot was purchased at.
+
306  STAmount const pricePurchased = auctionSlot[sfPrice];
+
307  assert(timeSlot);
+
308  auto const fractionUsed =
+
309  (Number(*timeSlot) + 1) / AUCTION_SLOT_TIME_INTERVALS;
+
310  auto const fractionRemaining = Number(1) - fractionUsed;
+
311  auto const computedPrice = [&]() -> Number {
+
312  auto const p1_05 = Number(105, -2);
+
313  // First interval slot price
+
314  if (*timeSlot == 0)
+
315  return pricePurchased * p1_05 + minSlotPrice;
+
316  // Other intervals slot price
+
317  return pricePurchased * p1_05 * (1 - power(fractionUsed, 60)) +
+
318  minSlotPrice;
+
319  }();
+
320 
+
321  auto const payPrice = getPayPrice(computedPrice);
+
322 
+
323  if (!payPrice)
+
324  return {payPrice.error(), false};
+
325 
+
326  // Refund the previous owner. If the time slot is 0 then
+
327  // the owner is refunded 95% of the amount.
+
328  auto const refund = fractionRemaining * pricePurchased;
+
329  if (refund > *payPrice)
+
330  {
+
331  // This error case should never occur.
+
332  JLOG(ctx_.journal.fatal()) << "AMM Bid: refund exceeds payPrice "
+
333  << refund << " " << *payPrice;
+
334  return {tecINTERNAL, false};
+
335  }
+
336  res = accountSend(
+
337  sb,
+
338  account_,
+
339  auctionSlot[sfAccount],
+
340  toSTAmount(lpTokens.issue(), refund),
+
341  ctx_.journal);
+
342  if (res != tesSUCCESS)
+
343  {
+
344  JLOG(ctx_.journal.debug()) << "AMM Bid: failed to refund.";
+
345  return {res, false};
+
346  }
+
347 
+
348  auto const burn = *payPrice - refund;
+
349  res = updateSlot(discountedFee, *payPrice, burn);
+
350  }
351 
-
352  auto const result = applyBid(ctx_, sb, account_, j_);
-
353  if (result.second)
-
354  sb.apply(ctx_.rawView());
-
355 
-
356  return result.first;
-
357 }
-
358 
-
359 } // namespace ripple
+
352  return {res, res == tesSUCCESS};
+
353 }
+
354 
+
355 TER
+
356 AMMBid::doApply()
+
357 {
+
358  // This is the ledger view that we work against. Transactions are applied
+
359  // as we go on processing transactions.
+
360  Sandbox sb(&ctx_.view());
+
361 
+
362  auto const result = applyBid(ctx_, sb, account_, j_);
+
363  if (result.second)
+
364  sb.apply(ctx_.rawView());
+
365 
+
366  return result.first;
+
367 }
+
368 
+
369 } // namespace ripple
beast::Journal::fatal
Stream fatal() const
Definition: Journal.h:338
ripple::ReadView::info
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
ripple::STArray::size
size_type size() const
Definition: STArray.h:248
-
ripple::STObject::getFieldArray
const STArray & getFieldArray(SField const &field) const
Definition: STObject.cpp:624
+
ripple::STObject::getFieldArray
const STArray & getFieldArray(SField const &field) const
Definition: STObject.cpp:639
ripple::preflight2
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
Definition: Transactor.cpp:133
ripple::sfDiscountedFee
const SF_UINT16 sfDiscountedFee
ripple::sfAsset
const SF_ISSUE sfAsset
@@ -456,7 +466,7 @@ $(function() {
ripple::getFee
Number getFee(std::uint16_t tfee)
Convert to the fee from the basis points.
Definition: AMMCore.h:109
ripple::tecAMM_EMPTY
@ tecAMM_EMPTY
Definition: TER.h:312
ripple::ApplyContext::journal
const beast::Journal journal
Definition: ApplyContext.h:51
-
ripple::AMMBid::doApply
TER doApply() override
Definition: AMMBid.cpp:346
+
ripple::AMMBid::doApply
TER doApply() override
Definition: AMMBid.cpp:356
ripple::ApplyContext::rawView
RawView & rawView()
Definition: ApplyContext.h:67
ripple::sfPrice
const SF_AMOUNT sfPrice
ripple::PreflightContext::j
const beast::Journal j
Definition: Transactor.h:38
@@ -484,7 +494,7 @@ $(function() {
ripple::TER
TERSubset< CanCvtToTER > TER
Definition: TER.h:607
ripple::STAmount
Definition: STAmount.h:46
ripple::tecINTERNAL
@ tecINTERNAL
Definition: TER.h:290
-
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:481
+
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:496
ripple::ValStatus::current
@ current
This was a new validation and was added.
ripple::ApplyContext
State information when applying a tx.
Definition: ApplyContext.h:35
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
@@ -501,8 +511,9 @@ $(function() {
ripple::TOTAL_TIME_SLOT_SECS
constexpr std::uint32_t TOTAL_TIME_SLOT_SECS
Definition: AMMCore.h:34
ripple::temDISABLED
@ temDISABLED
Definition: TER.h:113
ripple::redeemIOU
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition: View.cpp:1399
+
ripple::ReadView::rules
virtual Rules const & rules() const =0
Returns the tx processing rules.
ripple::terNO_AMM
@ terNO_AMM
Definition: TER.h:220
-
ripple::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition: STObject.cpp:428
+
ripple::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition: STObject.cpp:443
ripple::ammLPHolds
STAmount ammLPHolds(ReadView const &view, Currency const &cur1, Currency const &cur2, AccountID const &ammAccount, AccountID const &lpAccount, beast::Journal const j)
Get the balance of LP tokens.
Definition: AMMUtils.cpp:104
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition: Transactor.h:88
std::optional
@@ -520,6 +531,7 @@ $(function() {
ripple::adjustLPTokens
STAmount adjustLPTokens(STAmount const &lptAMMBalance, STAmount const &lpTokens, bool isDeposit)
Definition: AMMHelpers.cpp:133
ripple::tfUniversalMask
constexpr std::uint32_t tfUniversalMask
Definition: TxFlags.h:60
ripple::sfAuctionSlot
const SField sfAuctionSlot
+
ripple::fixInnerObjTemplate
const uint256 fixInnerObjTemplate
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:235
ripple::Transactor::account_
const AccountID account_
Definition: Transactor.h:91
ripple::ApplyContext::tx
STTx const & tx
Definition: ApplyContext.h:48
diff --git a/AMMBid_8h_source.html b/AMMBid_8h_source.html index bd063cddbc..3549485ce5 100644 --- a/AMMBid_8h_source.html +++ b/AMMBid_8h_source.html @@ -121,7 +121,7 @@ $(function() {
ripple::AMMBid::AMMBid
AMMBid(ApplyContext &ctx)
Definition: AMMBid.h:70
ripple::Transactor
Definition: Transactor.h:85
ripple::AMMBid::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: AMMBid.cpp:35
-
ripple::AMMBid::doApply
TER doApply() override
Definition: AMMBid.cpp:346
+
ripple::AMMBid::doApply
TER doApply() override
Definition: AMMBid.cpp:356
ripple::Transactor::ConsequencesFactoryType
ConsequencesFactoryType
Definition: Transactor.h:101
ripple::TERSubset
Definition: TER.h:379
ripple::ApplyContext
State information when applying a tx.
Definition: ApplyContext.h:35
diff --git a/AMMCore_8cpp_source.html b/AMMCore_8cpp_source.html index 9f11527c53..cc49f376a2 100644 --- a/AMMCore_8cpp_source.html +++ b/AMMCore_8cpp_source.html @@ -228,7 +228,7 @@ $(function() {
ripple::temBAD_AMOUNT
@ temBAD_AMOUNT
Definition: TER.h:88
std::uint16_t
ripple::invalidAMMAssetPair
NotTEC invalidAMMAssetPair(Issue const &issue1, Issue const &issue2, std::optional< std::pair< Issue, Issue >> const &pair=std::nullopt)
Definition: AMMCore.cpp:79
-
ripple::STObject
Definition: STObject.h:53
+
ripple::STObject
Definition: STObject.h:54
ripple::Currency
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition: UintTypes.h:56
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::TOTAL_TIME_SLOT_SECS
constexpr std::uint32_t TOTAL_TIME_SLOT_SECS
Definition: AMMCore.h:34
diff --git a/AMMCore_8h_source.html b/AMMCore_8h_source.html index 90518e467a..6d24a05cfd 100644 --- a/AMMCore_8h_source.html +++ b/AMMCore_8h_source.html @@ -199,7 +199,7 @@ $(function() {
ripple::STAmount
Definition: STAmount.h:46
std::uint16_t
ripple::invalidAMMAssetPair
NotTEC invalidAMMAssetPair(Issue const &issue1, Issue const &issue2, std::optional< std::pair< Issue, Issue >> const &pair=std::nullopt)
Definition: AMMCore.cpp:79
-
ripple::STObject
Definition: STObject.h:53
+
ripple::STObject
Definition: STObject.h:54
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::TRADING_FEE_THRESHOLD
constexpr std::uint16_t TRADING_FEE_THRESHOLD
Definition: AMMCore.h:31
ripple::TOTAL_TIME_SLOT_SECS
constexpr std::uint32_t TOTAL_TIME_SLOT_SECS
Definition: AMMCore.h:34
diff --git a/AMMCreate_8cpp_source.html b/AMMCreate_8cpp_source.html index cdcc49b425..2d2859d2a4 100644 --- a/AMMCreate_8cpp_source.html +++ b/AMMCreate_8cpp_source.html @@ -450,7 +450,7 @@ $(function() {
379 } // namespace ripple
ripple::keylet::ownerDir
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition: Indexes.cpp:312
-
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:283
+
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:286
ripple::tecFROZEN
@ tecFROZEN
Definition: TER.h:283
ripple::Application::getOrderBookDB
virtual OrderBookDB & getOrderBookDB()=0
ripple::preflight2
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
Definition: Transactor.cpp:133
@@ -524,7 +524,7 @@ $(function() {
beast::Journal::error
Stream error() const
Definition: Journal.h:332
ripple::tecINTERNAL
@ tecINTERNAL
Definition: TER.h:290
ripple::xrpLiquid
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Definition: View.cpp:346
-
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:481
+
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:496
ripple::STTx
Definition: STTx.h:46
ripple::isXRP
bool isXRP(AccountID const &c)
Definition: AccountID.h:91
ripple::ApplyContext
State information when applying a tx.
Definition: ApplyContext.h:35
diff --git a/AMMDelete_8cpp_source.html b/AMMDelete_8cpp_source.html index f025dc7b1a..b86107f1d0 100644 --- a/AMMDelete_8cpp_source.html +++ b/AMMDelete_8cpp_source.html @@ -173,7 +173,7 @@ $(function() {
ripple::sfAsset2
const SF_ISSUE sfAsset2
ripple::TERSubset< CanCvtToTER >
ripple::Sandbox
Discardable, editable view to a ledger.
Definition: Sandbox.h:34
-
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:481
+
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:496
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::ApplyContext::view
ApplyView & view()
Definition: ApplyContext.h:54
ripple::AMMDelete::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition: AMMDelete.cpp:33
@@ -182,7 +182,7 @@ $(function() {
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::temDISABLED
@ temDISABLED
Definition: TER.h:113
ripple::terNO_AMM
@ terNO_AMM
Definition: TER.h:220
-
ripple::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition: AMMUtils.cpp:234
+
ripple::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition: AMMUtils.cpp:237
ripple::AMMDelete::doApply
TER doApply() override
Definition: AMMDelete.cpp:69
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition: Transactor.h:88
beast::Journal::debug
Stream debug() const
Definition: Journal.h:314
diff --git a/AMMDeposit_8cpp_source.html b/AMMDeposit_8cpp_source.html index 4d857315f7..b1182aef36 100644 --- a/AMMDeposit_8cpp_source.html +++ b/AMMDeposit_8cpp_source.html @@ -904,7 +904,7 @@ $(function() {
904 } // namespace ripple
ripple::AMMDeposit::singleDepositTokens
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.
Definition: AMMDeposit.cpp:752
-
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:283
+
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:286
ripple::tecFROZEN
@ tecFROZEN
Definition: TER.h:283
ripple::preflight2
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
Definition: Transactor.cpp:133
ripple::tecUNFUNDED_AMM
@ tecUNFUNDED_AMM
Definition: TER.h:308
@@ -967,7 +967,7 @@ $(function() {
beast::Journal::error
Stream error() const
Definition: Journal.h:332
ripple::tecINTERNAL
@ tecINTERNAL
Definition: TER.h:290
ripple::xrpLiquid
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Definition: View.cpp:346
-
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:481
+
ripple::STObject::getFlags
std::uint32_t getFlags() const
Definition: STObject.cpp:496
ripple::isXRP
bool isXRP(AccountID const &c)
Definition: AccountID.h:91
ripple::temBAD_AMOUNT
@ temBAD_AMOUNT
Definition: TER.h:88
std::uint16_t
diff --git a/AMMExtended__test_8cpp_source.html b/AMMExtended__test_8cpp_source.html index cca50deda4..f46c5d97fe 100644 --- a/AMMExtended__test_8cpp_source.html +++ b/AMMExtended__test_8cpp_source.html @@ -3997,7 +3997,7 @@ $(function() {
ripple::test::jtx::drops
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Definition: amount.h:241
ripple::test::jtx::same
bool same(STPathSet const &st1, Args const &... args)
Definition: TestHelpers.h:150
ripple::test::jtx::Env::rpc
Json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition: Env.h:711
-
ripple::test::jtx::AMM::ammAccount
AccountID const & ammAccount() const
Definition: AMM.h:255
+
ripple::test::jtx::AMM::ammAccount
AccountID const & ammAccount() const
Definition: AMM.h:336
ripple::test::AMMExtended_test::testPayStrand
void testPayStrand()
Definition: AMMExtended_test.cpp:3880
ripple::test::jtx::ter
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition: ter.h:33
ripple::test::AMMExtended_test::testRIPD1373
void testRIPD1373(FeatureBitset features)
Definition: AMMExtended_test.cpp:3681
@@ -4022,7 +4022,7 @@ $(function() {
ripple::test::jtx::require
Check a set of conditions.
Definition: require.h:63
ripple::test::jtx::xrpMinusFee
PrettyAmount xrpMinusFee(Env const &env, std::int64_t xrpAmount)
Definition: TestHelpers.cpp:93
ripple::test::AMMExtended_test::testCurrencyConversionInParts
void testCurrencyConversionInParts(FeatureBitset features)
Definition: AMMExtended_test.cpp:385
-
ripple::test::jtx::amm::pay
Json::Value pay(Account const &account, AccountID const &to, STAmount const &amount)
Definition: AMM.cpp:746
+
ripple::test::jtx::amm::pay
Json::Value pay(Account const &account, AccountID const &to, STAmount const &amount)
Definition: AMM.cpp:834
ripple::test::AMMExtended_test::path_find_consume_all
void path_find_consume_all()
Definition: AMMExtended_test.cpp:1441
ripple::test::jtx::AMMTestBase::gw
const jtx::Account gw
Definition: AMMTest.h:64
ripple::featureMultiSignReserve
const uint256 featureMultiSignReserve
@@ -4033,7 +4033,7 @@ $(function() {
ripple::test::jtx::Env::balance
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition: Env.cpp:183
ripple::tfPassive
constexpr std::uint32_t tfPassive
Definition: TxFlags.h:94
ripple::IOUAmount
Floating point representation of amounts with high dynamic range.
Definition: IOUAmount.h:43
-
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:62
+
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:123
ripple::test::AMMExtended_test::testRmFundedOffer
void testRmFundedOffer(FeatureBitset features)
Definition: AMMExtended_test.cpp:49
ripple::test::AMMExtended_test::run
void run() override
Definition: AMMExtended_test.cpp:3891
ripple::temBAD_PATH
@ temBAD_PATH
Definition: TER.h:95
@@ -4044,7 +4044,7 @@ $(function() {
ripple::test::BEAST_DEFINE_TESTSUITE_PRIO
BEAST_DEFINE_TESTSUITE_PRIO(AccountDelete, app, ripple, 2)
ripple::test::AMMExtended_test::testFlow
void testFlow()
Definition: AMMExtended_test.cpp:3817
ripple::STPathSet::empty
bool empty() const
Definition: STPathSet.h:503
-
ripple::test::jtx::AMM::expectBalances
bool expectBalances(STAmount const &asset1, STAmount const &asset2, IOUAmount const &lpt, std::optional< AccountID > const &account=std::nullopt) const
Verify the AMM balances.
Definition: AMM.cpp:203
+
ripple::test::jtx::AMM::expectBalances
bool expectBalances(STAmount const &asset1, STAmount const &asset2, IOUAmount const &lpt, std::optional< AccountID > const &account=std::nullopt) const
Verify the AMM balances.
Definition: AMM.cpp:227
ripple::test::AMMExtended_test::via_offers_via_gateway
void via_offers_via_gateway()
Definition: AMMExtended_test.cpp:1480
ripple::tecKILLED
@ tecKILLED
Definition: TER.h:296
ripple::test::AMMExtended_test::test_convert_all_of_an_asset
void test_convert_all_of_an_asset(FeatureBitset features)
Definition: AMMExtended_test.cpp:2950
@@ -4080,7 +4080,7 @@ $(function() {
ripple::test::AMMExtended_test::path_find_01
void path_find_01()
Definition: AMMExtended_test.cpp:1550
ripple::STAmount
Definition: STAmount.h:46
ripple::test::isOffer
bool isOffer(jtx::Env &env, jtx::Account const &account, STAmount const &takerPays, STAmount const &takerGets)
An offer exists.
Definition: PathSet.h:71
-
ripple::test::jtx::amm::trust
Json::Value trust(AccountID const &account, STAmount const &amount, std::uint32_t flags=0)
Definition: AMM.cpp:734
+
ripple::test::jtx::amm::trust
Json::Value trust(AccountID const &account, STAmount const &amount, std::uint32_t flags=0)
Definition: AMM.cpp:822
ripple::test::jtx::path
Add a path.
Definition: paths.h:55
ripple::test::jtx::AMMTest::pathTestEnv
jtx::Env pathTestEnv()
Definition: AMMTest.cpp:159
ripple::test::jtx::supported_amendments
FeatureBitset supported_amendments()
Definition: Env.h:70
@@ -4091,7 +4091,7 @@ $(function() {
ripple::test::jtx::fclear
Json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
Definition: flags.h:40
ripple::test::AMMExtended_test::testSellWithFillOrKill
void testSellWithFillOrKill(FeatureBitset features)
Definition: AMMExtended_test.cpp:828
ripple::tfFillOrKill
constexpr std::uint32_t tfFillOrKill
Definition: TxFlags.h:96
-
ripple::test::jtx::AMM::expectTradingFee
bool expectTradingFee(std::uint16_t fee) const
Definition: AMM.cpp:284
+
ripple::test::jtx::AMM::expectTradingFee
bool expectTradingFee(std::uint16_t fee) const
Definition: AMM.cpp:308
ripple::test::jtx::fee
Set the fee on a JTx.
Definition: fee.h:35
ripple::fix1578
const uint256 fix1578
ripple::test::equal
bool equal(std::unique_ptr< Step > const &s1, DirectStepInfo const &dsi)
Definition: PayStrand_test.cpp:89
@@ -4101,7 +4101,7 @@ $(function() {
ripple::tfSell
constexpr std::uint32_t tfSell
Definition: TxFlags.h:97
ripple::test::jtx::flags
Match set account flags.
Definition: flags.h:111
ripple::test::jtx::AMMTestBase::EUR
const jtx::IOU EUR
Definition: AMMTest.h:69
-
ripple::test::jtx::AMM::tokens
IOUAmount tokens() const
Definition: AMM.h:267
+
ripple::test::jtx::AMM::tokens
IOUAmount tokens() const
Definition: AMM.h:348
ripple::tecNO_LINE
@ tecNO_LINE
Definition: TER.h:281
ripple::test::AMMExtended_test::testPayment
void testPayment(FeatureBitset features)
Definition: AMMExtended_test.cpp:3050
ripple::tfSetfAuth
constexpr std::uint32_t tfSetfAuth
Definition: TxFlags.h:109
diff --git a/AMMInfo_8cpp_source.html b/AMMInfo_8cpp_source.html index 5314a1acd7..9496766d18 100644 --- a/AMMInfo_8cpp_source.html +++ b/AMMInfo_8cpp_source.html @@ -271,57 +271,60 @@ $(function() {
200  }
201  if (voteSlots.size() > 0)
202  ammResult[jss::vote_slots] = std::move(voteSlots);
-
203  if (amm->isFieldPresent(sfAuctionSlot))
-
204  {
-
205  auto const& auctionSlot =
-
206  static_cast<STObject const&>(amm->peekAtField(sfAuctionSlot));
-
207  if (auctionSlot.isFieldPresent(sfAccount))
-
208  {
-
209  Json::Value auction;
-
210  auto const timeSlot = ammAuctionTimeSlot(
-
211  ledger->info().parentCloseTime.time_since_epoch().count(),
-
212  auctionSlot);
-
213  auction[jss::time_interval] =
-
214  timeSlot ? *timeSlot : AUCTION_SLOT_TIME_INTERVALS;
-
215  auctionSlot[sfPrice].setJson(auction[jss::price]);
-
216  auction[jss::discounted_fee] = auctionSlot[sfDiscountedFee];
-
217  auction[jss::account] =
-
218  to_string(auctionSlot.getAccountID(sfAccount));
-
219  auction[jss::expiration] = to_iso8601(NetClock::time_point{
-
220  NetClock::duration{auctionSlot[sfExpiration]}});
-
221  if (auctionSlot.isFieldPresent(sfAuthAccounts))
-
222  {
-
223  Json::Value auth;
-
224  for (auto const& acct :
-
225  auctionSlot.getFieldArray(sfAuthAccounts))
-
226  {
-
227  Json::Value jv;
-
228  jv[jss::account] = to_string(acct.getAccountID(sfAccount));
-
229  auth.append(jv);
-
230  }
-
231  auction[jss::auth_accounts] = auth;
-
232  }
-
233  ammResult[jss::auction_slot] = std::move(auction);
-
234  }
-
235  }
-
236 
-
237  if (!isXRP(asset1Balance))
-
238  ammResult[jss::asset_frozen] =
-
239  isFrozen(*ledger, ammAccountID, issue1.currency, issue1.account);
-
240  if (!isXRP(asset2Balance))
-
241  ammResult[jss::asset2_frozen] =
-
242  isFrozen(*ledger, ammAccountID, issue2.currency, issue2.account);
-
243 
-
244  result[jss::amm] = std::move(ammResult);
-
245  if (!result.isMember(jss::ledger_index) &&
-
246  !result.isMember(jss::ledger_hash))
-
247  result[jss::ledger_current_index] = ledger->info().seq;
-
248  result[jss::validated] = context.ledgerMaster.isValidated(*ledger);
-
249 
-
250  return result;
-
251 }
+
203  assert(
+
204  !ledger->rules().enabled(fixInnerObjTemplate) ||
+
205  amm->isFieldPresent(sfAuctionSlot));
+
206  if (amm->isFieldPresent(sfAuctionSlot))
+
207  {
+
208  auto const& auctionSlot =
+
209  static_cast<STObject const&>(amm->peekAtField(sfAuctionSlot));
+
210  if (auctionSlot.isFieldPresent(sfAccount))
+
211  {
+
212  Json::Value auction;
+
213  auto const timeSlot = ammAuctionTimeSlot(
+
214  ledger->info().parentCloseTime.time_since_epoch().count(),
+
215  auctionSlot);
+
216  auction[jss::time_interval] =
+
217  timeSlot ? *timeSlot : AUCTION_SLOT_TIME_INTERVALS;
+
218  auctionSlot[sfPrice].setJson(auction[jss::price]);
+
219  auction[jss::discounted_fee] = auctionSlot[sfDiscountedFee];
+
220  auction[jss::account] =
+
221  to_string(auctionSlot.getAccountID(sfAccount));
+
222  auction[jss::expiration] = to_iso8601(NetClock::time_point{
+
223  NetClock::duration{auctionSlot[sfExpiration]}});
+
224  if (auctionSlot.isFieldPresent(sfAuthAccounts))
+
225  {
+
226  Json::Value auth;
+
227  for (auto const& acct :
+
228  auctionSlot.getFieldArray(sfAuthAccounts))
+
229  {
+
230  Json::Value jv;
+
231  jv[jss::account] = to_string(acct.getAccountID(sfAccount));
+
232  auth.append(jv);
+
233  }
+
234  auction[jss::auth_accounts] = auth;
+
235  }
+
236  ammResult[jss::auction_slot] = std::move(auction);
+
237  }
+
238  }
+
239 
+
240  if (!isXRP(asset1Balance))
+
241  ammResult[jss::asset_frozen] =
+
242  isFrozen(*ledger, ammAccountID, issue1.currency, issue1.account);
+
243  if (!isXRP(asset2Balance))
+
244  ammResult[jss::asset2_frozen] =
+
245  isFrozen(*ledger, ammAccountID, issue2.currency, issue2.account);
+
246 
+
247  result[jss::amm] = std::move(ammResult);
+
248  if (!result.isMember(jss::ledger_index) &&
+
249  !result.isMember(jss::ledger_hash))
+
250  result[jss::ledger_current_index] = ledger->info().seq;
+
251  result[jss::validated] = context.ledgerMaster.isValidated(*ledger);
252 
-
253 } // namespace ripple
+
253  return result;
+
254 }
+
255 
+
256 } // namespace ripple
ripple::ReadView::info
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
std::optional::has_value
T has_value(T... args)
@@ -330,6 +333,7 @@ $(function() {
ripple::Issue
A currency issued by an account.
Definition: Issue.h:35
ripple::sfAsset
const SF_ISSUE sfAsset
std::string
STL class.
+
ripple::Rules::enabled
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Definition: Rules.cpp:94
std::shared_ptr
STL class.
ripple::rpcINVALID_PARAMS
@ rpcINVALID_PARAMS
Definition: ErrorCodes.h:84
ripple::AUCTION_SLOT_TIME_INTERVALS
constexpr std::uint16_t AUCTION_SLOT_TIME_INTERVALS
Definition: AMMCore.h:35
@@ -372,10 +376,11 @@ $(function() {
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::getAccount
std::optional< AccountID > getAccount(Json::Value const &v, Json::Value &result)
Definition: AMMInfo.cpp:33
ripple::doAMMInfo
Json::Value doAMMInfo(RPC::JsonContext &context)
Definition: AMMInfo.cpp:74
-
ripple::STObject
Definition: STObject.h:53
+
ripple::STObject
Definition: STObject.h:54
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::rpcACT_MALFORMED
@ rpcACT_MALFORMED
Definition: ErrorCodes.h:90
ripple::LedgerMaster::isValidated
bool isValidated(ReadView const &ledger)
Definition: LedgerMaster.cpp:602
+
ripple::ReadView::rules
virtual Rules const & rules() const =0
Returns the tx processing rules.
ripple::ammLPHolds
STAmount ammLPHolds(ReadView const &view, Currency const &cur1, Currency const &cur2, AccountID const &ammAccount, AccountID const &lpAccount, beast::Journal const j)
Get the balance of LP tokens.
Definition: AMMUtils.cpp:104
std::optional
beast::Journal::debug
Stream debug() const
Definition: Journal.h:314
@@ -383,6 +388,7 @@ $(function() {
ripple::sfAccount
const SF_ACCOUNT sfAccount
ripple::rpcISSUE_MALFORMED
@ rpcISSUE_MALFORMED
Definition: ErrorCodes.h:146
ripple::sfAuctionSlot
const SField sfAuctionSlot
+
ripple::fixInnerObjTemplate
const uint256 fixInnerObjTemplate
ripple::RPC::JsonContext::params
Json::Value params
Definition: Context.h:64
ripple::RPC::inject_error
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
Definition: ErrorCodes.h:214
ripple::isFrozen
bool isFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition: View.cpp:203
diff --git a/AMMInfo__test_8cpp_source.html b/AMMInfo__test_8cpp_source.html index 521c021a44..d400971806 100644 --- a/AMMInfo__test_8cpp_source.html +++ b/AMMInfo__test_8cpp_source.html @@ -310,27 +310,27 @@ $(function() {
ripple::test::AMMInfo_test::testErrors
void testErrors()
Definition: AMMInfo_test.cpp:35
ripple::test::jtx::XRP
const XRP_t XRP
Converts to XRP Issue or STAmount.
Definition: amount.cpp:105
std::exception
STL class.
-
ripple::test::jtx::AMM::ammAccount
AccountID const & ammAccount() const
Definition: AMM.h:255
+
ripple::test::jtx::AMM::ammAccount
AccountID const & ammAccount() const
Definition: AMM.h:336
ripple::test::AMMInfo_test
Definition: AMMInfo_test.cpp:31
std::unordered_set
STL class.
std::vector
STL class.
ripple::Issue::currency
Currency currency
Definition: Issue.h:38
-
ripple::test::jtx::AMM::vote
void vote(std::optional< Account > const &account, std::uint32_t feeVal, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< jtx::seq > const &seq=std::nullopt, std::optional< std::pair< Issue, Issue >> const &assets=std::nullopt, std::optional< ter > const &ter=std::nullopt)
Definition: AMM.cpp:578
+
ripple::test::jtx::AMM::vote
void vote(std::optional< Account > const &account, std::uint32_t feeVal, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< jtx::seq > const &seq=std::nullopt, std::optional< std::pair< Issue, Issue >> const &assets=std::nullopt, std::optional< ter > const &ter=std::nullopt)
Definition: AMM.cpp:633
ripple::test::jtx::Account::human
std::string const & human() const
Returns the human readable public key.
Definition: Account.h:113
ripple::test::jtx::AMMTestBase::gw
const jtx::Account gw
Definition: AMMTest.h:64
ripple::test::jtx::AMMTestBase::carol
const jtx::Account carol
Definition: AMMTest.h:65
-
ripple::test::jtx::AMM::deposit
IOUAmount deposit(std::optional< Account > const &account, LPToken tokens, std::optional< STAmount > const &asset1InDetails=std::nullopt, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< ter > const &ter=std::nullopt)
Definition: AMM.cpp:383
+
ripple::test::jtx::AMM::deposit
IOUAmount deposit(std::optional< Account > const &account, LPToken tokens, std::optional< STAmount > const &asset1InDetails=std::nullopt, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< ter > const &ter=std::nullopt)
Definition: AMM.cpp:407
ripple::test::jtx::AMMTestBase::alice
const jtx::Account alice
Definition: AMMTest.h:66
std::tuple
ripple::test::jtx::IOU::issue
Issue issue() const
Definition: amount.h:303
-
ripple::test::jtx::AMM::bid
void bid(std::optional< Account > const &account, std::optional< std::variant< int, IOUAmount, STAmount >> const &bidMin=std::nullopt, std::optional< std::variant< int, IOUAmount, STAmount >> const &bidMax=std::nullopt, std::vector< Account > const &authAccounts={}, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< jtx::seq > const &seq=std::nullopt, std::optional< std::pair< Issue, Issue >> const &assets=std::nullopt, std::optional< ter > const &ter=std::nullopt)
Definition: AMM.cpp:599
+
ripple::test::jtx::AMM::bid
void bid(std::optional< Account > const &account, std::optional< std::variant< int, IOUAmount, STAmount >> const &bidMin=std::nullopt, std::optional< std::variant< int, IOUAmount, STAmount >> const &bidMax=std::nullopt, std::vector< Account > const &authAccounts={}, std::optional< std::uint32_t > const &flags=std::nullopt, std::optional< jtx::seq > const &seq=std::nullopt, std::optional< std::pair< Issue, Issue >> const &assets=std::nullopt, std::optional< ter > const &ter=std::nullopt)
Definition: AMM.cpp:660
ripple::IOUAmount
Floating point representation of amounts with high dynamic range.
Definition: IOUAmount.h:43
-
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:62
+
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:123
ripple::test::TrustFlag::freeze
@ freeze
std::unordered_set::contains
T contains(T... args)
ripple::test::jtx::Account::id
AccountID id() const
Returns the Account ID.
Definition: Account.h:106
-
ripple::test::jtx::AMM::ammRpcInfo
Json::Value ammRpcInfo(std::optional< AccountID > const &account=std::nullopt, std::optional< std::string > const &ledgerIndex=std::nullopt, std::optional< Issue > issue1=std::nullopt, std::optional< Issue > issue2=std::nullopt, std::optional< AccountID > const &ammAccount=std::nullopt, bool ignoreParams=false) const
Send amm_info RPC command.
Definition: AMM.cpp:136
-
ripple::test::jtx::AMM::expectAmmRpcInfo
bool expectAmmRpcInfo(STAmount const &asset1, STAmount const &asset2, IOUAmount const &balance, std::optional< AccountID > const &account=std::nullopt, std::optional< std::string > const &ledger_index=std::nullopt, std::optional< AccountID > const &ammAccount=std::nullopt) const
Definition: AMM.cpp:300
+
ripple::test::jtx::AMM::ammRpcInfo
Json::Value ammRpcInfo(std::optional< AccountID > const &account=std::nullopt, std::optional< std::string > const &ledgerIndex=std::nullopt, std::optional< Issue > issue1=std::nullopt, std::optional< Issue > issue2=std::nullopt, std::optional< AccountID > const &ammAccount=std::nullopt, bool ignoreParams=false) const
Send amm_info RPC command.
Definition: AMM.cpp:160
+
ripple::test::jtx::AMM::expectAmmRpcInfo
bool expectAmmRpcInfo(STAmount const &asset1, STAmount const &asset2, IOUAmount const &balance, std::optional< AccountID > const &account=std::nullopt, std::optional< std::string > const &ledger_index=std::nullopt, std::optional< AccountID > const &ammAccount=std::nullopt) const
Definition: AMM.cpp:324
ripple::test::jtx::AMMTestBase::bob
const jtx::Account bob
Definition: AMMTest.h:67
ripple::test::jtx::AMMTestBase
Definition: AMMTest.h:61
ripple::test::jtx::fset
Json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition: flags.cpp:28
@@ -341,7 +341,7 @@ $(function() {
ripple::test::AMMInfo_test::testVoteAndBid
void testVoteAndBid()
Definition: AMMInfo_test.cpp:111
ripple::test::AMMInfo_test::run
void run() override
Definition: AMMInfo_test.cpp:224
ripple::test::jtx::fclear
Json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
Definition: flags.h:40
-
ripple::test::jtx::AMM::expectTradingFee
bool expectTradingFee(std::uint16_t fee) const
Definition: AMM.cpp:284
+
ripple::test::jtx::AMM::expectTradingFee
bool expectTradingFee(std::uint16_t fee) const
Definition: AMM.cpp:308
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std::unordered_map::insert
T insert(T... args)
ripple::test::jtx::Env::fund
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition: Env.cpp:228
@@ -356,7 +356,7 @@ $(function() {
ripple::test::AMMInfo_test::testSimpleRpc
void testSimpleRpc()
Definition: AMMInfo_test.cpp:92
unordered_map
ripple::test::jtx::AMMTestBase::testAMM
void testAMM(std::function< void(jtx::AMM &, jtx::Env &)> &&cb, std::optional< std::pair< STAmount, STAmount >> const &pool=std::nullopt, std::uint16_t tfee=0, std::optional< jtx::ter > const &ter=std::nullopt, std::optional< FeatureBitset > const &features=std::nullopt)
testAMM() funds 30,000XRP and 30,000IOU for each non-XRP asset to Alice and Carol
Definition: AMMTest.cpp:101
-
ripple::test::jtx::AMM::lptIssue
Issue lptIssue() const
Definition: AMM.h:261
+
ripple::test::jtx::AMM::lptIssue
Issue lptIssue() const
Definition: AMM.h:342
ripple::test::jtx::Env
A transaction testing environment.
Definition: Env.h:116
ripple::Issue::account
AccountID account
Definition: Issue.h:39
std::exception::what
T what(T... args)
diff --git a/AMMLiquidity_8cpp_source.html b/AMMLiquidity_8cpp_source.html index 953c3e6e6f..647d0f828c 100644 --- a/AMMLiquidity_8cpp_source.html +++ b/AMMLiquidity_8cpp_source.html @@ -325,7 +325,7 @@ $(function() {
beast::Journal::debug
Stream debug() const
Definition: Journal.h:314
ripple::to_string
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Definition: app/misc/impl/Manifest.cpp:41
ripple::STAmount::cMaxOffset
static const int cMaxOffset
Definition: STAmount.h:64
-
ripple::ammAccountHolds
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition: AMMUtils.cpp:166
+
ripple::ammAccountHolds
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition: AMMUtils.cpp:169
ripple::STAmount::cMaxValue
static const std::uint64_t cMaxValue
Definition: STAmount.h:68
std::overflow_error::what
T what(T... args)
ripple::XRPAmount
Definition: XRPAmount.h:46
diff --git a/AMMTest_8cpp_source.html b/AMMTest_8cpp_source.html index bb2c7741ee..aa2ab934f6 100644 --- a/AMMTest_8cpp_source.html +++ b/AMMTest_8cpp_source.html @@ -375,7 +375,7 @@ $(function() {
ripple::Resource::feeReferenceRPC
const Charge feeReferenceRPC
std::tuple
ripple::test::jtx::Env::app
Application & app()
Definition: Env.h:241
-
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:62
+
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:123
std::function
ripple::test::jtx::envconfig
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition: envconfig.h:54
ripple::STParsedJSONObject::object
std::optional< STObject > object
The STObject if the parse was successful.
Definition: STParsedJSON.h:50
diff --git a/AMMTest_8h_source.html b/AMMTest_8h_source.html index ac275fa796..ea4ede6a4f 100644 --- a/AMMTest_8h_source.html +++ b/AMMTest_8h_source.html @@ -237,7 +237,7 @@ $(function() {
std::lock_guard
STL class.
ripple::test::jtx::AMMTestBase::alice
const jtx::Account alice
Definition: AMMTest.h:66
std::tuple
-
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:62
+
ripple::test::jtx::AMM
Convenience class to test AMM functionality.
Definition: AMM.h:123
std::function
ripple::test::jtx::Fund::IOUOnly
@ IOUOnly
ripple::test::jtx::AMMTest::find_paths
std::tuple< STPathSet, STAmount, STAmount > find_paths(jtx::Env &env, jtx::Account const &src, jtx::Account const &dst, STAmount const &saDstAmount, std::optional< STAmount > const &saSendMax=std::nullopt, std::optional< Currency > const &saSrcCurrency=std::nullopt)
Definition: AMMTest.cpp:232
diff --git a/AMMUtils_8cpp_source.html b/AMMUtils_8cpp_source.html index a66c172e5a..c6a8fc9a67 100644 --- a/AMMUtils_8cpp_source.html +++ b/AMMUtils_8cpp_source.html @@ -209,203 +209,216 @@ $(function() {
138 getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account)
139 {
140  using namespace std::chrono;
-
141  if (ammSle.isFieldPresent(sfAuctionSlot))
-
142  {
-
143  auto const& auctionSlot =
-
144  static_cast<STObject const&>(ammSle.peekAtField(sfAuctionSlot));
-
145  // Not expired
-
146  if (auto const expiration = auctionSlot[~sfExpiration];
-
147  duration_cast<seconds>(
-
148  view.info().parentCloseTime.time_since_epoch())
-
149  .count() < expiration)
-
150  {
-
151  if (auctionSlot[~sfAccount] == account)
-
152  return auctionSlot[sfDiscountedFee];
-
153  if (auctionSlot.isFieldPresent(sfAuthAccounts))
-
154  {
-
155  for (auto const& acct :
-
156  auctionSlot.getFieldArray(sfAuthAccounts))
-
157  if (acct[~sfAccount] == account)
-
158  return auctionSlot[sfDiscountedFee];
-
159  }
-
160  }
-
161  }
-
162  return ammSle[sfTradingFee];
-
163 }
-
164 
-
165 STAmount
-
166 ammAccountHolds(
-
167  ReadView const& view,
-
168  AccountID const& ammAccountID,
-
169  Issue const& issue)
-
170 {
-
171  if (isXRP(issue))
-
172  {
-
173  if (auto const sle = view.read(keylet::account(ammAccountID)))
-
174  return (*sle)[sfBalance];
-
175  }
-
176  else if (auto const sle = view.read(
-
177  keylet::line(ammAccountID, issue.account, issue.currency));
-
178  sle &&
-
179  !isFrozen(view, ammAccountID, issue.currency, issue.account))
-
180  {
-
181  auto amount = (*sle)[sfBalance];
-
182  if (ammAccountID > issue.account)
-
183  amount.negate();
-
184  amount.setIssuer(issue.account);
-
185  return amount;
-
186  }
-
187 
-
188  return STAmount{issue};
-
189 }
+
141  assert(
+
142  !view.rules().enabled(fixInnerObjTemplate) ||
+
143  ammSle.isFieldPresent(sfAuctionSlot));
+
144  if (ammSle.isFieldPresent(sfAuctionSlot))
+
145  {
+
146  auto const& auctionSlot =
+
147  static_cast<STObject const&>(ammSle.peekAtField(sfAuctionSlot));
+
148  // Not expired
+
149  if (auto const expiration = auctionSlot[~sfExpiration];
+
150  duration_cast<seconds>(
+
151  view.info().parentCloseTime.time_since_epoch())
+
152  .count() < expiration)
+
153  {
+
154  if (auctionSlot[~sfAccount] == account)
+
155  return auctionSlot[sfDiscountedFee];
+
156  if (auctionSlot.isFieldPresent(sfAuthAccounts))
+
157  {
+
158  for (auto const& acct :
+
159  auctionSlot.getFieldArray(sfAuthAccounts))
+
160  if (acct[~sfAccount] == account)
+
161  return auctionSlot[sfDiscountedFee];
+
162  }
+
163  }
+
164  }
+
165  return ammSle[sfTradingFee];
+
166 }
+
167 
+
168 STAmount
+
169 ammAccountHolds(
+
170  ReadView const& view,
+
171  AccountID const& ammAccountID,
+
172  Issue const& issue)
+
173 {
+
174  if (isXRP(issue))
+
175  {
+
176  if (auto const sle = view.read(keylet::account(ammAccountID)))
+
177  return (*sle)[sfBalance];
+
178  }
+
179  else if (auto const sle = view.read(
+
180  keylet::line(ammAccountID, issue.account, issue.currency));
+
181  sle &&
+
182  !isFrozen(view, ammAccountID, issue.currency, issue.account))
+
183  {
+
184  auto amount = (*sle)[sfBalance];
+
185  if (ammAccountID > issue.account)
+
186  amount.negate();
+
187  amount.setIssuer(issue.account);
+
188  return amount;
+
189  }
190 
-
191 static TER
-
192 deleteAMMTrustLines(
-
193  Sandbox& sb,
-
194  AccountID const& ammAccountID,
-
195  std::uint16_t maxTrustlinesToDelete,
-
196  beast::Journal j)
-
197 {
-
198  return cleanupOnAccountDelete(
-
199  sb,
-
200  keylet::ownerDir(ammAccountID),
-
201  [&](LedgerEntryType nodeType,
-
202  uint256 const&,
-
203  std::shared_ptr<SLE>& sleItem) -> std::pair<TER, SkipEntry> {
-
204  // Skip AMM
-
205  if (nodeType == LedgerEntryType::ltAMM)
-
206  return {tesSUCCESS, SkipEntry::Yes};
-
207  // Should only have the trustlines
-
208  if (nodeType != LedgerEntryType::ltRIPPLE_STATE)
-
209  {
-
210  JLOG(j.error())
-
211  << "deleteAMMTrustLines: deleting non-trustline "
-
212  << nodeType;
-
213  return {tecINTERNAL, SkipEntry::No};
-
214  }
-
215 
-
216  // Trustlines must have zero balance
-
217  if (sleItem->getFieldAmount(sfBalance) != beast::zero)
-
218  {
-
219  JLOG(j.error())
-
220  << "deleteAMMTrustLines: deleting trustline with "
-
221  "non-zero balance.";
-
222  return {tecINTERNAL, SkipEntry::No};
-
223  }
-
224 
-
225  return {
-
226  deleteAMMTrustLine(sb, sleItem, ammAccountID, j),
-
227  SkipEntry::No};
-
228  },
-
229  j,
-
230  maxTrustlinesToDelete);
-
231 }
-
232 
-
233 TER
-
234 deleteAMMAccount(
-
235  Sandbox& sb,
-
236  Issue const& asset,
-
237  Issue const& asset2,
-
238  beast::Journal j)
-
239 {
-
240  auto ammSle = sb.peek(keylet::amm(asset, asset2));
-
241  if (!ammSle)
-
242  {
-
243  JLOG(j.error()) << "deleteAMMAccount: AMM object does not exist "
-
244  << asset << " " << asset2;
-
245  return tecINTERNAL;
-
246  }
-
247 
-
248  auto const ammAccountID = (*ammSle)[sfAccount];
-
249  auto sleAMMRoot = sb.peek(keylet::account(ammAccountID));
-
250  if (!sleAMMRoot)
-
251  {
-
252  JLOG(j.error()) << "deleteAMMAccount: AMM account does not exist "
-
253  << to_string(ammAccountID);
-
254  return tecINTERNAL;
-
255  }
-
256 
-
257  if (auto const ter =
-
258  deleteAMMTrustLines(sb, ammAccountID, maxDeletableAMMTrustLines, j);
-
259  ter != tesSUCCESS)
-
260  return ter;
-
261 
-
262  auto const ownerDirKeylet = keylet::ownerDir(ammAccountID);
-
263  if (!sb.dirRemove(
-
264  ownerDirKeylet, (*ammSle)[sfOwnerNode], ammSle->key(), false))
-
265  {
-
266  JLOG(j.error()) << "deleteAMMAccount: failed to remove dir link";
-
267  return tecINTERNAL;
-
268  }
-
269  if (sb.exists(ownerDirKeylet) && !sb.emptyDirDelete(ownerDirKeylet))
-
270  {
-
271  JLOG(j.error()) << "deleteAMMAccount: cannot delete root dir node of "
-
272  << toBase58(ammAccountID);
-
273  return tecINTERNAL;
-
274  }
-
275 
-
276  sb.erase(ammSle);
-
277  sb.erase(sleAMMRoot);
+
191  return STAmount{issue};
+
192 }
+
193 
+
194 static TER
+
195 deleteAMMTrustLines(
+
196  Sandbox& sb,
+
197  AccountID const& ammAccountID,
+
198  std::uint16_t maxTrustlinesToDelete,
+
199  beast::Journal j)
+
200 {
+
201  return cleanupOnAccountDelete(
+
202  sb,
+
203  keylet::ownerDir(ammAccountID),
+
204  [&](LedgerEntryType nodeType,
+
205  uint256 const&,
+
206  std::shared_ptr<SLE>& sleItem) -> std::pair<TER, SkipEntry> {
+
207  // Skip AMM
+
208  if (nodeType == LedgerEntryType::ltAMM)
+
209  return {tesSUCCESS, SkipEntry::Yes};
+
210  // Should only have the trustlines
+
211  if (nodeType != LedgerEntryType::ltRIPPLE_STATE)
+
212  {
+
213  JLOG(j.error())
+
214  << "deleteAMMTrustLines: deleting non-trustline "
+
215  << nodeType;
+
216  return {tecINTERNAL, SkipEntry::No};
+
217  }
+
218 
+
219  // Trustlines must have zero balance
+
220  if (sleItem->getFieldAmount(sfBalance) != beast::zero)
+
221  {
+
222  JLOG(j.error())
+
223  << "deleteAMMTrustLines: deleting trustline with "
+
224  "non-zero balance.";
+
225  return {tecINTERNAL, SkipEntry::No};
+
226  }
+
227 
+
228  return {
+
229  deleteAMMTrustLine(sb, sleItem, ammAccountID, j),
+
230  SkipEntry::No};
+
231  },
+
232  j,
+
233  maxTrustlinesToDelete);
+
234 }
+
235 
+
236 TER
+
237 deleteAMMAccount(
+
238  Sandbox& sb,
+
239  Issue const& asset,
+
240  Issue const& asset2,
+
241  beast::Journal j)
+
242 {
+
243  auto ammSle = sb.peek(keylet::amm(asset, asset2));
+
244  if (!ammSle)
+
245  {
+
246  JLOG(j.error()) << "deleteAMMAccount: AMM object does not exist "
+
247  << asset << " " << asset2;
+
248  return tecINTERNAL;
+
249  }
+
250 
+
251  auto const ammAccountID = (*ammSle)[sfAccount];
+
252  auto sleAMMRoot = sb.peek(keylet::account(ammAccountID));
+
253  if (!sleAMMRoot)
+
254  {
+
255  JLOG(j.error()) << "deleteAMMAccount: AMM account does not exist "
+
256  << to_string(ammAccountID);
+
257  return tecINTERNAL;
+
258  }
+
259 
+
260  if (auto const ter =
+
261  deleteAMMTrustLines(sb, ammAccountID, maxDeletableAMMTrustLines, j);
+
262  ter != tesSUCCESS)
+
263  return ter;
+
264 
+
265  auto const ownerDirKeylet = keylet::ownerDir(ammAccountID);
+
266  if (!sb.dirRemove(
+
267  ownerDirKeylet, (*ammSle)[sfOwnerNode], ammSle->key(), false))
+
268  {
+
269  JLOG(j.error()) << "deleteAMMAccount: failed to remove dir link";
+
270  return tecINTERNAL;
+
271  }
+
272  if (sb.exists(ownerDirKeylet) && !sb.emptyDirDelete(ownerDirKeylet))
+
273  {
+
274  JLOG(j.error()) << "deleteAMMAccount: cannot delete root dir node of "
+
275  << toBase58(ammAccountID);
+
276  return tecINTERNAL;
+
277  }
278 
-
279  return tesSUCCESS;
-
280 }
+
279  sb.erase(ammSle);
+
280  sb.erase(sleAMMRoot);
281 
-
282 void
-
283 initializeFeeAuctionVote(
-
284  ApplyView& view,
-
285  std::shared_ptr<SLE>& ammSle,
-
286  AccountID const& account,
-
287  Issue const& lptIssue,
-
288  std::uint16_t tfee)
-
289 {
-
290  // AMM creator gets the voting slot.
-
291  STArray voteSlots;
-
292  STObject voteEntry{sfVoteEntry};
-
293  if (tfee != 0)
-
294  voteEntry.setFieldU16(sfTradingFee, tfee);
-
295  voteEntry.setFieldU32(sfVoteWeight, VOTE_WEIGHT_SCALE_FACTOR);
-
296  voteEntry.setAccountID(sfAccount, account);
-
297  voteSlots.push_back(voteEntry);
-
298  ammSle->setFieldArray(sfVoteSlots, voteSlots);
-
299  // AMM creator gets the auction slot for free.
-
300  auto& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot);
-
301  auctionSlot.setAccountID(sfAccount, account);
-
302  // current + sec in 24h
-
303  auto const expiration = std::chrono::duration_cast<std::chrono::seconds>(
-
304  view.info().parentCloseTime.time_since_epoch())
-
305  .count() +
-
306  TOTAL_TIME_SLOT_SECS;
-
307  auctionSlot.setFieldU32(sfExpiration, expiration);
-
308  auctionSlot.setFieldAmount(sfPrice, STAmount{lptIssue, 0});
-
309  // Set the fee
-
310  if (tfee != 0)
-
311  ammSle->setFieldU16(sfTradingFee, tfee);
-
312  else if (ammSle->isFieldPresent(sfTradingFee))
-
313  ammSle->makeFieldAbsent(sfTradingFee);
-
314  if (auto const dfee = tfee / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION)
-
315  auctionSlot.setFieldU16(sfDiscountedFee, dfee);
-
316  else if (auctionSlot.isFieldPresent(sfDiscountedFee))
-
317  auctionSlot.makeFieldAbsent(sfDiscountedFee);
-
318 }
-
319 
-
320 } // namespace ripple
+
282  return tesSUCCESS;
+
283 }
+
284 
+
285 void
+
286 initializeFeeAuctionVote(
+
287  ApplyView& view,
+
288  std::shared_ptr<SLE>& ammSle,
+
289  AccountID const& account,
+
290  Issue const& lptIssue,
+
291  std::uint16_t tfee)
+
292 {
+
293  auto const& rules = view.rules();
+
294  // AMM creator gets the voting slot.
+
295  STArray voteSlots;
+
296  STObject voteEntry = STObject::makeInnerObject(sfVoteEntry, rules);
+
297  if (tfee != 0)
+
298  voteEntry.setFieldU16(sfTradingFee, tfee);
+
299  voteEntry.setFieldU32(sfVoteWeight, VOTE_WEIGHT_SCALE_FACTOR);
+
300  voteEntry.setAccountID(sfAccount, account);
+
301  voteSlots.push_back(voteEntry);
+
302  ammSle->setFieldArray(sfVoteSlots, voteSlots);
+
303  // AMM creator gets the auction slot for free.
+
304  // AuctionSlot is created on AMMCreate and updated on AMMDeposit
+
305  // when AMM is in an empty state
+
306  if (rules.enabled(fixInnerObjTemplate) &&
+
307  !ammSle->isFieldPresent(sfAuctionSlot))
+
308  {
+
309  STObject auctionSlot = STObject::makeInnerObject(sfAuctionSlot, rules);
+
310  ammSle->set(std::move(auctionSlot));
+
311  }
+
312  STObject& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot);
+
313  auctionSlot.setAccountID(sfAccount, account);
+
314  // current + sec in 24h
+
315  auto const expiration = std::chrono::duration_cast<std::chrono::seconds>(
+
316  view.info().parentCloseTime.time_since_epoch())
+
317  .count() +
+
318  TOTAL_TIME_SLOT_SECS;
+
319  auctionSlot.setFieldU32(sfExpiration, expiration);
+
320  auctionSlot.setFieldAmount(sfPrice, STAmount{lptIssue, 0});
+
321  // Set the fee
+
322  if (tfee != 0)
+
323  ammSle->setFieldU16(sfTradingFee, tfee);
+
324  else if (ammSle->isFieldPresent(sfTradingFee))
+
325  ammSle->makeFieldAbsent(sfTradingFee);
+
326  if (auto const dfee = tfee / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION)
+
327  auctionSlot.setFieldU16(sfDiscountedFee, dfee);
+
328  else if (auctionSlot.isFieldPresent(sfDiscountedFee))
+
329  auctionSlot.makeFieldAbsent(sfDiscountedFee);
+
330 }
+
331 
+
332 } // namespace ripple
ripple::ReadView::info
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
-
ripple::STObject::peekAtField
const STBase & peekAtField(SField const &field) const
Definition: STObject.cpp:373
+
ripple::STObject::peekAtField
const STBase & peekAtField(SField const &field) const
Definition: STObject.cpp:388
ripple::keylet::ownerDir
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition: Indexes.cpp:312
-
ripple::STObject::setAccountID
void setAccountID(SField const &field, AccountID const &)
Definition: STObject.cpp:689
+
ripple::STObject::setAccountID
void setAccountID(SField const &field, AccountID const &)
Definition: STObject.cpp:710
ripple::STAmount::negate
void negate()
Definition: STAmount.h:405
ripple::issues
bool issues(DebtDirection dir)
Definition: Steps.h:51
-
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:283
+
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:286
std::make_tuple
T make_tuple(T... args)
ripple::sfDiscountedFee
const SF_UINT16 sfDiscountedFee
-
ripple::STObject::makeFieldAbsent
void makeFieldAbsent(SField const &field)
Definition: STObject.cpp:514
+
ripple::STObject::makeFieldAbsent
void makeFieldAbsent(SField const &field)
Definition: STObject.cpp:529
ripple::STLedgerEntry
Definition: STLedgerEntry.h:30
ripple::Issue
A currency issued by an account.
Definition: Issue.h:35
ripple::sfAsset
const SF_ISSUE sfAsset
+
ripple::Rules::enabled
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Definition: Rules.cpp:94
std::shared_ptr
STL class.
ripple::sfOwnerNode
const SF_UINT64 sfOwnerNode
-
ripple::STObject::setFieldU16
void setFieldU16(SField const &field, std::uint16_t)
Definition: STObject.cpp:653
+
ripple::STObject::setFieldU16
void setFieldU16(SField const &field, std::uint16_t)
Definition: STObject.cpp:674
ripple::VOTE_WEIGHT_SCALE_FACTOR
constexpr std::uint32_t VOTE_WEIGHT_SCALE_FACTOR
Definition: AMMCore.h:45
ripple::ammHolds
Expected< std::tuple< STAmount, STAmount, STAmount >, TER > ammHolds(ReadView const &view, SLE const &ammSle, std::optional< Issue > const &optIssue1, std::optional< Issue > const &optIssue2, FreezeHandling freezeHandling, beast::Journal const j)
Get AMM pool and LP token balances.
Definition: AMMUtils.cpp:45
ripple::sfVoteSlots
const SField sfVoteSlots
@@ -437,9 +450,11 @@ $(function() {
ripple::LedgerHeader::parentCloseTime
NetClock::time_point parentCloseTime
Definition: LedgerHeader.h:42
ripple::SkipEntry::Yes
@ Yes
ripple::sfAsset2
const SF_ISSUE sfAsset2
-
ripple::STObject::setFieldArray
void setFieldArray(SField const &field, STArray const &v)
Definition: STObject.cpp:725
+
ripple::STObject::setFieldArray
void setFieldArray(SField const &field, STArray const &v)
Definition: STObject.cpp:746
+
ripple::STObject::makeInnerObject
static STObject makeInnerObject(SField const &name, Rules const &rules)
Definition: STObject.cpp:63
ripple::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition: Indexes.cpp:142
-
ripple::STObject::getAccountID
AccountID getAccountID(SField const &field) const
Definition: STObject.cpp:589
+
ripple::STObject::setFieldAmount
void setFieldAmount(SField const &field, STAmount const &)
Definition: STObject.cpp:728
+
ripple::STObject::getAccountID
AccountID getAccountID(SField const &field) const
Definition: STObject.cpp:604
ripple::tecAMM_INVALID_TOKENS
@ tecAMM_INVALID_TOKENS
Definition: TER.h:311
ripple::sfAuthAccounts
const SField sfAuthAccounts
ripple::getTradingFee
std::uint16_t getTradingFee(ReadView const &view, SLE const &ammSle, AccountID const &account)
Get AMM trading fee for the given account.
Definition: AMMUtils.cpp:138
@@ -457,16 +472,17 @@ $(function() {
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::cleanupOnAccountDelete
TER cleanupOnAccountDelete(ApplyView &view, Keylet const &ownerDirKeylet, EntryDeleter const &deleter, beast::Journal j, std::optional< uint16_t > maxNodesToDelete)
Definition: View.cpp:1531
ripple::detail::ApplyViewBase::erase
void erase(std::shared_ptr< SLE > const &sle) override
Remove a peeked SLE.
Definition: ApplyViewBase.cpp:134
-
ripple::STObject
Definition: STObject.h:53
+
ripple::STObject
Definition: STObject.h:54
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:54
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
-
ripple::STObject::peekFieldObject
STObject & peekFieldObject(SField const &field)
Definition: STObject.cpp:439
+
ripple::STObject::peekFieldObject
STObject & peekFieldObject(SField const &field)
Definition: STObject.cpp:454
ripple::TOTAL_TIME_SLOT_SECS
constexpr std::uint32_t TOTAL_TIME_SLOT_SECS
Definition: AMMCore.h:34
ripple::LedgerEntryType
LedgerEntryType
Identifiers for on-ledger objects.
Definition: LedgerFormats.h:53
ripple::ApplyView::emptyDirDelete
bool emptyDirDelete(Keylet const &directory)
Remove the specified directory, if it is empty.
Definition: ApplyView.cpp:125
-
ripple::deleteAMMTrustLines
static TER deleteAMMTrustLines(Sandbox &sb, AccountID const &ammAccountID, std::uint16_t maxTrustlinesToDelete, beast::Journal j)
Definition: AMMUtils.cpp:192
-
ripple::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition: STObject.cpp:428
-
ripple::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition: AMMUtils.cpp:234
+
ripple::ReadView::rules
virtual Rules const & rules() const =0
Returns the tx processing rules.
+
ripple::deleteAMMTrustLines
static TER deleteAMMTrustLines(Sandbox &sb, AccountID const &ammAccountID, std::uint16_t maxTrustlinesToDelete, beast::Journal j)
Definition: AMMUtils.cpp:195
+
ripple::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition: STObject.cpp:443
+
ripple::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition: AMMUtils.cpp:237
ripple::ammLPHolds
STAmount ammLPHolds(ReadView const &view, Currency const &cur1, Currency const &cur2, AccountID const &ammAccount, AccountID const &lpAccount, beast::Journal const j)
Get the balance of LP tokens.
Definition: AMMUtils.cpp:104
ripple::SkipEntry::No
@ No
ripple::sfBalance
const SF_AMOUNT sfBalance
@@ -478,10 +494,13 @@ $(function() {
ripple::detail::ApplyViewBase::peek
std::shared_ptr< SLE > peek(Keylet const &k) override
Prepare to modify the SLE associated with key.
Definition: ApplyViewBase.cpp:128
ripple::ammLPTCurrency
Currency ammLPTCurrency(Currency const &cur1, Currency const &cur2)
Calculate Liquidity Provider Token (LPT) Currency.
Definition: AMMCore.cpp:42
ripple::sfAuctionSlot
const SField sfAuctionSlot
-
ripple::ammAccountHolds
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition: AMMUtils.cpp:166
+
ripple::fixInnerObjTemplate
const uint256 fixInnerObjTemplate
+
ripple::STObject::set
void set(const SOTemplate &)
Definition: STObject.cpp:115
+
ripple::STObject::setFieldU32
void setFieldU32(SField const &field, std::uint32_t)
Definition: STObject.cpp:680
+
ripple::ammAccountHolds
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition: AMMUtils.cpp:169
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:235
ripple::isFrozen
bool isFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition: View.cpp:203
-
ripple::STObject::getFieldAmount
STAmount const & getFieldAmount(SField const &field) const
Definition: STObject.cpp:603
+
ripple::STObject::getFieldAmount
STAmount const & getFieldAmount(SField const &field) const
Definition: STObject.cpp:618
ripple::Issue::account
AccountID account
Definition: Issue.h:39
std::chrono
diff --git a/AMMUtils_8h_source.html b/AMMUtils_8h_source.html index bb02829198..c159a7b3d3 100644 --- a/AMMUtils_8h_source.html +++ b/AMMUtils_8h_source.html @@ -169,7 +169,7 @@ $(function() {
117 
118 #endif // RIPPLE_APP_MISC_AMMUTILS_H_INLCUDED
-
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:283
+
ripple::initializeFeeAuctionVote
void initializeFeeAuctionVote(ApplyView &view, std::shared_ptr< SLE > &ammSle, AccountID const &account, Issue const &lptIssue, std::uint16_t tfee)
Initialize Auction and Voting slots and set the trading/discounted fee.
Definition: AMMUtils.cpp:286
std::shared_ptr
STL class.
ripple::ammHolds
Expected< std::tuple< STAmount, STAmount, STAmount >, TER > ammHolds(ReadView const &view, SLE const &ammSle, std::optional< Issue > const &optIssue1, std::optional< Issue > const &optIssue2, FreezeHandling freezeHandling, beast::Journal const j)
Get AMM pool and LP token balances.
Definition: AMMUtils.cpp:45
std::pair
@@ -183,10 +183,10 @@ $(function() {
std::uint16_t
ripple::Currency
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition: UintTypes.h:56
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
-
ripple::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition: AMMUtils.cpp:234
+
ripple::deleteAMMAccount
TER deleteAMMAccount(Sandbox &view, Issue const &asset, Issue const &asset2, beast::Journal j)
Delete trustlines to AMM.
Definition: AMMUtils.cpp:237
ripple::ammLPHolds
STAmount ammLPHolds(ReadView const &view, Currency const &cur1, Currency const &cur2, AccountID const &ammAccount, AccountID const &lpAccount, beast::Journal const j)
Get the balance of LP tokens.
Definition: AMMUtils.cpp:104
std::optional
-
ripple::ammAccountHolds
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition: AMMUtils.cpp:166
+
ripple::ammAccountHolds
STAmount ammAccountHolds(ReadView const &view, AccountID const &ammAccountID, Issue const &issue)
Returns total amount held by AMM for the given token.
Definition: AMMUtils.cpp:169
ripple::AccountID
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition: AccountID.h:49