|
| static std::optional< AccountID > | feePayerAccountRoot (ReadView const &view, STTx const &tx) |
| | Return the AccountRoot whose XRP balance actually absorbed a transaction's fee, if any.
|
| static bool | isVaultEmpty (Vault const &vault) |
| | Check whether a vault holds no assets.
|
| static bool | checkTotalsAddUp (Vault const &afterVault, Vault const &beforeVault, Asset const &vaultAsset, bool fix340Enabled, std::int32_t minScale, Number const &roundedVaultDelta, Number const &exactVaultDelta, char const *verb, beast::Journal const &j) |
| | Check that a vault's AssetsTotal and AssetsAvailable deltas add up against the real transfer, for deposit/withdraw/clawback.
|
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 (Legacy/CashBasis), or AssetsDeployed (FixedPrecision)
- 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
- FixedPrecision only: AssetsDeployed is non-negative and exactly representable at the asset's precision; AssetsDeployed changes only for ttLOAN_SET, ttLOAN_PAY and ttLOAN_MANAGE; AssetsDeployed is zero right after ttVAULT_CREATE and whenever shares outstanding return to zero; the stored AssetsTotal cache equals AssetsAvailable + AssetsDeployed, rounded Downward to the asset's precision
- FixedPrecision only: YieldUnrealized is non-negative; YieldUnrealized changes only for ttLOAN_SET, ttLOAN_PAY and ttLOAN_MANAGE
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 65 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 245 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 254 of file VaultInvariant.cpp.
| bool xrpl::ValidVault::checkTotalsAddUp |
( |
Vault const & | afterVault, |
|
|
Vault const & | beforeVault, |
|
|
Asset const & | vaultAsset, |
|
|
bool | fix340Enabled, |
|
|
std::int32_t | minScale, |
|
|
Number const & | roundedVaultDelta, |
|
|
Number const & | exactVaultDelta, |
|
|
char const * | verb, |
|
|
beast::Journal const & | j ) |
|
staticnodiscardprivate |
Check that a vault's AssetsTotal and AssetsAvailable deltas add up against the real transfer, for deposit/withdraw/clawback.
Shared body of the ttVAULT_DEPOSIT, ttVAULT_WITHDRAW and ttVAULT_CLAWBACK "assets outstanding"/"assets available" add-up checks, which differ only in the rounded/exact deltas plugged in and the verb used in the log message.
- Parameters
-
| afterVault | Snapshot of the vault after the transaction. |
| beforeVault | Snapshot of the vault before the transaction. |
| vaultAsset | The vault's underlying asset. |
| fix340Enabled | Whether fixCleanup3_4_0 is enabled. |
| minScale | The posterior scale computed by computeVaultMinScale. |
| roundedVaultDelta | The real transfer's delta, rounded to minScale. |
| exactVaultDelta | The real transfer's exact (unrounded) delta. |
| verb | The transaction name used in the log message ("deposit", "withdrawal" or "clawback"). |
| j | Journal for logging. |
- Returns
- false if either add-up check fails.
Definition at line 417 of file VaultInvariant.cpp.