More Info
Private Name Tags
ContractCreator
Latest 8 from a total of 8 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Buy Tokens | 20756503 | 72 days ago | IN | 0.00223642 ETH | 0.00027305 | ||||
Buy Tokens | 20751299 | 73 days ago | IN | 0.00199999 ETH | 0.00032131 | ||||
Buy Tokens | 19758033 | 211 days ago | IN | 0.00999999 ETH | 0.00065766 | ||||
Buy Tokens | 18773806 | 349 days ago | IN | 0.00399999 ETH | 0.00576377 | ||||
Buy Tokens | 18485434 | 390 days ago | IN | 0.02899999 ETH | 0.0037011 | ||||
Transfer Ownersh... | 18474027 | 391 days ago | IN | 0 ETH | 0.00044137 | ||||
Add Claim Manage... | 18474020 | 391 days ago | IN | 0 ETH | 0.00075615 | ||||
0x60a06040 | 18473902 | 391 days ago | IN | 0 ETH | 0.03681411 |
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
19564251 | 238 days ago | 0.03299999 ETH |
Loading...
Loading
Contract Name:
KannaDynamicPriceSale
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 1000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; /** * * __ .__ * | | ___\|/_ ____ ____ _\|/_ _______\|/_ | | ____ * | |/ /\__ \ / \ / \\__ \ / ___/\__ \ | | _/ __ \ * | < / __ \| | \ | \/ __ \_\___ \ / __ \| |_\ ___/ * |__|_ \(____ /___| /___| (____ /____ >(____ /____/\___ > * \/ \/ \/ \/ \/ \/ \/ \/ * * @title KNN Sale for KNN Token * @author KANNA Team * @custom:github https://github.com/kanna-coin * @custom:site https://kannacoin.io * @custom:discord https://discord.kannacoin.io */ contract KannaDynamicPriceSale is Ownable, AccessControl { IERC20 public immutable knnToken; bytes32 public constant CLAIM_MANAGER_ROLE = keccak256("CLAIM_MANAGER_ROLE"); bytes32 private constant _CLAIM_TYPEHASH = keccak256("Claim(address recipient,uint256 amountInKNN,uint256 ref,uint256 nonce)"); bytes32 private constant _BUY_TYPEHASH = keccak256( "BuyTokens(address recipient, uint256 knnPriceInUSD, uint16 incrementalNonce, uint256 dueDate, uint256 amountInETH, uint256 amountInETH, uint256 nonce)" ); uint256 public constant USD_AGGREGATOR_DECIMALS = 1e8; uint256 public constant KNN_DECIMALS = 1e18; uint256 public knnLocked; mapping(address => uint256) private incrementalNonces; mapping(address => uint256) private lockNonces; mapping(uint256 => bool) private claims; mapping(uint256 => bool) private delegatedNonces; event Purchase( address indexed holder, uint256 amountInWEI, uint256 knnPriceInUSD, uint256 ethPriceInUSD, uint256 indexed amountInKNN ); event Claim(address indexed holder, uint256 indexed ref, uint256 amountInKNN); event Lock(uint256 indexed ref, uint256 amountInKNN); event Unlock(uint256 indexed ref, uint256 amountInKNN); event Withdraw(address indexed recipient, uint256 amount); constructor(address _knnToken) { require(address(_knnToken) != address(0), "Invalid token address"); knnToken = IERC20(_knnToken); } modifier positiveAmount(uint256 amount) { require(amount > 0, "Invalid amount"); _; } /** * @dev Grants `CLAIM_MANAGER_ROLE` to a `claimManager` account. * * If `claimManager` account had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have admin role. * * May emit a {RoleGranted} event. */ function addClaimManager(address claimManager) external onlyOwner { _grantRole(CLAIM_MANAGER_ROLE, claimManager); } /** * @dev Removes `CLAIM_MANAGER_ROLE` from a `claimManager` account. * * If `claimManager` had been granted `CLAIM_MANAGER_ROLE`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have admin role. * * May emit a {RoleRevoked} event. */ function removeClaimManager(address claimManager) external onlyOwner { _revokeRole(CLAIM_MANAGER_ROLE, claimManager); } /** * @dev Withdraw ETH from sold tokens */ function withdraw(address payable recipient) external onlyOwner { uint256 amount = address(this).balance; recipient.transfer(amount); emit Withdraw(recipient, amount); } /** * @dev Retrieves available supply */ function availableSupply() public view returns (uint256) { return knnToken.balanceOf(address(this)) - knnLocked; } /** * @dev Decrease Total Supply * */ function lockSupply( uint256 amountInKNN, uint256 ref ) external onlyRole(CLAIM_MANAGER_ROLE) positiveAmount(amountInKNN) { require(availableSupply() >= amountInKNN, "Insufficient supply!"); knnLocked += amountInKNN; emit Lock(ref, amountInKNN); } /** * @dev Decrease Supply Locked * */ function unlockSupply( uint256 amountInKNN, uint256 ref ) external onlyRole(CLAIM_MANAGER_ROLE) positiveAmount(amountInKNN) { require(knnLocked >= amountInKNN, "Insufficient locked supply!"); knnLocked -= amountInKNN; emit Unlock(ref, amountInKNN); } /** * @dev release claimed tokens to recipient */ function claim(address recipient, uint256 amountInKNN, uint256 ref) external onlyRole(CLAIM_MANAGER_ROLE) { require(availableSupply() >= amountInKNN, "Insufficient available supply"); _claim(recipient, amountInKNN, ref); } /** * @dev release claimed locked tokens to recipient */ function claimLocked( address recipient, uint256 amountInKNN, uint256 ref, bytes memory signature, uint256 nonce ) external positiveAmount(amountInKNN) { require(knnLocked >= amountInKNN, "Insufficient locked amount"); bytes32 signedMessage = ECDSA.toEthSignedMessageHash( keccak256(abi.encode(_CLAIM_TYPEHASH, recipient, amountInKNN, ref, nonce)) ); address signer = ECDSA.recover(signedMessage, signature); _checkRole(CLAIM_MANAGER_ROLE, signer); _claim(recipient, amountInKNN, ref); knnLocked -= amountInKNN; lockNonces[recipient] = nonce + 1; } /** * @dev Return non-sold tokens and ends sale * */ function end(address leftoverRecipient) external onlyOwner { uint256 leftover = availableSupply(); if (leftover > 0) knnToken.transfer(leftoverRecipient, leftover); } /** * @dev Allows users to buy tokens for ETH * See {tokenQuotation} for unitPrice. * * Emits a {Purchase} event. */ function buyTokens( address recipient, uint256 knnPriceInUSD, bytes memory signature, uint16 incrementalNonce, uint256 dueDate, uint256 nonce, uint256 amountInKNN ) external payable { require(block.timestamp <= dueDate, "Signature is expired"); require(delegatedNonces[nonce] == false, "Nonce already used"); require(incrementalNonce == incrementalNonces[recipient] + 1, "Invalid Nonce"); require(msg.value > USD_AGGREGATOR_DECIMALS, "Invalid amount"); require(availableSupply() >= amountInKNN, "Insufficient supply!"); bytes32 signedMessage = ECDSA.toEthSignedMessageHash( keccak256( abi.encode( _BUY_TYPEHASH, recipient, knnPriceInUSD, incrementalNonce, dueDate, msg.value, amountInKNN, nonce ) ) ); address signer = ECDSA.recover(signedMessage, signature); _checkRole(CLAIM_MANAGER_ROLE, signer); knnToken.transfer(recipient, amountInKNN); uint256 ethPriceInUSD = (knnPriceInUSD * msg.value) / amountInKNN; emit Purchase(recipient, msg.value, knnPriceInUSD, ethPriceInUSD, amountInKNN); delegatedNonces[nonce] = true; incrementalNonces[recipient]++; } function _claim(address recipient, uint256 amountInKNN, uint256 ref) internal virtual positiveAmount(amountInKNN) { require(address(recipient) != address(0), "Invalid address"); require(claims[ref] == false, "Already claimed"); knnToken.transfer(recipient, amountInKNN); claims[ref] = true; emit Claim(recipient, ref, amountInKNN); } function getNonceAndDueDate(address recipient, uint256 amountInSeconds) external view returns (uint256, uint256) { return (incrementalNonces[recipient] + 1, block.timestamp + amountInSeconds); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { 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 (last updated v4.9.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 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.9.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 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @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 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// 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.9.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) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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 256, 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 << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.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 `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @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); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_knnToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":true,"internalType":"uint256","name":"ref","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountInKNN","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ref","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountInKNN","type":"uint256"}],"name":"Lock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountInWEI","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"knnPriceInUSD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethPriceInUSD","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"amountInKNN","type":"uint256"}],"name":"Purchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ref","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountInKNN","type":"uint256"}],"name":"Unlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"CLAIM_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"KNN_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USD_AGGREGATOR_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"claimManager","type":"address"}],"name":"addClaimManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"availableSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"knnPriceInUSD","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint16","name":"incrementalNonce","type":"uint16"},{"internalType":"uint256","name":"dueDate","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"amountInKNN","type":"uint256"}],"name":"buyTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amountInKNN","type":"uint256"},{"internalType":"uint256","name":"ref","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amountInKNN","type":"uint256"},{"internalType":"uint256","name":"ref","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"claimLocked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"leftoverRecipient","type":"address"}],"name":"end","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amountInSeconds","type":"uint256"}],"name":"getNonceAndDueDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"knnLocked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"knnToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountInKNN","type":"uint256"},{"internalType":"uint256","name":"ref","type":"uint256"}],"name":"lockSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"claimManager","type":"address"}],"name":"removeClaimManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountInKNN","type":"uint256"},{"internalType":"uint256","name":"ref","type":"uint256"}],"name":"unlockSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"recipient","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a06040523480156200001157600080fd5b506040516200214c3803806200214c8339810160408190526200003491620000fc565b6200003f33620000ac565b6001600160a01b0381166200009a5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420746f6b656e20616464726573730000000000000000000000604482015260640160405180910390fd5b6001600160a01b03166080526200012e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156200010f57600080fd5b81516001600160a01b03811681146200012757600080fd5b9392505050565b608051611fe662000166600039600081816102e101528181610b2b01528181610d2601528181610de001526113520152611fe66000f3fe6080604052600436106101a15760003560e01c80638da5cb5b116100e1578063a512261c1161008a578063d547741f11610064578063d547741f146104d1578063e7f30a06146104f1578063f2fde38b14610511578063fb1d1f731461053157600080fd5b8063a512261c14610450578063c958113714610468578063cb5a011a1461049c57600080fd5b80639ec85397116100bb5780639ec85397146103ff578063a217fddf1461041f578063a4a938091461043457600080fd5b80638da5cb5b1461037b57806391d14854146103995780639e302a48146103df57600080fd5b8063497980e31161014e5780636befc466116101285780636befc4661461031b578063715018a6146103315780637ecc2b56146103465780638c4dd39d1461035b57600080fd5b8063497980e31461029c57806351cff8d9146102af57806367cff967146102cf57600080fd5b80632bc43fd91161017f5780632bc43fd91461023c5780632f2ff15d1461025c57806336568abe1461027c57600080fd5b806301ffc9a7146101a657806306892e46146101db578063248a9ca3146101fd575b600080fd5b3480156101b257600080fd5b506101c66101c1366004611af0565b610551565b60405190151581526020015b60405180910390f35b3480156101e757600080fd5b506101fb6101f6366004611b32565b6105ea565b005b34801561020957600080fd5b5061022e610218366004611b54565b6000908152600160208190526040909120015490565b6040519081526020016101d2565b34801561024857600080fd5b506101fb610257366004611b82565b610705565b34801561026857600080fd5b506101fb610277366004611bb7565b610797565b34801561028857600080fd5b506101fb610297366004611bb7565b6107c2565b6101fb6102aa366004611c8a565b61084e565b3480156102bb57600080fd5b506101fb6102ca366004611d18565b610c4d565b3480156102db57600080fd5b506103037f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101d2565b34801561032757600080fd5b5061022e60025481565b34801561033d57600080fd5b506101fb610cd5565b34801561035257600080fd5b5061022e610ce9565b34801561036757600080fd5b506101fb610376366004611d18565b610da0565b34801561038757600080fd5b506000546001600160a01b0316610303565b3480156103a557600080fd5b506101c66103b4366004611bb7565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156103eb57600080fd5b506101fb6103fa366004611d18565b610e4d565b34801561040b57600080fd5b506101fb61041a366004611b32565b610e82565b34801561042b57600080fd5b5061022e600081565b34801561044057600080fd5b5061022e670de0b6b3a764000081565b34801561045c57600080fd5b5061022e6305f5e10081565b34801561047457600080fd5b5061022e7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec81565b3480156104a857600080fd5b506104bc6104b7366004611d35565b610f89565b604080519283526020830191909152016101d2565b3480156104dd57600080fd5b506101fb6104ec366004611bb7565b610fc5565b3480156104fd57600080fd5b506101fb61050c366004611d18565b610feb565b34801561051d57600080fd5b506101fb61052c366004611d18565b61101d565b34801561053d57600080fd5b506101fb61054c366004611d61565b6110aa565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806105e457507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec6106148161122b565b826000811161065b5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064015b60405180910390fd5b83610664610ce9565b10156106b25760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e7420737570706c79210000000000000000000000006044820152606401610652565b83600260008282546106c49190611de2565b909155505060405184815283907f46d326b399b600d54f10f9cc18580fd65427ff111e1ce74350b39e244cbfbcf8906020015b60405180910390a250505050565b7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec61072f8161122b565b82610738610ce9565b10156107865760405162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e7420617661696c61626c6520737570706c790000006044820152606401610652565b610791848484611235565b50505050565b600082815260016020819052604090912001546107b38161122b565b6107bd8383611426565b505050565b6001600160a01b03811633146108405760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610652565b61084a82826114ad565b5050565b8242111561089e5760405162461bcd60e51b815260206004820152601460248201527f5369676e617475726520697320657870697265640000000000000000000000006044820152606401610652565b60008281526006602052604090205460ff16156108fd5760405162461bcd60e51b815260206004820152601260248201527f4e6f6e636520616c7265616479207573656400000000000000000000000000006044820152606401610652565b6001600160a01b038716600090815260036020526040902054610921906001611de2565b8461ffff16146109735760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964204e6f6e6365000000000000000000000000000000000000006044820152606401610652565b6305f5e10034116109b75760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b806109c0610ce9565b1015610a0e5760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e7420737570706c79210000000000000000000000006044820152606401610652565b604080517f621700adc058743ffee91d59e8b1ef25eac657196470d7f0b9e68b4b36720e8760208201526001600160a01b038916918101919091526060810187905261ffff8516608082015260a081018490523460c082015260e081018290526101008101839052600090610acb90610120015b604051602081830303815290604052805190602001207f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b90506000610ad98288611530565b9050610b057feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec82611554565b60405163a9059cbb60e01b81526001600160a01b038a81166004830152602482018590527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015610b74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b989190611df5565b50600083610ba6348b611e17565b610bb09190611e2e565b60408051348152602081018c905290810182905290915084906001600160a01b038c16907fd721454499cf9c37b757e03b9d675df451c229048129d6e2d552216a035e6a559060600160405180910390a36000858152600660209081526040808320805460ff191660011790556001600160a01b038d16835260039091528120805491610c3c83611e50565b919050555050505050505050505050565b610c556115c9565b60405147906001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610c8d573d6000803e3d6000fd5b50816001600160a01b03167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a942436482604051610cc991815260200190565b60405180910390a25050565b610cdd6115c9565b610ce76000611623565b565b6002546040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600091906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d919190611e69565b610d9b9190611e82565b905090565b610da86115c9565b6000610db2610ce9565b9050801561084a5760405163a9059cbb60e01b81526001600160a01b038381166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015610e29573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bd9190611df5565b610e556115c9565b610e7f7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec826114ad565b50565b7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec610eac8161122b565b8260008111610eee5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b836002541015610f405760405162461bcd60e51b815260206004820152601b60248201527f496e73756666696369656e74206c6f636b656420737570706c792100000000006044820152606401610652565b8360026000828254610f529190611e82565b909155505060405184815283907f7fd927f00badd96e701196d54745980497c47930f11f838a72a18bca71d3608f906020016106f7565b6001600160a01b0382166000908152600360205260408120548190610faf906001611de2565b610fb98442611de2565b915091505b9250929050565b60008281526001602081905260409091200154610fe18161122b565b6107bd83836114ad565b610ff36115c9565b610e7f7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec82611426565b6110256115c9565b6001600160a01b0381166110a15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610652565b610e7f81611623565b83600081116110ec5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b84600254101561113e5760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e74206c6f636b656420616d6f756e740000000000006044820152606401610652565b604080517f4d9350fc2b7ed087de86125695c2672496684490c4d91402d6595d49d193f8b760208201526001600160a01b03881691810191909152606081018690526080810185905260a0810183905260009061119d9060c001610a82565b905060006111ab8286611530565b90506111d77feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec82611554565b6111e2888888611235565b86600260008282546111f49190611e82565b909155506112059050846001611de2565b6001600160a01b0390981660009081526004602052604090209790975550505050505050565b610e7f8133611554565b81600081116112775760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b6001600160a01b0384166112cd5760405162461bcd60e51b815260206004820152600f60248201527f496e76616c6964206164647265737300000000000000000000000000000000006044820152606401610652565b60008281526005602052604090205460ff161561132c5760405162461bcd60e51b815260206004820152600f60248201527f416c726561647920636c61696d656400000000000000000000000000000000006044820152606401610652565b60405163a9059cbb60e01b81526001600160a01b038581166004830152602482018590527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af115801561139b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bf9190611df5565b5060008281526005602052604090819020805460ff191660011790555182906001600160a01b038616907f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf7906114189087815260200190565b60405180910390a350505050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff1661084a5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff161561084a5760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080600061153f858561168b565b9150915061154c816116cd565b509392505050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff1661084a5761158781611832565b611592836020611844565b6040516020016115a3929190611eb9565b60408051601f198184030181529082905262461bcd60e51b825261065291600401611f3a565b6000546001600160a01b03163314610ce75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610652565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008082516041036116c15760208301516040840151606085015160001a6116b587828585611a2c565b94509450505050610fbe565b50600090506002610fbe565b60008160048111156116e1576116e1611f6d565b036116e95750565b60018160048111156116fd576116fd611f6d565b0361174a5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610652565b600281600481111561175e5761175e611f6d565b036117ab5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610652565b60038160048111156117bf576117bf611f6d565b03610e7f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610652565b60606105e46001600160a01b03831660145b60606000611853836002611e17565b61185e906002611de2565b67ffffffffffffffff81111561187657611876611be7565b6040519080825280601f01601f1916602001820160405280156118a0576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106118d7576118d7611f83565b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061192257611922611f83565b60200101906001600160f81b031916908160001a9053506000611946846002611e17565b611951906001611de2565b90505b60018111156119d6577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061199257611992611f83565b1a60f81b8282815181106119a8576119a8611f83565b60200101906001600160f81b031916908160001a90535060049490941c936119cf81611f99565b9050611954565b508315611a255760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610652565b9392505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611a635750600090506003611ae7565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611ab7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611ae057600060019250925050611ae7565b9150600090505b94509492505050565b600060208284031215611b0257600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114611a2557600080fd5b60008060408385031215611b4557600080fd5b50508035926020909101359150565b600060208284031215611b6657600080fd5b5035919050565b6001600160a01b0381168114610e7f57600080fd5b600080600060608486031215611b9757600080fd5b8335611ba281611b6d565b95602085013595506040909401359392505050565b60008060408385031215611bca57600080fd5b823591506020830135611bdc81611b6d565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112611c0e57600080fd5b813567ffffffffffffffff80821115611c2957611c29611be7565b604051601f8301601f19908116603f01168101908282118183101715611c5157611c51611be7565b81604052838152866020858801011115611c6a57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600080600060e0888a031215611ca557600080fd5b8735611cb081611b6d565b965060208801359550604088013567ffffffffffffffff811115611cd357600080fd5b611cdf8a828b01611bfd565b955050606088013561ffff81168114611cf757600080fd5b9699959850939660808101359560a0820135955060c0909101359350915050565b600060208284031215611d2a57600080fd5b8135611a2581611b6d565b60008060408385031215611d4857600080fd5b8235611d5381611b6d565b946020939093013593505050565b600080600080600060a08688031215611d7957600080fd5b8535611d8481611b6d565b94506020860135935060408601359250606086013567ffffffffffffffff811115611dae57600080fd5b611dba88828901611bfd565b95989497509295608001359392505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156105e4576105e4611dcc565b600060208284031215611e0757600080fd5b81518015158114611a2557600080fd5b80820281158282048414176105e4576105e4611dcc565b600082611e4b57634e487b7160e01b600052601260045260246000fd5b500490565b600060018201611e6257611e62611dcc565b5060010190565b600060208284031215611e7b57600080fd5b5051919050565b818103818111156105e4576105e4611dcc565b60005b83811015611eb0578181015183820152602001611e98565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611ef1816017850160208801611e95565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611f2e816028840160208801611e95565b01602801949350505050565b6020815260008251806020840152611f59816040850160208701611e95565b601f01601f19169190910160400192915050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600081611fa857611fa8611dcc565b50600019019056fea2646970667358221220d4cffec4d623849d72312ced23c63208a22192e8faaf4f634ec3a0a1b002b4c164736f6c6343000815003300000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a61
Deployed Bytecode
0x6080604052600436106101a15760003560e01c80638da5cb5b116100e1578063a512261c1161008a578063d547741f11610064578063d547741f146104d1578063e7f30a06146104f1578063f2fde38b14610511578063fb1d1f731461053157600080fd5b8063a512261c14610450578063c958113714610468578063cb5a011a1461049c57600080fd5b80639ec85397116100bb5780639ec85397146103ff578063a217fddf1461041f578063a4a938091461043457600080fd5b80638da5cb5b1461037b57806391d14854146103995780639e302a48146103df57600080fd5b8063497980e31161014e5780636befc466116101285780636befc4661461031b578063715018a6146103315780637ecc2b56146103465780638c4dd39d1461035b57600080fd5b8063497980e31461029c57806351cff8d9146102af57806367cff967146102cf57600080fd5b80632bc43fd91161017f5780632bc43fd91461023c5780632f2ff15d1461025c57806336568abe1461027c57600080fd5b806301ffc9a7146101a657806306892e46146101db578063248a9ca3146101fd575b600080fd5b3480156101b257600080fd5b506101c66101c1366004611af0565b610551565b60405190151581526020015b60405180910390f35b3480156101e757600080fd5b506101fb6101f6366004611b32565b6105ea565b005b34801561020957600080fd5b5061022e610218366004611b54565b6000908152600160208190526040909120015490565b6040519081526020016101d2565b34801561024857600080fd5b506101fb610257366004611b82565b610705565b34801561026857600080fd5b506101fb610277366004611bb7565b610797565b34801561028857600080fd5b506101fb610297366004611bb7565b6107c2565b6101fb6102aa366004611c8a565b61084e565b3480156102bb57600080fd5b506101fb6102ca366004611d18565b610c4d565b3480156102db57600080fd5b506103037f00000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a6181565b6040516001600160a01b0390911681526020016101d2565b34801561032757600080fd5b5061022e60025481565b34801561033d57600080fd5b506101fb610cd5565b34801561035257600080fd5b5061022e610ce9565b34801561036757600080fd5b506101fb610376366004611d18565b610da0565b34801561038757600080fd5b506000546001600160a01b0316610303565b3480156103a557600080fd5b506101c66103b4366004611bb7565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156103eb57600080fd5b506101fb6103fa366004611d18565b610e4d565b34801561040b57600080fd5b506101fb61041a366004611b32565b610e82565b34801561042b57600080fd5b5061022e600081565b34801561044057600080fd5b5061022e670de0b6b3a764000081565b34801561045c57600080fd5b5061022e6305f5e10081565b34801561047457600080fd5b5061022e7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec81565b3480156104a857600080fd5b506104bc6104b7366004611d35565b610f89565b604080519283526020830191909152016101d2565b3480156104dd57600080fd5b506101fb6104ec366004611bb7565b610fc5565b3480156104fd57600080fd5b506101fb61050c366004611d18565b610feb565b34801561051d57600080fd5b506101fb61052c366004611d18565b61101d565b34801561053d57600080fd5b506101fb61054c366004611d61565b6110aa565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806105e457507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec6106148161122b565b826000811161065b5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064015b60405180910390fd5b83610664610ce9565b10156106b25760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e7420737570706c79210000000000000000000000006044820152606401610652565b83600260008282546106c49190611de2565b909155505060405184815283907f46d326b399b600d54f10f9cc18580fd65427ff111e1ce74350b39e244cbfbcf8906020015b60405180910390a250505050565b7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec61072f8161122b565b82610738610ce9565b10156107865760405162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e7420617661696c61626c6520737570706c790000006044820152606401610652565b610791848484611235565b50505050565b600082815260016020819052604090912001546107b38161122b565b6107bd8383611426565b505050565b6001600160a01b03811633146108405760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610652565b61084a82826114ad565b5050565b8242111561089e5760405162461bcd60e51b815260206004820152601460248201527f5369676e617475726520697320657870697265640000000000000000000000006044820152606401610652565b60008281526006602052604090205460ff16156108fd5760405162461bcd60e51b815260206004820152601260248201527f4e6f6e636520616c7265616479207573656400000000000000000000000000006044820152606401610652565b6001600160a01b038716600090815260036020526040902054610921906001611de2565b8461ffff16146109735760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964204e6f6e6365000000000000000000000000000000000000006044820152606401610652565b6305f5e10034116109b75760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b806109c0610ce9565b1015610a0e5760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e7420737570706c79210000000000000000000000006044820152606401610652565b604080517f621700adc058743ffee91d59e8b1ef25eac657196470d7f0b9e68b4b36720e8760208201526001600160a01b038916918101919091526060810187905261ffff8516608082015260a081018490523460c082015260e081018290526101008101839052600090610acb90610120015b604051602081830303815290604052805190602001207f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b90506000610ad98288611530565b9050610b057feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec82611554565b60405163a9059cbb60e01b81526001600160a01b038a81166004830152602482018590527f00000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a61169063a9059cbb906044016020604051808303816000875af1158015610b74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b989190611df5565b50600083610ba6348b611e17565b610bb09190611e2e565b60408051348152602081018c905290810182905290915084906001600160a01b038c16907fd721454499cf9c37b757e03b9d675df451c229048129d6e2d552216a035e6a559060600160405180910390a36000858152600660209081526040808320805460ff191660011790556001600160a01b038d16835260039091528120805491610c3c83611e50565b919050555050505050505050505050565b610c556115c9565b60405147906001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610c8d573d6000803e3d6000fd5b50816001600160a01b03167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a942436482604051610cc991815260200190565b60405180910390a25050565b610cdd6115c9565b610ce76000611623565b565b6002546040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600091906001600160a01b037f00000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a6116906370a0823190602401602060405180830381865afa158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d919190611e69565b610d9b9190611e82565b905090565b610da86115c9565b6000610db2610ce9565b9050801561084a5760405163a9059cbb60e01b81526001600160a01b038381166004830152602482018390527f00000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a61169063a9059cbb906044016020604051808303816000875af1158015610e29573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bd9190611df5565b610e556115c9565b610e7f7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec826114ad565b50565b7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec610eac8161122b565b8260008111610eee5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b836002541015610f405760405162461bcd60e51b815260206004820152601b60248201527f496e73756666696369656e74206c6f636b656420737570706c792100000000006044820152606401610652565b8360026000828254610f529190611e82565b909155505060405184815283907f7fd927f00badd96e701196d54745980497c47930f11f838a72a18bca71d3608f906020016106f7565b6001600160a01b0382166000908152600360205260408120548190610faf906001611de2565b610fb98442611de2565b915091505b9250929050565b60008281526001602081905260409091200154610fe18161122b565b6107bd83836114ad565b610ff36115c9565b610e7f7feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec82611426565b6110256115c9565b6001600160a01b0381166110a15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610652565b610e7f81611623565b83600081116110ec5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b84600254101561113e5760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e74206c6f636b656420616d6f756e740000000000006044820152606401610652565b604080517f4d9350fc2b7ed087de86125695c2672496684490c4d91402d6595d49d193f8b760208201526001600160a01b03881691810191909152606081018690526080810185905260a0810183905260009061119d9060c001610a82565b905060006111ab8286611530565b90506111d77feca77a5bbbcf8baa6d8f93054311a3e6672f982247f67ba40cb896ecf1992aec82611554565b6111e2888888611235565b86600260008282546111f49190611e82565b909155506112059050846001611de2565b6001600160a01b0390981660009081526004602052604090209790975550505050505050565b610e7f8133611554565b81600081116112775760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b6044820152606401610652565b6001600160a01b0384166112cd5760405162461bcd60e51b815260206004820152600f60248201527f496e76616c6964206164647265737300000000000000000000000000000000006044820152606401610652565b60008281526005602052604090205460ff161561132c5760405162461bcd60e51b815260206004820152600f60248201527f416c726561647920636c61696d656400000000000000000000000000000000006044820152606401610652565b60405163a9059cbb60e01b81526001600160a01b038581166004830152602482018590527f00000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a61169063a9059cbb906044016020604051808303816000875af115801561139b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bf9190611df5565b5060008281526005602052604090819020805460ff191660011790555182906001600160a01b038616907f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf7906114189087815260200190565b60405180910390a350505050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff1661084a5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff161561084a5760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080600061153f858561168b565b9150915061154c816116cd565b509392505050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff1661084a5761158781611832565b611592836020611844565b6040516020016115a3929190611eb9565b60408051601f198184030181529082905262461bcd60e51b825261065291600401611f3a565b6000546001600160a01b03163314610ce75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610652565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008082516041036116c15760208301516040840151606085015160001a6116b587828585611a2c565b94509450505050610fbe565b50600090506002610fbe565b60008160048111156116e1576116e1611f6d565b036116e95750565b60018160048111156116fd576116fd611f6d565b0361174a5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610652565b600281600481111561175e5761175e611f6d565b036117ab5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610652565b60038160048111156117bf576117bf611f6d565b03610e7f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610652565b60606105e46001600160a01b03831660145b60606000611853836002611e17565b61185e906002611de2565b67ffffffffffffffff81111561187657611876611be7565b6040519080825280601f01601f1916602001820160405280156118a0576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106118d7576118d7611f83565b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061192257611922611f83565b60200101906001600160f81b031916908160001a9053506000611946846002611e17565b611951906001611de2565b90505b60018111156119d6577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061199257611992611f83565b1a60f81b8282815181106119a8576119a8611f83565b60200101906001600160f81b031916908160001a90535060049490941c936119cf81611f99565b9050611954565b508315611a255760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610652565b9392505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611a635750600090506003611ae7565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611ab7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611ae057600060019250925050611ae7565b9150600090505b94509492505050565b600060208284031215611b0257600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114611a2557600080fd5b60008060408385031215611b4557600080fd5b50508035926020909101359150565b600060208284031215611b6657600080fd5b5035919050565b6001600160a01b0381168114610e7f57600080fd5b600080600060608486031215611b9757600080fd5b8335611ba281611b6d565b95602085013595506040909401359392505050565b60008060408385031215611bca57600080fd5b823591506020830135611bdc81611b6d565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112611c0e57600080fd5b813567ffffffffffffffff80821115611c2957611c29611be7565b604051601f8301601f19908116603f01168101908282118183101715611c5157611c51611be7565b81604052838152866020858801011115611c6a57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600080600080600060e0888a031215611ca557600080fd5b8735611cb081611b6d565b965060208801359550604088013567ffffffffffffffff811115611cd357600080fd5b611cdf8a828b01611bfd565b955050606088013561ffff81168114611cf757600080fd5b9699959850939660808101359560a0820135955060c0909101359350915050565b600060208284031215611d2a57600080fd5b8135611a2581611b6d565b60008060408385031215611d4857600080fd5b8235611d5381611b6d565b946020939093013593505050565b600080600080600060a08688031215611d7957600080fd5b8535611d8481611b6d565b94506020860135935060408601359250606086013567ffffffffffffffff811115611dae57600080fd5b611dba88828901611bfd565b95989497509295608001359392505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156105e4576105e4611dcc565b600060208284031215611e0757600080fd5b81518015158114611a2557600080fd5b80820281158282048414176105e4576105e4611dcc565b600082611e4b57634e487b7160e01b600052601260045260246000fd5b500490565b600060018201611e6257611e62611dcc565b5060010190565b600060208284031215611e7b57600080fd5b5051919050565b818103818111156105e4576105e4611dcc565b60005b83811015611eb0578181015183820152602001611e98565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611ef1816017850160208801611e95565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611f2e816028840160208801611e95565b01602801949350505050565b6020815260008251806020840152611f59816040850160208701611e95565b601f01601f19169190910160400192915050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600081611fa857611fa8611dcc565b50600019019056fea2646970667358221220d4cffec4d623849d72312ced23c63208a22192e8faaf4f634ec3a0a1b002b4c164736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a61
-----Decoded View---------------
Arg [0] : _knnToken (address): 0x19B67Be378a5A66C641d15aEb46f2E94974a8A61
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000019b67be378a5a66c641d15aeb46f2e94974a8a61
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | Ether (ETH) | 100.00% | $3,331.74 | 0.0142 | $47.43 |
Loading...
Loading
[ Download: CSV Export ]
[ 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.