Overview
The UnstakingManager contract handles time-delayed withdrawals from StakingVaults. When a user withdraws from a vault with an unstaking delay, their tokens are held in this contract until the unlock time, after which they can be claimed.Key Features
- Time-Locked Withdrawals: Holds tokens until unlock time
- Cancel Option: Users can cancel and re-stake before unlock
- Simple Lock Management: Each withdrawal creates a numbered lock
- Immutable Configuration: Tied to specific vault and token
Lock Structure
address
Address that owns the lock
uint256
Amount of tokens locked
uint256
Timestamp when lock becomes claimable
uint256
Timestamp when lock was claimed (0 if unclaimed)
Functions
Create Lock
Create a new time-locked withdrawal (called only by vault).address
Address that will own the lock
uint256
Amount of tokens to lock
uint256
Timestamp when tokens become claimable
UnstakingManager.sol
Claim Lock
Claim tokens from an unlocked withdrawal.uint256
ID of the lock to claim
UnstakingManager.sol
Anyone can call this function, but tokens are always sent to the lock’s original owner. The lock must be past its unlock time and not already claimed.
Cancel Lock
Cancel a lock and re-stake the tokens back into the vault.uint256
ID of the lock to cancel
UnstakingManager.sol
This deposits the locked tokens back into the vault on behalf of the user. This is useful if the user changes their mind about unstaking or wants to avoid the waiting period.
View Functions
Get Lock Details
Retrieve information about a specific lock.UnstakingManager.sol
Target Token
Get the token being managed.UnstakingManager.sol
Vault
Get the associated StakingVault.UnstakingManager.sol
Events
event
Emitted when a new lock is createdParameters:
lockId- Unique identifier for the lockuser- Address that owns the lockamount- Amount of tokens lockedunlockTime- Timestamp when claimable
event
Emitted when a lock is cancelled and tokens are re-stakedParameters:
lockId- ID of the cancelled lock
event
Emitted when a lock is claimedParameters:
lockId- ID of the claimed lock
Errors
error
Thrown when caller is not authorized for the operation
error
Thrown when trying to claim before unlock time
error
Thrown when trying to claim or cancel an already-claimed lock
Usage Flow
Standard Unstaking
Cancel and Re-stake
Security Considerations
Locks cannot be transferred or traded. They are permanently tied to the original user address.
Lock ID Sequence
uint256
Counter that increments for each new lock, starting at 0