Skip to content

[W.I.P] feat Add Vault fixed-precision design notes - #7885

Draft
Tapanito wants to merge 6 commits into
developfrom
tapanito/lending-protocol-rounding
Draft

[W.I.P] feat Add Vault fixed-precision design notes#7885
Tapanito wants to merge 6 commits into
developfrom
tapanito/lending-protocol-rounding

Conversation

@Tapanito

Copy link
Copy Markdown
Contributor

Proposes a design-time sfPrecision ceiling for Vault rounding, decoupled from the Vault's internal running totals, plus a Dust Pseudo-account and sfDust accumulator to capture value a mandatory operation (loan repayment) would otherwise lose when that ceiling degrades.

High Level Overview of Change

Context of Change

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

Proposes a design-time sfPrecision ceiling for Vault rounding, decoupled
from the Vault's internal running totals, plus a Dust Pseudo-account and
sfDust accumulator to capture value a mandatory operation (loan
repayment) would otherwise lose when that ceiling degrades.
Tapanito added 5 commits July 29, 2026 14:52
Corrects SettleAdd's AssetsTotal update to stop double-counting
principal under cash-basis accounting, resolves the contradiction
between optional-operation and Case 2 dust routing, folds the loan's
own total-value floor into the loan.precision formula, and documents
several accepted risks and non-issues surfaced during review (Loan
acceptance griefing, DebtTotal's separate rounding behavior, and Dust
sweep-timing attribution).
Reorganizes the document into Problem / Summary / Technical Details
(Fields, Algorithm) / Appendix for easier reading, fixes an
sfLoanScale mislabel, and removes the sfDust ledger field in favor of
the Dust Pseudo-account's real balance as the single source of truth
- the old field was never decremented on the normal sweep path and
would have drifted from the account it was meant to mirror.
Reorganizes the design into a tighter Problem/Summary/Technical
Details(Fields, Algorithm)/Appendix layout and trims narrative prose
into scannable bullets without dropping content.

Closes the assetsTotalDelta open question: interest recognized on a
cash-basis repayment now gets the same two-stage dust truncation as
the settled custody amount, keyed to what AssetsTotal actually gains
rather than what custody gains, so a large Vault can no longer round
an entire interest payment to zero and lose it untracked.

Renames SettleAdd/MaybeSweep's pseudocode variables (e0/e1/settled_0/
dust_1/etc.) to descriptive names throughout.
Replaces the three separate documents (fixed-precision, derived-
precision, and the comparison memo) with a single design-vault-
precision.md that presents sfPrecision and the no-field alternative
as Option A / Option B, sharing the identical mechanism once and
branching only where they actually diverge.

Rewrites SettleAdd to perform the real AssetsTotal addition first and
read off the resulting scale, instead of independently truncating
amount and assetsTotalDelta against a precomputed boundary and
subtracting the shortfall afterward. The old approach could produce a
settled value that wasn't aligned to the vault's scale; the new one
can't, by construction, and also proves settled can never go negative.

Simplifies MaybeSweep to a direct transfer instead of routing through
SettleAdd, since the swept amount is already trimmed to fit before the
transfer happens.
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.

1 participant