mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Review feedback from @gregtatcam: constructRoundedLoanState
- Rename the overload of constructRoundedLoanState that takes components as inputs to constructLoanState. The original function did no rounding or enforcement of the inputs being rounded. - Left the overload constructRoundedLoanState(SLE::const_ref loan) alone, because Loan objects are assumed to be rounded.
This commit is contained in:
@@ -906,7 +906,7 @@ protected:
|
||||
state.loanScale,
|
||||
Number::upward);
|
||||
|
||||
auto currentRoundedState = constructRoundedLoanState(
|
||||
auto currentRoundedState = constructLoanState(
|
||||
state.totalValue,
|
||||
state.principalOutstanding,
|
||||
state.managementFeeOutstanding);
|
||||
@@ -2666,7 +2666,7 @@ protected:
|
||||
periodicRate,
|
||||
state.paymentRemaining,
|
||||
broker.params.managementFeeRate);
|
||||
auto const rounded = constructRoundedLoanState(
|
||||
auto const rounded = constructLoanState(
|
||||
state.totalValue,
|
||||
state.principalOutstanding,
|
||||
state.managementFeeOutstanding);
|
||||
@@ -5843,7 +5843,7 @@ protected:
|
||||
Number const latePaymentFeeRounded = roundToAsset(
|
||||
broker.asset, loanSle->at(sfLatePaymentFee), state.loanScale);
|
||||
|
||||
auto const roundedLoanState = constructRoundedLoanState(
|
||||
auto const roundedLoanState = constructLoanState(
|
||||
state.totalValue,
|
||||
state.principalOutstanding,
|
||||
state.managementFeeOutstanding);
|
||||
|
||||
@@ -153,12 +153,15 @@ calculateRawLoanState(
|
||||
std::uint32_t const paymentRemaining,
|
||||
TenthBips32 const managementFeeRate);
|
||||
|
||||
// Constructs a valid LoanState object from arbitrary inputs
|
||||
LoanState
|
||||
constructRoundedLoanState(
|
||||
constructLoanState(
|
||||
Number const& totalValueOutstanding,
|
||||
Number const& principalOutstanding,
|
||||
Number const& managementFeeOutstanding);
|
||||
|
||||
// Constructs a valid LoanState object from a Loan object, which always has
|
||||
// rounded values
|
||||
LoanState
|
||||
constructRoundedLoanState(SLE::const_ref loan);
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ tryOverpayment(
|
||||
{
|
||||
auto const raw = calculateRawLoanState(
|
||||
periodicPayment, periodicRate, paymentRemaining, managementFeeRate);
|
||||
auto const rounded = constructRoundedLoanState(
|
||||
auto const rounded = constructLoanState(
|
||||
totalValueOutstanding, principalOutstanding, managementFeeOutstanding);
|
||||
|
||||
auto const errors = rounded - raw;
|
||||
@@ -427,7 +427,7 @@ tryOverpayment(
|
||||
numZero,
|
||||
rounded.managementFeeDue);
|
||||
|
||||
auto const newRounded = constructRoundedLoanState(
|
||||
auto const newRounded = constructLoanState(
|
||||
totalValueOutstanding, principalOutstanding, managementFeeOutstanding);
|
||||
|
||||
newLoanProperties.totalValueOutstanding = newRounded.valueOutstanding;
|
||||
@@ -896,7 +896,7 @@ computePaymentComponents(
|
||||
.interestDue = roundToAsset(asset, trueTarget.interestDue, scale),
|
||||
.managementFeeDue =
|
||||
roundToAsset(asset, trueTarget.managementFeeDue, scale)};
|
||||
LoanState const currentLedgerState = constructRoundedLoanState(
|
||||
LoanState const currentLedgerState = constructLoanState(
|
||||
totalValueOutstanding, principalOutstanding, managementFeeOutstanding);
|
||||
|
||||
LoanDeltas deltas = currentLedgerState - roundedTarget;
|
||||
@@ -1307,7 +1307,7 @@ calculateRawLoanState(
|
||||
}
|
||||
|
||||
LoanState
|
||||
constructRoundedLoanState(
|
||||
constructLoanState(
|
||||
Number const& totalValueOutstanding,
|
||||
Number const& principalOutstanding,
|
||||
Number const& managementFeeOutstanding)
|
||||
@@ -1325,7 +1325,7 @@ constructRoundedLoanState(
|
||||
LoanState
|
||||
constructRoundedLoanState(SLE::const_ref loan)
|
||||
{
|
||||
return constructRoundedLoanState(
|
||||
return constructLoanState(
|
||||
loan->at(sfTotalValueOutstanding),
|
||||
loan->at(sfPrincipalOutstanding),
|
||||
loan->at(sfManagementFeeOutstanding));
|
||||
@@ -1527,7 +1527,7 @@ loanMakePayment(
|
||||
Number const closePaymentFee =
|
||||
roundToAsset(asset, loan->at(sfClosePaymentFee), loanScale);
|
||||
|
||||
LoanState const roundedLoanState = constructRoundedLoanState(
|
||||
LoanState const roundedLoanState = constructLoanState(
|
||||
totalValueOutstandingProxy,
|
||||
principalOutstandingProxy,
|
||||
managementFeeOutstandingProxy);
|
||||
|
||||
@@ -445,7 +445,7 @@ LoanSet::doApply()
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
LoanState const state = constructRoundedLoanState(
|
||||
LoanState const state = constructLoanState(
|
||||
properties.totalValueOutstanding,
|
||||
principalRequested,
|
||||
properties.managementFeeOwedToBroker);
|
||||
|
||||
Reference in New Issue
Block a user