xrpld
Loading...
Searching...
No Matches
LendingHelpers.h
1#pragma once
2
3#include <xrpl/basics/Number.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/beast/utility/Zero.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/ledger/ApplyView.h>
9#include <xrpl/ledger/ReadView.h>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/Asset.h>
12#include <xrpl/protocol/LedgerFormats.h> // IWYU pragma: keep
13#include <xrpl/protocol/Protocol.h>
14#include <xrpl/protocol/Rules.h>
15#include <xrpl/protocol/SField.h>
16#include <xrpl/protocol/STAmount.h>
17#include <xrpl/protocol/STLedgerEntry.h>
18#include <xrpl/protocol/STNumber.h> // IWYU pragma: keep
19#include <xrpl/protocol/STTx.h>
20#include <xrpl/protocol/TER.h>
21#include <xrpl/protocol/Units.h>
22
23#include <cstdint>
24#include <expected>
25#include <optional>
26#include <string_view>
27#include <utility>
28
29namespace xrpl {
30
50[[nodiscard]] TER
52 ReadView const& view,
53 SLE::ConstRef sleBroker,
54 Asset const& vaultAsset,
55 STAmount const& amount,
56 beast::Journal j,
57 std::string_view logPrefix);
58
59// Lending protocol has dependencies, so capture them here.
60bool
61checkLendingProtocolDependencies(Rules const& rules, STTx const& tx);
62
83
98
99static constexpr std::uint32_t kSecondsInYear = 365 * 24 * 60 * 60;
100
101Number
102loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval);
103
107inline Number
108roundPeriodicPayment(Asset const& asset, Number const& periodicPayment, std::int32_t scale)
109{
110 return roundToAsset(asset, periodicPayment, scale, Number::RoundingMode::Upward);
111}
112
113/* Represents the breakdown of amounts to be paid and changes applied to the
114 * Loan object while processing a loan payment.
115 *
116 * This structure is returned after processing a loan payment transaction and
117 * captures the amounts that need to be paid. The actual ledger entry changes
118 * are made in LoanPay based on this structure values.
119 *
120 * The sum of principalPaid, interestPaid, and feePaid represents the total
121 * amount to be deducted from the borrower's account. The valueChange field
122 * tracks whether the loan's total value increased or decreased beyond normal
123 * amortization.
124 *
125 * This structure is explained in the XLS-66 spec, section 3.2.4.2 (Payment
126 * Processing).
127 */
129{
130 // The amount of principal paid that reduces the loan balance.
131 // This amount is subtracted from sfPrincipalOutstanding in the Loan object
132 // and paid to the Vault
134
135 // The total amount of interest paid to the Vault.
136 // This includes:
137 // - Tracked interest from the amortization schedule
138 // - Untracked interest (e.g., late payment penalty interest)
139 // This value is always non-negative.
141
142 // The change in the loan's total value outstanding.
143 // - If valueChange < 0: Loan value decreased
144 // - If valueChange > 0: Loan value increased
145 // - If valueChange = 0: No value adjustment
146 //
147 // For regular on-time payments, this is always 0. Non-zero values occur
148 // when:
149 // - Overpayments reduce the loan balance beyond the scheduled amount
150 // - Late payments add penalty interest to the loan value
151 // - Early full payment may increase or decrease the loan value based on
152 // terms
154
155 /* The total amount of fees paid to the Broker.
156 * This includes:
157 * - Tracked management fees from the amortization schedule
158 * - Untracked fees (e.g., late payment fees, service fees, origination
159 * fees) This value is always non-negative.
160 */
162
164 operator+=(LoanPaymentParts const& other);
165
166 bool
167 operator==(LoanPaymentParts const& other) const;
168};
169
183{
184 // Total value still due to be paid by the borrower.
186 // Principal still due to be paid by the borrower.
188 // Interest still due to be paid to the Vault.
189 // This is a portion of interestOutstanding
191 // Management fee still due to be paid to the broker.
192 // This is a portion of interestOutstanding
194
195 // Interest still due to be paid by the borrower.
196 [[nodiscard]] Number
198 {
199 XRPL_ASSERT_PARTS(
201 "xrpl::LoanState::interestOutstanding",
202 "other values add up correctly");
204 }
205};
206
207/* Describes the initial computed properties of a loan.
208 *
209 * This structure contains the fundamental calculated values that define a
210 * loan's payment structure and amortization schedule. These properties are
211 * computed:
212 * - At loan creation (LoanSet transaction)
213 * - When loan terms change (e.g., after an overpayment that reduces the loan
214 * balance)
215 */
217{
218 // The unrounded amount to be paid at each regular payment period.
219 // Calculated using the standard amortization formula based on principal,
220 // interest rate, and number of payments.
221 // The actual amount paid in the LoanPay transaction must be rounded up to
222 // the precision of the asset and loan.
224
225 // The loan's current state, with all values rounded to the loan's scale.
227
228 // The scale (decimal places) used for rounding all loan amounts.
229 // This is the maximum of:
230 // - The asset's native scale
231 // - A minimum scale required to represent the periodic payment accurately
232 // All loan state values (principal, interest, fees) are rounded to this
233 // scale.
235
236 // The principal portion of the first payment.
238};
239
240// Some values get re-rounded to the vault scale any time they are adjusted. In
241// addition, they are prevented from ever going below zero. This helps avoid
242// accumulated rounding errors and leftover dust amounts.
243template <class NumberProxy>
244void
246 NumberProxy value,
247 Number const& adjustment,
248 Asset const& asset,
249 int vaultScale)
250{
251 value = roundToAsset(asset, value + adjustment, vaultScale);
252
253 if (*value < beast::kZero)
254 value = 0;
255}
256
257inline int
259{
260 if (!vaultSle)
261 return Number::kMinExponent - 1; // LCOV_EXCL_LINE
262 return scale(vaultSle->at(sfAssetsTotal), vaultSle->at(sfAsset));
263}
264
265// Compute the minimum required broker cover, rounded consistently.
266// DebtTotal is a broker-level aggregate maintained at vault scale, so the
267// rounding must also use vault scale — never an individual loan's scale.
268inline Number
269minimumBrokerCover(Number const& debtTotal, TenthBips32 coverRateMinimum, SLE::ConstRef vaultSle)
270{
271 XRPL_ASSERT(
272 vaultSle && vaultSle->getType() == ltVAULT, "xrpl::minimumBrokerCover : valid Vault sle");
274 return roundToAsset(
275 vaultSle->at(sfAsset),
276 tenthBipsOfValue(debtTotal, coverRateMinimum),
277 getAssetsTotalScale(vaultSle));
278}
279
280TER
282 Asset const& vaultAsset,
283 Number const& principalRequested,
284 bool expectInterest,
285 std::uint32_t paymentTotal,
286 LoanProperties const& properties,
288
289LoanState
291 Rules const& rules,
292 Number const& periodicPayment,
293 Number const& periodicRate,
294 std::uint32_t const paymentRemaining,
295 TenthBips32 const managementFeeRate);
296
297// Constructs a valid LoanState object from arbitrary inputs
298LoanState
300 Number const& totalValueOutstanding,
301 Number const& principalOutstanding,
302 Number const& managementFeeOutstanding);
303
304// Overload of constructLoanState() that reads the three tracked fields
305// directly from a Loan ledger object, which always holds rounded values,
306// rather than taking them as separate Number arguments.
307LoanState
309
310Number
312 Asset const& asset,
313 Number const& interest,
314 TenthBips32 managementFeeRate,
316
317Number
319 Number const& theoreticalPrincipalOutstanding,
320 Number const& periodicRate,
321 NetClock::time_point parentCloseTime,
322 std::uint32_t paymentInterval,
323 std::uint32_t prevPaymentDate,
324 std::uint32_t startDate,
325 TenthBips32 closeInterestRate);
326
327// Returns true if the loan's next payment is late per protocol rules. The
328// boundary is amendment-gated: with fixCleanup3_4_0 the due date must be
329// strictly in the past, otherwise the exact due-date instant counts as late.
330[[nodiscard]] bool
331isPaymentLate(ReadView const& view, SLE::ConstRef loanSle);
332
333// Deltas applied to Vault.AssetsTotal and LoanBroker.DebtTotal at a single
334// accounting touch point (origination, payment, impair/unimpair/default).
340
341// Instant interest recognition (pre-LendingProtocolV1_1): interest is
342// recognized into AssetsTotal/DebtTotal immediately, at origination.
344
345// LoanSet origination: what's added to Vault.AssetsTotal and LoanBroker.DebtTotal
347loanOriginationDeltas(Number const& principalRequested, Number const& interestDue);
348
349// LoanSet origination: would recognizing this loan's interest push
350// Vault.AssetsTotal past Vault.AssetsMaximum?
351bool
353 Number const& vaultMaximum,
354 Number const& vaultTotal,
355 Number const& interestDue);
356
357// LoanManage impair/unimpair/default: the vault's exposure to this loan
358Number
360
361// LoanPay: what's added to Vault.AssetsTotal and subtracted from LoanBroker.DebtTotal for a payment
364
365} // namespace instant_recognition
366
367// Cash-basis (LendingProtocolV1_1) recognition model: AssetsTotal/DebtTotal
368// are principal-only, interest is recognized only as it's actually paid.
369namespace cash_basis {
370
372loanOriginationDeltas(Number const& principalRequested);
373
374Number
376
379
380} // namespace cash_basis
381
382// Public dispatchers: pick cash_basis:: if featureLendingProtocolV1_1 is
383// enabled AND the Vault's LEVersion (VaultHelpers::getVaultVersion) is
384// VaultVersion::CashBasis, else instant_recognition::. These are the only entry points
385// transactors call.
388 SLE::ConstRef vaultSle,
389 Number const& principalRequested,
390 Number const& interestDue);
391
392bool
394 SLE::ConstRef vaultSle,
395 Number const& vaultTotal,
396 Number const& interestDue);
397
398Number
400
402loanPaymentDeltas(SLE::ConstRef vaultSle, LoanPaymentParts const& parts);
403
404namespace detail {
405// These classes and functions should only be accessed by LendingHelper
406// functions and unit tests
407
409
410/* Represents a single loan payment component parts.
411
412* This structure captures the "delta" (change) values that will be applied to
413* the tracked fields in the Loan ledger object when a payment is processed.
414*
415* These are called "deltas" because they represent the amount by which each
416* corresponding field in the Loan object will be reduced.
417* They are "tracked" as they change tracked loan values.
418*/
420{
421 // The change in total value outstanding for this payment.
422 // This amount will be subtracted from sfTotalValueOutstanding in the Loan
423 // object. Equal to the sum of trackedPrincipalDelta,
424 // trackedInterestPart(), and trackedManagementFeeDelta.
426
427 // The change in principal outstanding for this payment.
428 // This amount will be subtracted from sfPrincipalOutstanding in the Loan
429 // object, representing the portion of the payment that reduces the
430 // original loan amount.
432
433 // The change in management fee outstanding for this payment.
434 // This amount will be subtracted from sfManagementFeeOutstanding in the
435 // Loan object. This represents only the tracked management fees from the
436 // amortization schedule and does not include additional untracked fees
437 // (such as late payment fees) that go directly to the broker.
439
440 // Indicates if this payment has special handling requirements.
441 // - none: Regular scheduled payment
442 // - final: The last payment that closes out the loan
443 // - extra: An additional payment beyond the regular schedule (overpayment)
445
454 [[nodiscard]] Number
455 trackedInterestPart() const;
456};
457
458/* Extends PaymentComponents with untracked payment amounts.
459 *
460 * This structure adds untracked fees and interest to the base
461 * PaymentComponents, representing amounts that don't affect the Loan object's
462 * tracked state but are still part of the total payment due from the borrower.
463 *
464 * Untracked amounts include:
465 * - Late payment fees that go directly to the Broker
466 * - Late payment penalty interest that goes directly to the Vault
467 * - Service fees
468 *
469 * The key distinction is that tracked amounts reduce the Loan object's state
470 * (sfTotalValueOutstanding, sfPrincipalOutstanding,
471 * sfManagementFeeOutstanding), while untracked amounts are paid directly to the
472 * recipient without affecting the loan's amortization schedule.
473 */
475{
476 // Additional management fees that go directly to the Broker.
477 // This includes fees not part of the standard amortization schedule
478 // (e.g., late fees, service fees, origination fees).
479 // This value may be negative, though the final value returned in
480 // LoanPaymentParts.feePaid will never be negative.
482
483 // Additional interest that goes directly to the Vault.
484 // This includes interest not part of the standard amortization schedule
485 // (e.g., late payment penalty interest).
486 // This value may be negative, though the final value returned in
487 // LoanPaymentParts.interestPaid will never be negative.
489
490 // The complete amount due from the borrower for this payment.
491 // Calculated as: trackedValueDelta + untrackedInterest +
492 // untrackedManagementFee
493 //
494 // This value is used to validate that the payment amount provided by the
495 // borrower is sufficient to cover all components of the payment.
497
505};
506
507/* Represents the differences between two loan states.
508 *
509 * This structure is used to capture the change in each component of a loan's
510 * state, typically when computing the difference between two LoanState objects
511 * (e.g., before and after a payment). It is a convenient way to capture changes
512 * in each component. How that difference is used depends on the context.
513 */
515{
516 // The difference in principal outstanding between two loan states.
518
519 // The difference in interest due between two loan states.
521
522 // The difference in management fee outstanding between two loan states.
524
529 [[nodiscard]] Number
530 total() const
531 {
533 }
534
535 // Ensures all delta values are non-negative.
536 void
537 nonNegative();
538};
539
540std::expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
542 Rules const& rules,
543 Asset const& asset,
544 std::int32_t loanScale,
545 ExtendedPaymentComponents const& overpaymentComponents,
546 LoanState const& roundedLoanState,
547 Number const& periodicPayment,
548 Number const& periodicRate,
549 std::uint32_t paymentRemaining,
550 TenthBips16 const managementFeeRate,
552
553[[nodiscard]] Number
554computePowerMinusOne(Number const& periodicRate, std::uint32_t paymentsRemaining);
555
556[[nodiscard]] Number
557computePowerMinusOneHybrid(Number const& periodicRate, std::uint32_t paymentsRemaining);
558
559[[nodiscard]] Number
561 Rules const& rules,
562 Number const& periodicRate,
563 std::uint32_t paymentsRemaining);
564
567 Asset const& asset,
568 Number const& interest,
569 TenthBips16 managementFeeRate,
570 std::int32_t loanScale);
571
572Number
574 Rules const& rules,
575 Number const& principalOutstanding,
576 Number const& periodicRate,
577 std::uint32_t paymentsRemaining);
578
579Number
581 Rules const& rules,
582 Number const& periodicPayment,
583 Number const& periodicRate,
584 std::uint32_t paymentsRemaining);
585
586Number
588 Number const& principalOutstanding,
589 TenthBips32 lateInterestRate,
590 NetClock::time_point parentCloseTime,
591 std::uint32_t nextPaymentDueDate);
592
593Number
595 Number const& principalOutstanding,
596 Number const& periodicRate,
597 NetClock::time_point parentCloseTime,
598 std::uint32_t startDate,
599 std::uint32_t prevPaymentDate,
600 std::uint32_t paymentInterval);
601
602ExtendedPaymentComponents
604 Rules const& rules,
605 Asset const& asset,
606 int32_t const loanScale,
607 Number const& overpayment,
608 TenthBips32 const overpaymentInterestRate,
609 TenthBips32 const overpaymentFeeRate,
610 TenthBips16 const managementFeeRate);
611
612PaymentComponents
614 Rules const& rules,
615 Asset const& asset,
617 Number const& totalValueOutstanding,
618 Number const& principalOutstanding,
619 Number const& managementFeeOutstanding,
620 Number const& periodicPayment,
621 Number const& periodicRate,
622 std::uint32_t paymentRemaining,
623 TenthBips16 managementFeeRate);
624
625} // namespace detail
626
627detail::LoanStateDeltas
628operator-(LoanState const& lhs, LoanState const& rhs);
629
630LoanState
631operator-(LoanState const& lhs, detail::LoanStateDeltas const& rhs);
632
633LoanState
634operator+(LoanState const& lhs, detail::LoanStateDeltas const& rhs);
635
636LoanProperties
638 Rules const& rules,
639 Asset const& asset,
640 Number const& principalOutstanding,
641 TenthBips32 interestRate,
642 std::uint32_t paymentInterval,
643 std::uint32_t paymentsRemaining,
644 TenthBips32 managementFeeRate,
645 std::int32_t minimumScale);
646
647LoanProperties
649 Rules const& rules,
650 Asset const& asset,
651 Number const& principalOutstanding,
652 Number const& periodicRate,
653 std::uint32_t paymentsRemaining,
654 TenthBips32 managementFeeRate,
655 std::int32_t minimumScale);
656
657bool
658isRounded(Asset const& asset, Number const& value, std::int32_t scale);
659
660// Indicates what type of payment is being made.
661// regular, late, and full are mutually exclusive.
662// overpayment is an "add on" to a regular payment, and follows that path with
663// potential extra work at the end.
665
666std::expected<LoanPaymentParts, TER>
668 Asset const& asset,
669 ApplyView& view,
670 SLE::Ref loan,
671 SLE::ConstRef brokerSle,
672 STAmount const& amount,
673 LoanPaymentType const paymentType,
675
676} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
Number is a floating point type that can represent a wide range of values.
Definition Number.h:351
static constexpr int kMinExponent
Definition Number.h:361
A view into a ledger.
Definition ReadView.h:41
Rules controlling protocol behavior.
Definition Rules.h:40
std::shared_ptr< STLedgerEntry const > const & ConstRef
std::shared_ptr< STLedgerEntry > const & Ref
constexpr Zero kZero
Definition Zero.h:30
AccountingDeltas loanPaymentDeltas(LoanPaymentParts const &parts)
AccountingDeltas loanOriginationDeltas(Number const &principalRequested)
Number loanVaultExposure(SLE::ConstRef loanSle)
Number computePaymentFactor(Rules const &rules, Number const &periodicRate, std::uint32_t paymentsRemaining)
Number loanPrincipalFromPeriodicPayment(Rules const &rules, Number const &periodicPayment, Number const &periodicRate, std::uint32_t paymentsRemaining)
Number computePowerMinusOneHybrid(Number const &periodicRate, std::uint32_t paymentsRemaining)
Number loanPeriodicPayment(Rules const &rules, Number const &principalOutstanding, Number const &periodicRate, std::uint32_t paymentsRemaining)
Number loanAccruedInterest(Number const &principalOutstanding, Number const &periodicRate, NetClock::time_point parentCloseTime, std::uint32_t startDate, std::uint32_t prevPaymentDate, std::uint32_t paymentInterval)
std::pair< Number, Number > computeInterestAndFeeParts(Asset const &asset, Number const &interest, TenthBips16 managementFeeRate, std::int32_t loanScale)
Number loanLatePaymentInterest(Number const &principalOutstanding, TenthBips32 lateInterestRate, NetClock::time_point parentCloseTime, std::uint32_t nextPaymentDueDate)
std::expected< std::pair< LoanPaymentParts, LoanProperties >, TER > tryOverpayment(Rules const &rules, Asset const &asset, std::int32_t loanScale, ExtendedPaymentComponents const &overpaymentComponents, LoanState const &roundedLoanState, Number const &periodicPayment, Number const &periodicRate, std::uint32_t paymentRemaining, TenthBips16 const managementFeeRate, beast::Journal j)
ExtendedPaymentComponents computeOverpaymentComponents(Rules const &rules, Asset const &asset, int32_t const loanScale, Number const &overpayment, TenthBips32 const overpaymentInterestRate, TenthBips32 const overpaymentFeeRate, TenthBips16 const managementFeeRate)
Number computePowerMinusOne(Number const &periodicRate, std::uint32_t paymentsRemaining)
PaymentComponents computePaymentComponents(Rules const &rules, Asset const &asset, std::int32_t scale, Number const &totalValueOutstanding, Number const &principalOutstanding, Number const &managementFeeOutstanding, Number const &periodicPayment, Number const &periodicRate, std::uint32_t paymentRemaining, TenthBips16 managementFeeRate)
AccountingDeltas loanPaymentDeltas(LoanPaymentParts const &parts)
Number loanVaultExposure(SLE::ConstRef loanSle)
AccountingDeltas loanOriginationDeltas(Number const &principalRequested, Number const &interestDue)
bool loanOriginationExceedsVaultMaximum(Number const &vaultMaximum, Number const &vaultTotal, Number const &interestDue)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
static constexpr Number kNumZero
Definition Number.h:663
constexpr BaseUInt< Bits, Tag > operator+(BaseUInt< Bits, Tag > const &a, BaseUInt< Bits, Tag > const &b)
Definition base_uint.h:649
Number loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval)
bool loanOriginationExceedsVaultMaximum(SLE::ConstRef vaultSle, Number const &vaultTotal, Number const &interestDue)
Number operator-(Number const &x, Number const &y)
Definition Number.h:789
constexpr T tenthBipsOfValue(T value, TenthBips< TBips > bips)
Definition Protocol.h:139
void adjustImpreciseNumber(NumberProxy value, Number const &adjustment, Asset const &asset, int vaultScale)
int scale(Number const &number, Asset const &asset)
Get the scale of a Number for a given asset.
Definition STAmount.h:794
int getAssetsTotalScale(SLE::ConstRef vaultSle)
std::expected< LoanPaymentParts, TER > loanMakePayment(Asset const &asset, ApplyView &view, SLE::Ref loan, SLE::ConstRef brokerSle, STAmount const &amount, LoanPaymentType const paymentType, beast::Journal j)
TenthBips< std::uint32_t > TenthBips32
Definition Units.h:454
TenthBips< std::uint16_t > TenthBips16
Definition Units.h:453
TER checkLoanGuards(Asset const &vaultAsset, Number const &principalRequested, bool expectInterest, std::uint32_t paymentTotal, LoanProperties const &properties, beast::Journal j)
Number minimumBrokerCover(Number const &debtTotal, TenthBips32 coverRateMinimum, SLE::ConstRef vaultSle)
bool isPaymentLate(ReadView const &view, SLE::ConstRef loanSle)
std::optional< LoanDefaultFreezeExemptAccounts > getLoanDefaultFreezeExemptAccounts(ReadView const &view, STTx const &tx)
Resolves the accounts and asset a LoanManage default transaction is exempt from freeze/lock for.
LoanState computeTheoreticalLoanState(Rules const &rules, Number const &periodicPayment, Number const &periodicRate, std::uint32_t const paymentRemaining, TenthBips32 const managementFeeRate)
AccountingDeltas loanPaymentDeltas(SLE::ConstRef vaultSle, LoanPaymentParts const &parts)
void roundToAsset(A const &asset, Number &value)
Round an arbitrary precision Number IN PLACE to the precision of a given Asset.
Definition STAmount.h:735
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
Number roundPeriodicPayment(Asset const &asset, Number const &periodicPayment, std::int32_t scale)
Ensure the periodic payment is always rounded consistently.
Number computeManagementFee(Asset const &asset, Number const &interest, TenthBips32 managementFeeRate, std::int32_t scale)
TERSubset< CanCvtToTER > TER
Definition TER.h:654
Number loanVaultExposure(SLE::ConstRef vaultSle, SLE::ConstRef loanSle)
static constexpr std::uint32_t kSecondsInYear
LoanProperties computeLoanProperties(Rules const &rules, Asset const &asset, Number const &principalOutstanding, TenthBips32 interestRate, std::uint32_t paymentInterval, std::uint32_t paymentsRemaining, TenthBips32 managementFeeRate, std::int32_t minimumScale)
AccountingDeltas loanOriginationDeltas(SLE::ConstRef vaultSle, Number const &principalRequested, Number const &interestDue)
LoanState constructLoanState(Number const &totalValueOutstanding, Number const &principalOutstanding, Number const &managementFeeOutstanding)
TER canApplyToBrokerCover(ReadView const &view, SLE::ConstRef sleBroker, Asset const &vaultAsset, STAmount const &amount, beast::Journal j, std::string_view logPrefix)
Broker cover preclaim precision guard (fixCleanup3_2_0).
Number computeFullPaymentInterest(Number const &theoreticalPrincipalOutstanding, Number const &periodicRate, NetClock::time_point parentCloseTime, std::uint32_t paymentInterval, std::uint32_t prevPaymentDate, std::uint32_t startDate, TenthBips32 closeInterestRate)
bool checkLendingProtocolDependencies(Rules const &rules, STTx const &tx)
bool isRounded(Asset const &asset, Number const &value, std::int32_t scale)
The accounts and asset that LoanManage::defaultLoan's fixCleanup3_4_0 freeze/lock exemption applies t...
bool operator==(LoanPaymentParts const &other) const
LoanPaymentParts & operator+=(LoanPaymentParts const &other)
This structure captures the parts of a loan state.
Number principalOutstanding
Number interestOutstanding() const
ExtendedPaymentComponents(PaymentComponents const &p, Number fee, Number interest=kNumZero)
Number total() const
Calculates the total change across all components.
Number trackedInterestPart() const
Calculates the tracked interest portion of this payment.