Fixed-Precision Loans
Keeps LoanBroker and Loan amounts on the fixed precision grid of a Vault with LEVersion 2, and bounds new Loans and cover deposits by capacity
- Author
- Vytautas Vito Tumas
- Created
- 2026-11-25
- Updated
- 2026-11-25
- Requires
- XLS-65.7.1
- Discussion
- XRPLF/XRPL-Standards/discussions/190
- Amendment
LendingProtocolV1_2- Patch of
- XLS-0066: Lending Protocol
66.7.1 Fixed-Precision Loans¶
1. Abstract¶
Under LendingProtocolV1_2, a Vault created with LEVersion 2 fixes one precision grid, the base unit, for its whole life (XLS-65.7.1). This patch applies that grid to every LoanBroker attached to the Vault and every Loan issued through those brokers. A Loan's scale is the Vault's base exponent. LoanBroker.DebtTotal and the Vault's principal and interest records change by exact amounts. Cash moved into the Vault or the first-loss capital is rounded down so the receiving balance stays representable. New Loans and cover deposits are rejected when they would take the Vault or LoanBroker out of its Open zone.
2. Motivation¶
In the parent protocol a Loan fixes its scale at origination from the Vault's AssetsTotal, while the Vault's precision follows AssetsTotal as it grows. Once a Vault grows past a power of ten, it can no longer represent the amounts of a Loan originated earlier, and that Loan's payments, impairment and default fail with tecPRECISION_LOSS. A single grid for the Vault, its brokers and its Loans keeps every Loan representable for its whole life.
3. Specification¶
This patch changes the parent XLS-66 sections named below. The terms base exponent \(-P\), base unit \(10^{-P}\), live exponent, live unit, coarsened, Open-zone limit \(T_{\mathrm{dep}}(P)\), AssetsDeployed and YieldUnrealized are defined in XLS-65.7.1. All other parent behavior is unchanged.
3.1 Scope¶
The rules in this patch apply to a LoanBroker attached to a Vault with LEVersion 2, and to every Loan issued through it. A Vault with LEVersion 2 is also a cash-basis Vault, so XLS-66.4.1 applies as well. Brokers and Loans of Vaults with a lower LEVersion are unchanged.
3.2 Definitions¶
For a LoanBroker, the reference amount is LoanBroker.CoverAvailable. For an IOU asset:
- The posterior live exponent of a change
deltais the live exponent ofCoverAvailable + delta: the exponent of that sum in the 16-digit representation, but never below the base exponent. - An inflow of
rawtoCoverAvailableis credited asfloor(CoverAvailable + raw) - CoverAvailable, wherefloorrounds down to the posterior live exponent of the sum. - An outflow of
amountfromCoverAvailableisamountrounded toward zero to the posterior live exponent ofCoverAvailable - amount.
For an inflow to the Vault, the reference amount is Vault.AssetsAvailable, and the credit is floor(AssetsAvailable + raw) - AssetsAvailable, rounded down to the posterior live exponent of the sum.
For XRP and MPT assets, amounts are whole drops or units and these roundings do not apply.
3.3 Ledger Entry: LoanBroker¶
3.3.1 State Changes¶
DebtTotalchanges by the exact principal of eachLoanSet,LoanPayand default, and is never rounded to the Vault's live exponent.DebtMaximumis a multiple of the base unit.- In the minimum-cover checks of
LoanSet,LoanPay,LoanBrokerCoverWithdrawandLoanBrokerCoverClawback, the minimum coverDebtTotal × CoverRateMinimumis rounded up to the base unit. The default liquidation ofLoanManage(§3.11.2) does not round it to the base unit.
3.4 Ledger Entry: Loan¶
3.4.1 Fields¶
3.4.1.1 LoanScale¶
LoanScale is the Vault's base exponent \(-P\). TotalValueOutstanding, PrincipalOutstanding, ManagementFeeOutstanding and every fee field are rounded at that scale. PeriodicPayment is stored at full precision.
3.5 Transaction: LoanBrokerSet¶
3.5.1 Failure Conditions¶
In parent §3.3.3.2 check 11, a value field that is not a multiple of the base unit fails with tecPRECISION_LOSS.
3.6 Transaction: LoanBrokerCoverDeposit¶
3.6.1 Failure Conditions¶
The deposit is an inflow. Let credit be Amount credited as defined in §3.2. Added to parent §3.5.3.2, before the funds check:
fixCleanup3_2_0:creditis zero. (tecPRECISION_LOSS)- The posterior live exponent of
CoverAvailable + creditis not the base exponent. (tecLIMIT_EXCEEDED) CoverAvailable + creditexceeds the Open-zone limit \(T_{\mathrm{dep}}(P)\). (tecLIMIT_EXCEEDED)
The funds check uses credit.
3.6.2 State Changes¶
credit is transferred from the submitter to the broker pseudo-account, and LoanBroker.CoverAvailable increases by credit.
3.7 Transaction: LoanBrokerCoverWithdraw¶
3.7.1 Failure Conditions¶
The withdrawal is an outflow. Let amount be Amount rounded as defined in §3.2. If amount is zero, the transaction fails with tecPRECISION_LOSS; this replaces the fixCleanup3_2_0 precision check. All later checks use amount. There is no capacity check.
3.7.2 State Changes¶
LoanBroker.CoverAvailable decreases by amount, and amount is transferred.
3.8 Transaction: LoanBrokerCoverClawback¶
3.8.1 Failure Conditions¶
The clawback is an outflow. ClawAmount from parent §3.7.4 is rounded as defined in §3.2. If the result is zero, the transaction fails with tecPRECISION_LOSS; this replaces the fixCleanup3_2_0 precision check.
3.8.2 State Changes¶
LoanBroker.CoverAvailable decreases by the rounded ClawAmount, and that amount is clawed back.
3.9 Transaction: LoanSet¶
3.9.1 Failure Conditions¶
Added to parent §3.8.5.2:
- After the
LendingProtocolV1_1phase checks: the Vault is coarsened, that is, the live exponent ofVault.AssetsTotalis not the base exponent. (tecLIMIT_EXCEEDED) - The loan scale is the base exponent, so a value field that is not a multiple of the base unit fails with
tecPRECISION_LOSS. - After parent checks 15 to 18 and before check 19:
Vault.AssetsTotal + Vault.YieldUnrealized + InterestDueexceeds the Open-zone limit \(T_{\mathrm{dep}}(P)\), whereInterestDueis the new Loan's interest owed to the Vault. (tecLIMIT_EXCEEDED)
3.9.2 State Changes¶
Parent §3.8.6 step 6 becomes:
- Update
Vaultobject:- Decrease
Vault.AssetsAvailablebyPrincipalRequested. - Increase
Vault.AssetsDeployedbyPrincipalRequested. - Increase
Vault.YieldUnrealizedbyInterestDue. - Derive
Vault.AssetsTotalas defined in XLS-65.7.1.
- Decrease
In step 7, LoanBroker.DebtTotal increases by exactly PrincipalRequested.
3.10 Transaction: LoanPay¶
3.10.1 Failure Conditions¶
Parent §3.11.4.2 check 17 (tecPRECISION_LOSS when the Vault credit does not change Vault.AssetsAvailable) does not apply to a payment after which Loan.PaymentRemaining is 0.
3.10.2 State Changes¶
There is no capacity check. Parent §3.11.5 steps 6 and 7, and the amounts transferred, become:
creditisprincipalPaid + interestPaidcredited to the Vault as defined in §3.2.Vault.AssetsAvailableincreases bycredit.Vault.AssetsDeployeddecreases byprincipalPaid.Vault.YieldUnrealizedchanges by the change inLoan.TotalValueOutstanding - Loan.PrincipalOutstanding - Loan.ManagementFeeOutstandingcaused by the payment.Vault.AssetsTotalis derived as defined in XLS-65.7.1.LoanBroker.DebtTotaldecreases by exactlyprincipalPaid.- If the fee goes to the cover pool, the fee is credited to
LoanBroker.CoverAvailableas an inflow defined in §3.2, with no capacity check. If the result is zero, the payment still succeeds. - The Borrower sends
creditto the Vault pseudo-account and the credited fee to the fee destination. The difference between these amounts and the computed payment is not charged.
If the payment closes the Loan, credit is zero, and either the fee is zero or the fee destination is the Borrower, nothing is transferred.
If the Loan was impaired, the unimpairment before the payment decreases Vault.LossUnrealized by Loan.PrincipalOutstanding.
3.11 Transaction: LoanManage¶
3.11.1 Failure Conditions¶
This replaces parent §3.10.4.2 check 8: tfLoanImpair is specified and Vault.LossUnrealized + Loan.PrincipalOutstanding > Vault.AssetsDeployed. (tecLIMIT_EXCEEDED) As in the parent, the fixCleanup3_4_0 check 9 runs before it.
3.11.2 State Changes¶
Parent §3.10.5 becomes:
- If the
tfLoanDefaultflag is specified:- Compute
DefaultCovered = min((LoanBroker.DebtTotal × CoverRateMinimum) × CoverRateLiquidation, Loan.PrincipalOutstanding, LoanBroker.CoverAvailable), where both products are rounded up. For XRP and MPT, roundDefaultCoveredtoward zero to a whole unit. For an IOU, creditDefaultCoveredto the Vault as defined in §3.2. Vault.AssetsAvailableincreases byDefaultCovered.Vault.AssetsDeployeddecreases byLoan.PrincipalOutstanding.Vault.YieldUnrealizeddecreases byLoan.TotalValueOutstanding - Loan.PrincipalOutstanding - Loan.ManagementFeeOutstanding.- If the Loan is impaired,
Vault.LossUnrealizeddecreases byLoan.PrincipalOutstanding. Vault.AssetsTotalis derived as defined in XLS-65.7.1. The uncovered principal leaves the Vault through this derivation.LoanBroker.DebtTotaldecreases by exactlyLoan.PrincipalOutstanding.LoanBroker.CoverAvailabledecreases byDefaultCovered.- The
Loanupdates of the parent apply. - If
DefaultCoveredis not zero, it is transferred from theLoanBrokerpseudo-account to theVaultpseudo-account.
- Compute
- If the
tfLoanImpairflag is specified,Vault.LossUnrealizedincreases byLoan.PrincipalOutstanding. TheLoanupdates of the parent apply, including settinglsfLoanImpaired. - If the
tfLoanUnimpairflag is specified,Vault.LossUnrealizeddecreases byLoan.PrincipalOutstanding. TheLoanupdates of the parent apply, including clearinglsfLoanImpaired.
4. Rationale¶
A Loan's schedule is computed at the Vault's base exponent, which never changes, so every Loan stays representable while the Vault grows. Principal and interest records change by exact amounts and never accumulate rounding residue. Cash credited to the Vault or the cover pool is rounded down so that the stored balance equals what the receiving account can hold; the sub-unit remainder is forgiven, never created.
New Loans and cover deposits are optional inflows and are bounded by the Open zone. Payments and fees are owed value and are always admitted, so a Loan can always be repaid. A Loan's scheduled interest is counted against capacity when the Loan is created, so its scheduled payments do not consume capacity later.
A payment that closes a Loan must succeed even if the Vault cannot represent the last sub-unit amount; otherwise the Loan could never be closed.
5. Security Considerations¶
The Vault forgives at most one live unit per credited payment or default. A Loan always closes on its last scheduled payment, and a default always closes the Loan, even when the credited amount is zero.
Implementations must apply the capacity checks only to new Loans and cover deposits. A capacity check on a payment or a redirected fee would let a Vault near capacity block repayment.