Address Contract Verified
Address
0x0CEb5296E8e68340bB4bD51c8330163C2Cb158e7
Balance
0 ETH
Nonce
1
Code Size
3339 bytes
Creator
0xAf0a1aE1...9698 at tx 0x97e2c1e1...e92880
Indexed Transactions
0
Contract Bytecode
3339 bytes
0x6080604052600436106100ab5760003560e01c80638da5cb5b116100645780638da5cb5b146101e1578063ac65a345146101ff578063afcc502714610223578063bd77ac2c14610262578063f2fde38b14610282578063ffa1ad74146102a2576100b2565b80630719c278146100fb5780632f99c6cc1461011d5780633ccfd60b1461016e578063715018a6146101835780637362377b1461019857806378e7e3d1146101ad576100b2565b366100b257005b600036606082828080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250508251955050602090910192505050f35b34801561010757600080fd5b5061011b610116366004610afd565b6102d6565b005b34801561012957600080fd5b506101517f000000000000000000000000fdb0fe67b9dc5b14d431171327b0c1a5e57431ca81565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561017a57600080fd5b5061011b61044f565b34801561018f57600080fd5b5061011b610613565b3480156101a457600080fd5b5061011b610625565b3480156101b957600080fd5b506101517f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b3480156101ed57600080fd5b506000546001600160a01b0316610151565b34801561020b57600080fd5b5061021560035481565b604051908152602001610165565b34801561022f57600080fd5b5061024361023e366004610b72565b610685565b604080516001600160a01b039093168352602083019190915201610165565b34801561026e57600080fd5b5061011b61027d366004610b72565b6106bd565b34801561028e57600080fd5b5061011b61029d366004610ba0565b610904565b3480156102ae57600080fd5b506102157f0000000000000000000000000000000000000000000000000000000000000fa281565b6102de610944565b600254156102ff5760405163625d776760e01b815260040160405180910390fd5b6101008111156103225760405163c40543d160e01b815260040160405180910390fd5b60005b8181101561037957600283838381811061034157610341610bc4565b83546001810185556000948552602090942060409091029290920192600202909101905061036f8282610bda565b5050600101610325565b506103846002610971565b60038190556002546001546040516370a0823160e01b81523060048201527f789e5936e710a4406d92dbda5f1c82b9dc3bdb0eda6c84d24476a0b5f5ba89df9392916001600160a01b0316906370a0823190602401602060405180830381865afa1580156103f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041a9190610c10565b6003546104279190610c3f565b6040805193845260208401929092529082015242606082015260800160405180910390a15050565b610457610944565b6001546040516370a0823160e01b81523060048201527fbf2ed60bd5b5965d685680c01195c9514e4382e28e3a5a2d2d5244bf59411b93916001600160a01b0316906370a0823190602401602060405180830381865afa1580156104bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e39190610c10565b604080519182524260208301520160405180910390a16002545b801561054f57600280548061051457610514610c66565b60008281526020812060026000199093019283020180546001600160a01b03191681556001015590558061054781610c7c565b9150506104fd565b5061055a6002610971565b60038190551561056c5761056c610c93565b6001546040516370a0823160e01b8152306004820152610611917f000000000000000000000000fdb0fe67b9dc5b14d431171327b0c1a5e57431ca916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156105da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fe9190610c10565b6001546001600160a01b031691906109bd565b565b61061b610944565b6106116000610a14565b61062d610944565b6040516001600160a01b037f000000000000000000000000fdb0fe67b9dc5b14d431171327b0c1a5e57431ca16904780156108fc02916000818181858888f19350505050158015610682573d6000803e3d6000fd5b50565b6002818154811061069557600080fd5b6000918252602090912060029091020180546001909101546001600160a01b03909116915082565b6106c5610944565b6002546000036106e857604051631a1a1dd160e21b815260040160405180910390fd5b600354811461070a57604051635c3ef66b60e01b815260040160405180910390fd5b6003546001546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015610755573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107799190610c10565b10156107985760405163356680b760e01b815260040160405180910390fd5b6003546002546001546040516370a0823160e01b81523060048201527f44fc992777aaddfc6c30cf4dc1e193aae715bd4d8d11e92708d6cbabbd5086bb93929183916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561080c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108309190610c10565b61083a9190610c3f565b6040805193845260208401929092529082015242606082015260800160405180910390a160006003556002545b80156108ec576108a0600261087d600184610ca9565b8154811061088d5761088d610bc4565b9060005260206000209060020201610a64565b60028054806108b1576108b1610c66565b60008281526020812060026000199093019283020180546001600160a01b0319168155600101559055806108e481610c7c565b915050610867565b506108f76002610971565b1561068257610682610c93565b61090c610944565b6001600160a01b03811661093b57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61068281610a14565b6000546001600160a01b031633146106115760405163118cdaa760e01b8152336004820152602401610932565b6000805b82548110156109b75782818154811061099057610990610bc4565b906000526020600020906002020160010154826109ad9190610cc2565b9150600101610975565b50919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610a0f908490610a86565b505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80546001808301549054610682926001600160a01b03918216929116906109bd565b600080602060008451602086016000885af180610aa9576040513d6000823e3d81fd5b50506000513d91508115610ac1578060011415610ace565b6001600160a01b0384163b155b15610af757604051635274afe760e01b81526001600160a01b0385166004820152602401610932565b50505050565b60008060208385031215610b1057600080fd5b823567ffffffffffffffff80821115610b2857600080fd5b818501915085601f830112610b3c57600080fd5b813581811115610b4b57600080fd5b8660208260061b8501011115610b6057600080fd5b60209290920196919550909350505050565b600060208284031215610b8457600080fd5b5035919050565b6001600160a01b038116811461068257600080fd5b600060208284031215610bb257600080fd5b8135610bbd81610b8b565b9392505050565b634e487b7160e01b600052603260045260246000fd5b8135610be581610b8b565b81546001600160a01b0319166001600160a01b03919091161781556020919091013560019190910155565b600060208284031215610c2257600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8181036000831280158383131683831282161715610c5f57610c5f610c29565b5092915050565b634e487b7160e01b600052603160045260246000fd5b600081610c8b57610c8b610c29565b506000190190565b634e487b7160e01b600052600160045260246000fd5b81810381811115610cbc57610cbc610c29565b92915050565b80820180821115610cbc57610cbc610c2956fea2646970667358221220dc73d53f6bc1b0dcfe61d84a5427b4eae86e1240a8969498a98fad00967e145164736f6c63430008180033
Verified Source Code Full Match
Compiler: v0.8.24+commit.e11b9ed9
EVM: paris
Optimization: Yes (200 runs)
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
SafeERC20.sol 198 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Disburser.sol 172 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// Audited utility code from openZepplin
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// Uncomment this line to use console.log
// import "hardhat/console.sol";
/// @title PloughShare Disburser
/// @author SJH Services
/// @notice PloughShare~Disburser: A token distribution contract for Ox Securities
/// @notice
/// @notice Typical workflow is: configure(), [external deposit transfer], disburse(), [withdraw() for cancellation]
/// @dev v0.4 Currently disburses USDT on the Ethereum mainnet and Tron mainnet
contract Disburser is Ownable {
using SafeERC20 for IERC20;
/// @notice The limit on array length, use batches to process more transactions.
uint internal constant MAX_PAYMENTS = 256;
/// @notice The PloughShare contract version number (XXXYYYZZZ represents vXXX.YYY.ZZZ).
uint public immutable VERSION;
/// @notice address: the withdrawal recipient address
address payable public immutable BENEFICIARY;
/// @notice The on-chain TetherToken contract address.
address public immutable TETHER;
/// @notice Callable safeERC20 interface to the TetherToken contract.
IERC20 private tether;
/// @notice This structure type represents an [account, amount] pair to be disbursed to a payee.
/// @notice Following the behaviour of USDT, all (amount) values are in units of 1e-6 USD.
/// @notice By way of example: 1_990_000 == $1.99USDT.
struct Payment {
address payable account;
uint amount;
}
/// @notice The stored array of payments to be made in the next Disbursement.
Payment[] public pendingPayments;
/// @notice The sum of all pendingPayments currently configured for the next Disbursement.
uint public totalAmountPending;
event Withdrawal(uint amount, uint when);
event Disbursement(uint totalAmount, uint numberOfPayees, int residualBalance, uint when);
event Configuration(uint totalAmount, uint numberOfPayees, int requiredDeposit, uint when);
error AlreadyPendingPayments();
error TooManyPayments();
error NoPendingPayments();
error IncorrectTotalAmount();
error InsufficientFunds();
/// @notice Deploy the contract by passing a version number and tether token address.
/// @param _version represents the contract code version, as tracked in the ploughshare repo
/// @param _tether is the external USDT TetherToken contract address, implementing ERC20
constructor(uint _version, address _tether, address _beneficiary) Ownable(msg.sender) payable {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log(" Disburser.constructor: version is %o and block timestamp is %o", _version, block.timestamp);
// console.log(" Disburser.constructor: tether address set to %o", _tether);
// console.log(" Disburser.constructor: beneficiary address set to %o", _beneficiary);
// console.log(" Disburser.constructor: DISBURSER address set to %o", address(this));
VERSION = _version;
TETHER = _tether;
tether = IERC20(TETHER);
BENEFICIARY = payable(_beneficiary);
}
/// @notice Compute the total amount over an array of Payments.
/// @param payments an array of payments to sum over
/// @return totalAmount the sum of all payments in the array
function computeTotalAmount(Payment[] storage payments) internal view returns (uint totalAmount) {
totalAmount = 0;
for (uint i = 0; i < payments.length; i++) {
totalAmount += payments[i].amount;
}
}
/// @notice Allow the owner to input a table of recipients and corresponding payment amounts.
/// @notice Stores the data and emits a summary.
/// @param payments an array of Payment structs, each bing an (account, amount) pair
function configure(Payment[] calldata payments) public onlyOwner {
// console.log(" Disburser.configure: there are %o pending payments, %o new payments, "
// "and block timestamp is %o", pendingPayments.length, payments.length, block.timestamp);
if (pendingPayments.length != 0) revert AlreadyPendingPayments();
if (payments.length > MAX_PAYMENTS) revert TooManyPayments();
// since we can't simply copy pendingPayments = payments we iterate through
for (uint i = 0; i < payments.length; i++) {
pendingPayments.push(payments[i]);
}
totalAmountPending = computeTotalAmount(pendingPayments);
emit Configuration(totalAmountPending, pendingPayments.length,
int(totalAmountPending)-int(tether.balanceOf(address(this))), block.timestamp);
}
/// @notice Process a single Payment, transferring the funds.
/// @param payment a payment Struct containing (account, amount)
function makePayment(Payment storage payment) internal {
tether.safeTransfer(payment.account, payment.amount);
}
/// @notice Allow the owner to trigger a configured batch of USDT payments.
/// @notice Emits an initial summary, then clears stored data as payments are made, and emits a final summary.
/// @param totalAmount the function requires confirmation of the total as a safety feature
function disburse(uint totalAmount) public onlyOwner {
// console.log(" Disburser.disburse: there are %d pending payments and block timestamp is %o",
// pendingPayments.length, block.timestamp);
if (pendingPayments.length == 0) revert NoPendingPayments();
if (totalAmount != totalAmountPending) revert IncorrectTotalAmount();
if (tether.balanceOf(address(this)) < totalAmountPending) revert InsufficientFunds();
emit Disbursement(totalAmountPending, pendingPayments.length,
int(tether.balanceOf(address(this)))-int(totalAmountPending), block.timestamp);
totalAmountPending = 0;
/// @dev state changing external calls
for (uint i = pendingPayments.length; i > 0; i--) {
makePayment(pendingPayments[i-1]);
pendingPayments.pop();
}
assert(computeTotalAmount(pendingPayments) == 0);
}
/// @notice Allow the owner to withdraw the entire current contract USDT balance and clear all pending payments.
/// @notice Any token balance is transferred to the beneficiary address.
function withdraw() public onlyOwner {
// console.log(" Disburser.withdraw: prior balance is %o and block timestamp is %o",
// tether.balanceOf(address(this)), block.timestamp);
emit Withdrawal(tether.balanceOf(address(this)), block.timestamp);
for (uint i = pendingPayments.length; i > 0; i--) {
pendingPayments.pop();
}
totalAmountPending = computeTotalAmount(pendingPayments);
assert(totalAmountPending == 0);
/// @dev state changing external call
tether.safeTransfer(BENEFICIARY, tether.balanceOf(address(this)));
}
/// @notice Allow the owner to withdraw the entire current contract ETHER balance and clear all pending payments.
/// @notice This should not be needed unless someone makes a mistake.
/// @notice Any ether balance is transferred to the beneficiary address.
function withdrawEther() public onlyOwner {
// console.log(" Disburser.withdrawEther: prior balance is %o and block timestamp is %o",
// address(this).balance, block.timestamp);
/// @dev state changing external call
BENEFICIARY.transfer(address(this).balance);
}
/// @notice Allow any address to deposit ETHER.
receive() external payable {}
/// @notice Allow any address to deposit ETHER, even with a badly formed call.
fallback(bytes calldata input) external payable returns (bytes memory output) {
output = input;
}
}
Read Contract
BENEFICIARY 0x2f99c6cc → address
TETHER 0x78e7e3d1 → address
VERSION 0xffa1ad74 → uint256
owner 0x8da5cb5b → address
pendingPayments 0xafcc5027 → address, uint256
totalAmountPending 0xac65a345 → uint256
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
configure 0xac125a50
tuple[] payments
disburse 0xbd77ac2c
uint256 totalAmount
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
withdrawEther 0x7362377b
No parameters
Recent Transactions
No transactions found for this address