Fixed Precision Vault
Fixes one precision grid per Vault for the life of the Vault and derives AssetsTotal from cash and deployed principal
- Author
- Vytautas Vito Tumas
- Created
- 2026-11-25
- Updated
- 2026-11-25
- Requires
- XLS-65.4.3
- Discussion
- XRPLF/XRPL-Standards/discussions/192
- Amendment
LendingProtocolV1_2- Patch of
- XLS-0065: Single Asset Tokenized Vault
65.7.1 Fixed Precision Vault¶
1. Abstract¶
Each Vault created under this amendment fixes one precision grid for its whole lifetime. The Vault's Scale field, \(P\), sets the grid at \(10^{-P}\). The Lending Protocol side of the amendment issues every Loan through such a Vault at the same grid (XLS-66.7.1). A Loan's schedule therefore stays representable for its whole life, however large the Vault grows.
A fixed grid gives a fixed capacity. The largest amount representable at \(10^{-P}\) with 16 significant digits is \((10^{16}-1) \times 10^{-P}\). Deposits and new Loans are admitted only while the Vault stays within the first 90% of that capacity, the Open zone. The remainder is kept for value the Vault has already earned.
Two Vault fields are added. AssetsDeployed records the principal the Vault has lent out. YieldUnrealized records the scheduled interest that active Loans owe to the Vault. AssetsTotal becomes a derived value: after every operation it is AssetsAvailable + AssetsDeployed, rounded down to the asset's 16-digit precision. It carries no accumulated rounding. Capacity is measured as AssetsTotal + YieldUnrealized, so a Loan's scheduled interest is reserved against capacity when the Loan is originated.
Vaults created before the amendment are unaffected, apart from the VaultSet AssetsMaximum check of §3.5.
2. Motivation¶
The Single Asset Vault stores its asset balances as IOU amounts with 16 significant digits. The precision of those balances follows the magnitude of AssetsTotal. A Vault holding a small balance carries many decimal places. As deposits raise AssetsTotal past each power of ten, the Vault loses one decimal place.
Loans issued through a LoanBroker fix their own precision at origination. A Loan originated while the Vault carried eight decimal places records its schedule at eight decimal places. A later deposit can move the Vault to six decimal places. Every repayment, impairment, and default of that Loan then produces amounts the Vault can no longer represent. The protocol rejects those transactions to protect ledger consistency, and the Loan stays open until AssetsTotal falls back below the threshold. The borrower has no action available to close it.
Interest earned by the Vault adds to AssetsTotal without any deposit. When AssetsTotal sits at the edge of its representable range, that growth has nowhere to go, and a mandatory repayment can fail for the same reason a deposit does.
3. Specification¶
3.1. Overview¶
All behaviour in this specification applies to a Vault whose LEVersion is 2 (FixedPrecision). VaultCreate writes LEVersion = 2 when LendingProtocolV1_1, LendingProtocolV1_2 and fixCleanup3_4_0 are all enabled (XLS-65.4.3). A FixedPrecision Vault keeps cash-basis interest recognition. The one rule that applies to every Vault once LendingProtocolV1_2 is enabled is the VaultSet check of §3.5.
Throughout, an optional inflow is value added at the submitter's discretion: VaultDeposit, and a new Loan in LoanSet. Mandatory growth is value the Vault has already earned: interest and principal received through LoanPay, and First-Loss Capital received on default. An outflow removes cash from the Vault: VaultWithdraw and VaultClawback.
3.2. Arithmetic¶
3.2.1. Representation¶
A non-zero IOU amount has the form \(m \times 10^{e}\) with \(10^{15} \le m \le 10^{16}-1\). An IOU amount carries 16 significant digits. Write \(e_{\mathrm{dyn}}(T)\) for the exponent of amount \(T\) in this form, rounding \(T\) down to 16 digits. When \(T\) grows past \((10^{16}-1) \times 10^{e}\), the exponent increases by one and the smallest representable step grows tenfold. When \(T\) shrinks below \(10^{15} \times 10^{e}\), the exponent decreases by one.
XRP amounts are integers of drops. MPT amounts are integers of MPT units. Both have exponent 0.
3.2.2. Scale¶
Scale \(P\) is an integer with \(0 \le P \le 10\), stored on the Vault at creation and fixed for the life of the Vault. The base exponent is \(-P\) and the base unit is \(10^{-P}\). For XRP and MPT, \(P = 0\).
3.2.3. Live exponent¶
The live exponent of a reference amount \(R\) is
\[ e(R) = \max\left(-P,\; e_{\mathrm{dyn}}(R)\right), \qquad e(0) = -P . \]
The live unit is \(10^{e(R)}\) and the live scale is \(s = -e(R)\), the number of decimal places of the live unit. While \(R\) fits at the base exponent, the live exponent equals the base exponent. When \(R\) grows beyond \((10^{16}-1) \times 10^{-P}\), the live exponent coarsens. When \(R\) shrinks back, it re-fines, down to the base exponent.
The Vault is coarsened when the live exponent of AssetsTotal is above \(-P\).
3.2.4. Operation rule¶
An operation that moves cash into or out of the Vault changes AssetsAvailable by a delta \(\Delta\). The delta is rounded before it is applied:
| Operation | Reference amount \(R\) | Rounding of \(\Delta\) |
|---|---|---|
VaultDeposit |
AssetsTotal |
Toward zero at \(e(R + \Delta)\), where \(R + \Delta\) is evaluated with round-to-nearest. |
VaultWithdraw, VaultClawback |
AssetsAvailable |
Magnitude toward zero at \(e(R - \lvert\Delta\rvert)\), where \(R - \lvert\Delta\rvert\) is evaluated with round-to-nearest. |
LoanPay credit, First-Loss Capital on default |
AssetsAvailable |
\(R + \Delta\) is rounded down at its own live exponent; the applied delta is that result minus \(R\). |
The outflow grid is the posterior grid of AssetsAvailable, the balance the cash actually leaves. It is not the grid of the derived AssetsTotal.
A rounded delta of zero fails the transaction with tecPRECISION_LOSS for:
VaultDeposit;VaultWithdrawandVaultClawback, except where the parent already allows shares to be redeemed or burned for zero assets: a withdrawal that redeems every outstanding share, a share-denominated withdrawal from a Vault whoseAssetsTotalequals itsLossUnrealized, and aVaultClawbackby the Vault Owner that burns a holder's shares;- a
LoanPayafter which the Loan'sPaymentRemainingis not zero.
A withdrawal or clawback whose non-zero rounded delta leaves the stored AssetsAvailable unchanged also fails with tecPRECISION_LOSS.
Two Vault credits may round to zero and still succeed, with no cash moved: a LoanPay that closes the Loan (its PaymentRemaining becomes zero), and the First-Loss Capital of a LoanManage default. In both cases the Loan's accounting still changes, and the Vault forgives the sub-unit remainder (XLS-66.7.1).
For XRP and MPT the rounding is a no-op.
3.2.5. Capacity and zones¶
The Vault's capacity value is
\[ C_{\mathrm{vault}} = \mathrm{AssetsTotal} + \mathrm{YieldUnrealized}, \]
evaluated on the posterior state with the delta rounded toward zero. The Open-zone limit is
\[ T_{\mathrm{dep}}(P) = 9 \times 10^{15} \times 10^{-P}, \]
which is 90% of the largest amount representable at the base exponent.
| Zone | Posterior capacity | Optional inflows | Mandatory growth |
|---|---|---|---|
| Open | \(C_{\mathrm{vault}} \le T_{\mathrm{dep}}(P)\) | Admitted | Admitted |
| Beyond | \(C_{\mathrm{vault}} > T_{\mathrm{dep}}(P)\) | Fail with tecLIMIT_EXCEEDED |
Admitted; the Vault may coarsen |
An optional inflow is also admitted only when the posterior live exponent of AssetsTotal equals the base exponent. A coarsened Vault rejects optional inflows with tecLIMIT_EXCEEDED until it re-fines.
Only optional inflows are checked against the zones, each on its own posterior state: VaultDeposit (§3.7) and LoanSet (§3.10). Mandatory growth and outflows are never checked. A Vault whose capacity falls back into the Open zone admits optional inflows again.
3.2.6. Vault balances¶
AssetsDeployed is the principal the Vault has lent out and not yet received back.
YieldUnrealized is the scheduled interest that active Loans owe to the Vault and that it has yet to receive. Each Lending Protocol transaction changes it by the change in the affected Loan's TotalValueOutstanding - PrincipalOutstanding - ManagementFeeOutstanding. The transactions that maintain it are specified in XLS-66.7.1.
YieldUnrealized takes no part in share conversions. Share price is computed from AssetsTotal and LossUnrealized as before.
AssetsTotal is derived. Every read of the Vault's total value, including share conversions, uses AssetsAvailable + AssetsDeployed. After every operation the stored AssetsTotal is set to that sum, rounded down to the asset's 16-digit precision. While the sum fits in 16 digits it is exact. Above that, the stored value is a floor of the exact sum, recomputed on every operation rather than carried forward. Because AssetsDeployed is never negative, the stored AssetsTotal is never below AssetsAvailable.
AssetsAvailable is the Vault pseudo-account's cash. It changes by the rounded delta of §3.2.4 and is stored at the asset's 16-digit precision. After coarsening it can keep a residue finer than the live unit.
AssetsDeployed, LossUnrealized and YieldUnrealized move no cash and are changed by exact amounts taken from the Loan. Each must remain exactly representable at the asset's 16-digit precision.
All five fields are written by a single balance update. That update fails the transaction with tefBAD_LEDGER if any of AssetsAvailable, AssetsDeployed, LossUnrealized or YieldUnrealized would become negative. It fails with tecLIMIT_EXCEEDED if LossUnrealized would exceed AssetsDeployed.
AssetsMaximum is compared against the derived AssetsTotal alone.
3.3. Ledger Entry: Vault¶
3.3.1. Fields¶
The Vault ledger entry gains two fields, and the meaning of two existing fields changes. All other fields are unchanged.
| Field Name | Constant | Required | JSON Type | Internal Type | Default Value | Description |
|---|---|---|---|---|---|---|
AssetsDeployed |
No | No | string |
NUMBER |
0 |
Principal lent out by the Vault and not yet received back. Zero at creation. |
YieldUnrealized |
No | No | string |
NUMBER |
0 |
Scheduled interest owed to the Vault by active Loans and not yet received. Zero at creation. |
Scale |
Yes | No | number |
UINT8 |
6 |
The scale \(P\). Range 0 to 10. Default 6 for an IOU asset. Absent for XRP and MPT, which means 0. Fixed for the life of the Vault. |
LEVersion |
Yes | No | number |
UINT8 |
2 |
2 (FixedPrecision) for Vaults created under this amendment. |
3.3.2. Invariants¶
For a Vault with LEVersion 2, these hold after every transaction:
AssetsTotalequalsAssetsAvailable + AssetsDeployed, rounded down to the asset's 16-digit precision.AssetsDeployed >= 0, and it is exactly representable at the asset's 16-digit precision.YieldUnrealized >= 0.LossUnrealized <= AssetsDeployed. This replaces the comparison ofLossUnrealizedwithAssetsTotal - AssetsAvailablein parent §3.1.10 invariant 5.- If the share
OutstandingAmountis zero,AssetsDeployedis zero, in addition to parent invariant 7. - A newly created Vault has
AssetsDeployedandYieldUnrealizedequal to zero. AssetsDeployedandYieldUnrealizedchange only inLoanSet,LoanPayandLoanManage.LossUnrealizedchanges only inLoanManageandLoanPay, as in parent invariant 15.
The parent accounting-delta invariants of VaultDeposit, VaultWithdraw and VaultClawback change as follows:
- The change in
AssetsAvailablemust equal the exact change in the Vault pseudo-account's balance, with no rounding tolerance. - The change in
AssetsTotalis not compared with the pseudo-account's balance change, becauseAssetsTotalis a derived floor (invariant 1 covers it). - The sign checks on the Vault's balance change use the exact change, not the change rounded to the
AssetsTotalscale.
3.4. Transaction: VaultCreate¶
3.4.1. Failure Conditions¶
3.4.1.1. Data Verification¶
Scaleis present and greater than 10. (temMALFORMED) This replaces the limit of 18 for a Vault that will be created withLEVersion2.
3.4.1.2. Protocol-Level Failures¶
AssetsMaximumis present and is not a multiple of \(10^{-P}\) that is exactly representable for the asset. (tecPRECISION_LOSS) \(P\) isScale, or 6 whenScaleis absent and the asset is an IOU.
3.4.2. State Changes¶
On success the Vault records LEVersion = 2, AssetsDeployed = 0 and YieldUnrealized = 0.
3.5. Transaction: VaultSet¶
3.5.1. Failure Conditions¶
This rule applies to every Vault once LendingProtocolV1_2 is enabled, whatever its LEVersion:
AssetsMaximumis present and is not exactly representable at the Vault's scale. (tecPRECISION_LOSS) For a Vault withLEVersion2 the scale is the base exponent \(-P\). For other Vaults it is the current exponent ofAssetsTotal.
Scale cannot be changed.
3.6. Transaction: VaultDelete¶
Unchanged. The parent check that AssetsTotal is zero reads the derived total, so a Vault with non-zero AssetsDeployed cannot be deleted.
3.7. Transaction: VaultDeposit¶
3.7.1. Failure Conditions¶
3.7.1.1. Protocol-Level Failures¶
VaultDeposit is an optional inflow. The deposit is rounded as in §3.2.4 and the shares are computed from it. Then, before the AssetsMaximum check of the parent:
- The posterior live exponent of
AssetsTotalis not the base exponent \(-P\). (tecLIMIT_EXCEEDED) - The posterior capacity
AssetsTotal + YieldUnrealizedexceeds \(T_{\mathrm{dep}}(P)\). (tecLIMIT_EXCEEDED)
For XRP and MPT the minimum deposit is one drop or one MPT unit.
3.8. Transaction: VaultWithdraw¶
VaultWithdraw is an outflow and has no zone check. The payout is rounded as in §3.2.4. The Vault may re-fine as a result.
3.8.1. Failure Conditions¶
3.8.1.1. Protocol-Level Failures¶
- The withdrawal redeems every outstanding share while
AssetsDeployedis non-zero. (tecHAS_OBLIGATIONS) The shares still have a claim on principal that is out on loan.
3.8.2. State Changes¶
A withdrawal that redeems every outstanding share pays out AssetsAvailable (XLS-65.2). It applies that payout through the balance update of §3.2.6, so it does not set AssetsTotal and AssetsAvailable to zero directly.
3.9. Transaction: VaultClawback¶
VaultClawback is an outflow and has no zone check. The recovered amount is rounded as in §3.2.4. The Vault may re-fine as a result.
3.9.1. Failure Conditions¶
3.9.1.1. Protocol-Level Failures¶
- The clawback would burn every outstanding share while
AssetsDeployedis non-zero. (tecHAS_OBLIGATIONS)
3.10. Lending Protocol transactions¶
The Lending Protocol changes the Vault only through the balance update of §3.2.6. The amounts are computed by XLS-66.7.1. The effect on the Vault is:
| Transaction | AssetsAvailable |
AssetsDeployed |
YieldUnrealized |
LossUnrealized |
|---|---|---|---|---|
LoanSet |
− principal | + principal | + the Loan's interest due | unchanged |
LoanPay |
+ principal and interest paid, rounded as in §3.2.4 | − principal paid | + change in the Loan's scheduled interest | − PrincipalOutstanding if the Loan was impaired, which the payment clears first |
LoanManage impair |
unchanged | unchanged | unchanged | + PrincipalOutstanding |
LoanManage unimpair |
unchanged | unchanged | unchanged | − PrincipalOutstanding |
LoanManage default |
+ First-Loss Capital applied, rounded as in §3.2.4 | − PrincipalOutstanding |
− the Loan's remaining scheduled interest | − PrincipalOutstanding if impaired |
LoanSet is an optional inflow. It fails with tecLIMIT_EXCEEDED when the Vault is coarsened, or when AssetsTotal + YieldUnrealized plus the new Loan's interest due exceeds \(T_{\mathrm{dep}}(P)\). An impairment that would make LossUnrealized exceed AssetsDeployed fails with tecLIMIT_EXCEEDED.
3.11. Legacy objects¶
A Vault with LEVersion below 2 keeps the behaviour it was created with. Its precision follows AssetsTotal, AssetsTotal is stored rather than derived, and the existing reconciliation tolerances apply. The capacity zones, AssetsDeployed, YieldUnrealized and the fixed grid apply only to Vaults with LEVersion 2. The VaultSet check of §3.5 is the exception.
3.12. RPC: vault_info¶
The Vault ledger entry returns AssetsDeployed, YieldUnrealized and LEVersion wherever Vault fields are returned. No method is added or removed.
3.12.1. Request Fields¶
Unchanged.
3.12.2. Response Fields¶
| Field Name | Always Present? | JSON Type | Description |
|---|---|---|---|
vault.AssetsDeployed |
No | string |
Principal lent out by the Vault and not yet received back. |
vault.YieldUnrealized |
No | string |
Scheduled interest owed to the Vault by active Loans and not yet received. |
vault.LEVersion |
No | number |
The accounting version of the Vault. Set by VaultCreate and never changed. |
3.12.3. Failure Conditions¶
Unchanged.
3.12.4. Example Request¶
{
"method": "vault_info",
"params": [
{
"vault_id": "2DE64CA41250EF3CB7D2B127D6CEC31F747492CAE2BD1628CA02EA1FFE7475B3"
}
]
}
3.12.5. Example Response¶
A Vault holding an IOU with Scale 6, created under this amendment, with one active Loan of principal 10 owing 2.5 of scheduled interest:
{
"result": {
"ledger_current_index": 7,
"status": "success",
"validated": false,
"vault": {
"Account": "rKwvc1mgHLyHKY3yRUqVwffWtsxYb3QLWf",
"Asset": {
"currency": "IOU",
"issuer": "r9cZ5oHbdL4Z9Maj6TdnfAos35nVzYuNds"
},
"AssetsAvailable": "90",
"AssetsDeployed": "10",
"AssetsTotal": "100",
"Flags": 0,
"LEVersion": 2,
"LedgerEntryType": "Vault",
"LossUnrealized": "0",
"Owner": "rwhaYGnJMexktjhxAKzRwoCcQ2g6hvBDWu",
"OwnerNode": "0",
"PreviousTxnID": "1484794AE38DBB7C6F4E0B7536CC560B418135BEDB0F8904349F7F8A3B496826",
"PreviousTxnLgrSeq": 6,
"Scale": 6,
"Sequence": 5,
"ShareMPTID": "00000001C752C42A1EBD6BF2403134F7CFD2F1D835AFD26E",
"WithdrawalPolicy": 1,
"YieldUnrealized": "2.5",
"index": "2DE64CA41250EF3CB7D2B127D6CEC31F747492CAE2BD1628CA02EA1FFE7475B3",
"shares": {
"Flags": 0,
"Issuer": "rKwvc1mgHLyHKY3yRUqVwffWtsxYb3QLWf",
"LedgerEntryType": "MPTokenIssuance",
"OutstandingAmount": "100",
"OwnerNode": "0",
"PreviousTxnID": "1484794AE38DBB7C6F4E0B7536CC560B418135BEDB0F8904349F7F8A3B496826",
"PreviousTxnLgrSeq": 6,
"Sequence": 1,
"index": "F84AE266C348540D7134F1A683392C3B97C3EEFDE9FEF6F2055B3B92550FB44A",
"mpt_issuance_id": "00000001C752C42A1EBD6BF2403134F7CFD2F1D835AFD26E"
}
}
}
}
4. Rationale¶
A fixed grid gives a fixed capacity. Dividing it into an Open zone for optional inflows and headroom for mandatory growth means scheduled repayments never fail for lack of precision. A Loan is admitted only when the whole of its scheduled interest fits in the Open zone alongside the current balance. When that interest is later paid it moves from YieldUnrealized into AssetsTotal, so capacity is unchanged.
AssetsTotal is derived rather than accumulated. Under cash-basis accounting it equals the Vault's cash plus the principal it has lent. Storing the principal as AssetsDeployed and recomputing the total after every operation removes every rounding residue an incremented total would carry once the Vault has coarsened. It also lets impairment, default and full redemption read principal exactly, instead of inferring it from a rounded difference.
Rounding AssetsTotal down rather than to nearest means the derived total never overstates the assets behind the shares.
Outflows round at the posterior grid of AssetsAvailable because that is the balance the cash leaves. Rounding at the coarser AssetsTotal grid would discard digits that the cash balance can still hold.
YieldUnrealized takes no part in share conversions. Share price is computed from AssetsTotal and LossUnrealized as before.
5. Security Considerations¶
An optional inflow is admitted only when the Vault is at its base exponent and stays within the Open zone, so a depositor cannot push the Vault into a state where scheduled repayments lose precision.
A VaultDeposit, VaultWithdraw or VaultClawback whose rounded delta is zero fails with tecPRECISION_LOSS, so shares are never minted or burned for no cash, except in the zero-value cases of §3.2.4 that the parent already allows. A closing LoanPay or a default may credit the Vault zero. The forgiven amount is below one live unit, and it lets the Loan close.
Because AssetsTotal is recomputed from exact components after every operation, no rounding residue survives. A full redemption or clawback of every share is refused while AssetsDeployed is non-zero. Otherwise a Vault could be left with no shares but principal still on loan.
YieldUnrealized, AssetsDeployed and LossUnrealized are never allowed to go negative, and LossUnrealized cannot exceed AssetsDeployed. A Loan can only be impaired for principal the Vault actually has on loan.
Vaults created before the amendment keep the behaviour they were created with. The VaultSet AssetsMaximum check applies to them too, but it only rejects a cap that would otherwise be rounded silently.