More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 16 from a total of 16 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Withdraw To By L... | 4042694 | 24 hrs ago | IN | 0 BERA | 0.00001188 | ||||
Withdraw To By L... | 3865870 | 5 days ago | IN | 0 BERA | 0.00000876 | ||||
Set Whitelist St... | 3861783 | 5 days ago | IN | 0 BERA | 0.00000005 | ||||
Set Whitelist St... | 3861770 | 5 days ago | IN | 0 BERA | 0.00000005 | ||||
Set Whitelist St... | 3861760 | 5 days ago | IN | 0 BERA | 0.00000005 | ||||
Set Whitelist St... | 3861624 | 5 days ago | IN | 0 BERA | 0.00000004 | ||||
Set Whitelist St... | 3861542 | 5 days ago | IN | 0 BERA | 0.00000005 | ||||
Set Whitelist St... | 3861528 | 5 days ago | IN | 0 BERA | 0.00000003 | ||||
Set Whitelist St... | 3861509 | 5 days ago | IN | 0 BERA | 0.00000005 | ||||
Set Whitelist St... | 3861477 | 5 days ago | IN | 0 BERA | 0.00000005 | ||||
Set Whitelist St... | 3856859 | 5 days ago | IN | 0 BERA | 0.0000002 | ||||
Approve | 3777073 | 7 days ago | IN | 0 BERA | 0.00000023 | ||||
Approve | 3776550 | 7 days ago | IN | 0 BERA | 0.00000023 | ||||
Deposit For | 3774815 | 7 days ago | IN | 0 BERA | 0.00001134 | ||||
Set Whitelist St... | 3774815 | 7 days ago | IN | 0 BERA | 0.00000506 | ||||
Set Whitelist St... | 3774813 | 7 days ago | IN | 0 BERA | 0.00000506 |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
RewardToken
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 1000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import {ERC20WrapperLocked} from "./ERC20WrapperLocked.sol"; /// @title RewardToken /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @author ZeroLend (https://zerolend.xyz/) /// @notice A wrapper for locked ERC20 tokens that can be withdrawn as per the lock schedule. /// @dev This contract implements a specific unlock schedule for reward tokens. Tokens are unlocked over a 180-day /// period. 20% is unlocked immediately, and the remaining 80% unlocks linearly over 6 months, reaching full unlock at /// maturity. The linear unlock starts LOCK_NORMALIZATION_FACTOR after the lock is created. contract RewardToken is ERC20WrapperLocked { /// @notice Constructor for RewardToken /// @param _owner Address of the contract owner /// @param _receiver Address of the receiver /// @param _underlying Address of the underlying ERC20 token constructor(address _owner, address _receiver, address _underlying) ERC20WrapperLocked(_owner, _receiver, _underlying, "ZeroLend Reward Token", "ZEROr") {} /// @notice Calculates the share of tokens that can be unlocked based on the lock timestamp /// @param lockTimestamp The timestamp when the tokens were locked /// @return The share of tokens that can be freely unlocked (in basis points) function _calculateUnlockShare(uint256 lockTimestamp) internal view virtual override returns (uint256) { if (lockTimestamp > block.timestamp) return 0; unchecked { uint256 timeElapsed = block.timestamp - lockTimestamp; if (timeElapsed <= LOCK_NORMALIZATION_FACTOR) { return 0.2e18; } else if (timeElapsed >= 180 days) { return SCALE; } else { return (timeElapsed - LOCK_NORMALIZATION_FACTOR) * 0.8e18 / (180 days - LOCK_NORMALIZATION_FACTOR) + 0.2e18; } } } }
// 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// 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); }
// 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";
// 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";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC-20 * applications. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Skips emitting an {Approval} event indicating an allowance update. This is not * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve]. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * * ```solidity * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance < type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/ERC20Wrapper.sol) pragma solidity ^0.8.20; import {IERC20, IERC20Metadata, ERC20} from "../ERC20.sol"; import {SafeERC20} from "../utils/SafeERC20.sol"; /** * @dev Extension of the ERC-20 token contract to support token wrapping. * * Users can deposit and withdraw "underlying tokens" and receive a matching number of "wrapped tokens". This is useful * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the * wrapping of an existing "basic" ERC-20 into a governance token. * * WARNING: Any mechanism in which the underlying token changes the {balanceOf} of an account without an explicit transfer * may desynchronize this contract's supply and its underlying balance. Please exercise caution when wrapping tokens that * may undercollateralize the wrapper (i.e. wrapper's total supply is higher than its underlying balance). See {_recover} * for recovering value accrued to the wrapper. */ abstract contract ERC20Wrapper is ERC20 { IERC20 private immutable _underlying; /** * @dev The underlying token couldn't be wrapped. */ error ERC20InvalidUnderlying(address token); constructor(IERC20 underlyingToken) { if (underlyingToken == this) { revert ERC20InvalidUnderlying(address(this)); } _underlying = underlyingToken; } /** * @dev See {ERC20-decimals}. */ function decimals() public view virtual override returns (uint8) { try IERC20Metadata(address(_underlying)).decimals() returns (uint8 value) { return value; } catch { return super.decimals(); } } /** * @dev Returns the address of the underlying ERC-20 token that is being wrapped. */ function underlying() public view returns (IERC20) { return _underlying; } /** * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens. */ function depositFor(address account, uint256 value) public virtual returns (bool) { address sender = _msgSender(); if (sender == address(this)) { revert ERC20InvalidSender(address(this)); } if (account == address(this)) { revert ERC20InvalidReceiver(account); } SafeERC20.safeTransferFrom(_underlying, sender, address(this), value); _mint(account, value); return true; } /** * @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens. */ function withdrawTo(address account, uint256 value) public virtual returns (bool) { if (account == address(this)) { revert ERC20InvalidReceiver(account); } _burn(_msgSender(), value); SafeERC20.safeTransfer(_underlying, account, value); return true; } /** * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake or acquired from * rebasing mechanisms. Internal function that can be exposed with access control if desired. */ function _recover(address account) internal virtual returns (uint256) { uint256 value = _underlying.balanceOf(address(this)) - totalSupply(); _mint(account, value); return value; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC-20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// 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); }
// 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); } }
// 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; } }
// 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableMap.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableMap.js. pragma solidity ^0.8.20; import {EnumerableSet} from "./EnumerableSet.sol"; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * The following map types are supported: * * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0 * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0 * - `uint256 -> bytes32` (`UintToBytes32Map`) since v5.1.0 * - `address -> address` (`AddressToAddressMap`) since v5.1.0 * - `address -> bytes32` (`AddressToBytes32Map`) since v5.1.0 * - `bytes32 -> address` (`Bytes32ToAddressMap`) since v5.1.0 * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableMap. * ==== */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code repetition as possible, we write it in // terms of a generic Map type with bytes32 keys and values. The Map implementation uses private functions, // and user-facing implementations such as `UintToAddressMap` are just wrappers around the underlying Map. // This means that we can only create new EnumerableMaps for types that fit in bytes32. /** * @dev Query for a nonexistent map key. */ error EnumerableMapNonexistentKey(bytes32 key); struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping(bytes32 key => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32 key, bytes32 value) { bytes32 atKey = map._keys.at(index); return (atKey, map._values[atKey]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool exists, bytes32 value) { bytes32 val = map._values[key]; if (val == bytes32(0)) { return (contains(map, key), bytes32(0)); } else { return (true, val); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) { bytes32 value = map._values[key]; if (value == 0 && !contains(map, key)) { revert EnumerableMapNonexistentKey(key); } return value; } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) { return map._keys.values(); } // UintToUintMap struct UintToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToUintMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToUintMap storage map, uint256 index) internal view returns (uint256 key, uint256 value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (uint256(atKey), uint256(val)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool exists, uint256 value) { (bool success, bytes32 val) = tryGet(map._inner, bytes32(key)); return (success, uint256(val)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key))); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(UintToUintMap storage map) internal view returns (uint256[] memory) { bytes32[] memory store = keys(map._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } // UintToAddressMap struct UintToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256 key, address value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (uint256(atKey), address(uint160(uint256(val)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool exists, address value) { (bool success, bytes32 val) = tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(val)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key))))); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) { bytes32[] memory store = keys(map._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } // UintToBytes32Map struct UintToBytes32Map { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToBytes32Map storage map, uint256 key, bytes32 value) internal returns (bool) { return set(map._inner, bytes32(key), value); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToBytes32Map storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToBytes32Map storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToBytes32Map storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToBytes32Map storage map, uint256 index) internal view returns (uint256 key, bytes32 value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (uint256(atKey), val); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToBytes32Map storage map, uint256 key) internal view returns (bool exists, bytes32 value) { (bool success, bytes32 val) = tryGet(map._inner, bytes32(key)); return (success, val); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToBytes32Map storage map, uint256 key) internal view returns (bytes32) { return get(map._inner, bytes32(key)); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(UintToBytes32Map storage map) internal view returns (uint256[] memory) { bytes32[] memory store = keys(map._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressToUintMap struct AddressToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToUintMap storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToUintMap storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToUintMap storage map, uint256 index) internal view returns (address key, uint256 value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (address(uint160(uint256(atKey))), uint256(val)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(AddressToUintMap storage map, address key) internal view returns (bool exists, uint256 value) { (bool success, bytes32 val) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, uint256(val)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToUintMap storage map, address key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))))); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(AddressToUintMap storage map) internal view returns (address[] memory) { bytes32[] memory store = keys(map._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressToAddressMap struct AddressToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(AddressToAddressMap storage map, address key, address value) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToAddressMap storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToAddressMap storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToAddressMap storage map, uint256 index) internal view returns (address key, address value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (address(uint160(uint256(atKey))), address(uint160(uint256(val)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(AddressToAddressMap storage map, address key) internal view returns (bool exists, address value) { (bool success, bytes32 val) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, address(uint160(uint256(val)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToAddressMap storage map, address key) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(uint256(uint160(key))))))); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(AddressToAddressMap storage map) internal view returns (address[] memory) { bytes32[] memory store = keys(map._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressToBytes32Map struct AddressToBytes32Map { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(AddressToBytes32Map storage map, address key, bytes32 value) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), value); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToBytes32Map storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToBytes32Map storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToBytes32Map storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToBytes32Map storage map, uint256 index) internal view returns (address key, bytes32 value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (address(uint160(uint256(atKey))), val); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(AddressToBytes32Map storage map, address key) internal view returns (bool exists, bytes32 value) { (bool success, bytes32 val) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, val); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToBytes32Map storage map, address key) internal view returns (bytes32) { return get(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(AddressToBytes32Map storage map) internal view returns (address[] memory) { bytes32[] memory store = keys(map._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // Bytes32ToUintMap struct Bytes32ToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) { return set(map._inner, key, bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) { return remove(map._inner, key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) { return contains(map._inner, key); } /** * @dev Returns the number of elements in the map. O(1). */ function length(Bytes32ToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32 key, uint256 value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (atKey, uint256(val)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool exists, uint256 value) { (bool success, bytes32 val) = tryGet(map._inner, key); return (success, uint256(val)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) { return uint256(get(map._inner, key)); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) { bytes32[] memory store = keys(map._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } // Bytes32ToAddressMap struct Bytes32ToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(Bytes32ToAddressMap storage map, bytes32 key, address value) internal returns (bool) { return set(map._inner, key, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToAddressMap storage map, bytes32 key) internal returns (bool) { return remove(map._inner, key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (bool) { return contains(map._inner, key); } /** * @dev Returns the number of elements in the map. O(1). */ function length(Bytes32ToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToAddressMap storage map, uint256 index) internal view returns (bytes32 key, address value) { (bytes32 atKey, bytes32 val) = at(map._inner, index); return (atKey, address(uint160(uint256(val)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (bool exists, address value) { (bool success, bytes32 val) = tryGet(map._inner, key); return (success, address(uint160(uint256(val)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToAddressMap storage map, bytes32 key) internal view returns (address) { return address(uint160(uint256(get(map._inner, key)))); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(Bytes32ToAddressMap storage map) internal view returns (bytes32[] memory) { bytes32[] memory store = keys(map._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import {ERC20Wrapper, ERC20, IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol"; import {Ownable, Context} from "@openzeppelin/contracts/access/Ownable.sol"; import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; /// @title ERC20WrapperLocked /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A wrapper for locked ERC20 tokens that can be withdrawn as per the lock schedule. /// @dev Regular wrapping (`depositFor`), unwrapping (`withdrawTo`) are only supported for whitelisted callers with /// an ADMIN whitelist status. Regular ERC20 `transfer` and `transferFrom` are only supported between two whitelisted /// accounts. Under other circumstances, conditions apply; look at the `_update` function. If the account balance is /// non-whitelisted, their tokens can only be withdrawn as per the lock schedule and the remainder of the amount is /// transferred to the receiver address configured. If the account has a DISTRIBUTOR whitelist status, their tokens /// cannot be unwrapped by them, but in order to be unwrapped, they can only be transferred to the account that is not /// whitelisted and become a subject to the locking schedule or transferred to the account with an ADMIN whitelist /// status. A whitelisted account can always degrade their whitelist status and become a subject to the locking /// schedule. /// @dev Avoid giving an ADMIN whitelist status to untrusted addresses. They can be used by non-whitelisted accounts and /// accounts with the DISTRIBUTOR whitelist status to avoid the lock schedule. /// @dev Avoid giving approvals to untrusted spenders. If approved by both a whitelisted account and a non-whitelisted /// account, they can reset the non-whitelisted account's lock schedule. /// @dev The wrapped token is assumed to be well behaved, including not rebasing, not attempting to re-enter this /// wrapper contract, and not presenting any other weird behavior. abstract contract ERC20WrapperLocked is Ownable, ERC20Wrapper { using EnumerableMap for EnumerableMap.UintToUintMap; using SafeERC20 for IERC20; error NotAuthorized(); error ControllerDisabled(); /// @notice The factor used to normalize lock timestamps to daily intervals /// @dev This constant is used to round down timestamps to the nearest day when creating locks uint256 internal constant LOCK_NORMALIZATION_FACTOR = 1 days; /// @notice Scaling factor for percentage calculations uint256 internal constant SCALE = 1e18; /// @notice Constant representing no whitelist status uint256 public constant WHITELIST_STATUS_NONE = 0; /// @notice Constant representing admin whitelist status uint256 public constant WHITELIST_STATUS_ADMIN = 1; /// @notice Constant representing distributor whitelist status uint256 public constant WHITELIST_STATUS_DISTRIBUTOR = 2; /// @notice Address that will receive the remainder of the tokens after the lock schedule is applied. If zero /// address, the remainder of the tokens will be sent to the owner. address public remainderReceiver; /// @notice Mapping to store whitelist status of an addresses mapping(address => uint256) public whitelistStatus; /// @notice Mapping to store locked token amount for each address and normalized lock timestamp mapping(address => EnumerableMap.UintToUintMap) internal lockedAmounts; /// @notice Emitted when the remainder receiver address is set or changed /// @param remainderReceiver The address of the new remainder receiver event RemainderReceiverSet(address indexed remainderReceiver); /// @notice Emitted when an account's whitelist status changes /// @param account The address of the account /// @param status The new whitelist status event WhitelistStatusSet(address indexed account, uint256 status); /// @notice Emitted when a new lock is created for an account /// @param account The address of the account for which the lock was created /// @param lockTimestamp The normalized timestamp of the created lock event LockCreated(address indexed account, uint256 lockTimestamp); /// @notice Emitted when a lock is removed for an account /// @param account The address of the account for which the lock was removed /// @param lockTimestamp The normalized timestamp of the removed lock event LockRemoved(address indexed account, uint256 lockTimestamp); /// @notice Error thrown when an invalid whitelist status is provided error InvalidWhitelistStatus(); /// @notice Thrown when the remainder loss is not allowed but the calculated remainder amount is non-zero error RemainderLossNotAllowed(); /// @notice Modifier to restrict function access to the whitelisted addresses /// @param account The address to check for whitelist status modifier onlyWhitelisted(address account) { if (whitelistStatus[account] == WHITELIST_STATUS_NONE) revert NotAuthorized(); _; } /// @notice Modifier to restrict function access to the whitelisted ADMIN addresses /// @param account The address to check for whitelist status modifier onlyWhitelistedAdmin(address account) { if (whitelistStatus[account] != WHITELIST_STATUS_ADMIN) revert NotAuthorized(); _; } /// @notice Constructor for ERC20WrapperLocked /// @param _owner Address of the contract owner /// @param _remainderReceiver Address that will receive the remainder of the tokens after the lock schedule is /// applied. If zero address, the remainder of the tokens will be sent to the owner. /// @param _underlying Address of the underlying ERC20 token /// @param _name Name of the wrapper token /// @param _symbol Symbol of the wrapper token constructor( address _owner, address _remainderReceiver, address _underlying, string memory _name, string memory _symbol ) Ownable(_owner) ERC20Wrapper(IERC20(_underlying)) ERC20(_name, _symbol) { remainderReceiver = _remainderReceiver; emit RemainderReceiverSet(_remainderReceiver); } /// @notice Disables the ability to renounce ownership of the contract function renounceOwnership() public pure override { revert NotAuthorized(); } /// @notice Sets a new remainder receiver address /// @param _remainderReceiver The address of the new remainder receiver. If zero address, the remainder of the /// tokens function setRemainderReceiver(address _remainderReceiver) public onlyOwner { if (remainderReceiver != _remainderReceiver) { remainderReceiver = _remainderReceiver; emit RemainderReceiverSet(_remainderReceiver); } } /// @notice Sets the whitelist status for a specified account /// @param account The address to set the whitelist status for /// @param status The new whitelist status to set function setWhitelistStatus(address account, uint256 status) public onlyOwner { if (whitelistStatus[account] != status) _setWhitelistStatus(account, status); } /// @notice Allows a whitelisted account to degrade its own whitelist status /// @param status The new whitelist status to set function setWhitelistStatus(uint256 status) public onlyWhitelisted(_msgSender()) { address account = _msgSender(); if (whitelistStatus[account] != status) { if (status == WHITELIST_STATUS_ADMIN) { revert NotAuthorized(); } else { _setWhitelistStatus(account, status); } } } /// @notice Deposits tokens for a specified account /// @param account The address to deposit tokens for /// @param amount The amount of tokens to deposit /// @return bool indicating success of the deposit function depositFor(address account, uint256 amount) public virtual override onlyWhitelistedAdmin(_msgSender()) returns (bool) { return super.depositFor(account, amount); } /// @notice Withdraws tokens to a specified account /// @param account The address to withdraw tokens to /// @param amount The amount of tokens to withdraw /// @return bool indicating success of the withdrawal function withdrawTo(address account, uint256 amount) public virtual override onlyWhitelistedAdmin(_msgSender()) returns (bool) { return super.withdrawTo(account, amount); } /// @notice Transfers tokens to a specified address /// @param to The address to transfer tokens to /// @param amount The amount of tokens to transfer /// @return bool indicating success of the transfer function transfer(address to, uint256 amount) public virtual override returns (bool) { return super.transfer(to, amount); } /// @notice Transfers tokens from one address to another /// @param from The address to transfer tokens from /// @param to The address to transfer tokens to /// @param amount The amount of tokens to transfer /// @return bool indicating success of the transfer function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { return super.transferFrom(from, to, amount); } /// @notice Withdraws tokens to a specified account based on a specific normalized lock timestamp as per the lock /// schedule. The remainder of the tokens are transferred to the receiver address configured. /// @param account The address to receive the withdrawn tokens /// @param lockTimestamp The normalized lock timestamp to withdraw tokens for /// @param allowRemainderLoss If true, is it allowed for the remainder of the tokens to be transferred to the /// receiver address configured as per the lock schedule. If false and the calculated remainder amount is non-zero, /// the withdrawal will revert. /// @return bool indicating success of the withdrawal function withdrawToByLockTimestamp(address account, uint256 lockTimestamp, bool allowRemainderLoss) public virtual returns (bool) { uint256[] memory lockTimestamps = new uint256[](1); lockTimestamps[0] = lockTimestamp; return withdrawToByLockTimestamps(account, lockTimestamps, allowRemainderLoss); } /// @notice Withdraws tokens to a specified account based on multiple normalized lock timestamps as per the lock /// schedule. /// The remainder of the tokens are transferred to the receiver address configured. /// @param account The address to receive the withdrawn tokens /// @param lockTimestamps An array of normalized lock timestamps to withdraw tokens for /// @param allowRemainderLoss If true, is it allowed for the remainder of the tokens to be transferred to the /// receiver address configured as per the lock schedule. If false and the calculated remainder amount is non-zero, /// the withdrawal will revert. /// @return bool indicating success of the withdrawal function withdrawToByLockTimestamps(address account, uint256[] memory lockTimestamps, bool allowRemainderLoss) public virtual returns (bool) { IERC20 asset = underlying(); address sender = _msgSender(); uint256 totalAccountAmount; uint256 totalRemainderAmount; for (uint256 i = 0; i < lockTimestamps.length; ++i) { uint256 lockTimestamp = lockTimestamps[i]; (uint256 accountAmount, uint256 remainderAmount) = getWithdrawAmountsByLockTimestamp(sender, lockTimestamp); if (lockedAmounts[sender].remove(lockTimestamp)) { emit LockRemoved(sender, lockTimestamp); } totalAccountAmount += accountAmount; totalRemainderAmount += remainderAmount; } _burn(sender, totalAccountAmount + totalRemainderAmount); asset.safeTransfer(account, totalAccountAmount); if (totalRemainderAmount != 0) { if (!allowRemainderLoss) revert RemainderLossNotAllowed(); address receiver = remainderReceiver; asset.safeTransfer(receiver == address(0) ? owner() : receiver, totalRemainderAmount); } return true; } /// @notice Calculates the withdraw amounts for a given account and normalized lock timestamp /// @param account The address of the account to check /// @param lockTimestamp The normalized lock timestamp to check for withdraw amounts /// @return accountAmount The amount that can be unlocked and sent to the account /// @return remainderAmount The amount that will be transferred to the configured receiver address function getWithdrawAmountsByLockTimestamp(address account, uint256 lockTimestamp) public view virtual returns (uint256, uint256) { (, uint256 amount) = lockedAmounts[account].tryGet(lockTimestamp); uint256 accountShare = _calculateUnlockShare(lockTimestamp); uint256 accountAmount = amount * accountShare / SCALE; uint256 remainderAmount = amount - accountAmount; return (accountAmount, remainderAmount); } /// @notice Gets the number of locked amount entries for an account /// @param account The address to check /// @return The number of locked amount entries function getLockedAmountsLength(address account) public view returns (uint256) { return lockedAmounts[account].length(); } /// @notice Gets all the normalized lock timestamps of locked amounts for an account /// @param account The address to check /// @return An array of normalized lock timestamps function getLockedAmountsLockTimestamps(address account) public view returns (uint256[] memory) { return lockedAmounts[account].keys(); } /// @notice Gets the locked amount for an account at a specific normalized lock timestamp /// @param account The address to check /// @param lockTimestamp The normalized lock timestamp to check /// @return The locked amount at the specified timestamp function getLockedAmountByLockTimestamp(address account, uint256 lockTimestamp) public view returns (uint256) { (, uint256 amount) = lockedAmounts[account].tryGet(lockTimestamp); return amount; } /// @notice Gets all locked amounts for an account /// @param account The address to check /// @return Two arrays: normalized lock timestamps and corresponding amounts function getLockedAmounts(address account) public view returns (uint256[] memory, uint256[] memory) { EnumerableMap.UintToUintMap storage map = lockedAmounts[account]; uint256[] memory lockTimestamps = map.keys(); uint256[] memory amounts = new uint256[](lockTimestamps.length); for (uint256 i = 0; i < lockTimestamps.length; i++) { amounts[i] = map.get(lockTimestamps[i]); } return (lockTimestamps, amounts); } /// @notice Internal function to update balances /// @dev Regular ERC20 transfers are only supported between two whitelisted addresses. When the amount is /// transferred from non-whitelisted address to a whitelisted address, the locked amount entries get subsequently /// removed starting from the oldest lock, up to the point when the whole requested amount is transferred freely. /// When the amount is transferred from a whitelisted address to a non-whitelisted address, the amount is locked as /// per the lock schedule. Transfers from a non-whitelisted address to another non-whitelisted address are not /// supported and will revert. /// @param from Address to transfer from /// @param to Address to transfer to /// @param amount Amount to transfer function _update(address from, address to, uint256 amount) internal virtual override { if (amount != 0) { bool fromIsWhitelisted = whitelistStatus[from] != WHITELIST_STATUS_NONE; bool toIsWhitelisted = whitelistStatus[to] != WHITELIST_STATUS_NONE; if ((from == address(0) || fromIsWhitelisted) && to != address(0) && !toIsWhitelisted) { // Covers minting and transfers from whitelisted to non-whitelisted EnumerableMap.UintToUintMap storage map = lockedAmounts[to]; uint256 normalizedTimestamp = _getNormalizedTimestamp(); (, uint256 currentAmount) = map.tryGet(normalizedTimestamp); if (map.set(normalizedTimestamp, currentAmount + amount)) { emit LockCreated(to, normalizedTimestamp); } } else if (!fromIsWhitelisted && toIsWhitelisted) { // Covers transfers from non-whitelisted to whitelisted EnumerableMap.UintToUintMap storage map = lockedAmounts[from]; uint256[] memory lockTimestamps = map.keys(); uint256 unlockedAmount; for (uint256 i = 0; i < lockTimestamps.length; ++i) { uint256 lockTimestamp = lockTimestamps[i]; uint256 currentAmount = map.get(lockTimestamp); if (unlockedAmount + currentAmount > amount) { uint256 releasedAmount = amount - unlockedAmount; map.set(lockTimestamp, currentAmount - releasedAmount); currentAmount = releasedAmount; } else { map.remove(lockTimestamp); emit LockRemoved(from, lockTimestamp); } unlockedAmount += currentAmount; if (unlockedAmount >= amount) break; } } else if (from != address(0) && !fromIsWhitelisted && to != address(0) && !toIsWhitelisted) { // Covers transfers from non-whitelisted to non-whitelisted revert NotAuthorized(); } } // For burning and transfers from whitelisted to whitelisted, no special handling needs to be done. // `_setWhitelistStatus` ensures that only non-whitelisted accounts can have locked amounts super._update(from, to, amount); } /// @notice Sets the whitelist status for an account /// @dev If the account is being whitelisted, all locked amounts are removed, resulting in all tokens being /// unlocked. If the account is being removed from the whitelist, the current account balance is locked. A side /// effect of this behavior is that the owner (and by extension, approved token spenders) can modify the lock /// schedule for users. For example, by adding and then removing the account from the whitelist, or by transferring /// tokens from a non-whitelisted account to a whitelisted account and back, the owner and approved token spenders /// can reset the unlock schedule for that account. It should be noted that the ability to modify whitelist status /// and its effects on locks is a core feature of this contract. On the other hand, regular users must be vigilant /// about which addresses they approve to spend their locked tokens which is not unlike other ERC20 approvals. /// @param account The address to set the whitelist status for /// @param status The whitelist status to set function _setWhitelistStatus(address account, uint256 status) internal { if (status > WHITELIST_STATUS_DISTRIBUTOR) revert InvalidWhitelistStatus(); if (status == WHITELIST_STATUS_NONE) { uint256 amount = balanceOf(account); if (amount != 0) { uint256 normalizedTimestamp = _getNormalizedTimestamp(); lockedAmounts[account].set(normalizedTimestamp, amount); emit LockCreated(account, normalizedTimestamp); } } else { EnumerableMap.UintToUintMap storage map = lockedAmounts[account]; uint256[] memory lockTimestamps = map.keys(); for (uint256 i = 0; i < lockTimestamps.length; ++i) { map.remove(lockTimestamps[i]); emit LockRemoved(account, lockTimestamps[i]); } } whitelistStatus[account] = status; emit WhitelistStatusSet(account, status); } /// @notice Calculates the share of tokens that can be unlocked based on the lock timestamp /// @dev This function should be overridden by the child contract to implement the specific unlock schedule /// @param lockTimestamp The timestamp when the tokens were locked /// @return The share of tokens that can be freely unlocked (in basis points) function _calculateUnlockShare(uint256 lockTimestamp) internal view virtual returns (uint256); /// @notice Internal function to get the normalized timestamp /// @return The normalized timestamp (rounded down to the nearest day) function _getNormalizedTimestamp() internal view virtual returns (uint256) { return block.timestamp - (block.timestamp % LOCK_NORMALIZATION_FACTOR); } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"address","name":"_underlying","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ControllerDisabled","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"ERC20InvalidUnderlying","type":"error"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"EnumerableMapNonexistentKey","type":"error"},{"inputs":[],"name":"InvalidWhitelistStatus","type":"error"},{"inputs":[],"name":"NotAuthorized","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"RemainderLossNotAllowed","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"lockTimestamp","type":"uint256"}],"name":"LockCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"lockTimestamp","type":"uint256"}],"name":"LockRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"remainderReceiver","type":"address"}],"name":"RemainderReceiverSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"status","type":"uint256"}],"name":"WhitelistStatusSet","type":"event"},{"inputs":[],"name":"WHITELIST_STATUS_ADMIN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELIST_STATUS_DISTRIBUTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELIST_STATUS_NONE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"lockTimestamp","type":"uint256"}],"name":"getLockedAmountByLockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLockedAmounts","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLockedAmountsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getLockedAmountsLockTimestamps","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"lockTimestamp","type":"uint256"}],"name":"getWithdrawAmountsByLockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"remainderReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_remainderReceiver","type":"address"}],"name":"setRemainderReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"status","type":"uint256"}],"name":"setWhitelistStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"status","type":"uint256"}],"name":"setWhitelistStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistStatus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"lockTimestamp","type":"uint256"},{"internalType":"bool","name":"allowRemainderLoss","type":"bool"}],"name":"withdrawToByLockTimestamp","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"lockTimestamps","type":"uint256[]"},{"internalType":"bool","name":"allowRemainderLoss","type":"bool"}],"name":"withdrawToByLockTimestamps","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a060405234801561001057600080fd5b506040516122c53803806122c583398101604081905261002f916101dd565b8282826040518060400160405280601581526020017f5a65726f4c656e642052657761726420546f6b656e0000000000000000000000815250604051806040016040528060058152602001642d22a927b960d91b8152508282828760006001600160a01b0316816001600160a01b0316036100c557604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b6100ce81610171565b5060046100db83826102bf565b5060056100e882826102bf565b5050306001600160a01b0383160390506101175760405163438d6fe360e01b81523060048201526024016100bc565b6001600160a01b03908116608052600680546001600160a01b03191691861691821790556040517fa2697f04f820814f2c44a4a80765636bd7cc0539020abdaccf5b959537c0a54290600090a2505050505050505061037d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146101d857600080fd5b919050565b6000806000606084860312156101f257600080fd5b6101fb846101c1565b9250610209602085016101c1565b9150610217604085016101c1565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061024a57607f821691505b60208210810361026a57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156102ba57806000526020600020601f840160051c810160208510156102975750805b601f840160051c820191505b818110156102b757600081556001016102a3565b50505b505050565b81516001600160401b038111156102d8576102d8610220565b6102ec816102e68454610236565b84610270565b6020601f82116001811461032057600083156103085750848201515b600019600385901b1c1916600184901b1784556102b7565b600084815260208120601f198516915b828110156103505787850151825560209485019460019092019101610330565b508482101561036e5786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b608051611f116103b460003960008181610331015281816107070152818161094401528181610e620152610f200152611f116000f3fe608060405234801561001057600080fd5b50600436106101da5760003560e01c80636f307dc31161010457806395d89b41116100a2578063ccaf1c4b11610071578063ccaf1c4b1461040f578063dd62ed3e1461042f578063e186935214610468578063f2fde38b1461049057600080fd5b806395d89b41146103e4578063a9059cbb146103ec578063bd95c017146103ff578063cac01cbc1461040757600080fd5b80638a677c9f116100de5780638a677c9f1461039a5780638d2589b0146103ad5780638da5cb5b146103c057806390797498146103d157600080fd5b80636f307dc31461032f57806370a0823114610369578063715018a61461039257600080fd5b8063224b8d6e1161017c578063313ce5671161014b578063313ce567146102ce578063421a10de146102e8578063612d793d146102fb57806367f747ef1461031c57600080fd5b8063224b8d6e14610275578063235d94f31461028857806323b872dd146102a85780632f4f21e2146102bb57600080fd5b806318160ddd116101b857806318160ddd146102325780631ab27b951461023a5780631b70209a1461024d578063205c28781461026257600080fd5b8063015f011e146101df57806306fdde03146101fa578063095ea7b31461020f575b600080fd5b6101e7600181565b6040519081526020015b60405180910390f35b6102026104a3565b6040516101f19190611ad8565b61022261021d366004611b3d565b610535565b60405190151581526020016101f1565b6003546101e7565b610222610248366004611b77565b61054f565b61026061025b366004611b3d565b6105a8565b005b610222610270366004611b3d565b6105dd565b610260610283366004611bb3565b610622565b61029b610296366004611bcc565b610695565b6040516101f19190611c23565b6102226102b6366004611c36565b6106b9565b6102226102c9366004611b3d565b6106c6565b6102d6610703565b60405160ff90911681526020016101f1565b6101e76102f6366004611b3d565b610793565b61030e610309366004611bcc565b6107b7565b6040516101f1929190611c73565b61026061032a366004611bcc565b610891565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b0390911681526020016101f1565b6101e7610377366004611bcc565b6001600160a01b031660009081526001602052604090205490565b610260610906565b6101e76103a8366004611bcc565b61091f565b600654610351906001600160a01b031681565b6000546001600160a01b0316610351565b6102226103df366004611cae565b610940565b610202610ae0565b6102226103fa366004611b3d565b610aef565b6101e7600281565b6101e7600081565b6101e761041d366004611bcc565b60076020526000908152604090205481565b6101e761043d366004611d94565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b61047b610476366004611b3d565b610b02565b604080519283526020830191909152016101f1565b61026061049e366004611bcc565b610b76565b6060600480546104b290611dc7565b80601f01602080910402602001604051908101604052809291908181526020018280546104de90611dc7565b801561052b5780601f106105005761010080835404028352916020019161052b565b820191906000526020600020905b81548152906001019060200180831161050e57829003601f168201915b5050505050905090565b600033610543818585610bcf565b60019150505b92915050565b60408051600180825281830190925260009182919060208083019080368337019050509050838160008151811061058857610588611dfb565b60200260200101818152505061059f858285610940565b95945050505050565b6105b0610bdc565b6001600160a01b03821660009081526007602052604090205481146105d9576105d98282610c24565b5050565b336000818152600760205260408120549091906001146106105760405163ea8e4eb560e01b815260040160405180910390fd5b61061a8484610e1d565b949350505050565b3360008181526007602052604090205461064f5760405163ea8e4eb560e01b815260040160405180910390fd5b33600081815260076020526040902054831461069057600183036106865760405163ea8e4eb560e01b815260040160405180910390fd5b6106908184610c24565b505050565b6001600160a01b038116600090815260086020526040902060609061054990610e91565b600061061a848484610e9e565b336000818152600760205260408120549091906001146106f95760405163ea8e4eb560e01b815260040160405180910390fd5b61061a8484610ec2565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561077f575060408051601f3d908101601f1916820190925261077c91810190611e11565b60015b61078e5750601290565b905090565b919050565b6001600160a01b0382166000908152600860205260408120819061059f9084610f51565b6001600160a01b03811660009081526008602052604081206060918291906107de82610e91565b90506000815167ffffffffffffffff8111156107fc576107fc611c98565b604051908082528060200260200182016040528015610825578160200160208202803683370190505b50905060005b82518110156108855761086083828151811061084957610849611dfb565b602002602001015185610f6d90919063ffffffff16565b82828151811061087257610872611dfb565b602090810291909101015260010161082b565b50909590945092505050565b610899610bdc565b6006546001600160a01b03828116911614610903576006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517fa2697f04f820814f2c44a4a80765636bd7cc0539020abdaccf5b959537c0a54290600090a25b50565b60405163ea8e4eb560e01b815260040160405180910390fd5b6001600160a01b038116600090815260086020526040812061054990610f79565b60007f0000000000000000000000000000000000000000000000000000000000000000338280805b8751811015610a3257600088828151811061098557610985611dfb565b6020026020010151905060008061099c8784610b02565b6001600160a01b038916600090815260086020526040902091935091506109c39084610f84565b15610a0c57866001600160a01b03167f5981e4d35a45c9e8c96ae51ca0f24127eaad820537621c89bbe1ba8b1712b61b84604051610a0391815260200190565b60405180910390a25b610a168287611e4a565b9550610a228186611e4a565b9450505050806001019050610968565b50610a4683610a418385611e4a565b610f90565b610a5a6001600160a01b0385168984610fc6565b8015610ad25785610a97576040517f93c4aad800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006546001600160a01b0316610ad08115610ab25781610abf565b6000546001600160a01b03165b6001600160a01b0387169084610fc6565b505b506001979650505050505050565b6060600580546104b290611dc7565b6000610afb838361103a565b9392505050565b6001600160a01b038216600090815260086020526040812081908190610b289085610f51565b9150506000610b3685611048565b90506000670de0b6b3a7640000610b4d8385611e5d565b610b579190611e8a565b90506000610b658285611e9e565b9195509093505050505b9250929050565b610b7e610bdc565b6001600160a01b038116610bc6576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610903816110c0565b610690838383600161111d565b6000546001600160a01b03163314610c22576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610bbd565b565b6002811115610c5f576040517fd5fb0c3c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80610cff576001600160a01b0382166000908152600160205260409020548015610cf9576000610c8d611225565b6001600160a01b0385166000908152600860205260409020909150610cb390828461123e565b50836001600160a01b03167f68f4429ffe70afd17cd51d3c12265a7698579e0dc36b7099e2f6d5263e739d3982604051610cef91815260200190565b60405180910390a2505b50610dc4565b6001600160a01b038216600090815260086020526040812090610d2182610e91565b905060005b8151811015610dc057610d5b828281518110610d4457610d44611dfb565b602002602001015184610f8490919063ffffffff16565b50846001600160a01b03167f5981e4d35a45c9e8c96ae51ca0f24127eaad820537621c89bbe1ba8b1712b61b838381518110610d9957610d99611dfb565b6020026020010151604051610db091815260200190565b60405180910390a2600101610d26565b5050505b6001600160a01b03821660008181526007602052604090819020839055517faa5d9115062744c4c316306720e23b83bac0a85ffd8fc0b0a43cb9e457fc62b390610e119084815260200190565b60405180910390a25050565b6000306001600160a01b03841603610e535760405163ec442f0560e01b81526001600160a01b0384166004820152602401610bbd565b610e5d3383610f90565b610e887f00000000000000000000000000000000000000000000000000000000000000008484610fc6565b50600192915050565b60606000610afb8361124b565b600033610eac858285611256565b610eb78585856112e8565b506001949350505050565b600033308103610ee757604051634b637e8f60e11b8152306004820152602401610bbd565b306001600160a01b03851603610f1b5760405163ec442f0560e01b81526001600160a01b0385166004820152602401610bbd565b610f477f0000000000000000000000000000000000000000000000000000000000000000823086611347565b6105438484611380565b6000808080610f6086866113b6565b9097909650945050505050565b6000610afb83836113f0565b600061054982611450565b6000610afb838361145b565b6001600160a01b038216610fba57604051634b637e8f60e11b815260006004820152602401610bbd565b6105d982600083611478565b6040516001600160a01b0383811660248301526044820183905261069091859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506116fd565b6000336105438185856112e8565b60004282111561105a57506000919050565b4282900362015180811161107857506702c68af0bb14000092915050565b62ed4e0081106110925750670de0b6b3a764000092915050565b62ebfc80670b1a2bc2ec5000006201517f19830102046702c68af0bb14000001915050919050565b50919050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038416611160576040517fe602df0500000000000000000000000000000000000000000000000000000000815260006004820152602401610bbd565b6001600160a01b0383166111a3576040517f94280d6200000000000000000000000000000000000000000000000000000000815260006004820152602401610bbd565b6001600160a01b038085166000908152600260209081526040808320938716835292905220829055801561121f57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161121691815260200190565b60405180910390a35b50505050565b60006112346201518042611eb1565b6107899042611e9e565b600061061a848484611787565b6060610549826117a4565b6001600160a01b0383811660009081526002602090815260408083209386168352929052205460001981101561121f57818110156112d9576040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024810182905260448101839052606401610bbd565b61121f8484848403600061111d565b6001600160a01b03831661131257604051634b637e8f60e11b815260006004820152602401610bbd565b6001600160a01b03821661133c5760405163ec442f0560e01b815260006004820152602401610bbd565b610690838383611478565b6040516001600160a01b03848116602483015283811660448301526064820183905261121f9186918216906323b872dd90608401610ff3565b6001600160a01b0382166113aa5760405163ec442f0560e01b815260006004820152602401610bbd565b6105d960008383611478565b60008181526002830160205260408120548190806113e5576113d885856117b1565b925060009150610b6f9050565b600192509050610b6f565b600081815260028301602052604081205480158015611416575061141484846117b1565b155b15610afb576040517f02b5668600000000000000000000000000000000000000000000000000000000815260048101849052602401610bbd565b6000610549826117bd565b60008181526002830160205260408120819055610afb83836117c7565b80156116f2576001600160a01b038084166000818152600760205260408082205493861682529020549115159115159015806114b15750815b80156114c557506001600160a01b03841615155b80156114cf575080155b1561156e576001600160a01b0384166000908152600860205260408120906114f5611225565b905060006115038383610f51565b915061151d9050826115158884611e4a565b85919061123e565b1561156657866001600160a01b03167f68f4429ffe70afd17cd51d3c12265a7698579e0dc36b7099e2f6d5263e739d398360405161155d91815260200190565b60405180910390a25b5050506116ef565b811580156115795750805b1561169d576001600160a01b0385166000908152600860205260408120906115a082610e91565b90506000805b82518110156116945760008382815181106115c3576115c3611dfb565b6020026020010151905060006115e28287610f6d90919063ffffffff16565b9050886115ef8286611e4a565b1115611621576000611601858b611e9e565b9050611619836116118385611e9e565b89919061123e565b509050611670565b61162b8683610f84565b508a6001600160a01b03167f5981e4d35a45c9e8c96ae51ca0f24127eaad820537621c89bbe1ba8b1712b61b8360405161166791815260200190565b60405180910390a25b61167a8185611e4a565b935088841061168a575050611694565b50506001016115a6565b505050506116ef565b6001600160a01b038516158015906116b3575081155b80156116c757506001600160a01b03841615155b80156116d1575080155b156116ef5760405163ea8e4eb560e01b815260040160405180910390fd5b50505b6106908383836117d3565b600080602060008451602086016000885af180611720576040513d6000823e3d81fd5b50506000513d91508115611738578060011415611745565b6001600160a01b0384163b155b1561121f576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610bbd565b6000828152600284016020526040812082905561061a8484611916565b60606000610afb83611922565b6000610afb838361197e565b6000610549825490565b6000610afb8383611996565b6001600160a01b0383166117fe5780600360008282546117f39190611e4a565b909155506118899050565b6001600160a01b0383166000908152600160205260409020548181101561186a576040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024810182905260448101839052606401610bbd565b6001600160a01b03841660009081526001602052604090209082900390555b6001600160a01b0382166118a5576003805482900390556118c4565b6001600160a01b03821660009081526001602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161190991815260200190565b60405180910390a3505050565b6000610afb8383611a89565b60608160000180548060200260200160405190810160405280929190818152602001828054801561197257602002820191906000526020600020905b81548152602001906001019080831161195e575b50505050509050919050565b60008181526001830160205260408120541515610afb565b60008181526001830160205260408120548015611a7f5760006119ba600183611e9e565b85549091506000906119ce90600190611e9e565b9050808214611a335760008660000182815481106119ee576119ee611dfb565b9060005260206000200154905080876000018481548110611a1157611a11611dfb565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a4457611a44611ec5565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610549565b6000915050610549565b6000818152600183016020526040812054611ad057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610549565b506000610549565b602081526000825180602084015260005b81811015611b065760208186018101516040868401015201611ae9565b506000604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b038116811461078e57600080fd5b60008060408385031215611b5057600080fd5b611b5983611b26565b946020939093013593505050565b8035801515811461078e57600080fd5b600080600060608486031215611b8c57600080fd5b611b9584611b26565b925060208401359150611baa60408501611b67565b90509250925092565b600060208284031215611bc557600080fd5b5035919050565b600060208284031215611bde57600080fd5b610afb82611b26565b600081518084526020840193506020830160005b82811015611c19578151865260209586019590910190600101611bfb565b5093949350505050565b602081526000610afb6020830184611be7565b600080600060608486031215611c4b57600080fd5b611c5484611b26565b9250611c6260208501611b26565b929592945050506040919091013590565b604081526000611c866040830185611be7565b828103602084015261059f8185611be7565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215611cc357600080fd5b611ccc84611b26565b9250602084013567ffffffffffffffff811115611ce857600080fd5b8401601f81018613611cf957600080fd5b803567ffffffffffffffff811115611d1357611d13611c98565b8060051b604051601f19603f830116810181811067ffffffffffffffff82111715611d4057611d40611c98565b604052918252602081840181019290810189841115611d5e57600080fd5b6020850194505b83851015611d8157843580825260209586019590935001611d65565b509450611baa9250505060408501611b67565b60008060408385031215611da757600080fd5b611db083611b26565b9150611dbe60208401611b26565b90509250929050565b600181811c90821680611ddb57607f821691505b6020821081036110ba57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215611e2357600080fd5b815160ff81168114610afb57600080fd5b634e487b7160e01b600052601160045260246000fd5b8082018082111561054957610549611e34565b808202811582820484141761054957610549611e34565b634e487b7160e01b600052601260045260246000fd5b600082611e9957611e99611e74565b500490565b8181038181111561054957610549611e34565b600082611ec057611ec0611e74565b500690565b634e487b7160e01b600052603160045260246000fdfea264697066735822122027c6bdcbc84885c1d437bbdb8280ec9c82e6b8678a55c6d6ec6bb0441bdd48ae64736f6c634300081c00330000000000000000000000000f6e98a756a40dd050dc78959f45559f98d3289d00000000000000000000000054061e18cd88d2de9af3d3d7fdf05472253b29e0000000000000000000000000486e2f66cd5f38772164237c69d8304045ee1651
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80636f307dc31161010457806395d89b41116100a2578063ccaf1c4b11610071578063ccaf1c4b1461040f578063dd62ed3e1461042f578063e186935214610468578063f2fde38b1461049057600080fd5b806395d89b41146103e4578063a9059cbb146103ec578063bd95c017146103ff578063cac01cbc1461040757600080fd5b80638a677c9f116100de5780638a677c9f1461039a5780638d2589b0146103ad5780638da5cb5b146103c057806390797498146103d157600080fd5b80636f307dc31461032f57806370a0823114610369578063715018a61461039257600080fd5b8063224b8d6e1161017c578063313ce5671161014b578063313ce567146102ce578063421a10de146102e8578063612d793d146102fb57806367f747ef1461031c57600080fd5b8063224b8d6e14610275578063235d94f31461028857806323b872dd146102a85780632f4f21e2146102bb57600080fd5b806318160ddd116101b857806318160ddd146102325780631ab27b951461023a5780631b70209a1461024d578063205c28781461026257600080fd5b8063015f011e146101df57806306fdde03146101fa578063095ea7b31461020f575b600080fd5b6101e7600181565b6040519081526020015b60405180910390f35b6102026104a3565b6040516101f19190611ad8565b61022261021d366004611b3d565b610535565b60405190151581526020016101f1565b6003546101e7565b610222610248366004611b77565b61054f565b61026061025b366004611b3d565b6105a8565b005b610222610270366004611b3d565b6105dd565b610260610283366004611bb3565b610622565b61029b610296366004611bcc565b610695565b6040516101f19190611c23565b6102226102b6366004611c36565b6106b9565b6102226102c9366004611b3d565b6106c6565b6102d6610703565b60405160ff90911681526020016101f1565b6101e76102f6366004611b3d565b610793565b61030e610309366004611bcc565b6107b7565b6040516101f1929190611c73565b61026061032a366004611bcc565b610891565b7f000000000000000000000000486e2f66cd5f38772164237c69d8304045ee16515b6040516001600160a01b0390911681526020016101f1565b6101e7610377366004611bcc565b6001600160a01b031660009081526001602052604090205490565b610260610906565b6101e76103a8366004611bcc565b61091f565b600654610351906001600160a01b031681565b6000546001600160a01b0316610351565b6102226103df366004611cae565b610940565b610202610ae0565b6102226103fa366004611b3d565b610aef565b6101e7600281565b6101e7600081565b6101e761041d366004611bcc565b60076020526000908152604090205481565b6101e761043d366004611d94565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b61047b610476366004611b3d565b610b02565b604080519283526020830191909152016101f1565b61026061049e366004611bcc565b610b76565b6060600480546104b290611dc7565b80601f01602080910402602001604051908101604052809291908181526020018280546104de90611dc7565b801561052b5780601f106105005761010080835404028352916020019161052b565b820191906000526020600020905b81548152906001019060200180831161050e57829003601f168201915b5050505050905090565b600033610543818585610bcf565b60019150505b92915050565b60408051600180825281830190925260009182919060208083019080368337019050509050838160008151811061058857610588611dfb565b60200260200101818152505061059f858285610940565b95945050505050565b6105b0610bdc565b6001600160a01b03821660009081526007602052604090205481146105d9576105d98282610c24565b5050565b336000818152600760205260408120549091906001146106105760405163ea8e4eb560e01b815260040160405180910390fd5b61061a8484610e1d565b949350505050565b3360008181526007602052604090205461064f5760405163ea8e4eb560e01b815260040160405180910390fd5b33600081815260076020526040902054831461069057600183036106865760405163ea8e4eb560e01b815260040160405180910390fd5b6106908184610c24565b505050565b6001600160a01b038116600090815260086020526040902060609061054990610e91565b600061061a848484610e9e565b336000818152600760205260408120549091906001146106f95760405163ea8e4eb560e01b815260040160405180910390fd5b61061a8484610ec2565b60007f000000000000000000000000486e2f66cd5f38772164237c69d8304045ee16516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561077f575060408051601f3d908101601f1916820190925261077c91810190611e11565b60015b61078e5750601290565b905090565b919050565b6001600160a01b0382166000908152600860205260408120819061059f9084610f51565b6001600160a01b03811660009081526008602052604081206060918291906107de82610e91565b90506000815167ffffffffffffffff8111156107fc576107fc611c98565b604051908082528060200260200182016040528015610825578160200160208202803683370190505b50905060005b82518110156108855761086083828151811061084957610849611dfb565b602002602001015185610f6d90919063ffffffff16565b82828151811061087257610872611dfb565b602090810291909101015260010161082b565b50909590945092505050565b610899610bdc565b6006546001600160a01b03828116911614610903576006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517fa2697f04f820814f2c44a4a80765636bd7cc0539020abdaccf5b959537c0a54290600090a25b50565b60405163ea8e4eb560e01b815260040160405180910390fd5b6001600160a01b038116600090815260086020526040812061054990610f79565b60007f000000000000000000000000486e2f66cd5f38772164237c69d8304045ee1651338280805b8751811015610a3257600088828151811061098557610985611dfb565b6020026020010151905060008061099c8784610b02565b6001600160a01b038916600090815260086020526040902091935091506109c39084610f84565b15610a0c57866001600160a01b03167f5981e4d35a45c9e8c96ae51ca0f24127eaad820537621c89bbe1ba8b1712b61b84604051610a0391815260200190565b60405180910390a25b610a168287611e4a565b9550610a228186611e4a565b9450505050806001019050610968565b50610a4683610a418385611e4a565b610f90565b610a5a6001600160a01b0385168984610fc6565b8015610ad25785610a97576040517f93c4aad800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006546001600160a01b0316610ad08115610ab25781610abf565b6000546001600160a01b03165b6001600160a01b0387169084610fc6565b505b506001979650505050505050565b6060600580546104b290611dc7565b6000610afb838361103a565b9392505050565b6001600160a01b038216600090815260086020526040812081908190610b289085610f51565b9150506000610b3685611048565b90506000670de0b6b3a7640000610b4d8385611e5d565b610b579190611e8a565b90506000610b658285611e9e565b9195509093505050505b9250929050565b610b7e610bdc565b6001600160a01b038116610bc6576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610903816110c0565b610690838383600161111d565b6000546001600160a01b03163314610c22576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610bbd565b565b6002811115610c5f576040517fd5fb0c3c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80610cff576001600160a01b0382166000908152600160205260409020548015610cf9576000610c8d611225565b6001600160a01b0385166000908152600860205260409020909150610cb390828461123e565b50836001600160a01b03167f68f4429ffe70afd17cd51d3c12265a7698579e0dc36b7099e2f6d5263e739d3982604051610cef91815260200190565b60405180910390a2505b50610dc4565b6001600160a01b038216600090815260086020526040812090610d2182610e91565b905060005b8151811015610dc057610d5b828281518110610d4457610d44611dfb565b602002602001015184610f8490919063ffffffff16565b50846001600160a01b03167f5981e4d35a45c9e8c96ae51ca0f24127eaad820537621c89bbe1ba8b1712b61b838381518110610d9957610d99611dfb565b6020026020010151604051610db091815260200190565b60405180910390a2600101610d26565b5050505b6001600160a01b03821660008181526007602052604090819020839055517faa5d9115062744c4c316306720e23b83bac0a85ffd8fc0b0a43cb9e457fc62b390610e119084815260200190565b60405180910390a25050565b6000306001600160a01b03841603610e535760405163ec442f0560e01b81526001600160a01b0384166004820152602401610bbd565b610e5d3383610f90565b610e887f000000000000000000000000486e2f66cd5f38772164237c69d8304045ee16518484610fc6565b50600192915050565b60606000610afb8361124b565b600033610eac858285611256565b610eb78585856112e8565b506001949350505050565b600033308103610ee757604051634b637e8f60e11b8152306004820152602401610bbd565b306001600160a01b03851603610f1b5760405163ec442f0560e01b81526001600160a01b0385166004820152602401610bbd565b610f477f000000000000000000000000486e2f66cd5f38772164237c69d8304045ee1651823086611347565b6105438484611380565b6000808080610f6086866113b6565b9097909650945050505050565b6000610afb83836113f0565b600061054982611450565b6000610afb838361145b565b6001600160a01b038216610fba57604051634b637e8f60e11b815260006004820152602401610bbd565b6105d982600083611478565b6040516001600160a01b0383811660248301526044820183905261069091859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506116fd565b6000336105438185856112e8565b60004282111561105a57506000919050565b4282900362015180811161107857506702c68af0bb14000092915050565b62ed4e0081106110925750670de0b6b3a764000092915050565b62ebfc80670b1a2bc2ec5000006201517f19830102046702c68af0bb14000001915050919050565b50919050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038416611160576040517fe602df0500000000000000000000000000000000000000000000000000000000815260006004820152602401610bbd565b6001600160a01b0383166111a3576040517f94280d6200000000000000000000000000000000000000000000000000000000815260006004820152602401610bbd565b6001600160a01b038085166000908152600260209081526040808320938716835292905220829055801561121f57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161121691815260200190565b60405180910390a35b50505050565b60006112346201518042611eb1565b6107899042611e9e565b600061061a848484611787565b6060610549826117a4565b6001600160a01b0383811660009081526002602090815260408083209386168352929052205460001981101561121f57818110156112d9576040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024810182905260448101839052606401610bbd565b61121f8484848403600061111d565b6001600160a01b03831661131257604051634b637e8f60e11b815260006004820152602401610bbd565b6001600160a01b03821661133c5760405163ec442f0560e01b815260006004820152602401610bbd565b610690838383611478565b6040516001600160a01b03848116602483015283811660448301526064820183905261121f9186918216906323b872dd90608401610ff3565b6001600160a01b0382166113aa5760405163ec442f0560e01b815260006004820152602401610bbd565b6105d960008383611478565b60008181526002830160205260408120548190806113e5576113d885856117b1565b925060009150610b6f9050565b600192509050610b6f565b600081815260028301602052604081205480158015611416575061141484846117b1565b155b15610afb576040517f02b5668600000000000000000000000000000000000000000000000000000000815260048101849052602401610bbd565b6000610549826117bd565b60008181526002830160205260408120819055610afb83836117c7565b80156116f2576001600160a01b038084166000818152600760205260408082205493861682529020549115159115159015806114b15750815b80156114c557506001600160a01b03841615155b80156114cf575080155b1561156e576001600160a01b0384166000908152600860205260408120906114f5611225565b905060006115038383610f51565b915061151d9050826115158884611e4a565b85919061123e565b1561156657866001600160a01b03167f68f4429ffe70afd17cd51d3c12265a7698579e0dc36b7099e2f6d5263e739d398360405161155d91815260200190565b60405180910390a25b5050506116ef565b811580156115795750805b1561169d576001600160a01b0385166000908152600860205260408120906115a082610e91565b90506000805b82518110156116945760008382815181106115c3576115c3611dfb565b6020026020010151905060006115e28287610f6d90919063ffffffff16565b9050886115ef8286611e4a565b1115611621576000611601858b611e9e565b9050611619836116118385611e9e565b89919061123e565b509050611670565b61162b8683610f84565b508a6001600160a01b03167f5981e4d35a45c9e8c96ae51ca0f24127eaad820537621c89bbe1ba8b1712b61b8360405161166791815260200190565b60405180910390a25b61167a8185611e4a565b935088841061168a575050611694565b50506001016115a6565b505050506116ef565b6001600160a01b038516158015906116b3575081155b80156116c757506001600160a01b03841615155b80156116d1575080155b156116ef5760405163ea8e4eb560e01b815260040160405180910390fd5b50505b6106908383836117d3565b600080602060008451602086016000885af180611720576040513d6000823e3d81fd5b50506000513d91508115611738578060011415611745565b6001600160a01b0384163b155b1561121f576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610bbd565b6000828152600284016020526040812082905561061a8484611916565b60606000610afb83611922565b6000610afb838361197e565b6000610549825490565b6000610afb8383611996565b6001600160a01b0383166117fe5780600360008282546117f39190611e4a565b909155506118899050565b6001600160a01b0383166000908152600160205260409020548181101561186a576040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024810182905260448101839052606401610bbd565b6001600160a01b03841660009081526001602052604090209082900390555b6001600160a01b0382166118a5576003805482900390556118c4565b6001600160a01b03821660009081526001602052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161190991815260200190565b60405180910390a3505050565b6000610afb8383611a89565b60608160000180548060200260200160405190810160405280929190818152602001828054801561197257602002820191906000526020600020905b81548152602001906001019080831161195e575b50505050509050919050565b60008181526001830160205260408120541515610afb565b60008181526001830160205260408120548015611a7f5760006119ba600183611e9e565b85549091506000906119ce90600190611e9e565b9050808214611a335760008660000182815481106119ee576119ee611dfb565b9060005260206000200154905080876000018481548110611a1157611a11611dfb565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a4457611a44611ec5565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610549565b6000915050610549565b6000818152600183016020526040812054611ad057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610549565b506000610549565b602081526000825180602084015260005b81811015611b065760208186018101516040868401015201611ae9565b506000604082850101526040601f19601f83011684010191505092915050565b80356001600160a01b038116811461078e57600080fd5b60008060408385031215611b5057600080fd5b611b5983611b26565b946020939093013593505050565b8035801515811461078e57600080fd5b600080600060608486031215611b8c57600080fd5b611b9584611b26565b925060208401359150611baa60408501611b67565b90509250925092565b600060208284031215611bc557600080fd5b5035919050565b600060208284031215611bde57600080fd5b610afb82611b26565b600081518084526020840193506020830160005b82811015611c19578151865260209586019590910190600101611bfb565b5093949350505050565b602081526000610afb6020830184611be7565b600080600060608486031215611c4b57600080fd5b611c5484611b26565b9250611c6260208501611b26565b929592945050506040919091013590565b604081526000611c866040830185611be7565b828103602084015261059f8185611be7565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215611cc357600080fd5b611ccc84611b26565b9250602084013567ffffffffffffffff811115611ce857600080fd5b8401601f81018613611cf957600080fd5b803567ffffffffffffffff811115611d1357611d13611c98565b8060051b604051601f19603f830116810181811067ffffffffffffffff82111715611d4057611d40611c98565b604052918252602081840181019290810189841115611d5e57600080fd5b6020850194505b83851015611d8157843580825260209586019590935001611d65565b509450611baa9250505060408501611b67565b60008060408385031215611da757600080fd5b611db083611b26565b9150611dbe60208401611b26565b90509250929050565b600181811c90821680611ddb57607f821691505b6020821081036110ba57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215611e2357600080fd5b815160ff81168114610afb57600080fd5b634e487b7160e01b600052601160045260246000fd5b8082018082111561054957610549611e34565b808202811582820484141761054957610549611e34565b634e487b7160e01b600052601260045260246000fd5b600082611e9957611e99611e74565b500490565b8181038181111561054957610549611e34565b600082611ec057611ec0611e74565b500690565b634e487b7160e01b600052603160045260246000fdfea264697066735822122027c6bdcbc84885c1d437bbdb8280ec9c82e6b8678a55c6d6ec6bb0441bdd48ae64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000f6e98a756a40dd050dc78959f45559f98d3289d00000000000000000000000054061e18cd88d2de9af3d3d7fdf05472253b29e0000000000000000000000000486e2f66cd5f38772164237c69d8304045ee1651
-----Decoded View---------------
Arg [0] : _owner (address): 0x0F6e98A756A40dD050dC78959f45559F98d3289d
Arg [1] : _receiver (address): 0x54061E18cd88D2de9af3D3D7FDF05472253B29E0
Arg [2] : _underlying (address): 0x486E2f66cD5F38772164237C69d8304045eE1651
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000000f6e98a756a40dd050dc78959f45559f98d3289d
Arg [1] : 00000000000000000000000054061e18cd88d2de9af3d3d7fdf05472253b29e0
Arg [2] : 000000000000000000000000486e2f66cd5f38772164237c69d8304045ee1651
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.