Invariants: Vault object and MPTokenIssuance for vault shares.
- vault deleted and vault created is empty
- vault created must be linked to pseudo-account for shares and assets
- vault must have MPTokenIssuance for shares
- vault without shares outstanding must have no shares
- loss unrealized does not exceed the difference between assets total and assets available
- assets available do not exceed assets total
- vault deposit increases assets and share issuance, and adds to: total assets, assets available, shares outstanding
- vault withdrawal and clawback reduce assets and share issuance, and subtracts from: total assets, assets available, shares outstanding
- vault set must not alter the vault assets or shares balance
- no vault transaction can change loss unrealized (it's updated by loan transactions)
- a created closed-ended vault must satisfy MIN_INVESTMENT_PERIOD <= RedemptionDate - SubscriptionDate < MAX_INVESTMENT_PERIOD
- vault deposit may only succeed when the vault phase is NoPhase or Subscription
- vault withdrawal may not succeed when the vault phase is Investment
- closed-ended loan origination (ttLOAN_SET) may only succeed when the vault phase is Investment
Immutability of VaultKind, SubscriptionDate and RedemptionDate is enforced by NoModifiedUnmodifiableFields (see InvariantCheck.cpp). From featureLendingProtocolV1_1 onwards, immutability of the vault's Asset, pseudo-account and ShareMPTID is likewise enforced by NoModifiedUnmodifiableFields; prior to that amendment it is checked here.
Definition at line 56 of file VaultInvariant.h.
Return the AccountRoot whose XRP balance actually absorbed a transaction's fee, if any.
Mirrors Transactor::getFeePayer, but resolves to std::nullopt for a pre-funded sponsorship: that fee is drawn from the ltSponsorship object's sfFeeAmount, never from the sponsor's own AccountRoot, so there is no balance to add back there.
- Parameters
-
| view | Read-only view of the ledger after the transaction. |
| tx | The transaction being applied. |
- Returns
- The fee-paying AccountRoot's id, or
std::nullopt when the fee was not drawn from any AccountRoot balance.
Definition at line 240 of file VaultInvariant.cpp.
Return the vault-asset delta for a party inspected as a withdrawal/deposit counterparty, adjusted for the fee.
Calls deltaAssets for id and, for XRP transactions, adds the consumed fee back only when id is the AccountRoot that actually paid it (per feePayerAccountRoot) – so the invariant sees the net asset movement rather than a fee-reduced balance change, regardless of whether id is the sender, a distinct destination, a delegate, or a co-signed fee sponsor. Post-fixCleanup3_4_0, any resulting economically-zero delta is always normalized to absence.
Pre-fixCleanup3_4_0 this replicates the legacy behaviour exactly: only tx[sfAccount] could ever receive a fee correction (and only when it was itself, per STTx::getFeePayerID, the fee payer). After that sender-only correction a zero delta is collapsed to absence; if the correction does not apply, a present-zero delta is kept as-is.
- Parameters
-
| view | Read-only view of the ledger after the transaction. |
| id | Account being inspected as sender or destination. |
| tx | The transaction being applied. |
| fee | Fee charged by this transaction. |
| fix340Enabled | Whether fixCleanup3_4_0 is enabled, as already determined once by finalize. |
- Returns
- The fee-adjusted delta, or
std::nullopt if the net delta is zero (always post-amendment; pre-amendment only after the sender-only fee correction) or the entry was not touched.
Definition at line 249 of file VaultInvariant.cpp.