Skip to content

LoanSet

[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/.

Creates a new Loan ledger entry, representing a loan agreement between a Loan Broker and Borrower.

The LoanSet transaction is a mutual agreement between the Loan Broker and Borrower, and must be signed by both parties. The following multi-signature flow can be initiated by either party:

  1. The borrower or loan broker creates the transaction with the preagreed terms of the loan. They sign the transaction and set the SigningPubKey, TxnSignature, Signers, Account, Fee, Sequence, and Counterparty fields.
  2. The counterparty verifies the loan terms and signature before signing and submitting the transaction.

(Requires the Lending Protocol amendment )

Example LoanSet JSON

{
  "TransactionType": "LoanSet",
  "Account": "rEXAMPLE9AbCdEfGhIjKlMnOpQrStUvWxYz",
  "Fee": "12",
  "Flags": 0,
  "LastLedgerSequence": 7108682,
  "Sequence": 8,
  "Data": "546869732069732061726269747261727920646174612061626F757420746865206C6F616E2E",
  "Counterparty": "rCOUNTER9AbCdEfGhIjKlMnOpQrStUvWxYz",
  "LoanOriginationFee": 100,
  "LoanServiceFee": 10,
  "LatePaymentFee": 5,
  "ClosePaymentFee": 20,
  "OverpaymentFee": 5,
  "InterestRate": 500,
  "LateInterestRate": 1000,
  "CloseInterestRate": 200,
  "OverpaymentInterestRate": 5,
  "PrincipalRequested": 10000,
  "PaymentTotal": 12,
  "PaymentInterval": 2592000,
  "GracePeriod": 604800,
  "SigningPubKey": "03C040CAC1E164B0E385D31E41447FE6B8960E0D202811CFDA08B55BA29E08C6B0",
  "TxnSignature": "30440220549D359F792E155D20B5E8B3423F0F844CCF7C86986EB85BE482908A55A7157D02207B464FFE57E75D9693BAC445540CF078E9E0B6452C917DE4D66F27918D32A170",
  "hash": "831EEFF19C980FC348E984625FE41AEB27301B0B072D4239A980E78B86B2515C"
}

LoanSet Fields

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

Field NameJSON TypeInternal TypeRequired?Description
LoanBrokerIDStringHash256YesThe ID of the LoanBroker ledger entry.
FlagsStringUInt32NoFlags for the loan.
DataStringBlobNoArbitrary metadata in hex format (max 256 bytes).
CounterpartyStringAccountIDNoThe address of the counterparty of the loan.
LoanOriginationFeeNumberNumberNoThe amount paid to the LoanBroker owner when the loan is created.
LoanServiceFeeNumberNumberNoThe amount paid to the LoanBroker owner with each loan payment.
LatePaymentFeeNumberNumberNoThe amount paid to the LoanBroker owner for late payments.
ClosePaymentFeeNumberNumberNoThe amount paid to the LoanBroker owner for early full repayment.
OverpaymentFeeNumberUInt32NoA fee charged on overpayments, in units of 1/10th basis points. Valid values are 0 to 100000 (inclusive), representing 0% to 100%.
InterestRateNumberUInt32NoThe annualized interest rate of the loan, in units of 1/10th basis points. Valid values are 0 to 100000 (inclusive), representing 0% to 100%.
LateInterestRateNumberUInt32NoA premium added to the interest rate for late payments, in units of 1/10th basis points. Valid values are 0 to 100000 (inclusive), representing 0% to 100%.
CloseInterestRateNumberUInt32NoA fee charged for repaying the loan early, in units of 1/10th basis points. Valid values are 0 to 100000 (inclusive), representing 0% to 100%.
OverpaymentInterestRateNumberUInt32NoThe interest rate charged on overpayments, in units of 1/10th basis points. Valid values are 0 to 100000 (inclusive), representing 0% to 100%.
PrincipalRequestedNumberNumberYesThe principal loan amount requested by the borrower.
PaymentTotalNumberUInt32NoThe total number of payments to be made against the loan.
PaymentIntervalNumberUInt32NoThe number of seconds between loan payments.
GracePeriodNumberUInt32NoThe number of seconds after the loan's payment due date when it can be defaulted.
SigningPubKeyStringBlobYesThe public key used to verify the validity of the first signer's signature.
TxnSignatureStringBlobYesThe hex encoding of the digital signature for the first signing.
hashStringHash256YesThe unique identifying hash of the partially-signed transaction.

CounterpartySignature Fields

An inner object that contains the signatures of the counterparty of the transaction. The object contains the following fields:

Field NameJSON TypeInternal TypeRequired?Description
SigningPubKeyStringSTBlobNoThe public key used to verify the validity of the signature.
SignatureStringSTBlobNoThe signature over all signing fields.
SignersListSTArrayNoAn array of transaction signatures from the counterparty.

The final transaction must include either:

  • Both the SigningPubKey and TxnSignature fields.
  • The Signers field.
Note

This field isn't included in the LoanSet JSON, instead it's added to the stored transaction metadata after the counterparty submits the fully signed LoanSet transaction.

LoanSet Flags

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

Flag NameHex ValueDecimal ValueDescription
tfLoanOverpayment0x0001000065536Indicates that the loan supports overpayments.

Error Cases

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

Error CodeDescription
temBAD_SIGNER- The transaction is missing a CounterpartySignature field.
- This transaction is part of a Batch transaction, but didn't specify a Counterparty.
temINVALIDOne or more of the numeric fields are outside their valid ranges. For example, the GracePeriod can't be longer than the PaymentInterval.
tecNO_ENTRYThe LoanBroker doesn't exist.
tecNO_PERMISSIONNeither the transaction sender's Account or the Counterparty field owns the associated LoanBroker ledger entry.
tecINSUFFICIENT_FUNDS- The Vault associated with the LoanBroker doesn't have enough assets to fund the loan.
- The LoanBroker ledger entry doesn't have enough first-loss capital to meet the minimum coverage requirement for the new total debt.
tecLIMIT_EXCEEDEDThe requested loan would cause the LoanBroker ledger entry to exceed it's maximum allowed debt.
tecINSUFFICIENT_RESERVEThe borrower's account doesn't have enough XRP to meet the reserve requirements.