Skip to content

Conversation

@pdp2121
Copy link
Collaborator

@pdp2121 pdp2121 commented Nov 10, 2025

High Level Overview of Change

Add support for XLS-0066 Lending Protocol.

Context of Change

The specification can be found here: XRPLF/XRPL-Standards#240
The cpp implementation is available here: XRPLF/rippled#5270

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Translation Updates
  • Release

Before / After

LoanBrokerSet

(Special case for DebtMaximum:

The maximum amount the protocol can owe the Vault. The default value of 0 means there is no limit to the debt. Must not be negative.

when zero, the UI will display No Limit)

Screenshot 2025-12-05 at 10 26 50 AM Screenshot 2025-12-05 at 10 25 00 AM

LoanBrokerDelete

(This one is failing due to Loan term had not expired, but all fields are there):

Screenshot 2025-11-10 at 12 30 18 PM Screenshot 2025-11-10 at 12 30 32 PM

LoanBrokerCoverDeposit

Screenshot 2025-11-10 at 12 31 05 PM Screenshot 2025-11-10 at 12 31 24 PM

LoanBrokerCoverWithdraw

Screenshot 2025-11-10 at 12 31 55 PM Screenshot 2025-11-10 at 12 32 05 PM

LoanBrokerCoverCallback

(There a special case for Amount field when it is set to zero:

The First-Loss Capital amount to clawback. If the amount is 0 or not provided, clawback funds up to LoanBroker.DebtTotal * LoanBroker.CoverRateMinimum.

which has been handled by the code)

Screenshot 2025-11-10 at 12 32 20 PM Screenshot 2025-11-10 at 12 32 51 PM

LoanSet

localhost_3000_lend devnet rippletest net_transactions_5A579D21B53A8D113D612D05AF191A59F852DD9FBBF58AB093F4F5270F7C07A2 Screenshot 2025-12-05 at 10 25 10 AM

LoanPay

Screenshot 2025-11-10 at 12 37 18 PM Screenshot 2025-11-10 at 12 37 32 PM

LoanManage (with Flags displayed in Detailed tab)

Screenshot 2025-11-10 at 12 37 55 PM Screenshot 2025-11-10 at 12 38 09 PM Screenshot 2025-11-10 at 12 38 28 PM

LoanDelete

(This one is failing due to Loan term had not expired, but all fields are there)

Screenshot 2025-11-10 at 12 39 02 PM Screenshot 2025-11-10 at 12 39 16 PM

MPT as underlying asset is displayed correctly

Screenshot 2025-12-07 at 6 55 08 PM

Test Plan

@ripple ripple deleted a comment Nov 20, 2025
@ripple ripple deleted a comment Nov 20, 2025
@ripple ripple deleted a comment Nov 20, 2025
@ripple ripple deleted a comment Nov 20, 2025
@ripple ripple deleted a comment Nov 20, 2025
@ripple ripple deleted a comment Nov 20, 2025
@ripple ripple deleted a comment Nov 21, 2025
@ripple ripple deleted a comment Nov 25, 2025
@pdp2121 pdp2121 requested a review from kuan121 December 8, 2025 17:03
@pdp2121
Copy link
Collaborator Author

pdp2121 commented Dec 8, 2025

@kuan121 the PR is ready to next round of reviews. Thanks for great catches in the last round! I have updated the screenshots and marked comments as resolved (feel free to unresolve if needed, I just marked them for my own sanity checks)

Comment on lines +295 to +296
digits = 2,
cutoff = 0.01,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't cutoff be derived from digits?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't harm to have both, since user might want to see 0.99998 with 0.01 cutoff for example

const coverRateMinimum = fields.CoverRateMinimum || 0

// CoverRateMinimum is in 1/10th basis points, so divide by 100000
const requiredCover = debtTotal * (coverRateMinimum / 100000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw consts defined for the 1/10th basis points somewhere else, can we reuse that here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other ones were used to show percentage, so that variable is 1000, not 100000

* - IOU: { "currency": "USD", "issuer": "rXXX..." }
* - MPT: { "mpt_issuance_id": "000000..." }
*/
export function formatAsset(asset: any): Asset {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this moved from somewhere else? I believe this logic is already in xrpl.js if we could reuse that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a future improvements, since we use isMPT boolean in some rendering functions, so we cannot directly use xrpl.js without fixing all of them

Copy link
Collaborator

@achowdhry-ripple achowdhry-ripple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nits but overall looks good!

@pdp2121 pdp2121 merged commit 1b45895 into staging Dec 15, 2025
5 checks passed
@pdp2121 pdp2121 deleted the lending-protocol-basic branch December 15, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants