Skip to content

LoanPay

[Source]

Attention

Lending Protocol and Single Asset Vaults are disabled on Devnet. You have two options for testing these features:

  1. Run rippled in stand-alone mode and enable LendingProtocol and SingleAssetVault in the rippled.cfg file.
  2. Connect to the Lending Protocol-specific Devnet at https://lend.devnet.rippletest.net:51234/.

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 Lending Protocol amendment )

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 transaction pseudo-code.

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.
AmountNumberAmountYesThe 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.

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 account submitting the transaction isn't the borrower on the loan.
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 borrower's account is frozen for the specified asset, or the loan broker's pseudo-account is deep-frozen and can't receive funds.