Skip to content

Vault & DailyUnstakeQueue

Vault

contracts/src/core/Vault.sol

Holds all staked DIEM and interacts with Venice's staking contract. Only Pool can call deposit and unstake functions (onlyPool modifier).

Key functions

notifyDeposit(uint256 amount) — called by Pool after DIEM arrives in the vault. Triggers Venice staking. DIEM must already be in the vault before this is called (Pool transfers directly, avoiding a double-hop).

requestUnstake(uint256 amount, address beneficiary) — delegates to DailyUnstakeQueue. Venice imposes a ~24h cooldown; the queue tracks which day the request was made.

claimExit(uint64 requestDay, address beneficiary) — delegates to DailyUnstakeQueue. Transfers DIEM to beneficiary once the cooldown has elapsed.

Access control

Pool ──onlyPool──► Vault

                   DailyUnstakeQueue ──onlyVault──► (claim)

Only Pool may call notifyDeposit, requestUnstake, and claimExit. Only the DailyUnstakeQueue may call claim on the vault itself.


DailyUnstakeQueue

contracts/src/core/DailyUnstakeQueue.sol

Manages the Venice unstake cooldown. Requests are indexed by UTC day number (block.timestamp / 86400). A request from day D becomes claimable on day D+1 (or later, depending on Venice's actual cooldown).

State

solidity
mapping(uint64 requestDay => mapping(address => uint256)) public requests;

Flow

User calls Pool.requestExit(amount)
  → Pool calls vault.requestUnstake(amount, user)
    → Queue records: requests[today][user] += amount
    → Venice unstake initiated

Next day (or later):
User calls Pool.claimExit(requestDay)
  → Pool calls vault.claimExit(requestDay, user)
    → Queue calls Venice withdraw
    → DIEM transferred to user

Why queue by day?

Venice batches unstakes per day. Keying by UTC day lets the vault call Venice's unstake once per day for the entire batch, rather than one call per user.

Released under the MIT License.