mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 14:50:54 +00:00
Add addVaultAssets, removeVaultAssets (two overloads: plain accountSend and doWithdraw-based), clawbackVaultAssets, and moveVaultAssets as the single points through which a Vault's sfAssetsTotal/sfAssetsAvailable are mutated and funds move to/from its pseudo-account: - addVaultAssets increases both fields and transfers in from a sender. - removeVaultAssets/clawbackVaultAssets decrease both fields equally and transfer out; a FinalRemoval flag hard-resets both fields to exactly zero on a Vault's last withdrawal, since the discounted exchange-rate formula can produce values with more precision than the asset can canonically represent, and subtracting such a value would leave a non-canonical residual instead of an exact zero. - moveVaultAssets decreases only sfAssetsAvailable, for disbursements (e.g. a loan's principal and origination fee) where sfAssetsTotal independently grows via accrued interest. Also consolidate getAssetsTotalScale into VaultHelpers::getVaultScale, and move isRounded from LendingHelpers into STAmount.h alongside the other rounding utilities.