Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 16729219 | 612 days ago | IN | 0 ETH | 0.14613444 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
SpectreAllocations
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/SignatureCheckerUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import { ITether } from "./interfaces/Tether.sol"; import { ISpectreAllocations, ProjectConfig } from "./interfaces/ISpectreAllocations.sol"; contract SpectreAllocations is OwnableUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable, ISpectreAllocations { using StringsUpgradeable for uint256; using ECDSAUpgradeable for bytes32; using SafeERC20Upgradeable for IERC20Upgradeable; IERC721Upgradeable spectreContract; IERC20 USDC; IERC20 USDT; mapping(bytes32 => ProjectConfig) private configuredProjects; mapping(bytes32 => mapping(address => uint256)) private investmentPerUser; mapping(bytes32 => bool) private projectExists; mapping(bytes32 => mapping(uint256 => address)) public tokenLock; mapping(bytes32 => bool) public refundsActiveForProject; mapping(address => bool) public partnerCollections; address public tetherContract; event EntryUpdate(bytes32 project, address investor); function initialize(address _spectre, address _tether) external initializer { __Ownable_init(); __Pausable_init(); __ReentrancyGuard_init(); spectreContract = IERC721Upgradeable(_spectre); tetherContract = _tether; USDC = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48); USDT = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7); } /** * @param projectName : bytes32 representation of the project name * @param sig : the signatures generated for the user, including the amount. * @param amount : the amount the user want to invest. Need that for accounting * and verifying the signature. * @param tokenId: the Spectre tokenId. User need to be the owner. * will also need it to verify if its a whale token. */ function addInvestmentToProject( bytes32 projectName, bytes memory sig, uint256 amount, uint256 tokenId, address gatingContract, bool useUSDT ) external whenNotPaused nonReentrant { // checks if the project exist require( projectExists[projectName], "addInvestmentToProject: project not found" ); ProjectConfig storage project = configuredProjects[projectName]; address holder; if (gatingContract == tetherContract) { holder = getHolder(tokenId); } else if (gatingContract == address(spectreContract)) { holder = msg.sender; require( spectreContract.balanceOf(holder) > 0, "addInvestmentToProject: no pass found" ); require( project.openForHolders, "addInvestmentToProject: whales only" ); } else { require( partnerCollections[gatingContract], "addInvestmentToProject: collection not partnered" ); // TODO: Add in so we check ERC165 interface to verify balance of the tokens holder = msg.sender; } if (tokenLock[projectName][tokenId] == address(0)) { tokenLock[projectName][tokenId] = holder; } else { require( tokenLock[projectName][tokenId] == holder, "addInvestmentToProject: token already invested" ); } require( project.endDate >= block.timestamp, "addInvestmentToProject: project ended" ); require(!project.paused, "addInvestmentToProject: project paused"); require( SignatureCheckerUpgradeable.isValidSignatureNow( project.signer, keccak256(abi.encodePacked(msg.sender, amount)) .toEthSignedMessageHash(), sig ), "Unauthorized" ); require( project.totalCollected + amount <= project.maxAllocations, "addInvestToProject: allocation filled" ); /* check that the amount to invest is still within the limit of the user. */ uint256 userInvestment = investmentPerUser[projectName][msg.sender]; if ( gatingContract == address(spectreContract) || gatingContract == tetherContract ) { require( userInvestment + amount <= project.maxAllocationsPerUser, "addInvestmentToProject: overallocated" ); } else { require( userInvestment + amount <= project.maxAllocationsPerNonHolder, "addInvestmentToProject: overallocated" ); } if (useUSDT) USDT.transferFrom(msg.sender, address(this), amount); else USDC.transferFrom(msg.sender, address(this), amount); investmentPerUser[projectName][holder] += amount; project.totalCollected += amount; emit EntryUpdate(projectName, holder); } function projectConfig(bytes32 project) external view returns (ProjectConfig memory) { require(projectExists[project], "projectConfig: not configured"); return configuredProjects[project]; } function invested(bytes32 project, address investor) external view returns (uint256) { require(projectExists[project], "invested: project not found"); return investmentPerUser[project][investor]; } function exists(bytes32 project) external view returns (bool) { return projectExists[project]; } function addProject( bytes32 projectName, uint256 _maxAllocations, uint256 _maxAllocationsPerUser, uint256 _maxAllocationsPerWhale, uint256 _maxAllocationsPerNonHolder, uint256 _endDate, address _signer, bool _openForHolders, bool _openForWhales, bool _openForPublic ) external onlyOwner { configuredProjects[projectName] = ProjectConfig({ maxAllocations: _maxAllocations, maxAllocationsPerUser: _maxAllocationsPerUser, maxAllocationsPerWhale: _maxAllocationsPerWhale, maxAllocationsPerNonHolder: _maxAllocationsPerNonHolder, totalCollected: 0, endDate: _endDate, signer: _signer, paused: false, openForHolders: _openForHolders, openForWhales: _openForWhales, openForPublic: _openForPublic }); projectExists[projectName] = true; } function toggleProjectOpenForHolders(bytes32 projectName) external onlyOwner { require( projectExists[projectName], "toggleProjectOpenForHolders: project not found" ); configuredProjects[projectName].openForHolders = !configuredProjects[ projectName ].openForHolders; } function toggleProjectOpenForWhales(bytes32 projectName) external onlyOwner { require( projectExists[projectName], "toggleProjectOpenForWhales: project not found" ); configuredProjects[projectName].openForWhales = !configuredProjects[ projectName ].openForWhales; } function toggleProjectOpenForPublic(bytes32 projectName) external onlyOwner { require( projectExists[projectName], "toggleProjectOpenForPublic: project not found" ); configuredProjects[projectName].openForPublic = !configuredProjects[ projectName ].openForPublic; } function editProjectMaxAllocations( bytes32 projectName, uint256 _maxAllocations ) external onlyOwner { require( projectExists[projectName], "editProjectMaxAllocations: project not found" ); configuredProjects[projectName].maxAllocations = _maxAllocations; } function editProjectMaxAllocationPerUser( bytes32 projectName, uint256 _maxAllocationsPerUser ) external onlyOwner { require( projectExists[projectName], "editProjectMaxAllocationPerUser: project not found" ); configuredProjects[projectName] .maxAllocationsPerUser = _maxAllocationsPerUser; } function editMaxAllocationPerWhale(bytes32 projectName, uint256 _amount) external onlyOwner { require( projectExists[projectName], "editProjectMaxAllocationPerWhale: project not found" ); configuredProjects[projectName].maxAllocationsPerWhale = _amount; } function editMaxAllocationsPerNonHolder( bytes32 projectName, uint256 _amount ) external onlyOwner { require( projectExists[projectName], "editMaxAllocationsPerNonHolder: project not found" ); configuredProjects[projectName].maxAllocationsPerNonHolder = _amount; } function editProjectEndDate(bytes32 projectName, uint256 _endDate) external onlyOwner { require( projectExists[projectName], "editProjectEndDate: project not found" ); configuredProjects[projectName].endDate = _endDate; } function editProjectSigner(bytes32 projectName, address _signer) external onlyOwner { require( projectExists[projectName], "editProjectSigner: project not found" ); configuredProjects[projectName].signer = _signer; } function editProjectPaused(bytes32 projectName, bool _paused) external onlyOwner { require( projectExists[projectName], "editProjectPaused: project not found" ); configuredProjects[projectName].paused = _paused; } function setSpectreAddress(address _spectre) external onlyOwner { require( _spectre != address(0), "setSpectreAddress: address can't be zero address" ); require( _spectre != address(spectreContract), "setSpectreAddress: provided address must differ from existing one" ); spectreContract = IERC721Upgradeable(_spectre); } function setTetherAddress(address _tether) external onlyOwner { require( _tether != address(0), "setTetherAddress: address can't be zero address" ); require( _tether != tetherContract, "setTetherAddress: provided address must differ from existing one" ); tetherContract = _tether; } function setUSDC(address _USDC) external onlyOwner { require(_USDC != address(0), "setUSDC: address can't be zero address"); require( _USDC != address(USDC), "setUSDC: provided address must differ from existing one" ); USDC = IERC20(_USDC); } function setUSDT(address _USDT) external onlyOwner { require(_USDT != address(0), "setUSDT: address can't be zero address"); require( _USDT != address(USDT), "setUSDT: provided address must differ from existing one" ); USDT = IERC20(_USDT); } function getHolder(uint256 tokenId) internal view returns (address) { ITether tether = ITether(tetherContract); require(tether.isActive(tokenId), "getHolder: tether not active"); require( tether.ownerOf(tokenId) == msg.sender, "getHolder: wallet not valid proxy" ); address holder = tether.links(tokenId).holder; require( spectreContract.balanceOf(holder) > 0, "getHolder: proxied wallet needs to hold a pass" ); return holder; } function withdrawUSDC(address _receiver) external onlyOwner { uint256 balance = USDC.balanceOf(address(this)); USDC.transfer(_receiver, balance); } function withdrawUSDT(address _receiver) external onlyOwner { uint256 balance = USDT.balanceOf(address(this)); USDT.transfer(_receiver, balance); } function userRefund( bytes32 projectName, uint256 tokenId, address verifyContract ) external nonReentrant { address holder; if (verifyContract == tetherContract) { holder = getHolder(tokenId); } else { holder = msg.sender; } require(refundsActiveForProject[projectName], "userRefund: not active"); uint256 amountInvested = investmentPerUser[projectName][holder]; require(amountInvested > 0, "userRefund: no investments"); investmentPerUser[projectName][holder] = 0; configuredProjects[projectName].totalCollected -= amountInvested; require( USDC.transfer(holder, amountInvested), "userRefund: transfer failed" ); } function toggleRefundsActive(bytes32 projectName) external onlyOwner { require( projectExists[projectName], "toggleRefundsActive: project not found" ); refundsActiveForProject[projectName] = !refundsActiveForProject[ projectName ]; } function addToInvestmentMapping( bytes32 projectName, address investor, uint256 amount ) external onlyOwner { require( projectExists[projectName], "addToInvestmentMapping: project not found" ); _addInvestment(projectName, investor, amount); } function removeFromInvestmentMapping( bytes32 projectName, address investor, uint256 amount ) external onlyOwner { require( projectExists[projectName], "removeFromInvestmentMapping: project not found" ); _deductInvestment(projectName, investor, amount); } function moveInvestment( bytes32 projectName, address from, address to, uint256 amount ) external onlyOwner { require( projectExists[projectName], "moveInvestment: project not found" ); _deductInvestment(projectName, from, amount); _addInvestment(projectName, to, amount); } function _addInvestment( bytes32 projectName, address investor, uint256 amount ) internal { investmentPerUser[projectName][investor] += amount; configuredProjects[projectName].totalCollected += amount; emit EntryUpdate(projectName, investor); } function _deductInvestment( bytes32 projectName, address investor, uint256 amount ) internal { investmentPerUser[projectName][investor] -= amount; configuredProjects[projectName].totalCollected -= amount; emit EntryUpdate(projectName, investor); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.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. * * By default, the owner account will be the one that deploys the contract. 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 OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @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 { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271Upgradeable { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../StringsUpgradeable.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.0; import "./ECDSAUpgradeable.sol"; import "../AddressUpgradeable.sol"; import "../../interfaces/IERC1271Upgradeable.sol"; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Gnosis Safe. * * _Available since v4.1._ */ library SignatureCheckerUpgradeable { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (address recovered, ECDSAUpgradeable.RecoverError error) = ECDSAUpgradeable.tryRecover(hash, signature); if (error == ECDSAUpgradeable.RecoverError.NoError && recovered == signer) { return true; } (bool success, bytes memory result) = signer.staticcall( abi.encodeWithSelector(IERC1271Upgradeable.isValidSignature.selector, hash, signature) ); return (success && result.length == 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271Upgradeable.isValidSignature.selector)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @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[EIP 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 v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../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. * * By default, the owner account will be the one that deploys the contract. 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; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @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 { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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 { require(newOwner != address(0), "Ownable: new owner is the zero address"); _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 v4.4.1 (interfaces/IERC1271.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; import "../Address.sol"; import "../../interfaces/IERC1271.sol"; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Gnosis Safe. * * _Available since v4.1._ */ library SignatureChecker { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); if (error == ECDSA.RecoverError.NoError && recovered == signer) { return true; } (bool success, bytes memory result) = signer.staticcall( abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature) ); return (success && result.length == 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * 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[EIP 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 v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/BitMaps.sol) pragma solidity ^0.8.0; /** * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. * Largely inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor]. */ library BitMaps { struct BitMap { mapping(uint256 => uint256) _data; } /** * @dev Returns whether the bit at `index` is set. */ function get(BitMap storage bitmap, uint256 index) internal view returns (bool) { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); return bitmap._data[bucket] & mask != 0; } /** * @dev Sets the bit at `index` to the boolean `value`. */ function setTo( BitMap storage bitmap, uint256 index, bool value ) internal { if (value) { set(bitmap, index); } else { unset(bitmap, index); } } /** * @dev Sets the bit at `index`. */ function set(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] |= mask; } /** * @dev Unsets the bit at `index`. */ function unset(BitMap storage bitmap, uint256 index) internal { uint256 bucket = index >> 8; uint256 mask = 1 << (index & 0xff); bitmap._data[bucket] &= ~mask; } }
// SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.6; /** @title Account-bound tokens * @dev See https://eips.ethereum.org/EIPS/eip-4973 * Note: the ERC-165 identifier for this interface is 0x5164cf47 */ interface IERC4973 { /// @dev This emits when ownership of any ABT changes by any mechanism. /// This event emits when ABTs are given or equipped and unequipped /// (`to` == 0). event Transfer( address indexed from, address indexed to, uint256 indexed tokenId ); /// @notice Count all ABTs assigned to an owner /// @dev ABTs assigned to the zero address are considered invalid, and this /// function throws for queries about the zero address. /// @param owner An address for whom to query the balance /// @return The number of ABTs owned by `address owner`, possibly zero function balanceOf(address owner) external view returns (uint256); /// @notice Find the address bound to an ERC4973 account-bound token /// @dev ABTs assigned to zero address are considered invalid, and queries /// about them do throw. /// @param tokenId The identifier for an ABT. /// @return The address of the owner bound to the ABT. function ownerOf(uint256 tokenId) external view returns (address); /// @notice Removes the `uint256 tokenId` from an account. At any time, an /// ABT receiver must be able to disassociate themselves from an ABT /// publicly through calling this function. After successfully executing this /// function, given the parameters for calling `function give` or /// `function take` a token must be re-equipable. /// @dev Must emit a `event Transfer` with the `address to` field pointing to /// the zero address. /// @param tokenId The identifier for an ABT. function unequip(uint256 tokenId) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; struct ProjectConfig { uint256 maxAllocations; uint256 maxAllocationsPerUser; uint256 maxAllocationsPerWhale; uint256 maxAllocationsPerNonHolder; uint256 totalCollected; uint256 endDate; address signer; bool paused; bool openForHolders; bool openForWhales; bool openForPublic; } interface ISpectreAllocations { function exists(bytes32 project) external view returns (bool); function invested(bytes32 project, address investor) external view returns (uint256); function projectConfig(bytes32 project) external view returns (ProjectConfig memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {IERC4973} from './ERC4973.sol'; import {BitMaps} from '@openzeppelin/contracts/utils/structs/BitMaps.sol'; import {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol'; import {SignatureChecker} from '@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol'; import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; import {Pausable} from '@openzeppelin/contracts/security/Pausable.sol'; import {ReentrancyGuard} from '@openzeppelin/contracts/security/ReentrancyGuard.sol'; import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; struct Link { uint64 tokenIndex; uint192 expiration; address holder; } interface ITether is IERC4973 { event Tether(address holder, address operator, uint256 tokenId); event Untether(address holder, address operator); function refresh(uint256 tokenId, uint256 validityPeriod_) external; function isActive (uint256 tokenId) external view returns (bool); function exists(address active, address passive) external view returns (bool); function tokenId(address active, address passive) external view returns (uint256); function links(uint256 tokenId) external view returns (Link memory); }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"project","type":"bytes32"},{"indexed":false,"internalType":"address","name":"investor","type":"address"}],"name":"EntryUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"bytes","name":"sig","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"gatingContract","type":"address"},{"internalType":"bool","name":"useUSDT","type":"bool"}],"name":"addInvestmentToProject","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"uint256","name":"_maxAllocations","type":"uint256"},{"internalType":"uint256","name":"_maxAllocationsPerUser","type":"uint256"},{"internalType":"uint256","name":"_maxAllocationsPerWhale","type":"uint256"},{"internalType":"uint256","name":"_maxAllocationsPerNonHolder","type":"uint256"},{"internalType":"uint256","name":"_endDate","type":"uint256"},{"internalType":"address","name":"_signer","type":"address"},{"internalType":"bool","name":"_openForHolders","type":"bool"},{"internalType":"bool","name":"_openForWhales","type":"bool"},{"internalType":"bool","name":"_openForPublic","type":"bool"}],"name":"addProject","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"address","name":"investor","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"addToInvestmentMapping","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"editMaxAllocationPerWhale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"editMaxAllocationsPerNonHolder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"uint256","name":"_endDate","type":"uint256"}],"name":"editProjectEndDate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"uint256","name":"_maxAllocationsPerUser","type":"uint256"}],"name":"editProjectMaxAllocationPerUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"uint256","name":"_maxAllocations","type":"uint256"}],"name":"editProjectMaxAllocations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"bool","name":"_paused","type":"bool"}],"name":"editProjectPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"address","name":"_signer","type":"address"}],"name":"editProjectSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"project","type":"bytes32"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spectre","type":"address"},{"internalType":"address","name":"_tether","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"project","type":"bytes32"},{"internalType":"address","name":"investor","type":"address"}],"name":"invested","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"moveInvestment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"partnerCollections","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"project","type":"bytes32"}],"name":"projectConfig","outputs":[{"components":[{"internalType":"uint256","name":"maxAllocations","type":"uint256"},{"internalType":"uint256","name":"maxAllocationsPerUser","type":"uint256"},{"internalType":"uint256","name":"maxAllocationsPerWhale","type":"uint256"},{"internalType":"uint256","name":"maxAllocationsPerNonHolder","type":"uint256"},{"internalType":"uint256","name":"totalCollected","type":"uint256"},{"internalType":"uint256","name":"endDate","type":"uint256"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"bool","name":"openForHolders","type":"bool"},{"internalType":"bool","name":"openForWhales","type":"bool"},{"internalType":"bool","name":"openForPublic","type":"bool"}],"internalType":"struct ProjectConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"refundsActiveForProject","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"address","name":"investor","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"removeFromInvestmentMapping","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spectre","type":"address"}],"name":"setSpectreAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tether","type":"address"}],"name":"setTetherAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_USDC","type":"address"}],"name":"setUSDC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_USDT","type":"address"}],"name":"setUSDT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tetherContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"}],"name":"toggleProjectOpenForHolders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"}],"name":"toggleProjectOpenForPublic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"}],"name":"toggleProjectOpenForWhales","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"}],"name":"toggleRefundsActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenLock","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"projectName","type":"bytes32"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"verifyContract","type":"address"}],"name":"userRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"withdrawUSDC","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"withdrawUSDT","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50613647806100206000396000f3fe608060405234801561001057600080fd5b50600436106102415760003560e01c8063715018a611610145578063b8a95832116100bd578063dc52e6c61161008c578063f6cdc2cf11610071578063f6cdc2cf14610528578063fa06dc881461053b578063fe07bc4a1461054e57600080fd5b8063dc52e6c614610502578063f2fde38b1461051557600080fd5b8063b8a9583214610485578063be0822e814610498578063bec30440146104cc578063c518a23c146104ef57600080fd5b806387f59419116101145780638dd59bda116100f95780638dd59bda1461043c5780639965e5f01461045f578063b3e089a21461047257600080fd5b806387f59419146104045780638da5cb5b1461041757600080fd5b8063715018a6146103b6578063743677db146103be57806375fb98b2146103d1578063784e63fa146103e457600080fd5b806338a699a4116101d857806356d875f9116101a757806359db80f81161018c57806359db80f8146103855780635c975abb146103985780636f49a7d6146103a357600080fd5b806356d875f914610351578063583af2d61461036457600080fd5b806338a699a4146102e0578063485cc9551461031857806350c1b9231461032b5780635231793d1461033e57600080fd5b806324929b571161021457806324929b571461029457806330e21482146102a757806331cc5f6c146102ba57806336653f33146102cd57600080fd5b8063047515591461024657806309dfa24f1461025b5780630ea3782b1461026e57806317cf395b14610281575b600080fd5b61025961025436600461305d565b610561565b005b61025961026936600461307a565b6106b6565b61025961027c3660046130fc565b61073f565b61025961028f3660046131ce565b611031565b6102596102a236600461305d565b61124e565b6102596102b5366004613207565b61137a565b6102596102c836600461305d565b611435565b6102596102db366004613237565b611524565b6103036102ee36600461325c565b600090815260ce602052604090205460ff1690565b60405190151581526020015b60405180910390f35b610259610326366004613275565b6115c7565b61025961033936600461305d565b611766565b61025961034c36600461307a565b611879565b61025961035f36600461307a565b61191a565b610377610372366004613237565b6119bb565b60405190815260200161030f565b61025961039336600461305d565b611a44565b60975460ff16610303565b6102596103b136600461307a565b611af4565b610259611b92565b6102596103cc36600461307a565b611ba6565b6102596103df36600461325c565b611c47565b6103f76103f236600461325c565b611cf3565b60405161030f91906132a3565b61025961041236600461325c565b611e72565b6033546001600160a01b03165b6040516001600160a01b03909116815260200161030f565b61030361044a36600461305d565b60d16020526000908152604090205460ff1681565b61025961046d36600461333f565b611f1e565b61025961048036600461305d565b611fb5565b61025961049336600461325c565b6120c8565b6104246104a636600461307a565b60cf6020908152600092835260408084209091529082529020546001600160a01b031681565b6103036104da36600461325c565b60d06020526000908152604090205460ff1681565b6102596104fd366004613377565b612174565b60d254610424906001600160a01b031681565b61025961052336600461305d565b61221c565b61025961053636600461333f565b612295565b6102596105493660046133bf565b612318565b61025961055c36600461325c565b612481565b610569612558565b6001600160a01b0381166105ea5760405162461bcd60e51b815260206004820152603060248201527f73657453706563747265416464726573733a20616464726573732063616e277460448201527f206265207a65726f20616464726573730000000000000000000000000000000060648201526084015b60405180910390fd5b60c9546001600160a01b03908116908216036106945760405162461bcd60e51b815260206004820152604160248201527f73657453706563747265416464726573733a2070726f7669646564206164647260448201527f657373206d757374206469666665722066726f6d206578697374696e67206f6e60648201527f6500000000000000000000000000000000000000000000000000000000000000608482015260a4016105e1565b60c980546001600160a01b0319166001600160a01b0392909216919091179055565b6106be612558565b600082815260ce602052604090205460ff1661072a5760405162461bcd60e51b815260206004820152602560248201527f6564697450726f6a656374456e64446174653a2070726f6a656374206e6f7420604482015264199bdd5b9960da1b60648201526084016105e1565b600091825260cc602052604090912060050155565b6107476125b2565b61074f612605565b600086815260ce602052604090205460ff166107bf5760405162461bcd60e51b815260206004820152602960248201527f616464496e766573746d656e74546f50726f6a6563743a2070726f6a656374206044820152681b9bdd08199bdd5b9960ba1b60648201526084016105e1565b600086815260cc6020526040812060d2549091906001600160a01b03908116908516036107f6576107ef8561265e565b90506109f1565b60c9546001600160a01b0390811690851603610960575060c9546040516370a0823160e01b81523360048201819052916000916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561085b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087f9190613459565b116108da5760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a206e6f207061737320604482015264199bdd5b9960da1b60648201526084016105e1565b6006820154600160a81b900460ff1661095b5760405162461bcd60e51b815260206004820152602360248201527f616464496e766573746d656e74546f50726f6a6563743a207768616c6573206f60448201527f6e6c79000000000000000000000000000000000000000000000000000000000060648201526084016105e1565b6109f1565b6001600160a01b038416600090815260d1602052604090205460ff166109ee5760405162461bcd60e51b815260206004820152603060248201527f616464496e766573746d656e74546f50726f6a6563743a20636f6c6c6563746960448201527f6f6e206e6f7420706172746e657265640000000000000000000000000000000060648201526084016105e1565b50335b600088815260cf602090815260408083208884529091529020546001600160a01b0316610a4f57600088815260cf60209081526040808320888452909152902080546001600160a01b0319166001600160a01b038316179055610ae9565b600088815260cf602090815260408083208884529091529020546001600160a01b03828116911614610ae95760405162461bcd60e51b815260206004820152602e60248201527f616464496e766573746d656e74546f50726f6a6563743a20746f6b656e20616c60448201527f726561647920696e76657374656400000000000000000000000000000000000060648201526084016105e1565b4282600501541015610b635760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a2070726f6a6563742060448201527f656e64656400000000000000000000000000000000000000000000000000000060648201526084016105e1565b6006820154600160a01b900460ff1615610be55760405162461bcd60e51b815260206004820152602660248201527f616464496e766573746d656e74546f50726f6a6563743a2070726f6a6563742060448201527f706175736564000000000000000000000000000000000000000000000000000060648201526084016105e1565b60068201546040516bffffffffffffffffffffffff193360601b16602082015260348101889052610c90916001600160a01b031690610c8a90605401604051602081830303815290604052805190602001206040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b896129ac565b610cdc5760405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a6564000000000000000000000000000000000000000060448201526064016105e1565b81546004830154610cee908890613488565b1115610d625760405162461bcd60e51b815260206004820152602560248201527f616464496e76657374546f50726f6a6563743a20616c6c6f636174696f6e206660448201527f696c6c656400000000000000000000000000000000000000000000000000000060648201526084016105e1565b600088815260cd6020908152604080832033845290915290205460c9546001600160a01b0386811691161480610da5575060d2546001600160a01b038681169116145b15610e1a576001830154610db98883613488565b1115610e155760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a206f766572616c6c6f60448201526418d85d195960da1b60648201526084016105e1565b610e85565b6003830154610e298883613488565b1115610e855760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a206f766572616c6c6f60448201526418d85d195960da1b60648201526084016105e1565b8315610f0c5760cb546040516323b872dd60e01b8152336004820152306024820152604481018990526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015610ee2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f06919061349b565b50610f89565b60ca546040516323b872dd60e01b8152336004820152306024820152604481018990526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015610f63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f87919061349b565b505b600089815260cd602090815260408083206001600160a01b038616845290915281208054899290610fbb908490613488565b9250508190555086836004016000828254610fd69190613488565b9091555050604080518a81526001600160a01b03841660208201527fe120e13cc9c899ee648a9c74336bbc9c9b02e764b3cd2c672f80c5f7445be4d4910160405180910390a15050506110296001606555565b505050505050565b611039612605565b60d2546000906001600160a01b03908116908316036110625761105b8361265e565b9050611065565b50335b600084815260d0602052604090205460ff166110c35760405162461bcd60e51b815260206004820152601660248201527f75736572526566756e643a206e6f74206163746976650000000000000000000060448201526064016105e1565b600084815260cd602090815260408083206001600160a01b0385168452909152902054806111335760405162461bcd60e51b815260206004820152601a60248201527f75736572526566756e643a206e6f20696e766573746d656e747300000000000060448201526064016105e1565b600085815260cd602090815260408083206001600160a01b0386168452825280832083905587835260cc909152812060040180548392906111759084906134b8565b909155505060ca5460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb906044016020604051808303816000875af11580156111cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f1919061349b565b61123d5760405162461bcd60e51b815260206004820152601b60248201527f75736572526566756e643a207472616e73666572206661696c6564000000000060448201526064016105e1565b50506112496001606555565b505050565b611256612558565b6001600160a01b0381166112d25760405162461bcd60e51b815260206004820152602f60248201527f736574546574686572416464726573733a20616464726573732063616e27742060448201527f6265207a65726f2061646472657373000000000000000000000000000000000060648201526084016105e1565b60d2546001600160a01b0390811690821603611358576040805162461bcd60e51b81526020600482015260248101919091527f736574546574686572416464726573733a2070726f766964656420616464726560448201527f7373206d757374206469666665722066726f6d206578697374696e67206f6e6560648201526084016105e1565b60d280546001600160a01b0319166001600160a01b0392909216919091179055565b611382612558565b600082815260ce602052604090205460ff166113ec5760405162461bcd60e51b8152602060048201526024808201527f6564697450726f6a6563745061757365643a2070726f6a656374206e6f7420666044820152631bdd5b9960e21b60648201526084016105e1565b600091825260cc60205260409091206006018054911515600160a01b027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b61143d612558565b60ca546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114aa9190613459565b60ca5460405163a9059cbb60e01b81526001600160a01b0385811660048301526024820184905292935091169063a9059cbb906044015b6020604051808303816000875af1158015611500573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611249919061349b565b61152c612558565b600082815260ce602052604090205460ff166115965760405162461bcd60e51b8152602060048201526024808201527f6564697450726f6a6563745369676e65723a2070726f6a656374206e6f7420666044820152631bdd5b9960e21b60648201526084016105e1565b600091825260cc602052604090912060060180546001600160a01b0319166001600160a01b03909216919091179055565b600054610100900460ff16158080156115e75750600054600160ff909116105b806116015750303b158015611601575060005460ff166001145b6116735760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016105e1565b6000805460ff191660011790558015611696576000805461ff0019166101001790555b61169e612b3b565b6116a6612bae565b6116ae612c21565b60c980546001600160a01b038086166001600160a01b03199283161790925560d280549285169282169290921790915560ca8054821673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4817905560cb805490911673dac17f958d2ee523a2206206994597c13d831ec71790558015611249576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a1505050565b61176e612558565b6001600160a01b0381166117d35760405162461bcd60e51b815260206004820152602660248201527f736574555344543a20616464726573732063616e2774206265207a65726f206160448201526564647265737360d01b60648201526084016105e1565b60cb546001600160a01b03908116908216036118575760405162461bcd60e51b815260206004820152603760248201527f736574555344543a2070726f76696465642061646472657373206d757374206460448201527f69666665722066726f6d206578697374696e67206f6e6500000000000000000060648201526084016105e1565b60cb80546001600160a01b0319166001600160a01b0392909216919091179055565b611881612558565b600082815260ce602052604090205460ff166119055760405162461bcd60e51b815260206004820152603260248201527f6564697450726f6a6563744d6178416c6c6f636174696f6e506572557365723a60448201527f2070726f6a656374206e6f7420666f756e64000000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912060010155565b611922612558565b600082815260ce602052604090205460ff166119a65760405162461bcd60e51b815260206004820152603360248201527f6564697450726f6a6563744d6178416c6c6f636174696f6e5065725768616c6560448201527f3a2070726f6a656374206e6f7420666f756e640000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912060020155565b600082815260ce602052604081205460ff16611a195760405162461bcd60e51b815260206004820152601b60248201527f696e7665737465643a2070726f6a656374206e6f7420666f756e64000000000060448201526064016105e1565b50600082815260cd602090815260408083206001600160a01b03851684529091529020545b92915050565b611a4c612558565b60cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611a95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab99190613459565b60cb5460405163a9059cbb60e01b81526001600160a01b0385811660048301526024820184905292935091169063a9059cbb906044016114e1565b611afc612558565b600082815260ce602052604090205460ff16611b805760405162461bcd60e51b815260206004820152602c60248201527f6564697450726f6a6563744d6178416c6c6f636174696f6e733a2070726f6a6560448201527f6374206e6f7420666f756e64000000000000000000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912055565b611b9a612558565b611ba46000612c94565b565b611bae612558565b600082815260ce602052604090205460ff16611c325760405162461bcd60e51b815260206004820152603160248201527f656469744d6178416c6c6f636174696f6e735065724e6f6e486f6c6465723a2060448201527f70726f6a656374206e6f7420666f756e6400000000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912060030155565b611c4f612558565b600081815260ce602052604090205460ff16611cc35760405162461bcd60e51b815260206004820152602d60248201527f746f67676c6550726f6a6563744f70656e466f725768616c65733a2070726f6a60448201526c1958dd081b9bdd08199bdd5b99609a1b60648201526084016105e1565b600090815260cc60205260409020600601805460ff60b01b198116600160b01b9182900460ff1615909102179055565b611d6160405180610160016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000151581526020016000151581526020016000151581526020016000151581525090565b600082815260ce602052604090205460ff16611dbf5760405162461bcd60e51b815260206004820152601d60248201527f70726f6a656374436f6e6669673a206e6f7420636f6e6669677572656400000060448201526064016105e1565b50600090815260cc6020908152604091829020825161016081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201546080820152600582015460a08201526006909101546001600160a01b03811660c083015260ff600160a01b82048116151560e0840152600160a81b820481161515610100840152600160b01b820481161515610120840152600160b81b90910416151561014082015290565b611e7a612558565b600081815260ce602052604090205460ff16611efe5760405162461bcd60e51b815260206004820152602660248201527f746f67676c65526566756e64734163746976653a2070726f6a656374206e6f7460448201527f20666f756e64000000000000000000000000000000000000000000000000000060648201526084016105e1565b600090815260d060205260409020805460ff19811660ff90911615179055565b611f26612558565b600083815260ce602052604090205460ff16611faa5760405162461bcd60e51b815260206004820152602e60248201527f72656d6f766546726f6d496e766573746d656e744d617070696e673a2070726f60448201527f6a656374206e6f7420666f756e6400000000000000000000000000000000000060648201526084016105e1565b611249838383612ce6565b611fbd612558565b6001600160a01b0381166120225760405162461bcd60e51b815260206004820152602660248201527f736574555344433a20616464726573732063616e2774206265207a65726f206160448201526564647265737360d01b60648201526084016105e1565b60ca546001600160a01b03908116908216036120a65760405162461bcd60e51b815260206004820152603760248201527f736574555344433a2070726f76696465642061646472657373206d757374206460448201527f69666665722066726f6d206578697374696e67206f6e6500000000000000000060648201526084016105e1565b60ca80546001600160a01b0319166001600160a01b0392909216919091179055565b6120d0612558565b600081815260ce602052604090205460ff166121445760405162461bcd60e51b815260206004820152602d60248201527f746f67676c6550726f6a6563744f70656e466f725075626c69633a2070726f6a60448201526c1958dd081b9bdd08199bdd5b99609a1b60648201526084016105e1565b600090815260cc60205260409020600601805460ff60b81b198116600160b81b9182900460ff1615909102179055565b61217c612558565b600084815260ce602052604090205460ff166122005760405162461bcd60e51b815260206004820152602160248201527f6d6f7665496e766573746d656e743a2070726f6a656374206e6f7420666f756e60448201527f640000000000000000000000000000000000000000000000000000000000000060648201526084016105e1565b61220b848483612ce6565b612216848383612d81565b50505050565b612224612558565b6001600160a01b0381166122895760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105e1565b61229281612c94565b50565b61229d612558565b600083815260ce602052604090205460ff1661230d5760405162461bcd60e51b815260206004820152602960248201527f616464546f496e766573746d656e744d617070696e673a2070726f6a656374206044820152681b9bdd08199bdd5b9960ba1b60648201526084016105e1565b611249838383612d81565b612320612558565b6040805161016081018252998a526020808b01998a528a820198895260608b01978852600060808c0181815260a08d019889526001600160a01b0397881660c08e0190815260e08e018381529715156101008f019081529615156101208f019081529515156101408f019081529e835260cc84528483209d518e559b516001808f01919091559a5160028e0155985160038d0155975160048c0155955160058b01559751600690990180549351925191519a51999094167fffffffffffffffffffffff00000000000000000000000000000000000000000090931692909217600160a01b91151591909102177fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff16600160a81b9115159190910260ff60b01b191617600160b01b971515979097029690961760ff60b81b1916600160b81b951515959095029490941790945560ce909252909120805460ff19169091179055565b612489612558565b600081815260ce602052604090205460ff1661250d5760405162461bcd60e51b815260206004820152602e60248201527f746f67676c6550726f6a6563744f70656e466f72486f6c646572733a2070726f60448201527f6a656374206e6f7420666f756e6400000000000000000000000000000000000060648201526084016105e1565b600090815260cc6020526040902060060180547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff8116600160a81b9182900460ff1615909102179055565b6033546001600160a01b03163314611ba45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105e1565b60975460ff1615611ba45760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016105e1565b6002606554036126575760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105e1565b6002606555565b60d2546040517f82afd23b000000000000000000000000000000000000000000000000000000008152600481018390526000916001600160a01b03169081906382afd23b90602401602060405180830381865afa1580156126c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e7919061349b565b6127335760405162461bcd60e51b815260206004820152601c60248201527f676574486f6c6465723a20746574686572206e6f74206163746976650000000060448201526064016105e1565b6040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810184905233906001600160a01b03831690636352211e90602401602060405180830381865afa158015612793573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b791906134cb565b6001600160a01b0316146128335760405162461bcd60e51b815260206004820152602160248201527f676574486f6c6465723a2077616c6c6574206e6f742076616c69642070726f7860448201527f790000000000000000000000000000000000000000000000000000000000000060648201526084016105e1565b6040517f881d8a40000000000000000000000000000000000000000000000000000000008152600481018490526000906001600160a01b0383169063881d8a4090602401606060405180830381865afa158015612894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b891906134e8565b60409081015160c95491516370a0823160e01b81526001600160a01b03808316600483015291935060009291909116906370a0823190602401602060405180830381865afa15801561290e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129329190613459565b116129a55760405162461bcd60e51b815260206004820152602e60248201527f676574486f6c6465723a2070726f786965642077616c6c6574206e656564732060448201527f746f20686f6c642061207061737300000000000000000000000000000000000060648201526084016105e1565b9392505050565b60008060006129bb8585612dd9565b909250905060008160048111156129d4576129d4613581565b1480156129f25750856001600160a01b0316826001600160a01b0316145b15612a02576001925050506129a5565b600080876001600160a01b0316631626ba7e60e01b8888604051602401612a2a9291906135bb565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051612a9591906135f5565b600060405180830381855afa9150503d8060008114612ad0576040519150601f19603f3d011682016040523d82523d6000602084013e612ad5565b606091505b5091509150818015612ae8575080516020145b8015612b28575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090612b269083016020908101908401613459565b145b98975050505050505050565b6001606555565b600054610100900460ff16612ba65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba4612e1e565b600054610100900460ff16612c195760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba4612e92565b600054610100900460ff16612c8c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba4612f09565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600083815260cd602090815260408083206001600160a01b038616845290915281208054839290612d189084906134b8565b9091555050600083815260cc602052604081206004018054839290612d3e9084906134b8565b9091555050604080518481526001600160a01b03841660208201527fe120e13cc9c899ee648a9c74336bbc9c9b02e764b3cd2c672f80c5f7445be4d49101611759565b600083815260cd602090815260408083206001600160a01b038616845290915281208054839290612db3908490613488565b9091555050600083815260cc602052604081206004018054839290612d3e908490613488565b6000808251604103612e0f5760208301516040840151606085015160001a612e0387828585612f74565b94509450505050612e17565b506000905060025b9250929050565b600054610100900460ff16612e895760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba433612c94565b600054610100900460ff16612efd5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b6097805460ff19169055565b600054610100900460ff16612b345760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612fab575060009050600361302f565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612fff573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166130285760006001925092505061302f565b9150600090505b94509492505050565b6001600160a01b038116811461229257600080fd5b803561305881613038565b919050565b60006020828403121561306f57600080fd5b81356129a581613038565b6000806040838503121561308d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156130db576130db61309c565b604052919050565b801515811461229257600080fd5b8035613058816130e3565b60008060008060008060c0878903121561311557600080fd5b8635955060208088013567ffffffffffffffff8082111561313557600080fd5b818a0191508a601f83011261314957600080fd5b81358181111561315b5761315b61309c565b61316d601f8201601f191685016130b2565b91508082528b8482850101111561318357600080fd5b808484018584013760008482840101525080975050505060408701359350606087013592506131b46080880161304d565b91506131c260a088016130f1565b90509295509295509295565b6000806000606084860312156131e357600080fd5b833592506020840135915060408401356131fc81613038565b809150509250925092565b6000806040838503121561321a57600080fd5b82359150602083013561322c816130e3565b809150509250929050565b6000806040838503121561324a57600080fd5b82359150602083013561322c81613038565b60006020828403121561326e57600080fd5b5035919050565b6000806040838503121561328857600080fd5b823561329381613038565b9150602083013561322c81613038565b600061016082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c08301516132fc60c08401826001600160a01b03169052565b5060e083015161331060e084018215159052565b506101008381015115159083015261012080840151151590830152610140928301511515929091019190915290565b60008060006060848603121561335457600080fd5b83359250602084013561336681613038565b929592945050506040919091013590565b6000806000806080858703121561338d57600080fd5b84359350602085013561339f81613038565b925060408501356133af81613038565b9396929550929360600135925050565b6000806000806000806000806000806101408b8d0312156133df57600080fd5b8a35995060208b0135985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b013561341481613038565b935060e08b0135613424816130e3565b92506101008b0135613435816130e3565b91506101208b0135613446816130e3565b809150509295989b9194979a5092959850565b60006020828403121561346b57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b80820180821115611a3e57611a3e613472565b6000602082840312156134ad57600080fd5b81516129a5816130e3565b81810381811115611a3e57611a3e613472565b6000602082840312156134dd57600080fd5b81516129a581613038565b6000606082840312156134fa57600080fd5b6040516060810167ffffffffffffffff828210818311171561351e5761351e61309c565b8160405284519150808216821461353457600080fd5b508152602083015177ffffffffffffffffffffffffffffffffffffffffffffffff8116811461356257600080fd5b6020820152604083015161357581613038565b60408201529392505050565b634e487b7160e01b600052602160045260246000fd5b60005b838110156135b257818101518382015260200161359a565b50506000910152565b82815260406020820152600082518060408401526135e0816060850160208701613597565b601f01601f1916919091016060019392505050565b60008251613607818460208701613597565b919091019291505056fea264697066735822122066a5755dd6ce1dcc33c5d78f84723d99dc8463d96caf886d2c5c2e28076cf79964736f6c63430008110033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102415760003560e01c8063715018a611610145578063b8a95832116100bd578063dc52e6c61161008c578063f6cdc2cf11610071578063f6cdc2cf14610528578063fa06dc881461053b578063fe07bc4a1461054e57600080fd5b8063dc52e6c614610502578063f2fde38b1461051557600080fd5b8063b8a9583214610485578063be0822e814610498578063bec30440146104cc578063c518a23c146104ef57600080fd5b806387f59419116101145780638dd59bda116100f95780638dd59bda1461043c5780639965e5f01461045f578063b3e089a21461047257600080fd5b806387f59419146104045780638da5cb5b1461041757600080fd5b8063715018a6146103b6578063743677db146103be57806375fb98b2146103d1578063784e63fa146103e457600080fd5b806338a699a4116101d857806356d875f9116101a757806359db80f81161018c57806359db80f8146103855780635c975abb146103985780636f49a7d6146103a357600080fd5b806356d875f914610351578063583af2d61461036457600080fd5b806338a699a4146102e0578063485cc9551461031857806350c1b9231461032b5780635231793d1461033e57600080fd5b806324929b571161021457806324929b571461029457806330e21482146102a757806331cc5f6c146102ba57806336653f33146102cd57600080fd5b8063047515591461024657806309dfa24f1461025b5780630ea3782b1461026e57806317cf395b14610281575b600080fd5b61025961025436600461305d565b610561565b005b61025961026936600461307a565b6106b6565b61025961027c3660046130fc565b61073f565b61025961028f3660046131ce565b611031565b6102596102a236600461305d565b61124e565b6102596102b5366004613207565b61137a565b6102596102c836600461305d565b611435565b6102596102db366004613237565b611524565b6103036102ee36600461325c565b600090815260ce602052604090205460ff1690565b60405190151581526020015b60405180910390f35b610259610326366004613275565b6115c7565b61025961033936600461305d565b611766565b61025961034c36600461307a565b611879565b61025961035f36600461307a565b61191a565b610377610372366004613237565b6119bb565b60405190815260200161030f565b61025961039336600461305d565b611a44565b60975460ff16610303565b6102596103b136600461307a565b611af4565b610259611b92565b6102596103cc36600461307a565b611ba6565b6102596103df36600461325c565b611c47565b6103f76103f236600461325c565b611cf3565b60405161030f91906132a3565b61025961041236600461325c565b611e72565b6033546001600160a01b03165b6040516001600160a01b03909116815260200161030f565b61030361044a36600461305d565b60d16020526000908152604090205460ff1681565b61025961046d36600461333f565b611f1e565b61025961048036600461305d565b611fb5565b61025961049336600461325c565b6120c8565b6104246104a636600461307a565b60cf6020908152600092835260408084209091529082529020546001600160a01b031681565b6103036104da36600461325c565b60d06020526000908152604090205460ff1681565b6102596104fd366004613377565b612174565b60d254610424906001600160a01b031681565b61025961052336600461305d565b61221c565b61025961053636600461333f565b612295565b6102596105493660046133bf565b612318565b61025961055c36600461325c565b612481565b610569612558565b6001600160a01b0381166105ea5760405162461bcd60e51b815260206004820152603060248201527f73657453706563747265416464726573733a20616464726573732063616e277460448201527f206265207a65726f20616464726573730000000000000000000000000000000060648201526084015b60405180910390fd5b60c9546001600160a01b03908116908216036106945760405162461bcd60e51b815260206004820152604160248201527f73657453706563747265416464726573733a2070726f7669646564206164647260448201527f657373206d757374206469666665722066726f6d206578697374696e67206f6e60648201527f6500000000000000000000000000000000000000000000000000000000000000608482015260a4016105e1565b60c980546001600160a01b0319166001600160a01b0392909216919091179055565b6106be612558565b600082815260ce602052604090205460ff1661072a5760405162461bcd60e51b815260206004820152602560248201527f6564697450726f6a656374456e64446174653a2070726f6a656374206e6f7420604482015264199bdd5b9960da1b60648201526084016105e1565b600091825260cc602052604090912060050155565b6107476125b2565b61074f612605565b600086815260ce602052604090205460ff166107bf5760405162461bcd60e51b815260206004820152602960248201527f616464496e766573746d656e74546f50726f6a6563743a2070726f6a656374206044820152681b9bdd08199bdd5b9960ba1b60648201526084016105e1565b600086815260cc6020526040812060d2549091906001600160a01b03908116908516036107f6576107ef8561265e565b90506109f1565b60c9546001600160a01b0390811690851603610960575060c9546040516370a0823160e01b81523360048201819052916000916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561085b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087f9190613459565b116108da5760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a206e6f207061737320604482015264199bdd5b9960da1b60648201526084016105e1565b6006820154600160a81b900460ff1661095b5760405162461bcd60e51b815260206004820152602360248201527f616464496e766573746d656e74546f50726f6a6563743a207768616c6573206f60448201527f6e6c79000000000000000000000000000000000000000000000000000000000060648201526084016105e1565b6109f1565b6001600160a01b038416600090815260d1602052604090205460ff166109ee5760405162461bcd60e51b815260206004820152603060248201527f616464496e766573746d656e74546f50726f6a6563743a20636f6c6c6563746960448201527f6f6e206e6f7420706172746e657265640000000000000000000000000000000060648201526084016105e1565b50335b600088815260cf602090815260408083208884529091529020546001600160a01b0316610a4f57600088815260cf60209081526040808320888452909152902080546001600160a01b0319166001600160a01b038316179055610ae9565b600088815260cf602090815260408083208884529091529020546001600160a01b03828116911614610ae95760405162461bcd60e51b815260206004820152602e60248201527f616464496e766573746d656e74546f50726f6a6563743a20746f6b656e20616c60448201527f726561647920696e76657374656400000000000000000000000000000000000060648201526084016105e1565b4282600501541015610b635760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a2070726f6a6563742060448201527f656e64656400000000000000000000000000000000000000000000000000000060648201526084016105e1565b6006820154600160a01b900460ff1615610be55760405162461bcd60e51b815260206004820152602660248201527f616464496e766573746d656e74546f50726f6a6563743a2070726f6a6563742060448201527f706175736564000000000000000000000000000000000000000000000000000060648201526084016105e1565b60068201546040516bffffffffffffffffffffffff193360601b16602082015260348101889052610c90916001600160a01b031690610c8a90605401604051602081830303815290604052805190602001206040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b896129ac565b610cdc5760405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a6564000000000000000000000000000000000000000060448201526064016105e1565b81546004830154610cee908890613488565b1115610d625760405162461bcd60e51b815260206004820152602560248201527f616464496e76657374546f50726f6a6563743a20616c6c6f636174696f6e206660448201527f696c6c656400000000000000000000000000000000000000000000000000000060648201526084016105e1565b600088815260cd6020908152604080832033845290915290205460c9546001600160a01b0386811691161480610da5575060d2546001600160a01b038681169116145b15610e1a576001830154610db98883613488565b1115610e155760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a206f766572616c6c6f60448201526418d85d195960da1b60648201526084016105e1565b610e85565b6003830154610e298883613488565b1115610e855760405162461bcd60e51b815260206004820152602560248201527f616464496e766573746d656e74546f50726f6a6563743a206f766572616c6c6f60448201526418d85d195960da1b60648201526084016105e1565b8315610f0c5760cb546040516323b872dd60e01b8152336004820152306024820152604481018990526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015610ee2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f06919061349b565b50610f89565b60ca546040516323b872dd60e01b8152336004820152306024820152604481018990526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015610f63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f87919061349b565b505b600089815260cd602090815260408083206001600160a01b038616845290915281208054899290610fbb908490613488565b9250508190555086836004016000828254610fd69190613488565b9091555050604080518a81526001600160a01b03841660208201527fe120e13cc9c899ee648a9c74336bbc9c9b02e764b3cd2c672f80c5f7445be4d4910160405180910390a15050506110296001606555565b505050505050565b611039612605565b60d2546000906001600160a01b03908116908316036110625761105b8361265e565b9050611065565b50335b600084815260d0602052604090205460ff166110c35760405162461bcd60e51b815260206004820152601660248201527f75736572526566756e643a206e6f74206163746976650000000000000000000060448201526064016105e1565b600084815260cd602090815260408083206001600160a01b0385168452909152902054806111335760405162461bcd60e51b815260206004820152601a60248201527f75736572526566756e643a206e6f20696e766573746d656e747300000000000060448201526064016105e1565b600085815260cd602090815260408083206001600160a01b0386168452825280832083905587835260cc909152812060040180548392906111759084906134b8565b909155505060ca5460405163a9059cbb60e01b81526001600160a01b038481166004830152602482018490529091169063a9059cbb906044016020604051808303816000875af11580156111cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f1919061349b565b61123d5760405162461bcd60e51b815260206004820152601b60248201527f75736572526566756e643a207472616e73666572206661696c6564000000000060448201526064016105e1565b50506112496001606555565b505050565b611256612558565b6001600160a01b0381166112d25760405162461bcd60e51b815260206004820152602f60248201527f736574546574686572416464726573733a20616464726573732063616e27742060448201527f6265207a65726f2061646472657373000000000000000000000000000000000060648201526084016105e1565b60d2546001600160a01b0390811690821603611358576040805162461bcd60e51b81526020600482015260248101919091527f736574546574686572416464726573733a2070726f766964656420616464726560448201527f7373206d757374206469666665722066726f6d206578697374696e67206f6e6560648201526084016105e1565b60d280546001600160a01b0319166001600160a01b0392909216919091179055565b611382612558565b600082815260ce602052604090205460ff166113ec5760405162461bcd60e51b8152602060048201526024808201527f6564697450726f6a6563745061757365643a2070726f6a656374206e6f7420666044820152631bdd5b9960e21b60648201526084016105e1565b600091825260cc60205260409091206006018054911515600160a01b027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b61143d612558565b60ca546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114aa9190613459565b60ca5460405163a9059cbb60e01b81526001600160a01b0385811660048301526024820184905292935091169063a9059cbb906044015b6020604051808303816000875af1158015611500573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611249919061349b565b61152c612558565b600082815260ce602052604090205460ff166115965760405162461bcd60e51b8152602060048201526024808201527f6564697450726f6a6563745369676e65723a2070726f6a656374206e6f7420666044820152631bdd5b9960e21b60648201526084016105e1565b600091825260cc602052604090912060060180546001600160a01b0319166001600160a01b03909216919091179055565b600054610100900460ff16158080156115e75750600054600160ff909116105b806116015750303b158015611601575060005460ff166001145b6116735760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016105e1565b6000805460ff191660011790558015611696576000805461ff0019166101001790555b61169e612b3b565b6116a6612bae565b6116ae612c21565b60c980546001600160a01b038086166001600160a01b03199283161790925560d280549285169282169290921790915560ca8054821673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4817905560cb805490911673dac17f958d2ee523a2206206994597c13d831ec71790558015611249576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020015b60405180910390a1505050565b61176e612558565b6001600160a01b0381166117d35760405162461bcd60e51b815260206004820152602660248201527f736574555344543a20616464726573732063616e2774206265207a65726f206160448201526564647265737360d01b60648201526084016105e1565b60cb546001600160a01b03908116908216036118575760405162461bcd60e51b815260206004820152603760248201527f736574555344543a2070726f76696465642061646472657373206d757374206460448201527f69666665722066726f6d206578697374696e67206f6e6500000000000000000060648201526084016105e1565b60cb80546001600160a01b0319166001600160a01b0392909216919091179055565b611881612558565b600082815260ce602052604090205460ff166119055760405162461bcd60e51b815260206004820152603260248201527f6564697450726f6a6563744d6178416c6c6f636174696f6e506572557365723a60448201527f2070726f6a656374206e6f7420666f756e64000000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912060010155565b611922612558565b600082815260ce602052604090205460ff166119a65760405162461bcd60e51b815260206004820152603360248201527f6564697450726f6a6563744d6178416c6c6f636174696f6e5065725768616c6560448201527f3a2070726f6a656374206e6f7420666f756e640000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912060020155565b600082815260ce602052604081205460ff16611a195760405162461bcd60e51b815260206004820152601b60248201527f696e7665737465643a2070726f6a656374206e6f7420666f756e64000000000060448201526064016105e1565b50600082815260cd602090815260408083206001600160a01b03851684529091529020545b92915050565b611a4c612558565b60cb546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611a95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab99190613459565b60cb5460405163a9059cbb60e01b81526001600160a01b0385811660048301526024820184905292935091169063a9059cbb906044016114e1565b611afc612558565b600082815260ce602052604090205460ff16611b805760405162461bcd60e51b815260206004820152602c60248201527f6564697450726f6a6563744d6178416c6c6f636174696f6e733a2070726f6a6560448201527f6374206e6f7420666f756e64000000000000000000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912055565b611b9a612558565b611ba46000612c94565b565b611bae612558565b600082815260ce602052604090205460ff16611c325760405162461bcd60e51b815260206004820152603160248201527f656469744d6178416c6c6f636174696f6e735065724e6f6e486f6c6465723a2060448201527f70726f6a656374206e6f7420666f756e6400000000000000000000000000000060648201526084016105e1565b600091825260cc602052604090912060030155565b611c4f612558565b600081815260ce602052604090205460ff16611cc35760405162461bcd60e51b815260206004820152602d60248201527f746f67676c6550726f6a6563744f70656e466f725768616c65733a2070726f6a60448201526c1958dd081b9bdd08199bdd5b99609a1b60648201526084016105e1565b600090815260cc60205260409020600601805460ff60b01b198116600160b01b9182900460ff1615909102179055565b611d6160405180610160016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000151581526020016000151581526020016000151581526020016000151581525090565b600082815260ce602052604090205460ff16611dbf5760405162461bcd60e51b815260206004820152601d60248201527f70726f6a656374436f6e6669673a206e6f7420636f6e6669677572656400000060448201526064016105e1565b50600090815260cc6020908152604091829020825161016081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201546080820152600582015460a08201526006909101546001600160a01b03811660c083015260ff600160a01b82048116151560e0840152600160a81b820481161515610100840152600160b01b820481161515610120840152600160b81b90910416151561014082015290565b611e7a612558565b600081815260ce602052604090205460ff16611efe5760405162461bcd60e51b815260206004820152602660248201527f746f67676c65526566756e64734163746976653a2070726f6a656374206e6f7460448201527f20666f756e64000000000000000000000000000000000000000000000000000060648201526084016105e1565b600090815260d060205260409020805460ff19811660ff90911615179055565b611f26612558565b600083815260ce602052604090205460ff16611faa5760405162461bcd60e51b815260206004820152602e60248201527f72656d6f766546726f6d496e766573746d656e744d617070696e673a2070726f60448201527f6a656374206e6f7420666f756e6400000000000000000000000000000000000060648201526084016105e1565b611249838383612ce6565b611fbd612558565b6001600160a01b0381166120225760405162461bcd60e51b815260206004820152602660248201527f736574555344433a20616464726573732063616e2774206265207a65726f206160448201526564647265737360d01b60648201526084016105e1565b60ca546001600160a01b03908116908216036120a65760405162461bcd60e51b815260206004820152603760248201527f736574555344433a2070726f76696465642061646472657373206d757374206460448201527f69666665722066726f6d206578697374696e67206f6e6500000000000000000060648201526084016105e1565b60ca80546001600160a01b0319166001600160a01b0392909216919091179055565b6120d0612558565b600081815260ce602052604090205460ff166121445760405162461bcd60e51b815260206004820152602d60248201527f746f67676c6550726f6a6563744f70656e466f725075626c69633a2070726f6a60448201526c1958dd081b9bdd08199bdd5b99609a1b60648201526084016105e1565b600090815260cc60205260409020600601805460ff60b81b198116600160b81b9182900460ff1615909102179055565b61217c612558565b600084815260ce602052604090205460ff166122005760405162461bcd60e51b815260206004820152602160248201527f6d6f7665496e766573746d656e743a2070726f6a656374206e6f7420666f756e60448201527f640000000000000000000000000000000000000000000000000000000000000060648201526084016105e1565b61220b848483612ce6565b612216848383612d81565b50505050565b612224612558565b6001600160a01b0381166122895760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105e1565b61229281612c94565b50565b61229d612558565b600083815260ce602052604090205460ff1661230d5760405162461bcd60e51b815260206004820152602960248201527f616464546f496e766573746d656e744d617070696e673a2070726f6a656374206044820152681b9bdd08199bdd5b9960ba1b60648201526084016105e1565b611249838383612d81565b612320612558565b6040805161016081018252998a526020808b01998a528a820198895260608b01978852600060808c0181815260a08d019889526001600160a01b0397881660c08e0190815260e08e018381529715156101008f019081529615156101208f019081529515156101408f019081529e835260cc84528483209d518e559b516001808f01919091559a5160028e0155985160038d0155975160048c0155955160058b01559751600690990180549351925191519a51999094167fffffffffffffffffffffff00000000000000000000000000000000000000000090931692909217600160a01b91151591909102177fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff16600160a81b9115159190910260ff60b01b191617600160b01b971515979097029690961760ff60b81b1916600160b81b951515959095029490941790945560ce909252909120805460ff19169091179055565b612489612558565b600081815260ce602052604090205460ff1661250d5760405162461bcd60e51b815260206004820152602e60248201527f746f67676c6550726f6a6563744f70656e466f72486f6c646572733a2070726f60448201527f6a656374206e6f7420666f756e6400000000000000000000000000000000000060648201526084016105e1565b600090815260cc6020526040902060060180547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff8116600160a81b9182900460ff1615909102179055565b6033546001600160a01b03163314611ba45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105e1565b60975460ff1615611ba45760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016105e1565b6002606554036126575760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105e1565b6002606555565b60d2546040517f82afd23b000000000000000000000000000000000000000000000000000000008152600481018390526000916001600160a01b03169081906382afd23b90602401602060405180830381865afa1580156126c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e7919061349b565b6127335760405162461bcd60e51b815260206004820152601c60248201527f676574486f6c6465723a20746574686572206e6f74206163746976650000000060448201526064016105e1565b6040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810184905233906001600160a01b03831690636352211e90602401602060405180830381865afa158015612793573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b791906134cb565b6001600160a01b0316146128335760405162461bcd60e51b815260206004820152602160248201527f676574486f6c6465723a2077616c6c6574206e6f742076616c69642070726f7860448201527f790000000000000000000000000000000000000000000000000000000000000060648201526084016105e1565b6040517f881d8a40000000000000000000000000000000000000000000000000000000008152600481018490526000906001600160a01b0383169063881d8a4090602401606060405180830381865afa158015612894573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b891906134e8565b60409081015160c95491516370a0823160e01b81526001600160a01b03808316600483015291935060009291909116906370a0823190602401602060405180830381865afa15801561290e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129329190613459565b116129a55760405162461bcd60e51b815260206004820152602e60248201527f676574486f6c6465723a2070726f786965642077616c6c6574206e656564732060448201527f746f20686f6c642061207061737300000000000000000000000000000000000060648201526084016105e1565b9392505050565b60008060006129bb8585612dd9565b909250905060008160048111156129d4576129d4613581565b1480156129f25750856001600160a01b0316826001600160a01b0316145b15612a02576001925050506129a5565b600080876001600160a01b0316631626ba7e60e01b8888604051602401612a2a9291906135bb565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051612a9591906135f5565b600060405180830381855afa9150503d8060008114612ad0576040519150601f19603f3d011682016040523d82523d6000602084013e612ad5565b606091505b5091509150818015612ae8575080516020145b8015612b28575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090612b269083016020908101908401613459565b145b98975050505050505050565b6001606555565b600054610100900460ff16612ba65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba4612e1e565b600054610100900460ff16612c195760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba4612e92565b600054610100900460ff16612c8c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba4612f09565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600083815260cd602090815260408083206001600160a01b038616845290915281208054839290612d189084906134b8565b9091555050600083815260cc602052604081206004018054839290612d3e9084906134b8565b9091555050604080518481526001600160a01b03841660208201527fe120e13cc9c899ee648a9c74336bbc9c9b02e764b3cd2c672f80c5f7445be4d49101611759565b600083815260cd602090815260408083206001600160a01b038616845290915281208054839290612db3908490613488565b9091555050600083815260cc602052604081206004018054839290612d3e908490613488565b6000808251604103612e0f5760208301516040840151606085015160001a612e0387828585612f74565b94509450505050612e17565b506000905060025b9250929050565b600054610100900460ff16612e895760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b611ba433612c94565b600054610100900460ff16612efd5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b6097805460ff19169055565b600054610100900460ff16612b345760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016105e1565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612fab575060009050600361302f565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612fff573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166130285760006001925092505061302f565b9150600090505b94509492505050565b6001600160a01b038116811461229257600080fd5b803561305881613038565b919050565b60006020828403121561306f57600080fd5b81356129a581613038565b6000806040838503121561308d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156130db576130db61309c565b604052919050565b801515811461229257600080fd5b8035613058816130e3565b60008060008060008060c0878903121561311557600080fd5b8635955060208088013567ffffffffffffffff8082111561313557600080fd5b818a0191508a601f83011261314957600080fd5b81358181111561315b5761315b61309c565b61316d601f8201601f191685016130b2565b91508082528b8482850101111561318357600080fd5b808484018584013760008482840101525080975050505060408701359350606087013592506131b46080880161304d565b91506131c260a088016130f1565b90509295509295509295565b6000806000606084860312156131e357600080fd5b833592506020840135915060408401356131fc81613038565b809150509250925092565b6000806040838503121561321a57600080fd5b82359150602083013561322c816130e3565b809150509250929050565b6000806040838503121561324a57600080fd5b82359150602083013561322c81613038565b60006020828403121561326e57600080fd5b5035919050565b6000806040838503121561328857600080fd5b823561329381613038565b9150602083013561322c81613038565b600061016082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c08301516132fc60c08401826001600160a01b03169052565b5060e083015161331060e084018215159052565b506101008381015115159083015261012080840151151590830152610140928301511515929091019190915290565b60008060006060848603121561335457600080fd5b83359250602084013561336681613038565b929592945050506040919091013590565b6000806000806080858703121561338d57600080fd5b84359350602085013561339f81613038565b925060408501356133af81613038565b9396929550929360600135925050565b6000806000806000806000806000806101408b8d0312156133df57600080fd5b8a35995060208b0135985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b013561341481613038565b935060e08b0135613424816130e3565b92506101008b0135613435816130e3565b91506101208b0135613446816130e3565b809150509295989b9194979a5092959850565b60006020828403121561346b57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b80820180821115611a3e57611a3e613472565b6000602082840312156134ad57600080fd5b81516129a5816130e3565b81810381811115611a3e57611a3e613472565b6000602082840312156134dd57600080fd5b81516129a581613038565b6000606082840312156134fa57600080fd5b6040516060810167ffffffffffffffff828210818311171561351e5761351e61309c565b8160405284519150808216821461353457600080fd5b508152602083015177ffffffffffffffffffffffffffffffffffffffffffffffff8116811461356257600080fd5b6020820152604083015161357581613038565b60408201529392505050565b634e487b7160e01b600052602160045260246000fd5b60005b838110156135b257818101518382015260200161359a565b50506000910152565b82815260406020820152600082518060408401526135e0816060850160208701613597565b601f01601f1916919091016060019392505050565b60008251613607818460208701613597565b919091019291505056fea264697066735822122066a5755dd6ce1dcc33c5d78f84723d99dc8463d96caf886d2c5c2e28076cf79964736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.