xrpld
Loading...
Searching...
No Matches
xrpl::ValidLoan Class Reference

Invariants: Loans are internally consistent. More...

#include <LoanInvariant.h>

Collaboration diagram for xrpl::ValidLoan:

Public Member Functions

void visitEntry (bool, SLE::ConstRef, SLE::ConstRef)
bool finalize (STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &)

Private Attributes

std::vector< std::pair< SLE::const_pointer, SLE::const_pointer > > loans_
std::vector< std::pair< SLE::const_pointer, SLE::const_pointer > > deletedLoans_

Detailed Description

Invariants: Loans are internally consistent.

  1. If Loan.PaymentRemaining = 0 then Loan.PrincipalOutstanding = 0.
  2. A newly-created Loan against a closed-ended vault must satisfy StartDate + PaymentInterval * PaymentRemaining < Vault.RedemptionDate.
  3. An ltLOAN may only be created by a ttLOAN_SET transaction.
  4. Prior to featureLendingProtocolV1_1, the lsfLoanOverpayment flag on a Loan must not change. From featureLendingProtocolV1_1 onward the same rule is enforced by NoModifiedUnmodifiableFields.
  5. Under featureLendingProtocolV1_1: a. An ltLOAN may only be deleted by a ttLOAN_DELETE transaction. b. If Loan.PaymentRemaining = 0 then Loan.NextPaymentDueDate = 0. c. The lsfLoanImpaired flag may only change through a ttLOAN_MANAGE or ttLOAN_PAY transaction. d. The lsfLoanDefault flag may only change through a ttLOAN_MANAGE transaction. Combined with NoModifiedUnmodifiableFields, which rejects any clearing of lsfLoanDefault, this makes the flag write-once: ttLOAN_MANAGE may set it, and no transaction may clear it. e. Interest due, computed as TotalValueOutstanding - PrincipalOutstanding - ManagementFeeOutstanding, must not be negative. f. A Loan must reference a live ltLOAN_BROKER, and that broker must reference a live ltVAULT. g. Post-conditions for the Loan paid down by a successful ttLOAN_PAY: PaymentRemaining > 0 after: neither PrincipalOutstanding nor TotalValueOutstanding increases, and at least one of them strictly decreases; PaymentRemaining strictly decreases; NextPaymentDueDate advances by N * PaymentInterval, N > 0. PaymentRemaining == 0 after: pinned by checks 1 and 5b.

Definition at line 49 of file LoanInvariant.h.

Member Function Documentation

◆ visitEntry()

void xrpl::ValidLoan::visitEntry ( bool isDelete,
SLE::ConstRef before,
SLE::ConstRef after )

Definition at line 27 of file LoanInvariant.cpp.

◆ finalize()

bool xrpl::ValidLoan::finalize ( STTx const & tx,
TER const result,
XRPAmount const ,
ReadView const & view,
beast::Journal const & j )

Definition at line 43 of file LoanInvariant.cpp.

Member Data Documentation

◆ loans_

std::vector<std::pair<SLE::const_pointer, SLE::const_pointer> > xrpl::ValidLoan::loans_
private

Definition at line 53 of file LoanInvariant.h.

◆ deletedLoans_

std::vector<std::pair<SLE::const_pointer, SLE::const_pointer> > xrpl::ValidLoan::deletedLoans_
private

Definition at line 56 of file LoanInvariant.h.