mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-26 23:19:07 +00:00
docs: Clarify LEVersion and deprecate kVaultMaximumIouScale.
Split the pre-V1.2 Scale cap to kVaultMaximumLegacyIouScale so the old name can warn without breaking V1.2 call sites.
This commit is contained in:
@@ -235,11 +235,13 @@ sharesToAssetsWithdraw(
|
||||
isSoleShareholder(ReadView const& view, AccountID const& account, SLE::const_ref issuance);
|
||||
|
||||
/**
|
||||
* Resolves a Vault's LEVersion, the single point every accounting touch
|
||||
* point should call to determine which recognition model (instant interest
|
||||
* recognition vs. cash-basis) a Vault uses. Vaults created before featureLendingProtocolV1_1
|
||||
* activated never have sfLEVersion set, which resolves here to
|
||||
* VaultVersion::Legacy.
|
||||
* Resolves a Vault's LEVersion.
|
||||
*
|
||||
* LEVersion is the single point every accounting and rounding helper
|
||||
* should call to decide which protocol a Vault follows. It is written
|
||||
* at VaultCreate and is not updated afterwards, so a Vault created
|
||||
* under an older amendment keeps that behaviour after later amendments
|
||||
* activate. Absent sfLEVersion resolves to VaultVersion::Legacy.
|
||||
*
|
||||
* @param vault The vault SLE.
|
||||
*
|
||||
|
||||
@@ -311,23 +311,40 @@ constexpr std::uint8_t kVaultStrategyFirstComeFirstServe = 1;
|
||||
* Default IOU scale factor for a Vault
|
||||
*/
|
||||
constexpr std::uint8_t kVaultDefaultIouScale = 6;
|
||||
/**
|
||||
* Maximum scale factor for a Vault. The number is chosen to ensure that
|
||||
* 1 IOU can be always converted to shares.
|
||||
* 10^19 > maxMPTokenAmount (2^64-1) > 10^18
|
||||
*/
|
||||
constexpr std::uint8_t kVaultMaximumIouScale = 18;
|
||||
|
||||
/**
|
||||
* Maximum fixed-precision IOU scale factor for a Vault.
|
||||
* Maximum Scale for a Vault created before featureLendingProtocolV1_2.
|
||||
* Chosen so 1 IOU can always convert to shares:
|
||||
* 10^19 > maxMPTokenAmount (2^64-1) > 10^18.
|
||||
*/
|
||||
constexpr std::uint8_t kVaultMaximumLegacyIouScale = 18;
|
||||
|
||||
/**
|
||||
* Maximum Scale for a Vault created under featureLendingProtocolV1_2.
|
||||
*/
|
||||
constexpr std::uint8_t kVaultMaximumFixedIouScale = 10;
|
||||
|
||||
/**
|
||||
* Vault ledger-entry schema versions. Assigned to newly created Vaults by
|
||||
* featureLendingProtocolV1_1 and later protocol amendments. Vaults created
|
||||
* before activation are left without LEVersion (implicit legacy version 0,
|
||||
* instant interest recognition).
|
||||
* @deprecated Use kVaultMaximumFixedIouScale for V1.2 vaults, or
|
||||
* kVaultMaximumLegacyIouScale for pre-V1.2 vaults.
|
||||
*/
|
||||
[[deprecated("Use kVaultMaximumFixedIouScale or kVaultMaximumLegacyIouScale")]]
|
||||
constexpr std::uint8_t kVaultMaximumIouScale = kVaultMaximumLegacyIouScale;
|
||||
|
||||
/**
|
||||
* Vault ledger-entry schema versions, persisted as sfLEVersion.
|
||||
*
|
||||
* LEVersion records which protocol a Vault was created under so later
|
||||
* amendments can change the rules for new Vaults without rewriting
|
||||
* existing ones. VaultCreate writes it from the then-active lending
|
||||
* amendments; later transactions do not update it. A Vault created
|
||||
* under an older amendment keeps that amendment's behaviour for its
|
||||
* lifetime, even after a newer lending amendment activates.
|
||||
*
|
||||
* Absent sfLEVersion is implicit Legacy (version 0): instant interest
|
||||
* recognition and a dynamic AssetsTotal scale. CashBasis (V1.1) uses
|
||||
* cash-basis recognition on the same dynamic scale. FixedPrecision
|
||||
* (V1.2) keeps cash-basis recognition and adds the lifetime base grid.
|
||||
*/
|
||||
enum class VaultVersion : uint8_t {
|
||||
Legacy = 0,
|
||||
|
||||
@@ -103,7 +103,7 @@ VaultCreate::preflight(PreflightContext const& ctx)
|
||||
|
||||
auto const maximumScale = ctx.rules.enabled(featureLendingProtocolV1_2)
|
||||
? kVaultMaximumFixedIouScale
|
||||
: kVaultMaximumIouScale;
|
||||
: kVaultMaximumLegacyIouScale;
|
||||
if (scale > maximumScale)
|
||||
return temMALFORMED;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class VaultFixedPrecision_test : public VaultTestBase
|
||||
|
||||
Vault const vault{env};
|
||||
auto [tx, keylet] = vault.create({.owner = owner, .asset = asset});
|
||||
tx[sfScale] = kVaultMaximumIouScale;
|
||||
tx[sfScale] = kVaultMaximumLegacyIouScale;
|
||||
env(tx);
|
||||
env.close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user