mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-23 15:20:54 +00:00
feat: Add a new closed ended vault to extend SAV (#7921)
Co-authored-by: Vito Tumas <5780819+Tapanito@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <mpt_protocol.h>
|
||||
#include <secp256k1_mpt.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -327,6 +328,36 @@ enum class VaultVersion : uint8_t {
|
||||
CashBasis,
|
||||
};
|
||||
|
||||
/**
|
||||
* Vault kind. Distinguishes closed-ended vaults from the default open-ended
|
||||
* kind. Persisted as sfVaultKind (UINT8); absent means OpenEnded.
|
||||
*/
|
||||
enum class VaultKind : std::uint8_t {
|
||||
OpenEnded = 0,
|
||||
ClosedEnded = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Lifecycle phase of a vault. Open-ended vaults are always NoPhase; the other
|
||||
* three values are the phases of a closed-ended vault.
|
||||
*/
|
||||
enum class VaultPhase : std::uint8_t {
|
||||
NoPhase = 0,
|
||||
Subscription,
|
||||
Investment,
|
||||
Redemption,
|
||||
};
|
||||
|
||||
/**
|
||||
* Bounds on the length of a closed-ended vault's Investment phase
|
||||
* (RedemptionDate - SubscriptionDate). At vault creation the gap must satisfy
|
||||
* kMinInvestmentPeriod <= gap < kMaxInvestmentPeriod.
|
||||
*/
|
||||
constexpr std::uint32_t kMinInvestmentPeriod =
|
||||
std::chrono::seconds{std::chrono::minutes{1}}.count();
|
||||
// This is 946708560 seconds which 30 x 365.2425 days (the average length of a Gregorian year).
|
||||
constexpr std::uint32_t kMaxInvestmentPeriod = std::chrono::seconds{std::chrono::years{30}}.count();
|
||||
|
||||
/**
|
||||
* Maximum recursion depth for vault shares being put as an asset inside
|
||||
* another vault; counted from 0
|
||||
|
||||
@@ -506,6 +506,9 @@ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({
|
||||
{sfWithdrawalPolicy, SoeRequired},
|
||||
{sfScale, SoeDefault},
|
||||
{sfLEVersion, SoeDefault},
|
||||
{sfVaultKind, SoeDefault},
|
||||
{sfSubscriptionDate, SoeOptional},
|
||||
{sfRedemptionDate, SoeOptional},
|
||||
// no SharesTotal ever (use MPTIssuance.sfOutstandingAmount)
|
||||
// no PermissionedDomainID ever (use MPTIssuance.sfDomainID)
|
||||
}))
|
||||
|
||||
@@ -27,6 +27,7 @@ TYPED_SFIELD(sfUNLModifyDisabling, UINT8, 17)
|
||||
TYPED_SFIELD(sfWasLockingChainSend, UINT8, 19)
|
||||
TYPED_SFIELD(sfWithdrawalPolicy, UINT8, 20)
|
||||
TYPED_SFIELD(sfContractResult, UINT8, 21)
|
||||
TYPED_SFIELD(sfVaultKind, UINT8, 22)
|
||||
|
||||
// 16-bit integers (common)
|
||||
TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::kSmdNever)
|
||||
@@ -116,6 +117,8 @@ TYPED_SFIELD(sfSponsoringOwnerCount, UINT32, 71)
|
||||
TYPED_SFIELD(sfSponsoringAccountCount, UINT32, 72)
|
||||
TYPED_SFIELD(sfRemainingOwnerCount, UINT32, 73)
|
||||
TYPED_SFIELD(sfSponsorFlags, UINT32, 74)
|
||||
TYPED_SFIELD(sfSubscriptionDate, UINT32, 75)
|
||||
TYPED_SFIELD(sfRedemptionDate, UINT32, 76)
|
||||
|
||||
// 64-bit integers (common)
|
||||
TYPED_SFIELD(sfIndexNext, UINT64, 1)
|
||||
|
||||
@@ -862,6 +862,9 @@ TRANSACTION(ttVAULT_CREATE, 65, VaultCreate,
|
||||
{sfWithdrawalPolicy, SoeOptional},
|
||||
{sfData, SoeOptional},
|
||||
{sfScale, SoeOptional},
|
||||
{sfVaultKind, SoeOptional},
|
||||
{sfSubscriptionDate, SoeOptional},
|
||||
{sfRedemptionDate, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transaction updates a single asset vault. */
|
||||
|
||||
Reference in New Issue
Block a user