Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ckeshava committed Apr 5, 2024
2 parents bf1712a + 16a6515 commit 015c5cd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/test/app/AMM_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,17 +1128,24 @@ struct AMM_test : public jtx::AMMTest
expectLedgerEntryRoot(env, carol, XRPAmount{28'999'999'990}));
});

// equal asset deposit: the specified value of LPTokens triggers a
// rounding-down of LPTokens in the adjustLPToken calculations
// equal asset deposit: unit test to exercise the rounding-down of
// LPTokens in the adjustLPToken calculations. Any LPTokens with a
// non-zero fractional part will trigger this piece of code
// (AMMHelpers.cpp: adjustLPTokens)
testAMM([&](AMM& ammAlice, Env& env) {
const IOUAmount newLPTokens{UINT64_C(488088'4817015109), -10};
// Approximately 1% of the existing pool
const Number deltaLPTokens{UINT64_C(100000'1), -1};
const IOUAmount newLPTokens{deltaLPTokens.mantissa(),
deltaLPTokens.exponent()};

// carol performs a two-asset deposit
ammAlice.deposit(DepositArg{.account = carol, .tokens =
newLPTokens});

// fraction of newLPTokens/(existing LPToken balance). Carol is
// seeking additional 488088.4817015109 LPTokens. The existing
// seeking additional 100000.1 LPTokens. The existing
// LPToken balance is 1e7
const Number fr = Number{UINT64_C(488088'4817015109), -10}/1e7;
const Number fr = deltaLPTokens/1e7;

// The below equations are based on Equation 1, 2 from XLS-30d
// specification, Section: 2.3.1.2
Expand Down

0 comments on commit 015c5cd

Please sign in to comment.