chore: Add comment explaining why ammLPHolds is called twice (#6546)

This commit is contained in:
Mayukha Vadari
2026-03-17 16:11:36 -04:00
committed by GitHub
parent 5fc4ab3e37
commit 95a45d7442

View File

@@ -128,8 +128,7 @@ AMMClawback::applyGuts(Sandbox& sb)
if (sb.rules().enabled(fixAMMClawbackRounding))
{
// retrieve LP token balance inside the amendment gate to avoid
// inconsistent error behavior
// retrieve LP token balance inside the amendment gate to avoid inconsistent error behavior
auto const lpTokenBalance = ammLPHolds(sb, *ammSle, holder, j_);
if (lpTokenBalance == beast::zero)
return tecAMM_BALANCE;
@@ -138,7 +137,6 @@ AMMClawback::applyGuts(Sandbox& sb)
!res)
return res.error(); // LCOV_EXCL_LINE
}
auto const expected =
ammHolds(sb, *ammSle, asset, asset2, FreezeHandling::fhIGNORE_FREEZE, ctx_.journal);
@@ -151,6 +149,8 @@ AMMClawback::applyGuts(Sandbox& sb)
STAmount amountWithdraw;
std::optional<STAmount> amount2Withdraw;
// calling a second time on purpose since `verifyAndAdjustLPTokenBalance` rounds and may adjust
// the balance
auto const holdLPtokens = ammLPHolds(sb, *ammSle, holder, j_);
if (holdLPtokens == beast::zero)
return tecAMM_BALANCE;