Skip to content

LoanPay

[Source]

Makes a payment on an active loan. Only the borrower on the loan can make payments, and payments must meet the minimum amount required for that period.

Requires the LendingProtocol amendment. Loading...

A loan payment has four types, depending on the amount and timing of the payment:

  • Regular Payment: A payment made on time, where the payment size and schedule are calculated with a standard amortization formula.
  • Late Payment: A payment made after the NextPaymentDueDate in the Loan ledger entry. Late payments include a LatePaymentFee and LateInterestRate.
  • Early Full Payment: A payment that covers the outstanding principal of the loan. A CloseInterestRate is charged on the outstanding principal.
  • Overpayment: A payment that exceeds the required minimum payment amount.

To see how loan payment transactions are calculated, see LoanPay Implementation Reference.

Example LoanPay JSON

{
  "TransactionType": "LoanPay",
  "Account": "rBORROWER9AbCdEfGhIjKlMnOpQrStUvWxYz",
  "Fee": "12",
  "Flags": 0,
  "LoanID": "ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890",
  "Amount": 1000,
  "Sequence": 10,
  "LastLedgerSequence": 7108701
}

LoanPay Fields

In addition to the common fields, LoanPay transactions use the following fields:

Field NameJSON TypeInternal TypeRequired?Description
LoanIDStringHash256YesThe ID of the Loan ledger entry to repay.
AmountCurrency AmountAmountYesThe amount to pay toward the loan.

LoanPay Flags

Transactions of the LoanPay type support additional values in the flags field, as follows:

Flag NameHex ValueDecimal ValueDescription
tfLoanOverpayment0x0001000065536Indicates that the remaining payment amount should be treated as an overpayment.
tfLoanFullPayment0x00020000131072Indicates that the borrower is making a full early repayment.
tfLoanLatePayment0x00040000262144Indicates that the borrower is making a late loan payment.

Error Cases

Besides errors that can occur for all transactions, LoanPay transactions can result in the following transaction result codes:

Error CodeDescription
temINVALIDThe LoanID field is missing or set to zero.
temBAD_AMOUNTThe Amount field must specify a positive value.
tecNO_ENTRYThe loan specified by LoanID doesn't exist.
tecNO_PERMISSIONThe transaction lacks the required permissions. This can occur when:
  • The account submitting the transaction isn't the borrower on the loan.
  • The loan doesn't permit overpayments.

    Requires the fixCleanup3_1_3 amendment. Loading...

tecTOO_SOONThe loan hasn't started yet.
tecKILLEDThe loan is already fully paid.
tecWRONG_ASSETThe asset specified by Amount doesn't match the asset of the loan.
tecFROZENThe trust line token is frozen globally or frozen for the borrower; the vault's pseudo-account or the loan broker's pseudo-account is deep-frozen and can't receive funds.
tecLOCKEDThe MPT asset is locked globally, for the borrower, for the vault's pseudo-account, or for the LoanBroker pseudo-account.
tecEXPIREDThe loan payment is late, and the tfLoanLatePayment flag isn't enabled. A payment made at exactly NextPaymentDueDate is considered on time.

Requires the fixCleanup3_4_0 amendment. Loading...

tecINSUFFICIENT_PAYMENTThe Amount is less than the minimum amount required for the loan payment type.
tecINSUFFICIENT_FUNDSThe borrower doesn't hold the full Amount, even if the payment needs less than that. If the asset is XRP, this could be because of the reserve requirement.
tecNO_AUTHThe asset requires authorization, and the borrower isn't authorized to hold it. For MPTs, an issuer can revoke authorization after the loan is originated.
tecNO_LINEThe asset is a trust line token whose issuer requires authorization, and the borrower doesn't have a trust line for it. This can happen if a trust line is deleted before making a repayment.
tecPRECISION_LOSSThe payment's effect on the vault is too small to register after rounding to the vault's precision, so the vault's AssetsAvailable or AssetsTotal wouldn't change.
temINVALID_FLAGThe transaction enables more than one of tfLoanOverpayment, tfLoanFullPayment, and tfLoanLatePayment. Only one can be enabled at a time.