Show / Hide Table of Contents

Class LoanPayments

What a Loan entry says about the next payment, without asking the node.

Inheritance
object
LoanPayments
Namespace: Xrpl.Sugar
Assembly: Xrpl.dll
Syntax
public static class LoanPayments
Remarks

RegularPaymentCap(LOLoan, IssuedCurrency) bounds the next regular payment from the entry alone. LatePaymentDue(LOLoan, IssuedCurrency, ushort, DateTime, LedgerRules) and FullPaymentDue(LOLoan, IssuedCurrency, ushort, DateTime, LedgerRules) repeat rippled's own computation for a given parent close time, and PaymentForAmount(LOLoan, IssuedCurrency, ushort, XrplNumber, DateTime, bool, LedgerRules) what a regular LoanPay does with a given Amount - several payments, an overpayment; LoanSchedule projects the regular payments.

Methods

| Edit this page View Source

FullPaymentDue(LOLoan, IssuedCurrency, ushort, DateTime, LedgerRules)

What closing the loan early (LoanPay with tfLoanFullPayment) costs in a ledger whose parent closed at parentCloseTime: the outstanding principal and management fee, interest accrued since the last payment on the theoretical principal, the prepayment penalty (CloseInterestRate) and ClosePaymentFee, computed the way rippled's computeFullPayment computes it.

Declaration
public static LoanPaymentDue FullPaymentDue(LOLoan loan, Common.IssuedCurrency asset, ushort managementFeeRate, DateTime parentCloseTime, LedgerRules options = null)
Parameters
Type Name Description
LOLoan loan

The Loan entry.

Common.IssuedCurrency asset

The loan asset: the asset of the broker's vault.

ushort managementFeeRate

The broker's ManagementFeeRate, in 1/10th of a basis point.

DateTime parentCloseTime

The close time of the ledger before the one the payment lands in. A local time is converted to UTC; an unspecified one is taken as UTC.

LedgerRules options

The amendments in force; the current rules when null.

Returns
Type Description
LoanPaymentDue

null when a full payment is not accepted: one payment or none remains (the node answers tecKILLED), or the next payment is already late (tecEXPIRED).

Exceptions
Type Condition
OverflowException

An amount is beyond decimal.

| Edit this page View Source

IsPastGracePeriod(LOLoan, DateTime, bool)

Whether the broker may default the loan (LoanManage with tfLoanDefault): the grace period after NextPaymentDueDate has run out.

Declaration
public static bool IsPastGracePeriod(LOLoan loan, DateTime parentCloseTime, bool boundaryIsPast)
Parameters
Type Name Description
LOLoan loan

The loan entry.

DateTime parentCloseTime

The close time of the ledger before the one the transaction lands in. A local time is converted to UTC; an unspecified one is taken as UTC.

bool boundaryIsPast

Whether the exact end of the grace period already counts. rippled counted it until fixCleanup3_4_0, and not since.

Returns
Type Description
bool
| Edit this page View Source

IsPaymentLate(LOLoan, DateTime, bool)

Whether a payment made in a ledger whose parent closed at parentCloseTime counts as late.

Declaration
public static bool IsPaymentLate(LOLoan loan, DateTime parentCloseTime, bool dueTimeIsLate)
Parameters
Type Name Description
LOLoan loan

The loan entry.

DateTime parentCloseTime

The close time of the ledger before the one the payment lands in. A local time is converted to UTC; an unspecified one is taken as UTC.

bool dueTimeIsLate

Whether a payment exactly at NextPaymentDueDate is late. rippled counted it late until fixCleanup3_4_0, and on time since.

Returns
Type Description
bool
| Edit this page View Source

LatePaymentDue(LOLoan, IssuedCurrency, ushort, DateTime, LedgerRules)

What a late payment (LoanPay with tfLoanLatePayment) costs in a ledger whose parent closed at parentCloseTime: the regular payment, the service fee, LatePaymentFee, and late interest on the outstanding principal for the time past NextPaymentDueDate, computed the way rippled's computeLatePayment computes it.

Declaration
public static LoanPaymentDue LatePaymentDue(LOLoan loan, Common.IssuedCurrency asset, ushort managementFeeRate, DateTime parentCloseTime, LedgerRules options = null)
Parameters
Type Name Description
LOLoan loan

The Loan entry.

Common.IssuedCurrency asset

The loan asset: the asset of the broker's vault.

ushort managementFeeRate

The broker's ManagementFeeRate, in 1/10th of a basis point.

DateTime parentCloseTime

The close time of the ledger before the one the payment lands in. A local time is converted to UTC; an unspecified one is taken as UTC.

LedgerRules options

The amendments in force; the current rules when null.

Returns
Type Description
LoanPaymentDue

null when the payment is not late at that time (the node answers tecTOO_SOON) or the loan is paid off.

Exceptions
Type Condition
OverflowException

An amount is beyond decimal.

| Edit this page View Source

PaymentForAmount(LOLoan, IssuedCurrency, ushort, XrplNumber, DateTime, bool, LedgerRules)

What a LoanPay without the late or full payment flag does with amount in a ledger whose parent closed at parentCloseTime: as many regular payments as the amount covers, up to 100, then - with overpayment (tfLoanOverpayment) on a loan that allows it - the rest as an overpayment that repays principal and re-amortizes the loan. Computed the way rippled's makeRegularPayment computes it.

Declaration
public static LoanAmountPayment PaymentForAmount(LOLoan loan, Common.IssuedCurrency asset, ushort managementFeeRate, XrplNumber amount, DateTime parentCloseTime, bool overpayment = false, LedgerRules options = null)
Parameters
Type Name Description
LOLoan loan

The Loan entry.

Common.IssuedCurrency asset

The loan asset: the asset of the broker's vault.

ushort managementFeeRate

The broker's ManagementFeeRate, in 1/10th of a basis point.

XrplNumber amount

The transaction's Amount, in the asset's own unit (drops for XRP).

DateTime parentCloseTime

The close time of the ledger before the one the payment lands in. A local time is converted to UTC; an unspecified one is taken as UTC.

bool overpayment

Whether the transaction carries tfLoanOverpayment.

LedgerRules options

The amendments in force; the current rules when null.

Returns
Type Description
LoanAmountPayment
Remarks

The node takes what the payments cost, not the whole Amount: an amount the overpayment cannot use - one its fee and penalty interest would eat, or one that would leave the loan unable to amortize - is left with the payer, and the result then shows no overpayment. An impaired loan is taken as it stands; the node unimpairs it first.

Exceptions
Type Condition
OverflowException

An amount is beyond decimal.

| Edit this page View Source

RegularPaymentCap(LOLoan, IssuedCurrency)

The most the next regular payment can take, in the asset's own unit (drops for XRP): an amount that always settles it. On the final payment this is exact - TotalValueOutstanding plus LoanServiceFee. Before that it is PeriodicPayment rounded up to the asset (whole units for XRP and MPT, the loan's LoanScale for an issued currency) plus LoanServiceFee.

Declaration
public static decimal? RegularPaymentCap(LOLoan loan, Common.IssuedCurrency asset)
Parameters
Type Name Description
LOLoan loan
Common.IssuedCurrency asset
Returns
Type Description
decimal?

null when the entry carries no periodic payment, or a value beyond decimal.

Remarks

rippled charges a regular payment as the step from the loan's current state to the rounded theoretical state after it, capped at the rounded PeriodicPayment (computePaymentComponents). The step can come out a rounding unit lower - a 90 MPT loan over three payments with PeriodicPayment 30.00002 is charged 30, not 31 - and the node takes only what it charges, not the whole Amount. Paying this cap is therefore safe; the exact figure is what PreviewLoanPay(IXrplClient, LoanPay, CancellationToken) reports.

A late payment adds late interest and LatePaymentFee on top, which this does not cover; preview it.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX