Review feedback from @gregtatcam: compute vs. calculate

- Rename the LendingHelper functions that started with `calculate` to
  start with `compute`.
This commit is contained in:
Ed Hennis
2025-11-23 21:41:38 -05:00
parent 4ba2514bfa
commit 4c28e750ff
3 changed files with 30 additions and 31 deletions

View File

@@ -911,7 +911,7 @@ protected:
state.principalOutstanding,
state.managementFeeOutstanding);
{
auto const raw = calculateRawLoanState(
auto const raw = computeRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining,
@@ -964,7 +964,7 @@ protected:
Number totalFeesPaid = 0;
std::size_t totalPaymentsMade = 0;
ripple::LoanState currentTrueState = calculateRawLoanState(
ripple::LoanState currentTrueState = computeRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining,
@@ -1019,7 +1019,7 @@ protected:
paymentComponents.trackedInterestPart() +
paymentComponents.trackedManagementFeeDelta);
ripple::LoanState const nextTrueState = calculateRawLoanState(
ripple::LoanState const nextTrueState = computeRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining - 1,
@@ -2662,7 +2662,7 @@ protected:
Number::upward));
{
auto const raw = calculateRawLoanState(
auto const raw = computeRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining,
@@ -2705,7 +2705,7 @@ protected:
Number totalInterestPaid = 0;
std::size_t totalPaymentsMade = 0;
ripple::LoanState currentTrueState = calculateRawLoanState(
ripple::LoanState currentTrueState = computeRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining,
@@ -2730,12 +2730,11 @@ protected:
paymentComponents.trackedValueDelta <=
roundedPeriodicPayment);
ripple::LoanState const nextTrueState =
calculateRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining - 1,
broker.params.managementFeeRate);
ripple::LoanState const nextTrueState = computeRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining - 1,
broker.params.managementFeeRate);
detail::LoanStateDeltas const deltas =
currentTrueState - nextTrueState;
@@ -5852,7 +5851,7 @@ protected:
auto const periodicRate =
loanPeriodicRate(interestRateValue, state.paymentInterval);
auto const rawLoanState = calculateRawLoanState(
auto const rawLoanState = computeRawLoanState(
state.periodicPayment,
periodicRate,
state.paymentRemaining,
@@ -5862,7 +5861,7 @@ protected:
auto const startDateSeconds = static_cast<std::uint32_t>(
state.startDate.time_since_epoch().count());
Number const fullPaymentInterest = calculateFullPaymentInterest(
Number const fullPaymentInterest = computeFullPaymentInterest(
rawLoanState.principalOutstanding,
periodicRate,
parentCloseTime,
@@ -6144,7 +6143,7 @@ protected:
loanPeriodicRate(after.interestRate, after.paymentInterval);
// Accrued + prepayment-penalty interest based on current periodic
// schedule
auto const fullPaymentInterest = calculateFullPaymentInterest(
auto const fullPaymentInterest = computeFullPaymentInterest(
after.periodicPayment,
periodicRate2,
after.paymentRemaining,
@@ -6180,7 +6179,7 @@ protected:
// Reference (clamped) computation: emulate a non-negative accrual
// window by clamping prevPaymentDate to 'now' for the full-pay path.
auto const prevClamped = std::min(after.previousPaymentDate, nowSecs);
auto const fullPaymentInterestClamped = calculateFullPaymentInterest(
auto const fullPaymentInterestClamped = computeFullPaymentInterest(
after.periodicPayment,
periodicRate2,
after.paymentRemaining,

View File

@@ -139,14 +139,14 @@ checkLoanGuards(
beast::Journal j);
LoanState
calculateRawLoanState(
computeRawLoanState(
Number const& periodicPayment,
Number const& periodicRate,
std::uint32_t const paymentRemaining,
TenthBips32 const managementFeeRate);
LoanState
calculateRawLoanState(
computeRawLoanState(
Number const& periodicPayment,
TenthBips32 interestRate,
std::uint32_t paymentInterval,
@@ -173,7 +173,7 @@ computeManagementFee(
std::int32_t scale);
Number
calculateFullPaymentInterest(
computeFullPaymentInterest(
Number const& rawPrincipalOutstanding,
Number const& periodicRate,
NetClock::time_point parentCloseTime,
@@ -183,7 +183,7 @@ calculateFullPaymentInterest(
TenthBips32 closeInterestRate);
Number
calculateFullPaymentInterest(
computeFullPaymentInterest(
Number const& periodicPayment,
Number const& periodicRate,
std::uint32_t paymentRemaining,

View File

@@ -371,7 +371,7 @@ tryOverpayment(
TenthBips16 const managementFeeRate,
beast::Journal j)
{
auto const raw = calculateRawLoanState(
auto const raw = computeRawLoanState(
periodicPayment, periodicRate, paymentRemaining, managementFeeRate);
auto const rounded = constructLoanState(
totalValueOutstanding, principalOutstanding, managementFeeOutstanding);
@@ -398,7 +398,7 @@ tryOverpayment(
<< ", first payment principal: "
<< newLoanProperties.firstPaymentPrincipal;
auto const newRaw = calculateRawLoanState(
auto const newRaw = computeRawLoanState(
newLoanProperties.periodicPayment,
periodicRate,
paymentRemaining,
@@ -764,7 +764,7 @@ computeFullPayment(
// Full payment interest consists of accrued normal interest and the
// prepayment penalty, as computed by 3.2.4.1.4.
auto const fullPaymentInterest = calculateFullPaymentInterest(
auto const fullPaymentInterest = computeFullPaymentInterest(
rawPrincipalOutstanding,
periodicRate,
view.parentCloseTime(),
@@ -886,7 +886,7 @@ computePaymentComponents(
.specialCase = PaymentSpecialCase::final};
}
LoanState const trueTarget = calculateRawLoanState(
LoanState const trueTarget = computeRawLoanState(
periodicPayment, periodicRate, paymentRemaining - 1, managementFeeRate);
LoanState const roundedTarget = LoanState{
.valueOutstanding =
@@ -1201,7 +1201,7 @@ checkLoanGuards(
}
Number
calculateFullPaymentInterest(
computeFullPaymentInterest(
Number const& rawPrincipalOutstanding,
Number const& periodicRate,
NetClock::time_point parentCloseTime,
@@ -1236,7 +1236,7 @@ calculateFullPaymentInterest(
}
Number
calculateFullPaymentInterest(
computeFullPaymentInterest(
Number const& periodicPayment,
Number const& periodicRate,
std::uint32_t paymentRemaining,
@@ -1250,7 +1250,7 @@ calculateFullPaymentInterest(
detail::loanPrincipalFromPeriodicPayment(
periodicPayment, periodicRate, paymentRemaining);
return calculateFullPaymentInterest(
return computeFullPaymentInterest(
rawPrincipalOutstanding,
periodicRate,
parentCloseTime,
@@ -1261,7 +1261,7 @@ calculateFullPaymentInterest(
}
LoanState
calculateRawLoanState(
computeRawLoanState(
Number const& periodicPayment,
Number const& periodicRate,
std::uint32_t const paymentRemaining,
@@ -1292,14 +1292,14 @@ calculateRawLoanState(
};
LoanState
calculateRawLoanState(
computeRawLoanState(
Number const& periodicPayment,
TenthBips32 interestRate,
std::uint32_t paymentInterval,
std::uint32_t const paymentRemaining,
TenthBips32 const managementFeeRate)
{
return calculateRawLoanState(
return computeRawLoanState(
periodicPayment,
loanPeriodicRate(interestRate, paymentInterval),
paymentRemaining,
@@ -1412,12 +1412,12 @@ computeLoanProperties(
auto const firstPaymentPrincipal = [&]() {
// Compute the parts for the first payment. Ensure that the
// principal payment will actually change the principal.
auto const startingState = calculateRawLoanState(
auto const startingState = computeRawLoanState(
periodicPayment,
periodicRate,
paymentsRemaining,
managementFeeRate);
auto const firstPaymentState = calculateRawLoanState(
auto const firstPaymentState = computeRawLoanState(
periodicPayment,
periodicRate,
paymentsRemaining - 1,