PendingWithdrawal.sol
Protocol documentation for the PendingWithdrawal.sol smart contract.
Contract Overview
Inherits:
ReentrancyGuard & Ownable from OpenZeppelin
Also imports
IERC20interface from OpenZeppelin which is used in the contract
Author: OffBlocks Team
Description: This contract manages pending withdrawals, allowing a delay period before tokens can be claimed, adding an additional layer of security to the withdrawal process.
State Variables
timestamps (
mapping(address => uint256)): Maps token addresses to their withdrawal timestamp. It stores the time when a withdrawal can be claimed for each token.
Errors
ZeroAddress: Triggered when an operation involves the zero address, which is usually invalid.
ZeroTokens: Occurs when an operation involves zero tokens, indicating either an invalid operation or that there are no tokens to operate with.
WithdrawalDelayNotPassed: Emitted when an attempt to claim a withdrawal is made before the specified delay has passed.
CancelTokenWithdrawalFailed: Indicates a failure in the token withdrawal cancellation process.
ClaimTokenWithdrawalFailed: Indicates a failure in the token withdrawal claiming process.
Events
InitiateWithdrawal: Emitted when a token withdrawal is initiated.
Parameters:
address indexed token,uint256 delay
ClaimWithdrawal: Emitted when a token withdrawal is successfully claimed.
Parameters:
address indexed to,address indexed token,uint256 amount
CancelWithdrawal: Emitted when a token withdrawal is canceled.
Parameters:
address indexed to,address indexed token,uint256 amount
Constructor
constructor(address _owner) Ownable(_owner);Description: Initializes the
PendingWithdrawalcontract with the smart wallet owner's address.Inputs:
_owner: The address of the contract owner, typically a user's smart wallet.
Functions
initiateTokenWithdrawal
function initiateTokenWithdrawal(address _token, uint256 _delay) external nonReentrant onlyOwner;Description: Initiates a withdrawal for a specified token with a delay.
Inputs:
_token: The address of the token._delay: The delay before the withdrawal can be claimed.
Modifiers:
nonReentrant,onlyOwner
cancelTokenWithdrawal
function cancelTokenWithdrawal(address _token) external nonReentrant onlyOwner;Description: Cancels a pending withdrawal for a specified token.
Inputs:
_token: The address of the token.
Modifiers:
nonReentrant,onlyOwner
claimTokenWithdrawal
function claimTokenWithdrawal(address _token, address _dest) external nonReentrant onlyOwner;Description: Claims a pending withdrawal for a specified token after the delay has passed.
Inputs:
_token: The address of the token._dest: The destination address for the tokens.
Modifiers:
nonReentrant,onlyOwner
Last updated