|
xrpld
|
Invariants: Vault object and MPTokenIssuance for vault shares. More...
#include <VaultInvariant.h>

Classes | |
| struct | Vault |
| struct | Shares |
| struct | DeltaInfo |
Public Member Functions | |
| void | visitEntry (bool, SLE::const_ref, SLE::const_ref) |
| bool | finalize (STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) |
Static Public Member Functions | |
| static std::int32_t | computeCoarsestScale (std::vector< DeltaInfo > const &numbers) |
Private Member Functions | |
| std::int32_t | computeVaultMinScale (DeltaInfo const &vaultDelta, Rules const &rules) const |
| Compute the minimum STAmount scale for rounding invariant calculations. | |
| std::optional< DeltaInfo > | deltaAssets (AccountID const &id) const |
| Return the vault-asset balance-change delta for an account. | |
| std::optional< DeltaInfo > | deltaAssetsTxAccount (STTx const &tx, XRPAmount fee) const |
| Return the vault-asset delta for the transaction's sending account, adjusted for the fee. | |
| std::optional< DeltaInfo > | deltaShares (AccountID const &id) const |
| Return the vault-share balance-change delta for an account. | |
| bool | finalizeLoanSet (ReadView const &view, beast::Journal const &j) const |
Invariant check for ttLOAN_SET. | |
Static Private Member Functions | |
| static bool | isVaultEmpty (Vault const &vault) |
| Check whether a vault holds no assets. | |
Private Attributes | |
| std::vector< Vault > | afterVault_ |
| std::vector< Shares > | afterMPTs_ |
| std::vector< Vault > | beforeVault_ |
| std::vector< Shares > | beforeMPTs_ |
| std::unordered_map< uint256, DeltaInfo > | deltas_ |
Static Private Attributes | |
| static constexpr Number | kZero {} |
Invariants: Vault object and MPTokenIssuance for vault shares.
Immutability of VaultKind, SubscriptionDate and RedemptionDate is enforced by NoModifiedUnmodifiableFields (see InvariantCheck.cpp).
Definition at line 53 of file VaultInvariant.h.
|
nodiscardprivate |
Compute the minimum STAmount scale for rounding invariant calculations.
Post-amendment (fixCleanup3_2_0) this is simply the posterior assetsTotal scale. Pre-amendment it is the coarsest scale across vaultDelta and both asset-field deltas.
| vaultDelta | Delta of the vault's asset balance for this transaction. |
| rules | Active ledger rules (used to check the amendment). |
Definition at line 309 of file VaultInvariant.cpp.
|
nodiscardprivate |
Return the vault-asset balance-change delta for an account.
Looks up the ledger-entry delta recorded during visitEntry for the account entry (XRP), trust line (IOU), or MPToken (MPT) that corresponds to the vault asset held by id.
| id | Account whose asset delta is requested. |
std::nullopt if the entry was not touched. Definition at line 206 of file VaultInvariant.cpp.
|
nodiscardprivate |
Return the vault-asset delta for the transaction's sending account, adjusted for the fee.
Calls deltaAssets for tx[sfAccount] and, for non-delegated XRP transactions, adds the consumed fee back so the invariant sees the net asset movement rather than the fee-reduced balance change.
| tx | The transaction being applied. |
| fee | Fee charged by this transaction. |
std::nullopt if the net delta is zero or the account entry was not touched. Definition at line 238 of file VaultInvariant.cpp.
|
nodiscardprivate |
Return the vault-share balance-change delta for an account.
For the vault's pseudo-account the MPTokenIssuance outstanding-amount delta is returned; for all other accounts the MPToken delta is returned.
| id | Account whose share delta is requested. |
std::nullopt if the entry was not touched. Definition at line 259 of file VaultInvariant.cpp.
|
staticnodiscardprivate |
Check whether a vault holds no assets.
| vault | Snapshot of the vault to test. |
true when both assetsAvailable and assetsTotal are zero. Definition at line 272 of file VaultInvariant.cpp.
|
nodiscardprivate |
Invariant check for ttLOAN_SET.
For a closed-ended vault, a loan may only be originated while the vault is in the Investment phase (strictly past SubscriptionDate and before RedemptionDate). Open-ended vaults (NoPhase) are unaffected. The complementary maturity bound (final payment strictly precedes RedemptionDate) is enforced by ValidLoan.
Definition at line 278 of file VaultInvariant.cpp.
|
staticnodiscard |
Definition at line 1191 of file VaultInvariant.cpp.
| void xrpl::ValidVault::visitEntry | ( | bool | isDelete, |
| SLE::const_ref | before, | ||
| SLE::const_ref | after ) |
Definition at line 85 of file VaultInvariant.cpp.
| bool xrpl::ValidVault::finalize | ( | STTx const & | tx, |
| TER const | ret, | ||
| XRPAmount const | fee, | ||
| ReadView const & | view, | ||
| beast::Journal const & | j ) |
Definition at line 335 of file VaultInvariant.cpp.
|
staticconstexprprivate |
Definition at line 55 of file VaultInvariant.h.
|
private |
Definition at line 96 of file VaultInvariant.h.
|
private |
Definition at line 97 of file VaultInvariant.h.
|
private |
Definition at line 98 of file VaultInvariant.h.
|
private |
Definition at line 99 of file VaultInvariant.h.
|
private |
Definition at line 100 of file VaultInvariant.h.