diff --git a/src/xrpld/app/misc/detail/AMMUtils.cpp b/src/xrpld/app/misc/detail/AMMUtils.cpp index f5f6ae6612c..73c4ae36010 100644 --- a/src/xrpld/app/misc/detail/AMMUtils.cpp +++ b/src/xrpld/app/misc/detail/AMMUtils.cpp @@ -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 diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 8347f476245..fc6e2565317 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -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) @@ -331,8 +332,7 @@ accountHolds( assert(sleAmm); - if ((zeroIfFrozen == fhZERO_IF_FROZEN) && - isLPTokenFrozen( + if (isLPTokenFrozen( view, account, (*sleAmm)[sfAsset].get(),