// SPDX-License-Identifier: GPL-3.0-only pragma solidity 0.8.12; /** * manage deposits and stakes. * deposit is just a balance used to pay for UserOperations (either by a paymaster or a wallet) * stake is value locked for at least "unstakeDelay" by a paymaster. */ interface IStakeManager { event Deposited( address indexed account, uint256 totalDeposit ); event Withdrawn( address indexed account, address withdrawAddress, uint256 amount ); /// Emitted once a stake is scheduled for withdrawal event StakeLocked( address indexed account, uint256 totalStaked, uint256 withdrawTime ); /// Emitted once a stake is scheduled for withdrawal event StakeUnlocked( address indexed account, uint256 withdrawTime ); event StakeWithdrawn( address indexed account, address withdrawAddress, uint256 amount ); /** * minimum time (in seconds) required to lock a paymaster stake before it can be withdraw. */ function unstakeDelaySec() external returns (uint32); /** * minimum value required to stake for a paymaster */ function paymasterStake() external returns (uint256); /** * @param deposit the account's deposit * @param staked true if this account is staked as a paymaster * @param stake actual amount of ether staked for this paymaster. must be above paymasterStake * @param unstakeDelaySec minimum delay to withdraw the stake. must be above the global unstakeDelaySec * @param withdrawTime - first block timestamp where 'withdrawStake' will be callable, or zero if already locked * @dev sizes were chosen so that (deposit,staked) fit into one cell (used during handleOps) * and the rest fit into a 2nd cell. * 112 bit allows for 2^15 eth * 64 bit for full timestamp * 32 bit allow 150 years for unstake delay */ struct DepositInfo { uint112 deposit; bool staked; uint112 stake; uint32 unstakeDelaySec; uint64 withdrawTime; } function getDepositInfo(address account) external view returns (DepositInfo memory info); /// return the deposit (for gas payment) of the account function balanceOf(address account) external view returns (uint256); /** * add to the deposit of the given account */ function depositTo(address account) external payable; /** * add to the account's stake - amount and delay * any pending unstake is first cancelled. * @param _unstakeDelaySec the new lock duration before the deposit can be withdrawn. */ function addStake(uint32 _unstakeDelaySec) external payable; /** * attempt to unlock the stake. * the value can be withdrawn (using withdrawStake) after the unstake delay. */ function unlockStake() external; /** * withdraw from the (unlocked) stake. * must first call unlockStake and wait for the unstakeDelay to pass * @param withdrawAddress the address to send withdrawn value. */ function withdrawStake(address payable withdrawAddress) external; /** * withdraw from the deposit. * @param withdrawAddress the address to send withdrawn value. * @param withdrawAmount the amount to withdraw. */ function withdrawTo(address payable withdrawAddress, uint256 withdrawAmount) external; }