ERC-6229 · Draft · ERC · 2022-12-21
ERC-6229: Tokenized Vaults with Lock-in Period
A draft ERC-4626 extension for vaults that lock funds in rounds: while locked, users schedule deposits and redemptions, which are settled at the new share price once the vault unlocks.
What problem does it solve?
ERC-4626 vaults assume you can deposit and withdraw at any time. Some strategies can't work that way: options vaults, fixed-term lending, or anything that commits capital for a period. During that period the vault's share price is unknown until the strategy finishes, so letting people enter or leave would be unfair to everyone else.
ERC-6229 adds a lock-in period to ERC-4626. While locked, normal deposits and withdrawals are blocked, but users can queue up their intent. When the vault unlocks, those queued requests are settled at the share price that is now known.
How it works
Vault state:
isLocked():trueduring a lock-in period.vaultRound(): starts at 0 and increments by 1 every time the vault becomes locked.
While locked:
scheduleDeposit(assets)pulls the underlying tokens into the vault but mints no shares yet.scheduleRedeem(shares)pulls the user's shares into the vault but returns no assets yet.- Both revert if the vault is unlocked. The standard ERC-4626
deposit,mint,withdrawandredeemshould revert while locked.
After unlocking:
settleDeposits(depositor)mints shares for all of that depositor's scheduled deposits at the current share price.settleRedemptions(redeemer)burns the scheduled shares and sends out the assets at the current share price.
Views getScheduledDeposits(depositor) and getScheduledRedemptions(redeemer) show pending amounts. Events ScheduleDeposit, ScheduleRedeem, SettleDeposits and SettleRedemptions include the round number.
There is no "schedule withdraw by asset amount", because how many assets your shares are worth can't be known until the round ends.
Sample code
User flow across one round (ethers v6):
import { Contract, parseUnits } from "ethers";
const vault = new Contract(VAULT, [
"function isLocked() view returns (bool)",
"function vaultRound() view returns (uint256)",
"function scheduleDeposit(uint256 assets)",
"function settleDeposits(address depositor) returns (uint256 newShares)",
"function getScheduledDeposits(address depositor) view returns (uint256)",
"function deposit(uint256 assets, address receiver) returns (uint256)",
], signer);
const amount = parseUnits("1000", 6);
await (await usdc.approve(VAULT, amount)).wait();
if (await vault.isLocked()) {
await (await vault.scheduleDeposit(amount)).wait(); // queued, no shares yet
// ...wait until the operator ends the round and isLocked() becomes false...
await (await vault.settleDeposits(await signer.getAddress())).wait();
} else {
await (await vault.deposit(amount, await signer.getAddress())).wait(); // normal ERC-4626 path
}
Things to know
- Status: Draft.
- The standard does not define who starts or ends a round, how long it lasts, or what the vault does with funds while locked. All of that is up to the implementation.
- Requests left unsettled across several rounds can be settled at the wrong share price. The spec lists possible fixes (block locking while requests are pending, force-settle on lock, or store the end price of each round) but does not require one.
- ERC-7540 (Final) solves a similar problem more generally with asynchronous request/claim flows for ERC-4626 vaults.