(Release 3.1) Lending protocol - ongoing work - XLS-66#6156
Merged
ximinez merged 26 commits intorelease-3.1from Jan 12, 2026
Merged
(Release 3.1) Lending protocol - ongoing work - XLS-66#6156ximinez merged 26 commits intorelease-3.1from
ximinez merged 26 commits intorelease-3.1from
Conversation
- Originally defined as uint64_t, but the testIssuerLoan() test called it with a negative number, causing an overflow to a very large number that in some circumstances could be silently cast back to an int64_t, but might not be. I believe this is UB, and we don't want to rely on that.
- Adds additional unit tests to cover math calculations. - Removes unused methods.
- add nodiscard to unimpairLoan, and check result in LoanPay - add a check to verify that issuer exists - improve LoanManage error code for dust amounts
- In overpayment results, the management fee was being calculated twice: once as part of the value change, and as part of the fees paid. Exclude it from the value change.
Co-authored-by: Shawn Xie <35279399+shawnxie999@users.noreply.github.com>
- Round the initial total value computation upward, unless there is 0-interest. - Rename getVaultScale to getAssetsTotalScale, and convert one incorrect computation to use it. - Use adjustImpreciseNumber for LossUnrealized. - Add some logging to computeLoanProperties.
1 task
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-3.1 #6156 +/- ##
=============================================
+ Coverage 79.3% 79.3% +0.1%
=============================================
Files 837 837
Lines 71432 71444 +12
Branches 8295 8243 -52
=============================================
+ Hits 56611 56667 +56
+ Misses 14821 14777 -44
🚀 New features to boost your workflow:
|
13 tasks
- Adds loan state to LoanProperties. - Cleans up computeLoanProperties. - Fixes missing management fee from overpayment.
* Replace accountHolds with accountSpendable when checking for account funds in VaultDeposit and LoanBrokerCoverDeposit
- Updates or fixes a couple of things I noticed while reviewing changes to the spec. - Rename sfPreviousPaymentDate to sfPreviousPaymentDueDate. - Make the vault asset cap check added in #6124 a little more robust: 1. Check in preflight if the vault is _already_ over the limit. 2. Prevent overflow when checking with the loan value. (Subtract instead of adding, in case the values are near maxint. Both return the same result. Also add a unit test so each case is covered.
This was referenced Jan 8, 2026
- Fixes LoanManage tfBAD_LEDGER case by capping the amount of FLC to use to cover a loss at the amount of cover available. - Check if the Vault pseudo-account is frozen in LoanBrokerSet
…6117) - Check the trust line limit is not exceeded for a withdraw to a third party Destination account.
gregtatcam
approved these changes
Jan 9, 2026
shawnxie999
approved these changes
Jan 9, 2026
…nez/lending-3.1 * mywork/ximinez/vault-fix-3.1: VaultClawback: Burn shares of an empty vault (6120) fix: Inner batch transactions never have valid signatures (6069) fix: Reorder Batch Preflight Errors (6176)
6ea71f9 to
8fc2551
Compare
Collaborator
Author
|
Do not merge until after #6203 |
shawnxie999
approved these changes
Jan 12, 2026
gregtatcam
approved these changes
Jan 12, 2026
- Reduce code duplication in LoanBrokerDelete - Reorder "canWithdraw" parameters to put "view" first - Combine accountSpendable into accountHolds - Avoid copies by taking a reference for the claw amount - Return function results directly - Fix typo for "parseLoan" in ledger_entry RPC - Improve some comments and unused variables - No need for late payment components lambda - Add explanatory comment for computeLoanProperties - Add comment linking computeRawLoanState to spec - Fix typo: TrueTotalPrincipalOutstanding - Fix missed ripple -> xrpl update - Remove unnecessary "else"s. - Clean up std::visit in accountHolds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
High Level Overview of Change
This PR is to apply the same code changes as are in #6102, to the
release-3.1branch.This PR continues the work started in #5270 and #6093. All new code changes that affect Lending should be done in this branch. That includes PRs.
Implement the Lending Protocol as described in XLS-66
Context of Change
Note: A lot of the changes in this branch are going to be cherry-picked from
developorximinez/lending-XLS-66-ongoing. That branch has had some significant refactors, in particular, renaming fromrippledtoxrpld. I'm not going to make any significant effort to undo name changes that don't affect the build. Specifically, that will means strings, such as inXRPL_ASSERTs.Type of Change
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)