mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
removes side-effects from tryOverpayment
This commit is contained in:
@@ -668,23 +668,14 @@ class LendingHelpers_test : public beast::unit_test::suite
|
|||||||
std::cout << loanProperites.loanState.interestOutstanding()
|
std::cout << loanProperites.loanState.interestOutstanding()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
Number totalValueOutstanding =
|
|
||||||
loanProperites.loanState.valueOutstanding;
|
|
||||||
Number principalOutstanding =
|
|
||||||
loanProperites.loanState.principalOutstanding;
|
|
||||||
Number managementFeeOutstanding =
|
|
||||||
loanProperites.loanState.managementFeeDue;
|
|
||||||
Number periodicPayment = loanProperites.periodicPayment;
|
Number periodicPayment = loanProperites.periodicPayment;
|
||||||
|
|
||||||
auto const ret = tryOverpayment(
|
auto const ret = tryOverpayment(
|
||||||
asset,
|
asset,
|
||||||
loanScale,
|
loanScale,
|
||||||
overpaymentComponents,
|
overpaymentComponents,
|
||||||
totalValueOutstanding,
|
loanProperites.loanState,
|
||||||
principalOutstanding,
|
|
||||||
managementFeeOutstanding,
|
|
||||||
periodicPayment,
|
periodicPayment,
|
||||||
paymentInterval,
|
|
||||||
periodicRate,
|
periodicRate,
|
||||||
paymentsRemaining,
|
paymentsRemaining,
|
||||||
managementFeeRate,
|
managementFeeRate,
|
||||||
@@ -692,50 +683,45 @@ class LendingHelpers_test : public beast::unit_test::suite
|
|||||||
|
|
||||||
BEAST_EXPECT(ret);
|
BEAST_EXPECT(ret);
|
||||||
|
|
||||||
auto const& actualPaymentParts = *ret;
|
auto const& [actualPaymentParts, newLoanProperties] = *ret;
|
||||||
|
auto const newState = newLoanProperties.loanState;
|
||||||
|
|
||||||
BEAST_EXPECTS(
|
BEAST_EXPECTS(
|
||||||
actualPaymentParts.valueChange ==
|
actualPaymentParts.valueChange ==
|
||||||
((totalValueOutstanding - principalOutstanding -
|
newState.interestDue - loanProperites.loanState.interestDue,
|
||||||
managementFeeOutstanding)) -
|
|
||||||
loanProperites.loanState.interestDue,
|
|
||||||
" valueChange mismatch: expected " +
|
" valueChange mismatch: expected " +
|
||||||
to_string(
|
to_string(
|
||||||
(totalValueOutstanding - principalOutstanding -
|
newState.interestDue -
|
||||||
managementFeeOutstanding) -
|
|
||||||
loanProperites.loanState.interestDue) +
|
loanProperites.loanState.interestDue) +
|
||||||
", got " + to_string(actualPaymentParts.valueChange));
|
", got " + to_string(actualPaymentParts.valueChange));
|
||||||
|
|
||||||
BEAST_EXPECTS(
|
BEAST_EXPECTS(
|
||||||
actualPaymentParts.feePaid ==
|
actualPaymentParts.feePaid ==
|
||||||
loanProperites.loanState.managementFeeDue -
|
loanProperites.loanState.managementFeeDue -
|
||||||
managementFeeOutstanding,
|
newState.managementFeeDue,
|
||||||
" feePaid mismatch: expected " +
|
" feePaid mismatch: expected " +
|
||||||
to_string(
|
to_string(
|
||||||
loanProperites.loanState.managementFeeDue -
|
loanProperites.loanState.managementFeeDue -
|
||||||
managementFeeOutstanding) +
|
newState.managementFeeDue) +
|
||||||
", got " + to_string(actualPaymentParts.feePaid));
|
", got " + to_string(actualPaymentParts.feePaid));
|
||||||
|
|
||||||
BEAST_EXPECTS(
|
BEAST_EXPECTS(
|
||||||
actualPaymentParts.principalPaid ==
|
actualPaymentParts.principalPaid ==
|
||||||
loanProperites.loanState.principalOutstanding -
|
loanProperites.loanState.principalOutstanding -
|
||||||
principalOutstanding,
|
newState.principalOutstanding,
|
||||||
" principalPaid mismatch: expected " +
|
" principalPaid mismatch: expected " +
|
||||||
to_string(
|
to_string(
|
||||||
loanProperites.loanState.principalOutstanding -
|
loanProperites.loanState.principalOutstanding -
|
||||||
principalOutstanding) +
|
newState.principalOutstanding) +
|
||||||
", got " + to_string(actualPaymentParts.principalPaid));
|
", got " + to_string(actualPaymentParts.principalPaid));
|
||||||
|
|
||||||
BEAST_EXPECTS(
|
BEAST_EXPECTS(
|
||||||
actualPaymentParts.interestPaid ==
|
actualPaymentParts.interestPaid ==
|
||||||
loanProperites.loanState.interestDue -
|
loanProperites.loanState.interestDue - newState.interestDue,
|
||||||
(totalValueOutstanding - principalOutstanding -
|
|
||||||
managementFeeOutstanding),
|
|
||||||
" interestPaid mismatch: expected " +
|
" interestPaid mismatch: expected " +
|
||||||
to_string(
|
to_string(
|
||||||
loanProperites.loanState.interestDue -
|
loanProperites.loanState.interestDue -
|
||||||
(totalValueOutstanding - principalOutstanding -
|
newState.interestDue) +
|
||||||
managementFeeOutstanding)) +
|
|
||||||
", got " + to_string(actualPaymentParts.interestPaid));
|
", got " + to_string(actualPaymentParts.interestPaid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -361,16 +361,13 @@ struct LoanStateDeltas
|
|||||||
nonNegative();
|
nonNegative();
|
||||||
};
|
};
|
||||||
|
|
||||||
Expected<LoanPaymentParts, TER>
|
Expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
|
||||||
tryOverpayment(
|
tryOverpayment(
|
||||||
Asset const& asset,
|
Asset const& asset,
|
||||||
std::int32_t loanScale,
|
std::int32_t loanScale,
|
||||||
ExtendedPaymentComponents const& overpaymentComponents,
|
ExtendedPaymentComponents const& overpaymentComponents,
|
||||||
Number& totalValueOutstanding,
|
LoanState const& roundedLoanState,
|
||||||
Number& principalOutstanding,
|
Number const& periodicPayment,
|
||||||
Number& managementFeeOutstanding,
|
|
||||||
Number& periodicPayment,
|
|
||||||
std::uint32_t paymentInterval,
|
|
||||||
Number const& periodicRate,
|
Number const& periodicRate,
|
||||||
std::uint32_t paymentRemaining,
|
std::uint32_t paymentRemaining,
|
||||||
TenthBips16 const managementFeeRate,
|
TenthBips16 const managementFeeRate,
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// DO NOT REMOVE forces header file include to sort first
|
// DO NOT REMOVE forces header file include to sort first
|
||||||
#include <xrpld/app/tx/detail/VaultCreate.h>
|
#include <xrpld/app/tx/detail/VaultCreate.h>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -382,16 +384,13 @@ doPayment(
|
|||||||
* The function preserves accumulated rounding errors across the re-amortization
|
* The function preserves accumulated rounding errors across the re-amortization
|
||||||
* to ensure the loan state remains consistent with its payment history.
|
* to ensure the loan state remains consistent with its payment history.
|
||||||
*/
|
*/
|
||||||
Expected<LoanPaymentParts, TER>
|
Expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
|
||||||
tryOverpayment(
|
tryOverpayment(
|
||||||
Asset const& asset,
|
Asset const& asset,
|
||||||
std::int32_t loanScale,
|
std::int32_t loanScale,
|
||||||
ExtendedPaymentComponents const& overpaymentComponents,
|
ExtendedPaymentComponents const& overpaymentComponents,
|
||||||
Number& totalValueOutstanding,
|
LoanState const& roundedOldState,
|
||||||
Number& principalOutstanding,
|
Number const& periodicPayment,
|
||||||
Number& managementFeeOutstanding,
|
|
||||||
Number& periodicPayment,
|
|
||||||
std::uint32_t paymentInterval,
|
|
||||||
Number const& periodicRate,
|
Number const& periodicRate,
|
||||||
std::uint32_t paymentRemaining,
|
std::uint32_t paymentRemaining,
|
||||||
TenthBips16 const managementFeeRate,
|
TenthBips16 const managementFeeRate,
|
||||||
@@ -401,15 +400,11 @@ tryOverpayment(
|
|||||||
auto const raw = computeRawLoanState(
|
auto const raw = computeRawLoanState(
|
||||||
periodicPayment, periodicRate, paymentRemaining, managementFeeRate);
|
periodicPayment, periodicRate, paymentRemaining, managementFeeRate);
|
||||||
|
|
||||||
// Get the actual loan state (with accumulated rounding from past payments)
|
|
||||||
auto const rounded = constructLoanState(
|
|
||||||
totalValueOutstanding, principalOutstanding, managementFeeOutstanding);
|
|
||||||
|
|
||||||
// Calculate the accumulated rounding errors. These need to be preserved
|
// Calculate the accumulated rounding errors. These need to be preserved
|
||||||
// across the re-amortization to maintain consistency with the loan's
|
// across the re-amortization to maintain consistency with the loan's
|
||||||
// payment history. Without preserving these errors, the loan could end
|
// payment history. Without preserving these errors, the loan could end
|
||||||
// up with a different total value than what the borrower has actually paid.
|
// up with a different total value than what the borrower has actually paid.
|
||||||
auto const errors = rounded - raw;
|
auto const errors = roundedOldState - raw;
|
||||||
|
|
||||||
// Compute the new principal by applying the overpayment to the raw
|
// Compute the new principal by applying the overpayment to the raw
|
||||||
// (theoretical) principal. Use max with 0 to ensure we never go negative.
|
// (theoretical) principal. Use max with 0 to ensure we never go negative.
|
||||||
@@ -450,37 +445,35 @@ tryOverpayment(
|
|||||||
// rounding errors. This ensures the loan's tracked state remains
|
// rounding errors. This ensures the loan's tracked state remains
|
||||||
// consistent with its payment history.
|
// consistent with its payment history.
|
||||||
|
|
||||||
principalOutstanding = std::clamp(
|
auto const principalOutstanding = std::clamp(
|
||||||
roundToAsset(
|
roundToAsset(
|
||||||
asset, newRaw.principalOutstanding, loanScale, Number::upward),
|
asset, newRaw.principalOutstanding, loanScale, Number::upward),
|
||||||
numZero,
|
numZero,
|
||||||
rounded.principalOutstanding);
|
roundedOldState.principalOutstanding);
|
||||||
totalValueOutstanding = std::clamp(
|
auto const totalValueOutstanding = std::clamp(
|
||||||
roundToAsset(
|
roundToAsset(
|
||||||
asset,
|
asset,
|
||||||
principalOutstanding + newRaw.interestOutstanding(),
|
principalOutstanding + newRaw.interestOutstanding(),
|
||||||
loanScale,
|
loanScale,
|
||||||
Number::upward),
|
Number::upward),
|
||||||
numZero,
|
numZero,
|
||||||
rounded.valueOutstanding);
|
roundedOldState.valueOutstanding);
|
||||||
managementFeeOutstanding = std::clamp(
|
auto const managementFeeOutstanding = std::clamp(
|
||||||
roundToAsset(asset, newRaw.managementFeeDue, loanScale),
|
roundToAsset(asset, newRaw.managementFeeDue, loanScale),
|
||||||
numZero,
|
numZero,
|
||||||
rounded.managementFeeDue);
|
roundedOldState.managementFeeDue);
|
||||||
|
|
||||||
auto const newRounded = constructLoanState(
|
auto const roundedNewState = constructLoanState(
|
||||||
totalValueOutstanding, principalOutstanding, managementFeeOutstanding);
|
totalValueOutstanding, principalOutstanding, managementFeeOutstanding);
|
||||||
|
|
||||||
// Update newLoanProperties so that checkLoanGuards can make an accurate
|
// Update newLoanProperties so that checkLoanGuards can make an accurate
|
||||||
// evaluation.
|
// evaluation.
|
||||||
newLoanProperties.loanState.valueOutstanding = newRounded.valueOutstanding;
|
newLoanProperties.loanState = roundedNewState;
|
||||||
|
|
||||||
JLOG(j.debug()) << "new rounded value: " << newRounded.valueOutstanding
|
JLOG(j.debug()) << "new rounded value: " << roundedNewState.valueOutstanding
|
||||||
<< ", principal: " << newRounded.principalOutstanding
|
<< ", principal: " << roundedNewState.principalOutstanding
|
||||||
<< ", interest gross: " << newRounded.interestOutstanding();
|
<< ", interest gross: "
|
||||||
|
<< roundedNewState.interestOutstanding();
|
||||||
// Update the periodic payment to reflect the re-amortized schedule
|
|
||||||
periodicPayment = newLoanProperties.periodicPayment;
|
|
||||||
|
|
||||||
// check that the loan is still valid
|
// check that the loan is still valid
|
||||||
if (auto const ter = checkLoanGuards(
|
if (auto const ter = checkLoanGuards(
|
||||||
@@ -490,7 +483,7 @@ tryOverpayment(
|
|||||||
// small interest amounts, that may have already been paid
|
// small interest amounts, that may have already been paid
|
||||||
// off. Check what's still outstanding. This should
|
// off. Check what's still outstanding. This should
|
||||||
// guarantee that the interest checks pass.
|
// guarantee that the interest checks pass.
|
||||||
newRounded.interestOutstanding() != beast::zero,
|
roundedNewState.interestOutstanding() != beast::zero,
|
||||||
paymentRemaining,
|
paymentRemaining,
|
||||||
newLoanProperties,
|
newLoanProperties,
|
||||||
j))
|
j))
|
||||||
@@ -520,19 +513,16 @@ tryOverpayment(
|
|||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const deltas = rounded - newRounded;
|
auto const deltas = roundedOldState - roundedNewState;
|
||||||
|
|
||||||
// The change in loan management fee is equal to the change between the old
|
// The change in loan management fee is equal to the change between the old
|
||||||
// and the new outstanding management fees
|
// and the new outstanding management fees
|
||||||
XRPL_ASSERT_PARTS(
|
XRPL_ASSERT_PARTS(
|
||||||
deltas.managementFee ==
|
deltas.managementFee ==
|
||||||
rounded.managementFeeDue - managementFeeOutstanding,
|
roundedOldState.managementFeeDue - managementFeeOutstanding,
|
||||||
"ripple::detail::tryOverpayment",
|
"ripple::detail::tryOverpayment",
|
||||||
"no fee change");
|
"no fee change");
|
||||||
|
|
||||||
auto const hypotheticalValueOutstanding =
|
|
||||||
rounded.valueOutstanding - deltas.principal;
|
|
||||||
|
|
||||||
// Calculate how the loan's value changed due to the overpayment.
|
// Calculate how the loan's value changed due to the overpayment.
|
||||||
// This should be negative (value decreased) or zero. A principal
|
// This should be negative (value decreased) or zero. A principal
|
||||||
// overpayment should never increase the loan's value.
|
// overpayment should never increase the loan's value.
|
||||||
@@ -543,21 +533,28 @@ tryOverpayment(
|
|||||||
"the loan. Ignore the overpayment";
|
"the loan. Ignore the overpayment";
|
||||||
return Unexpected(tesSUCCESS);
|
return Unexpected(tesSUCCESS);
|
||||||
}
|
}
|
||||||
return LoanPaymentParts{
|
|
||||||
// Principal paid is the reduction in principal outstanding
|
return std::make_pair(
|
||||||
.principalPaid = deltas.principal,
|
LoanPaymentParts{
|
||||||
// Interest paid is the reduction in interest due
|
// Principal paid is the reduction in principal outstanding
|
||||||
.interestPaid =
|
.principalPaid = deltas.principal,
|
||||||
deltas.interest + overpaymentComponents.untrackedInterest,
|
// Interest paid is the reduction in interest due
|
||||||
// Value change includes both the reduction from paying down principal
|
.interestPaid =
|
||||||
// (negative) and any untracked interest penalties (positive, e.g., if
|
deltas.interest + overpaymentComponents.untrackedInterest,
|
||||||
// the overpayment itself incurs a fee)
|
// Value change includes both the reduction from paying down
|
||||||
.valueChange =
|
// principal
|
||||||
valueChange + overpaymentComponents.trackedInterestPart(),
|
// (negative) and any untracked interest penalties (positive, e.g.,
|
||||||
// Fee paid includes both the reduction in tracked management fees and
|
// if
|
||||||
// any untracked fees on the overpayment itself
|
// the overpayment itself incurs a fee)
|
||||||
.feePaid = deltas.managementFee +
|
.valueChange =
|
||||||
overpaymentComponents.untrackedManagementFee};
|
valueChange + overpaymentComponents.trackedInterestPart(),
|
||||||
|
// Fee paid includes both the reduction in tracked management fees
|
||||||
|
// and
|
||||||
|
// any untracked fees on the overpayment itself
|
||||||
|
.feePaid = deltas.managementFee +
|
||||||
|
overpaymentComponents.untrackedManagementFee,
|
||||||
|
},
|
||||||
|
newLoanProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validates and applies an overpayment to the loan state.
|
/* Validates and applies an overpayment to the loan state.
|
||||||
@@ -581,20 +578,16 @@ doOverpayment(
|
|||||||
NumberProxy& principalOutstandingProxy,
|
NumberProxy& principalOutstandingProxy,
|
||||||
NumberProxy& managementFeeOutstandingProxy,
|
NumberProxy& managementFeeOutstandingProxy,
|
||||||
NumberProxy& periodicPaymentProxy,
|
NumberProxy& periodicPaymentProxy,
|
||||||
std::uint32_t const paymentInterval,
|
|
||||||
Number const& periodicRate,
|
Number const& periodicRate,
|
||||||
std::uint32_t const paymentRemaining,
|
std::uint32_t const paymentRemaining,
|
||||||
TenthBips16 const managementFeeRate,
|
TenthBips16 const managementFeeRate,
|
||||||
beast::Journal j)
|
beast::Journal j)
|
||||||
{
|
{
|
||||||
// Create temporary copies of the loan state that can be safely modified
|
auto const loanState = constructLoanState(
|
||||||
// and discarded if the overpayment doesn't work out. This prevents
|
totalValueOutstandingProxy,
|
||||||
// corrupting the actual ledger data if validation fails.
|
principalOutstandingProxy,
|
||||||
Number totalValueOutstanding = totalValueOutstandingProxy;
|
managementFeeOutstandingProxy);
|
||||||
Number principalOutstanding = principalOutstandingProxy;
|
auto const periodicPayment = periodicPaymentProxy;
|
||||||
Number managementFeeOutstanding = managementFeeOutstandingProxy;
|
|
||||||
Number periodicPayment = periodicPaymentProxy;
|
|
||||||
|
|
||||||
JLOG(j.debug())
|
JLOG(j.debug())
|
||||||
<< "overpayment components:"
|
<< "overpayment components:"
|
||||||
<< ", totalValue before: " << *totalValueOutstandingProxy
|
<< ", totalValue before: " << *totalValueOutstandingProxy
|
||||||
@@ -613,11 +606,8 @@ doOverpayment(
|
|||||||
asset,
|
asset,
|
||||||
loanScale,
|
loanScale,
|
||||||
overpaymentComponents,
|
overpaymentComponents,
|
||||||
totalValueOutstanding,
|
loanState,
|
||||||
principalOutstanding,
|
|
||||||
managementFeeOutstanding,
|
|
||||||
periodicPayment,
|
periodicPayment,
|
||||||
paymentInterval,
|
|
||||||
periodicRate,
|
periodicRate,
|
||||||
paymentRemaining,
|
paymentRemaining,
|
||||||
managementFeeRate,
|
managementFeeRate,
|
||||||
@@ -625,18 +615,19 @@ doOverpayment(
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return Unexpected(ret.error());
|
return Unexpected(ret.error());
|
||||||
|
|
||||||
auto const& loanPaymentParts = *ret;
|
auto const& [loanPaymentParts, newLoanProperties] = *ret;
|
||||||
|
auto const newRoundedLoanState = newLoanProperties.loanState;
|
||||||
|
|
||||||
// Safety check: the principal must have decreased. If it didn't (or
|
// Safety check: the principal must have decreased. If it didn't (or
|
||||||
// increased!), something went wrong in the calculation and we should
|
// increased!), something went wrong in the calculation and we should
|
||||||
// reject the overpayment.
|
// reject the overpayment.
|
||||||
if (principalOutstandingProxy <= principalOutstanding)
|
if (principalOutstandingProxy <= newRoundedLoanState.principalOutstanding)
|
||||||
{
|
{
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
JLOG(j.warn()) << "Overpayment not allowed: principal "
|
JLOG(j.warn()) << "Overpayment not allowed: principal "
|
||||||
<< "outstanding did not decrease. Before: "
|
<< "outstanding did not decrease. Before: "
|
||||||
<< *principalOutstandingProxy
|
<< *principalOutstandingProxy << ". After: "
|
||||||
<< ". After: " << principalOutstanding;
|
<< newRoundedLoanState.principalOutstanding;
|
||||||
return Unexpected(tesSUCCESS);
|
return Unexpected(tesSUCCESS);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
@@ -647,28 +638,29 @@ doOverpayment(
|
|||||||
|
|
||||||
XRPL_ASSERT_PARTS(
|
XRPL_ASSERT_PARTS(
|
||||||
overpaymentComponents.trackedPrincipalDelta ==
|
overpaymentComponents.trackedPrincipalDelta ==
|
||||||
principalOutstandingProxy - principalOutstanding,
|
principalOutstandingProxy -
|
||||||
|
newRoundedLoanState.principalOutstanding,
|
||||||
"ripple::detail::doOverpayment",
|
"ripple::detail::doOverpayment",
|
||||||
"principal change agrees");
|
"principal change agrees");
|
||||||
|
|
||||||
// I'm not 100% sure the following asserts are correct. If in doubt, and
|
// I'm not 100% sure the following asserts are correct. If in doubt, and
|
||||||
// everything else works, remove any that cause trouble.
|
// everything else works, remove any that cause trouble.
|
||||||
|
|
||||||
JLOG(j.debug()) << "valueChange: " << loanPaymentParts.valueChange
|
JLOG(j.debug())
|
||||||
<< ", totalValue before: " << *totalValueOutstandingProxy
|
<< "valueChange: " << loanPaymentParts.valueChange
|
||||||
<< ", totalValue after: " << totalValueOutstanding
|
<< ", totalValue before: " << *totalValueOutstandingProxy
|
||||||
<< ", totalValue delta: "
|
<< ", totalValue after: " << newRoundedLoanState.valueOutstanding
|
||||||
<< (totalValueOutstandingProxy - totalValueOutstanding)
|
<< ", totalValue delta: "
|
||||||
<< ", principalDelta: "
|
<< (totalValueOutstandingProxy - newRoundedLoanState.valueOutstanding)
|
||||||
<< overpaymentComponents.trackedPrincipalDelta
|
<< ", principalDelta: " << overpaymentComponents.trackedPrincipalDelta
|
||||||
<< ", principalPaid: " << loanPaymentParts.principalPaid
|
<< ", principalPaid: " << loanPaymentParts.principalPaid
|
||||||
<< ", Computed difference: "
|
<< ", Computed difference: "
|
||||||
<< overpaymentComponents.trackedPrincipalDelta -
|
<< overpaymentComponents.trackedPrincipalDelta -
|
||||||
(totalValueOutstandingProxy - totalValueOutstanding);
|
(totalValueOutstandingProxy - newRoundedLoanState.valueOutstanding);
|
||||||
|
|
||||||
XRPL_ASSERT_PARTS(
|
XRPL_ASSERT_PARTS(
|
||||||
loanPaymentParts.valueChange ==
|
loanPaymentParts.valueChange ==
|
||||||
totalValueOutstanding -
|
newRoundedLoanState.valueOutstanding -
|
||||||
(totalValueOutstandingProxy -
|
(totalValueOutstandingProxy -
|
||||||
overpaymentComponents.trackedPrincipalDelta) +
|
overpaymentComponents.trackedPrincipalDelta) +
|
||||||
overpaymentComponents.trackedInterestPart(),
|
overpaymentComponents.trackedInterestPart(),
|
||||||
@@ -683,10 +675,10 @@ doOverpayment(
|
|||||||
|
|
||||||
// All validations passed, so update the proxy objects (which will
|
// All validations passed, so update the proxy objects (which will
|
||||||
// modify the actual Loan ledger object)
|
// modify the actual Loan ledger object)
|
||||||
totalValueOutstandingProxy = totalValueOutstanding;
|
totalValueOutstandingProxy = newRoundedLoanState.valueOutstanding;
|
||||||
principalOutstandingProxy = principalOutstanding;
|
principalOutstandingProxy = newRoundedLoanState.principalOutstanding;
|
||||||
managementFeeOutstandingProxy = managementFeeOutstanding;
|
managementFeeOutstandingProxy = newRoundedLoanState.managementFeeDue;
|
||||||
periodicPaymentProxy = periodicPayment;
|
periodicPaymentProxy = newLoanProperties.periodicPayment;
|
||||||
|
|
||||||
return loanPaymentParts;
|
return loanPaymentParts;
|
||||||
}
|
}
|
||||||
@@ -1955,7 +1947,6 @@ loanMakePayment(
|
|||||||
principalOutstandingProxy,
|
principalOutstandingProxy,
|
||||||
managementFeeOutstandingProxy,
|
managementFeeOutstandingProxy,
|
||||||
periodicPaymentProxy,
|
periodicPaymentProxy,
|
||||||
paymentInterval,
|
|
||||||
periodicRate,
|
periodicRate,
|
||||||
paymentRemainingProxy,
|
paymentRemainingProxy,
|
||||||
managementFeeRate,
|
managementFeeRate,
|
||||||
|
|||||||
Reference in New Issue
Block a user