Skip to content

Add loan invariants - #616

Open
a1q123456 wants to merge 2 commits into
XRPLF:masterfrom
a1q123456:a1q123456/add-loan-transaction-invariants
Open

a1q123456 wants to merge 2 commits into
XRPLF:masterfrom
a1q123456:a1q123456/add-loan-transaction-invariants

Conversation

@a1q123456

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Context of Change

Type of Change

  • New XLS Draft
  • XLS Update (changes to an existing XLS)
  • XLS Status Change (e.g., Draft → Final, Draft → Stagnant)
  • Process/Meta (changes to CONTRIBUTING.md, XLS-1, templates, etc.)
  • Infrastructure (CI, workflows, scripts, website)
  • Documentation (README updates, typo fixes)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Several newly added invariants in XLS-0066 contradict existing specified state changes (and contain an internal definition inconsistency), which would mis-specify normative behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR strengthens the normative “Invariants” sections in the lending and vault XLS documents, aiming to make ledger-impact constraints explicit for broker deletion, loan lifecycle operations, and vault deletion.

Changes:

  • Adds invariants for LoanBrokerDelete, LoanSet, LoanDelete, LoanManage, and LoanPay in XLS-0066 (replacing several TBD placeholders).
  • Adds an explicit invariant in XLS-0065 requiring VaultDelete to delete the vault referenced by the transaction.
File summaries
File Description
XLS-0066-lending-protocol/README.md Adds/expands invariants for multiple lending transactions (broker deletion, loan create/delete/manage/pay).
XLS-0065-single-asset-vault/README.md Adds an explicit invariant tying VaultDelete to the VaultID in the transaction.
Review details

Suppressed comments (1)

XLS-0066-lending-protocol/README.md:1229

  • This invariant says LoanBroker.DebtTotal must be unchanged, but the defined state changes allow setting LoanBroker.DebtTotal = 0 when LoanBroker.OwnerCount == 0 to forgive rounding dust (3.9.4 step 5). The invariant should allow that explicit adjustment.
- The transaction must change nothing else: `Vault.AssetsTotal`, `Vault.AssetsAvailable`, `Vault.LossUnrealized`, the Vault pseudo-account balance, `LoanBroker.DebtTotal`, `LoanBroker.CoverAvailable` and the LoanBroker pseudo-account balance all unchanged.
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


- If `LoanBroker.OwnerCount = 0` the `DirectoryNode` will have at most one node (the root), which will only hold entries for `RippleState` or `MPToken` objects.
- The transaction must not touch any `Loan`.
- `LoanBroker.DebtTotal` and `LoanBroker.CoverAvailable` must both be zero when the `LoanBroker` is deleted.
#### 3.10.6 Invariants

**TBD**
This section uses `DefaultAmount` and `DefaultCovered` as computed in section 3.10.5, both taken from the pre-transaction state; for a cash-basis Vault, `DefaultAmount = Loan.PrincipalOutstanding`. Equalities on IOU amounts are evaluated as a single rounded residual with a tolerance of one unit at the comparison scale; XRP and MPT amounts compare exactly.

This branch has not been deployed

No deployments
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.

2 participants