ERC-6229 A tokenized vault with a lockup period (Tokenized Vaults with Lock-in Period)
Draft · Vaults & DeFi · created 2022-12-21
An extended standard that adds a lockup period to the ERC-4626 tokenized vault. While the vault is locked, deposits and withdrawals are blocked, but deposits and redemptions can be scheduled in advance and settled once the lock is lifted.
Why it is needed
The standard ERC-4626 vault is built on the premise that users (contracts or regular accounts) can deposit and withdraw the underlying asset at any time. But sometimes a vault needs to lock up assets for a period of time to execute a specific operating strategy. During this lockup period, neither withdrawals nor deposits should be allowed. The existing ERC-4626 has no way to express this locked state, nor any way to process deposit and withdrawal requests that come in while locked. As a result, each vault implements locking differently, and anyone handling such vaults cannot check status or queue requests in a common way. This standard extends ERC-4626 to define a common interface for querying lock status and round, and for scheduling deposits and redemptions during a lock to be settled once the lock is lifted.
In depth
ERC-4626 extension and minimal interface design
A vault following this standard must implement EIP-4626 for the base vault functionality and EIP-20 for representing shares. Terms are defined as follows: asset (the underlying EIP-20 token the vault accepts and manages), share (the EIP-20 token issued by the vault), locked and unlocked (the vault states that determine whether deposits and withdrawals are allowed), and round (the period during which the vault is locked). The standard deliberately defines only a minimal interface and does not specify when a lockup period starts or ends, or how the underlying asset is managed while locked.
Status queries: isLocked and vaultRound
isLocked is a view function that returns the vault's current status: true means locked, false means unlocked. vaultRound returns the current round, which must start at 0. It must increase by exactly 1 every time isLocked becomes true and a new round starts, and must not change in any other case. These two values let external parties check whether a vault is locked and which round it is in.
Scheduling functions: scheduleDeposit and scheduleRedeem
scheduleDeposit(assets) is a function for registering intent to deposit during a lock, and can only be called when isLocked is true. It must transfer the caller's assets to the vault but must not issue new shares, and must revert if the assets cannot be deposited or if isLocked is false. scheduleRedeem(shares) is a function for registering intent to redeem during a lock. It must transfer the caller's shares to the vault but must not send assets to the caller, and must revert if the shares cannot be redeemed or if isLocked is false. Each must emit a ScheduleDeposit or ScheduleRedeem event respectively.
Settlement functions and query functions
settleDeposits(depositor) processes all of depositor's scheduled deposits and issues newShares according to the current share price. settleRedemptions(redeemer) processes redeemer's scheduled redemptions, burning burnShares and returning redeemAssets to redeemer according to the current share price. Both functions can only be called when isLocked is false, and must revert if there are no scheduled deposits or redemptions for that address. For queries, getScheduledDeposits(depositor) returns the total scheduled deposit assets and getScheduledRedemptions(redeemer) returns the total scheduled redemption shares; neither should revert.
Why there is no withdrawal scheduling function
This standard has no function for scheduling a withdrawal by specifying an asset amount. Because the share price is not fixed during the lockup period, it is impossible to calculate in advance how much of the underlying asset can be returned. So redemptions can only be scheduled via scheduleRedeem based on a share amount rather than an asset amount, and are settled at the share price once the lock is lifted.
Compatibility with ERC-4626's base functions
While isLocked is true, EIP-4626's deposit, mint, withdraw, and redeem functions must revert. This prevents issuing or burning shares while the share price is not yet fixed. All deposits and withdrawals during a lock go only through the schedule-and-settle path.
A proposal still at the Draft stage
This ERC is a proposal created on December 21, 2022, and is in Draft status. It is not yet a finalized standard, so its content may change or progress on it may stall.
Things to watch out for
- The share price problem for unsettled scheduled entries: If a user reserves a deposit or redemption and it is not settled while isLocked is false, then gets settled after several rounds have passed, the vault will process it at the wrong share price. The standard does not specify a solution and leaves it to the implementer to decide what fits their use case. Suggested approaches include not starting the lock if there are unsettled reservations, forcibly settling reservations when the lock starts, or recording the end-of-round share price for each round and settling at that price.