Address Contract Verified
Address
0x0774dF07205a5E9261771b19afa62B6e757f7eF8
Balance
0 ETH
Nonce
1
Code Size
4227 bytes
Creator
0x1f4b5885...B899 at tx 0xc2be3627...3b87db
Indexed Transactions
0
Contract Bytecode
4227 bytes
0x608060408181526004918236101561001657600080fd5b600092833560e01c918263029c6c9f14610c13575081631b18d1e214610bdf578163214cb47f14610be45781632bbca15714610bdf5781632c30e13b14610b1d5781632deb902d14610afe5781633efcfda414610a4c5781633f90916a14610a2e5781634f0cb5f3146108285781634f8632ba146107ff57816351179303146107e057816354438127146104a55781638bad0c0a14610444578163937b2581146103d1578163d69c3d30146103b4578163e322ad2b14610390578163e53b201714610116575063f851a440146100eb57600080fd5b3461011257816003193601126101125760055490516001600160a01b039091168152602090f35b5080fd5b838334610112576020928360031936011261038c576001600160a01b03908161013d610c5c565b169073320623b8e4ff03373931769a31fc52a4e78b5d7082146103495784958360059695965416801560001461034357508360065416925b806101ad5750505082809281924791839183156101a3575b1690f115610199575080f35b51903d90823e3d90fd5b6108fc925061018d565b909486949296516370a0823160e01b815230888201528681602481865afa90811561033957829161030a575b5061026e9482918751958987019263a9059cbb60e01b845216602487015260448601526044855261020985610ca2565b86519461021586610cd4565b8886527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656489870152519082855af13d15610302573d9161025483610e84565b9261026187519485610cf0565b83523d898885013e610f85565b80518381159182156102de575b505090501561028a5750505080f35b5162461bcd60e51b815291820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260849150fd5b83809293500103126102fe5782015180151581036102fe5780838761027b565b8480fd5b606091610f85565b90508681813d8311610332575b6103218183610cf0565b81010312610112575161026e6101d9565b503d610317565b86513d84823e3d90fd5b92610175565b835162461bcd60e51b8152908101869052601d60248201527f63616e6e6f7420726573637565207468726f74746c656420746f6b656e0000006044820152606490fd5b8280fd5b5050346101125781600319360112610112576020906103ad610d12565b9051908152f35b505034610112578160031936011261011257602091549051908152f35b838334610112576020366003190112610112578235825260016020528082209182549260018060a01b036001820154169260ff60036002840154930154169381519586526020860152840152600382101561043157608083836060820152f35b634e487b7160e01b815260218452602490fd5b83346104a257806003193601126104a257600554816001600160a01b03821661046e338214611014565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f8280a36001600160a01b03191660055580f35b80fd5b9190503461038c578060031936011261038c5760249182356001600160a01b03818116928035928490036107dc57816006541633036107ae57821561076c5783156107335784516370a0823160e01b81523082820152602097908881898173320623b8e4ff03373931769a31fc52a4e78b5d705afa9081156107295782916106fc575b50610534858454610c95565b116106c557610541610d12565b80851161068b57846105569142600255610c72565b600355805496600019881461067a576001880182556224ea00420193844211610668578751906080820182811067ffffffffffffffff82111761065657918b6003928c9695948c52898352818301908b825260018d8501938b85526060860199898b528952528c872093518455600184019151166bffffffffffffffffffffffff60a01b8254161790555160028201550192519160038310156106465750509286928895927ff8de2b676e79a070c3f41e66a40f8d3b182f87df2cebce96c32222cbd8b57ea09560ff80198354169116179055610634838254610c95565b9055825191825288820152a351908152f35b634e487b7160e01b815260218552fd5b634e487b7160e01b8552604186528385fd5b50634e487b7160e01b82526011909252fd5b634e487b7160e01b82526011909252fd5b865162461bcd60e51b81528084018a90526015818a0152740c2dadeeadce840daeae6e840c4ca40787a40dac2f605b1b6044820152606490fd5b855162461bcd60e51b815280830189905260128189015271696e73756666696369656e742066756e647360701b6044820152606490fd5b90508881813d8311610722575b6107138183610cf0565b81010312610112575138610528565b503d610709565b87513d84823e3d90fd5b606490601487602088519362461bcd60e51b85528401528201527307461726765742063616e6e6f74206265203078360641b6044820152fd5b606490601d87602088519362461bcd60e51b85528401528201527f616d6f756e74206d7573742062652067726561746572207468616e20300000006044820152fd5b606490600987602088519362461bcd60e51b85528401528201526875736572206f6e6c7960b81b6044820152fd5b8680fd5b5050346101125781600319360112610112576020906002549051908152f35b50503461011257816003193601126101125760065490516001600160a01b039091168152602090f35b90503461038c57602080600319360112610a2a5781359261084b85548510610dfc565b8385526001825280852080548015610a1757600282015442106109d457600382019060ff82541660038110156109c15761095593929161088e6108959215610e38565b8754610c72565b8655600160ff19825416179055868060018060a01b036001840154169254928551938785019163a9059cbb60e01b835260248601526044850152604484526108dc84610ca2565b8551936108e885610cd4565b8785527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648886015251908273320623b8e4ff03373931769a31fc52a4e78b5d705af13d156109b9573d9061093b82610e84565b9161094886519384610cf0565b82523d898784013e610ea0565b8051838115918215610995575b505090501561028a575050507ff15b7b21c555c550d30c8224af754576b5565cebf57d2b09632cc8369bf8fc848280a280f35b83809293500103126109b55782015180151581036109b557808338610962565b8580fd5b606090610ea0565b634e487b7160e01b895260218752602489fd5b50505162461bcd60e51b815291820152601a60248201527f7769746864726177616c206973207374696c6c206c6f636b6564000000000000604482015260649150fd5b634e487b7160e01b875260018552602487fd5b8380fd5b90503461038c578260031936011261038c5760209250549051908152f35b90503461038c57602036600319011261038c57803591610a7760018060a01b03600554163314611014565b610a8384548410610dfc565b8284526001602052832090600382019160ff8354166003811015610aeb5790610aaf610ab79215610e38565b548254610c72565b9055805460ff191660021790557fe8de1e631ea541ac8e6cb398aafb71b991eb58d489298f7bc93ba7e17fa2042b8280a280f35b634e487b7160e01b865260218352602486fd5b5050346101125781600319360112610112576020906003549051908152f35b90503461038c57602036600319011261038c57610b38610c5c565b6005546001600160a01b039290610b529084163314611014565b60065492808416921693828514610b9c57505082907f35f07f4874eaaa6c61162149ee118b67b4007c893b4ccccf695cef56cfd63b248580a36001600160a01b0319161760065580f35b906020606492519162461bcd60e51b8352820152601c60248201527f6e657720757365722063616e206e6f74206265207468652073616d65000000006044820152fd5b610c39565b5050346101125781600319360112610112576020905173320623b8e4ff03373931769a31fc52a4e78b5d708152f35b849034610112578160031936011261011257806b033b2e3c9fd0803ce800000060209252f35b34610c57576000366003190112610c575760206040516224ea008152f35b600080fd5b600435906001600160a01b0382168203610c5757565b91908203918211610c7f57565b634e487b7160e01b600052601160045260246000fd5b91908201809211610c7f57565b6080810190811067ffffffffffffffff821117610cbe57604052565b634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff821117610cbe57604052565b90601f8019910116810190811067ffffffffffffffff821117610cbe57604052565b610d1e60025442610c72565b6b033b2e3c9fd0803ce80000009081810290808204831490151715610c7f57610d4f906224ea006003549104610c95565b90808211610df4575b506040516370a0823160e01b815230600482015260208160248173320623b8e4ff03373931769a31fc52a4e78b5d705afa8015610de857600090610db5575b610da5915060045490610c72565b808211610db0575090565b905090565b6020823d8211610de0575b81610dcd60209383610cf0565b810103126104a25750610da59051610d97565b3d9150610dc0565b6040513d6000823e3d90fd5b905038610d58565b15610e0357565b60405162461bcd60e51b815260206004820152600d60248201526c696e76616c6964206e6f6e636560981b6044820152606490fd5b15610e3f57565b60405162461bcd60e51b815260206004820152601960248201527f7769746864726177616c206973206e6f742070656e64696e67000000000000006044820152606490fd5b67ffffffffffffffff8111610cbe57601f01601f191660200190565b90919015610f165750805115610eb35790565b73320623b8e4ff03373931769a31fc52a4e78b5d703b15610ed15790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b815115610f265750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510610f6c575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350610f49565b91929015610fa25750815115610f99575090565b3b15610ed15790565b825190915015610fb55750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510610ffb575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350610fd8565b1561101b57565b60405162461bcd60e51b815260206004820152600a60248201526961646d696e206f6e6c7960b01b6044820152606490fdfea2646970667358221220da1d46fe164f83e0500b690e4d657e6ad32a036d697cb2d2674b5565b2347df064736f6c63430008130033
Verified Source Code Full Match
Compiler: v0.8.19+commit.7dd6d404
EVM: paris
Optimization: Yes (200 runs)
SlowerWallet.sol 281 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;
import { IERC20 } from "@openzeppelin/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/token/ERC20/utils/SafeERC20.sol";
contract SlowerWallet {
using SafeERC20 for IERC20;
/**
* @notice Data Structures
*/
/**
* @notice Withdrawal Statuses
*/
enum WithdrawalStatus {
Pending,
Completed,
Cancelled
}
/**
* @notice Withdrawal Request struct
* @param amount The amount of tokens to be withdrawn
* @param target The address of the recipient
* @param unlockTime The time at which the withdrawal can be completed
* @param status The status of the withdrawal
*/
struct WithdrawalRequest {
uint256 amount;
address target;
uint256 unlockTime;
WithdrawalStatus status;
}
/**
* @notice Events
*/
/**
* @notice Emitted when a withdrawal is initiated.
* @param nonce The nonce of the withdrawal
* @param to The address of the recipient
* @param amount The amount of tokens to be withdrawn
* @param unlockTime The time at which the withdrawal can be completed
*/
event WithdrawalInitiated(uint256 indexed nonce, address indexed to, uint256 amount, uint256 unlockTime);
/**
* @notice Emitted when a withdrawal is completed.
* @param nonce The nonce of the withdrawal
*/
event WithdrawalCompleted(uint256 indexed nonce);
/**
* @notice Emitted when a withdrawal is cancelled.
* @param nonce The nonce of the withdrawal
*/
event WithdrawalCancelled(uint256 indexed nonce);
/**
* @notice Emitted when the user role is changed.
* @param previousUser The address of the previous user
* @param newUser The address of the new user
*/
event UserChanged(address indexed previousUser, address indexed newUser);
/**
* @notice Emitted when the admin role is changed.
* @param previousAdmin The address of the previous admin
* @param newAdmin The address of the new admin
*/
event AdminChanged(address indexed previousAdmin, address indexed newAdmin);
/**
* @notice Parameters
* @dev Intentionally hardcoded
*/
IERC20 public constant throttledToken = IERC20(0x320623b8E4fF03373931769A31Fc52A4E78B5d70); // RSR
uint256 public constant throttlePeriod = 4 weeks;
uint256 public constant amountPerPeriod = 1_000_000_000 * (10 ** 18); // (at most) 1B every 4 weeks, throttled
uint256 public constant timelockDuration = 4 weeks;
/**
* @notice State
*/
/**
* @notice Withdrawal nonce
*/
uint256 public nextNonce;
/**
* @notice Nonce to withdrawal request mapping
*/
mapping(uint256 nonce => WithdrawalRequest request) public withdrawalRequests;
/**
* @notice Last withdrawal timestamp {s}
*/
uint256 public lastWithdrawalAt;
/**
* @notice Last remaining limit {qRSR}
*/
uint256 public lastRemainingLimit;
/**
* @notice Total pending withdrawals {qRSR}
*/
uint256 public totalPending;
/**
* @notice Admin address
*/
address public admin;
/**
* @notice User address
*/
address public user;
modifier onlyAdmin() {
require(msg.sender == admin, "admin only");
_;
}
modifier onlyUser() {
require(msg.sender == user, "user only");
_;
}
constructor(address _admin, address _user) {
require(_admin != address(0), "admin must be set");
require(_user != address(0), "user must be set");
admin = _admin;
user = _user;
emit AdminChanged(address(0), _admin);
emit UserChanged(address(0), _user);
}
/**
* @notice Helper function to calculate the maximum amount available to withdraw (subject to timelock)
* @return accumulatedWithdrawalAmount The maximum amount available to withdraw
*/
function availableToWithdraw() public view returns (uint256) {
uint256 timeSinceLastWithdrawal = block.timestamp - lastWithdrawalAt;
uint256 accumulatedWithdrawalAmount = ((timeSinceLastWithdrawal * amountPerPeriod) / throttlePeriod) +
lastRemainingLimit;
if (accumulatedWithdrawalAmount > amountPerPeriod) {
accumulatedWithdrawalAmount = amountPerPeriod;
}
uint256 availableBalance = throttledToken.balanceOf(address(this)) - totalPending;
if (accumulatedWithdrawalAmount > availableBalance) {
accumulatedWithdrawalAmount = availableBalance;
}
return accumulatedWithdrawalAmount;
}
/**
* @notice Initiate Withdrawal with a specific amount and target.
* The amount is immediately blocked but can only be withdrawn
* after the timelock period has passed.
* @param amount The amount of tokens to be withdrawn
* @param target The address of the recipient
* @return nonce The nonce of the withdrawal
*/
function initiateWithdrawal(uint256 amount, address target) external onlyUser returns (uint256) {
require(amount != 0, "amount must be greater than 0");
require(target != address(0), "target cannot be 0x0");
require(throttledToken.balanceOf(address(this)) >= totalPending + amount, "insufficient funds");
uint256 accumulatedWithdrawalAmount = availableToWithdraw();
require(amount <= accumulatedWithdrawalAmount, "amount must be <= max");
lastWithdrawalAt = block.timestamp;
lastRemainingLimit = accumulatedWithdrawalAmount - amount;
uint256 _nonce = nextNonce++;
withdrawalRequests[_nonce] = WithdrawalRequest({
amount: amount,
target: target,
unlockTime: block.timestamp + timelockDuration,
status: WithdrawalStatus.Pending
});
totalPending += amount;
emit WithdrawalInitiated(_nonce, target, amount, block.timestamp + timelockDuration);
return _nonce;
}
/**
* @notice Allows completing a withdrawal after the timelock period has passed.
* Completing a withdrawal is permissionless.
* @dev Does not impact the throttle.
* @param _nonce The nonce of the withdrawal
*/
function completeWithdrawal(uint256 _nonce) external {
require(_nonce < nextNonce, "invalid nonce");
WithdrawalRequest storage withdrawal = withdrawalRequests[_nonce];
assert(withdrawal.amount != 0);
require(withdrawal.unlockTime <= block.timestamp, "withdrawal is still locked");
require(withdrawal.status == WithdrawalStatus.Pending, "withdrawal is not pending");
totalPending -= withdrawal.amount;
withdrawal.status = WithdrawalStatus.Completed;
throttledToken.safeTransfer(withdrawal.target, withdrawal.amount);
emit WithdrawalCompleted(_nonce);
}
/**
* @notice Allows cancelling a withdrawal if it has not been completed already.
* Only the admin can cancel a withdrawal.
* @dev The throttle is NOT recharged on cancellation.
* @param _nonce The nonce of the withdrawal
*/
function cancelWithdrawal(uint256 _nonce) external onlyAdmin {
require(_nonce < nextNonce, "invalid nonce");
WithdrawalRequest storage withdrawal = withdrawalRequests[_nonce];
require(withdrawal.status == WithdrawalStatus.Pending, "withdrawal is not pending");
totalPending -= withdrawal.amount;
withdrawal.status = WithdrawalStatus.Cancelled;
emit WithdrawalCancelled(_nonce);
}
/**
* @notice Access Control: onlyAdmin
* @dev Admin can change user role.
* @param _newUser New user address
*/
function changeUser(address _newUser) external onlyAdmin {
require(_newUser != user, "new user can not be the same");
emit UserChanged(user, _newUser);
user = _newUser;
}
/**
* @notice Access Control: onlyAdmin
* @dev Admin role can NOT be changed (only renounced).
*/
function renounceAdmin() external onlyAdmin {
emit AdminChanged(admin, address(0));
admin = address(0);
}
/**
* @notice Rescue funds from contract
* @dev Disallows rescuing throttled token, pass 0x0 as _token to rescue ETH.
* Intentionally uses `transfer` instead of `call` for ETH
* @param _token The address of the token to be rescued
*/
function rescueFunds(address _token) external {
require(_token != address(throttledToken), "cannot rescue throttled token");
address recipient = admin == address(0) ? user : admin;
if (_token == address(0)) {
payable(recipient).transfer(address(this).balance);
} else {
IERC20(_token).safeTransfer(recipient, IERC20(_token).balanceOf(address(this)));
}
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Read Contract
admin 0xf851a440 → address
amountPerPeriod 0x029c6c9f → uint256
availableToWithdraw 0xe322ad2b → uint256
lastRemainingLimit 0x2deb902d → uint256
lastWithdrawalAt 0x51179303 → uint256
nextNonce 0xd69c3d30 → uint256
throttlePeriod 0x1b18d1e2 → uint256
throttledToken 0x214cb47f → address
timelockDuration 0x2bbca157 → uint256
totalPending 0x3f90916a → uint256
user 0x4f8632ba → address
withdrawalRequests 0x937b2581 → uint256, address, uint256, uint8
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
cancelWithdrawal 0x3efcfda4
uint256 _nonce
changeUser 0x2c30e13b
address _newUser
completeWithdrawal 0x4f0cb5f3
uint256 _nonce
initiateWithdrawal 0x54438127
uint256 amount
address target
returns: uint256
renounceAdmin 0x8bad0c0a
No parameters
rescueFunds 0xe53b2017
address _token
Recent Transactions
No transactions found for this address