Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Dec 18, 2024
1 parent 7f60ca9 commit ed061b9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
35 changes: 28 additions & 7 deletions src/xrpld/app/misc/detail/AMMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,34 @@ ammLPHolds(
AccountID const& lpAccount,
beast::Journal const j)
{
return accountHolds(
view,
lpAccount,
ammLPTCurrency(cur1, cur2),
ammAccount,
FreezeHandling::fhZERO_IF_FROZEN,
j);
auto const currency = ammLPTCurrency(cur1, cur2);
STAmount amount;

// IOU: Return balance on trust line modulo freeze
auto const sle = view.read(keylet::line(lpAccount, ammAccount, currency));
if (!sle)
{
amount.clear(Issue{currency, ammAccount});
}
else if (isFrozen(view, lpAccount, currency, ammAccount))
{
amount.clear(Issue{currency, ammAccount});
}
else
{
amount = sle->getFieldAmount(sfBalance);
if (lpAccount > ammAccount)
{
// Put balance in account terms.
amount.negate();
}
amount.setIssuer(ammAccount);
}
JLOG(j.trace()) << "ammLPHolds:"
<< " account=" << to_string(lpAccount)
<< " amount=" << amount.getFullText();

return view.balanceHook(lpAccount, ammAccount, amount);
}

STAmount
Expand Down
6 changes: 3 additions & 3 deletions src/xrpld/ledger/detail/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ accountHolds(

// if it's a LPToken, also need to check if issuers of the asset pair
// has frozen holder's trustline
if (view.rules().enabled(fixFrozenLPTokenTransfer))
if (view.rules().enabled(fixFrozenLPTokenTransfer) &&
zeroIfFrozen == fhZERO_IF_FROZEN)
{
auto const sleIssuer = view.read(keylet::account(issuer));
if (!sleIssuer)
Expand All @@ -331,8 +332,7 @@ accountHolds(

assert(sleAmm);

if ((zeroIfFrozen == fhZERO_IF_FROZEN) &&
isLPTokenFrozen(
if (isLPTokenFrozen(
view,
account,
(*sleAmm)[sfAsset].get<Issue>(),
Expand Down

0 comments on commit ed061b9

Please sign in to comment.