Address Details
contract
0x7D8E73deafDBAfc98fDBe7974168cFA6d8B9AE0C
- Contract Name
- Airgrab
- Creator
- 0xee6ce2–c8cf5a at 0x0e7766–034f66
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 461 Transactions
- Transfers
- 480 Transfers
- Gas Used
- 276,127,230
- Last Balance Update
- 27158824
Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
This contract has been partially verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- Airgrab
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 10000
- EVM Version
- paris
- Verified at
- 2024-06-04T15:02:51.767785Z
contracts/governance/Airgrab.sol
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.18; import { MerkleProof } from "openzeppelin-contracts-next/contracts/utils/cryptography/MerkleProof.sol"; import { IERC20 } from "openzeppelin-contracts-next/contracts/token/ERC20/IERC20.sol"; import { SafeERC20 } from "openzeppelin-contracts-next/contracts/token/ERC20/utils/SafeERC20.sol"; import { ECDSA } from "openzeppelin-contracts-next/contracts/utils/cryptography/ECDSA.sol"; import { SignatureChecker } from "openzeppelin-contracts-next/contracts/utils/cryptography/SignatureChecker.sol"; import { Strings } from "openzeppelin-contracts-next/contracts/utils/Strings.sol"; import { ReentrancyGuard } from "openzeppelin-contracts-next/contracts/security/ReentrancyGuard.sol"; import { ILocking } from "./locking/interfaces/ILocking.sol"; /** * @title Airgrab * @author Mento Labs * @notice This contract implements a token airgrab gated by a MerkleTree and KYC using fractal. * The airgrab also forces claimers to immediately lock their tokens as veTokens for a * predetermined period. */ contract Airgrab is ReentrancyGuard { using SafeERC20 for IERC20; uint32 public constant MAX_CLIFF_PERIOD = 103; uint32 public constant MAX_SLOPE_PERIOD = 104; /** * @notice Emitted when tokens are claimed * @param claimer The account claiming the tokens * @param amount The amount of tokens being claimed * @param lockId The ID of the resulting veMento lock */ event TokensClaimed(address indexed claimer, uint256 amount, uint256 lockId); /** * @notice Emitted when tokens are drained * @param token The token addresses that was drained * @param amount The amount drained */ event TokensDrained(address indexed token, uint256 amount); /// @notice The root of the merkle tree. bytes32 public immutable root; /// @notice The Fractal Credential message signer for KYC/KYB. address public immutable fractalSigner; /// @notice The Fractal Credential maximum age in seconds uint256 public immutable fractalMaxAge; /// @notice The timestamp when the airgrab ends. uint256 public immutable endTimestamp; /// @notice The slope period that the airgrab will be locked for. uint32 public immutable slopePeriod; /// @notice The cliff period that the airgrab will be locked for. uint32 public immutable cliffPeriod; /// @notice The token in the airgrab. IERC20 public immutable token; /// @notice The locking contract for veToken. ILocking public immutable locking; /// @notice The Mento Treasury address where unclaimed tokens will be refunded to. address payable public immutable mentoTreasury; /// @notice The map of addresses that have claimed mapping(address => bool) public claimed; /** * @dev Check if the account has a valid kyc signature. * See: https://docs.developer.fractal.id/fractal-credentials-api * https://github.com/trustfractal/credentials-api-verifiers * @notice This function checks the kyc signature with the data provided. * @param account The address of the account to check. * @param proof The kyc proof for the account. * @param validUntil The kyc proof valid until timestamp. * @param approvedAt The kyc proof approved at timestamp. * @param fractalId The kyc proof fractal id. */ modifier hasValidKyc( address account, bytes memory proof, uint256 validUntil, uint256 approvedAt, string memory fractalId ) { require(block.timestamp < validUntil, "Airgrab: KYC no longer valid"); require(fractalMaxAge == 0 || block.timestamp < approvedAt + fractalMaxAge, "Airgrab: KYC not recent enough"); string memory accountString = Strings.toHexString(uint256(uint160(account)), 20); bytes32 signedMessageHash = ECDSA.toEthSignedMessageHash( abi.encodePacked( accountString, ";", fractalId, ";", Strings.toString(approvedAt), ";", Strings.toString(validUntil), ";", // ISO 3166-1 alpha-2 country codes // DRC, CUBA, GB, IRAN, DPKR, MALI, MYANMAR, SOUTH SUDAN, SYRIA, US, YEMEN "level:plus+liveness;citizenship_not:;residency_not:cd,cu,gb,ir,kp,ml,mm,ss,sy,us,ye" ) ); require(SignatureChecker.isValidSignatureNow(fractalSigner, signedMessageHash, proof), "Airgrab: Invalid KYC"); _; } /** * @dev Check if the account can claim * @notice This modifier checks if the airgrab is still active, * if the account hasn't already claimed and if it's included * in the MerkleTree. * @param account The address of the account to check. * @param amount The amount of tokens to be claimed. * @param merkleProof The merkle proof for the account. */ modifier canClaim( address account, uint256 amount, bytes32[] calldata merkleProof ) { require(block.timestamp <= endTimestamp, "Airgrab: finished"); require(!claimed[account], "Airgrab: already claimed"); bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(account, amount)))); require(MerkleProof.verify(merkleProof, root, leaf), "Airgrab: not in tree"); _; } /** * @dev Constructor for the Airgrab contract. * @notice It checks and configures all immutable params * @param root_ The root of the merkle tree. * @param fractalSigner_ The Fractal message signer for KYC/KYB. * @param fractalMaxAge_ The Fractal Credential maximum age in seconds. * @param endTimestamp_ The timestamp when the airgrab ends. * @param cliffPeriod_ The cliff period that the airgrab will be locked for. * @param slopePeriod_ The slope period that the airgrab will be locked for. * @param token_ The token address in the airgrab. * @param locking_ The locking contract for veToken. * @param mentoTreasury_ The Mento Treasury address where unclaimed tokens will be refunded to. */ constructor( bytes32 root_, address fractalSigner_, uint256 fractalMaxAge_, uint256 endTimestamp_, uint32 cliffPeriod_, uint32 slopePeriod_, address token_, address locking_, address payable mentoTreasury_ ) { require(root_ != bytes32(0), "Airgrab: invalid root"); require(fractalSigner_ != address(0), "Airgrab: invalid fractal issuer"); require(endTimestamp_ > block.timestamp, "Airgrab: invalid end timestamp"); require(cliffPeriod_ <= MAX_CLIFF_PERIOD, "Airgrab: cliff period too large"); require(slopePeriod_ <= MAX_SLOPE_PERIOD, "Airgrab: slope period too large"); require(token_ != address(0), "Airgrab: invalid token"); require(locking_ != address(0), "Airgrab: invalid locking"); require(mentoTreasury_ != address(0), "Airgrab: invalid Mento Treasury"); root = root_; fractalSigner = fractalSigner_; fractalMaxAge = fractalMaxAge_; endTimestamp = endTimestamp_; cliffPeriod = cliffPeriod_; slopePeriod = slopePeriod_; token = IERC20(token_); locking = ILocking(locking_); mentoTreasury = mentoTreasury_; require(token.approve(locking_, type(uint256).max), "Airgrab: approval failed"); } /** * @dev Allows `msg.sender` to claim `amount` tokens if the merkle proof and kyc is valid. * @notice This function can be called by anybody, but the (msg.sender, amount) pair * must be in the merkle tree, has to not have claimed yet, and must have * an associated KYC signature from Fractal. And the airgrab must not have ended. * The tokens will be locked for the cliff and slope configured at the contract level. * @param amount The amount of tokens to be claimed. * @param delegate The address of the account that gets voting power delegated * @param merkleProof The merkle proof for the account. * @param fractalProof The Fractal KYC proof for the account. * @param fractalProofValidUntil The Fractal KYC proof valid until timestamp. * @param fractalProofApprovedAt The Fractal KYC proof approved at timestamp. * @param fractalId The Fractal KYC ID. */ function claim( uint96 amount, address delegate, bytes32[] calldata merkleProof, bytes calldata fractalProof, uint256 fractalProofValidUntil, uint256 fractalProofApprovedAt, string memory fractalId ) external hasValidKyc(msg.sender, fractalProof, fractalProofValidUntil, fractalProofApprovedAt, fractalId) canClaim(msg.sender, amount, merkleProof) nonReentrant { require(token.balanceOf(address(this)) >= amount, "Airgrab: insufficient balance"); claimed[msg.sender] = true; uint256 lockId = locking.lock(msg.sender, delegate, amount, slopePeriod, cliffPeriod); emit TokensClaimed(msg.sender, amount, lockId); } /** * @dev Allows the Mento Treasury to reclaim any tokens after the airgrab has ended. * @notice This function can only be called after the airgrab has ended. * @param tokenToDrain Token is parameterized in case the contract has been sent * tokens other than the airgrab token. */ function drain(address tokenToDrain) external nonReentrant { require(block.timestamp > endTimestamp, "Airgrab: not finished"); uint256 balance = IERC20(tokenToDrain).balanceOf(address(this)); require(balance > 0, "Airgrab: nothing to drain"); IERC20(tokenToDrain).safeTransfer(mentoTreasury, balance); emit TokensDrained(tokenToDrain, balance); } }
/ILocking.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.18; /** * @title ILocking * @notice Interface for the Locking contract */ interface ILocking { /** * @notice Locks a specified amount of tokens for a given period * @param account Account for which tokens are being locked * @param delegate Address that will receive the voting power from the locked tokens * If address(0) passed, voting power will be lost * @param amount Amount of tokens to lock * @param slope Period over which the tokens will unlock * @param cliff Initial period during which tokens remain locked and do not start unlocking * @return Id for the created lock */ function lock( address account, address delegate, uint96 amount, uint32 slope, uint32 cliff ) external returns (uint256); }
/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
/Strings.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
/math/Math.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
/IERC1271.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271 { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
/cryptography/ECDSA.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/cryptography/MerkleProof.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.0; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} * * _Available since v4.7._ */ function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. * * _Available since v4.4._ */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} * * _Available since v4.7._ */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). * * _Available since v4.7._ */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details. * * _Available since v4.7._ */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the merkle tree. uint256 leavesLen = leaves.length; uint256 totalHashes = proofFlags.length; // Check proof validity. require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof"); // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { return hashes[totalHashes - 1]; } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
/cryptography/SignatureChecker.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/SignatureChecker.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; import "../Address.sol"; import "../../interfaces/IERC1271.sol"; /** * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like * Argent and Gnosis Safe. * * _Available since v4.1._ */ library SignatureChecker { /** * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`. * * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus * change through time. It could return true at block N and false at block N+1 (or the opposite). */ function isValidSignatureNow( address signer, bytes32 hash, bytes memory signature ) internal view returns (bool) { (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature); if (error == ECDSA.RecoverError.NoError && recovered == signer) { return true; } (bool success, bytes memory result) = signer.staticcall( abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature) ); return (success && result.length == 32 && abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector)); } }
/ERC20/extensions/draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
Compiler Settings
{"viaIR":true,"remappings":["celo-foundry/=lib/celo-foundry/src/","contracts/=contracts/","ds-test/=lib/celo-foundry/lib/forge-std/lib/ds-test/src/","forge-std-next/=lib/forge-std-next/src/","forge-std/=lib/celo-foundry/lib/forge-std/src/","openzeppelin-contracts-next/=lib/openzeppelin-contracts-next/","openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/","openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/","openzeppelin-solidity/=lib/openzeppelin-contracts/","safe-contracts/=lib/safe-contracts/","test/=test/"],"optimizer":{"runs":10000,"enabled":true},"metadata":{"bytecodeHash":"none"},"libraries":{},"evmVersion":"paris","compilationTarget":{"contracts/governance/Airgrab.sol":"Airgrab"}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"bytes32","name":"root_","internalType":"bytes32"},{"type":"address","name":"fractalSigner_","internalType":"address"},{"type":"uint256","name":"fractalMaxAge_","internalType":"uint256"},{"type":"uint256","name":"endTimestamp_","internalType":"uint256"},{"type":"uint32","name":"cliffPeriod_","internalType":"uint32"},{"type":"uint32","name":"slopePeriod_","internalType":"uint32"},{"type":"address","name":"token_","internalType":"address"},{"type":"address","name":"locking_","internalType":"address"},{"type":"address","name":"mentoTreasury_","internalType":"address payable"}]},{"type":"event","name":"TokensClaimed","inputs":[{"type":"address","name":"claimer","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"lockId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"TokensDrained","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"MAX_CLIFF_PERIOD","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"MAX_SLOPE_PERIOD","inputs":[]},{"type":"function","stateMutability":"nonpayable","name":"claim","inputs":[{"type":"uint96","name":"amount","internalType":"uint96"},{"type":"address","name":"delegate","internalType":"address"},{"type":"bytes32[]","name":"merkleProof","internalType":"bytes32[]"},{"type":"bytes","name":"fractalProof","internalType":"bytes"},{"type":"uint256","name":"fractalProofValidUntil","internalType":"uint256"},{"type":"uint256","name":"fractalProofApprovedAt","internalType":"uint256"},{"type":"string","name":"fractalId","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"claimed","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"cliffPeriod","inputs":[]},{"type":"function","stateMutability":"nonpayable","name":"drain","inputs":[{"type":"address","name":"tokenToDrain","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"endTimestamp","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"fractalMaxAge","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"fractalSigner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ILocking"}],"name":"locking","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address payable"}],"name":"mentoTreasury","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"root","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"slopePeriod","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"token","inputs":[]}]
Contract Creation Code
0x6101a0604081815234620004b157819062001c0f8038038091620000248286620004b6565b843961012092839181010312620004b1578251602062000046818601620004f0565b92808601519160608701516200005f6080890162000505565b6200006d60a08a0162000505565b906200007c60c08b01620004f0565b926200008b60e08c01620004f0565b6101009b8c0151996001600160a01b03808c169a929992908b8d03620004b1576000976001895582156200046d5781841615620004295742861115620003e55763ffffffff606781891611620003a1576068908916116200035d5781169a8b156200031957169a8b15620002d55715620002915760805260a05260c05260e05288528852808261014095808752604461016098808a526101809a8b528751958693849263095ea7b360e01b8452600484015260001960248401525af1918215620002855781926200023d575b505015620001fb575051936116f7958662000518873960805186818161043f0152610a6c015260a05186818161048f01526108c7015260c0518681816106970152611137015260e0518681816101340152818161053301526108f20152518581816105730152610bc2015251848181610be901526110fd01525183818160e60152610ae1015251828181610c2d015261104f0152518181816101f901526110a00152f35b606491519062461bcd60e51b82526004820152601860248201527f416972677261623a20617070726f76616c206661696c656400000000000000006044820152fd5b9091508281813d83116200027d575b620002588183620004b6565b81010312620002795751908115158203620002765750388062000157565b80fd5b5080fd5b503d6200024c565b508351903d90823e3d90fd5b885162461bcd60e51b815260048101899052601f60248201527f416972677261623a20696e76616c6964204d656e746f205472656173757279006044820152606490fd5b895162461bcd60e51b8152600481018a9052601860248201527f416972677261623a20696e76616c6964206c6f636b696e6700000000000000006044820152606490fd5b8a5162461bcd60e51b8152600481018b9052601660248201527f416972677261623a20696e76616c696420746f6b656e000000000000000000006044820152606490fd5b8a5162461bcd60e51b8152600481018b9052601f60248201527f416972677261623a20736c6f706520706572696f6420746f6f206c61726765006044820152606490fd5b8b5162461bcd60e51b8152600481018c9052601f60248201527f416972677261623a20636c69666620706572696f6420746f6f206c61726765006044820152606490fd5b8a5162461bcd60e51b8152600481018b9052601e60248201527f416972677261623a20696e76616c696420656e642074696d657374616d7000006044820152606490fd5b8a5162461bcd60e51b8152600481018b9052601f60248201527f416972677261623a20696e76616c6964206672616374616c20697373756572006044820152606490fd5b8a5162461bcd60e51b8152600481018b9052601560248201527f416972677261623a20696e76616c696420726f6f7400000000000000000000006044820152606490fd5b600080fd5b601f909101601f19168101906001600160401b03821190821017620004da57604052565b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b0382168203620004b157565b519063ffffffff82168203620004b15756fe608080604052600436101561001357600080fd5b60003560e01c9081630b219c6314611121575080632f661946146110e057806341966664146110c4578063425e705e1461107357806358ad5a8b146110225780635dff1c2a14610597578063757dc92d14610556578063a85adeab1461051b578063aad83ff2146104ff578063c884ef83146104b3578063d934bcc014610462578063ebf0c71714610427578063ece531321461010f5763fc0c546a146100b957600080fd5b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b600080fd5b3461010a5760208060031936011261010a5761012961115a565b90610132611232565b7f00000000000000000000000000000000000000000000000000000000000000004211156103e3576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff928316928282602481875afa9182156103d7576000926103a8575b5081156103645761029d906000806040519261025384610245888a8301947fa9059cbb0000000000000000000000000000000000000000000000000000000086527f000000000000000000000000000000000000000000000000000000000000000016602484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03601f198101865285611199565b604051936102608561117d565b8785527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656488860152519082895af1610296611287565b90866112b7565b8051806102d7575b847f7ca3046ca99d7152bf8cb59d68d9a4f131c6b0dadfd2307f65609db067d5259a8585604051908152a26001600055005b8184918101031261010a5782015180159081150361010a576102fa5783806102a5565b6084826040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6064836040519062461bcd60e51b82526004820152601960248201527f416972677261623a206e6f7468696e6720746f20647261696e000000000000006044820152fd5b9091508281813d83116103d0575b6103c08183611199565b8101031261010a575190846101b6565b503d6103b6565b6040513d6000823e3d90fd5b6064906040519062461bcd60e51b82526004820152601560248201527f416972677261623a206e6f742066696e697368656400000000000000000000006044820152fd5b3461010a57600060031936011261010a5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461010a57602060031936011261010a5773ffffffffffffffffffffffffffffffffffffffff6104e161115a565b166000526001602052602060ff604060002054166040519015158152f35b3461010a57600060031936011261010a57602060405160688152f35b3461010a57600060031936011261010a5760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b3461010a57600060031936011261010a57602060405163ffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461010a5760e060031936011261010a576004356bffffffffffffffffffffffff8116810361010a576024359073ffffffffffffffffffffffffffffffffffffffff8216820361010a5767ffffffffffffffff806044351161010a5736602360443501121561010a5780604435600401351161010a573660246044356004013560051b60443501011161010a5760643581811161010a573660238201121561010a5780600401359082821161010a57366024838301011161010a5760c4359083821161010a573660238301121561010a5761067f61068a9236906024816004013591016111d8565b9260243692016111d8565b90608435421015610fde577f00000000000000000000000000000000000000000000000000000000000000008015908115610fc7575b5015610f83573360405193606085019085821090821117610f5457604052602a84526040366020860137835115610f255760306020850153835160011015610f25576078602185015360295b60018111610eb15750610e6d576108eb92610850607761072d60a435611378565b610738608435611378565b946040519586926020610754818601988981519384920161120f565b8401927f3b000000000000000000000000000000000000000000000000000000000000009384602082015261079382518093602060218501910161120f565b018360218201526107ae82518093602060228501910161120f565b018260228201526107c982518093602060238501910161120f565b019060238201527f6c6576656c3a706c75732b6c6976656e6573733b636974697a656e736869705f60248201527f6e6f743a3b7265736964656e63795f6e6f743a63642c63752c67622c69722c6b60448201527f702c6d6c2c6d6d2c73732c73792c75732c7965000000000000000000000000006064820152036057810185520183611199565b6108c2603a61085f8451611378565b936040519384916108b360208401977f19457468657265756d205369676e6564204d6573736167653a0a00000000000089526108a4815180926020898901910161120f565b8401915180938684019061120f565b0103601a810184520182611199565b5190207f000000000000000000000000000000000000000000000000000000000000000061150a565b15610e29577f00000000000000000000000000000000000000000000000000000000000000004211610de55733600052600160205260ff60406000205416610da1576040805133602082019081526bffffffffffffffffffffffff84169282019290925261096681606081015b03601f198101835282611199565b51902060405160208101918252602081526109808161117d565b5190206040519061099d60206044356004013560051b0183611199565b60443560048101358352602401602083015b60246044356004013560051b60443501018210610d91575050916000925b8251841015610a685760208460051b8401015190818110600014610a575760005260205260406000205b927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610a2857600101926109cd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b9060005260205260406000206109f7565b84907f000000000000000000000000000000000000000000000000000000000000000003610d4d57610a98611232565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260208160248173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa9081156103d757600091610d1b575b506bffffffffffffffffffffffff831611610cd757336000526001602052604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff604051917f748bb5e80000000000000000000000000000000000000000000000000000000083523360048401521660248201526bffffffffffffffffffffffff8216604482015263ffffffff807f00000000000000000000000000000000000000000000000000000000000000001660648301527f000000000000000000000000000000000000000000000000000000000000000016608482015260208160a481600073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af19081156103d757600091610ca5575b506bffffffffffffffffffffffff6040519216825260208201527f9923b4306c6c030f2bdfbf156517d5983b87e15b96176da122cd4f2effa4ba7b60403392a26001600055005b90506020813d602011610ccf575b81610cc060209383611199565b8101031261010a575182610c5e565b3d9150610cb3565b606460405162461bcd60e51b815260206004820152601d60248201527f416972677261623a20696e73756666696369656e742062616c616e63650000006044820152fd5b90506020813d602011610d45575b81610d3660209383611199565b8101031261010a575183610b12565b3d9150610d29565b606460405162461bcd60e51b815260206004820152601460248201527f416972677261623a206e6f7420696e20747265650000000000000000000000006044820152fd5b81358152602091820191016109af565b606460405162461bcd60e51b815260206004820152601860248201527f416972677261623a20616c726561647920636c61696d656400000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601160248201527f416972677261623a2066696e69736865640000000000000000000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601460248201527f416972677261623a20496e76616c6964204b59430000000000000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b906010600f82161015610f25578451821015610f25577f3031323334353637383961626364656600000000000000000000000000000000600f82161a6020838701015360041c908015610a28577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0161070c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b606460405162461bcd60e51b815260206004820152601e60248201527f416972677261623a204b5943206e6f7420726563656e7420656e6f75676800006044820152fd5b905060a435908101809111610a28574210866106c0565b606460405162461bcd60e51b815260206004820152601c60248201527f416972677261623a204b5943206e6f206c6f6e6765722076616c6964000000006044820152fd5b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461010a57600060031936011261010a57602060405160678152f35b3461010a57600060031936011261010a57602060405163ffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461010a57600060031936011261010a576020907f00000000000000000000000000000000000000000000000000000000000000008152f35b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361010a57565b6040810190811067ffffffffffffffff821117610f5457604052565b90601f601f19910116810190811067ffffffffffffffff821117610f5457604052565b67ffffffffffffffff8111610f5457601f01601f191660200190565b9291926111e4826111bc565b916111f26040519384611199565b82948184528183011161010a578281602093846000960137010152565b60005b8381106112225750506000910152565b8181015183820152602001611212565b600260005414611243576002600055565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b3d156112b2573d90611298826111bc565b916112a66040519384611199565b82523d6000602084013e565b606090565b9192901561131857508151156112cb575090565b3b156112d45790565b606460405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b82519091501561132b5750805190602001fd5b61134f9060405191829162461bcd60e51b8352602060048401526024830190611353565b0390fd5b90601f19601f6020936113718151809281875287808801910161120f565b0116010190565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000808210156114fc575b506d04ee2d6d415b85acef8100000000808310156114ed575b50662386f26fc10000808310156114de575b506305f5e100808310156114cf575b50612710808310156114c0575b5060648210156114b0575b600a809210156114a6575b60019081602181860195601f1961142d611417896111bc565b986114256040519a8b611199565b808a526111bc565b01366020890137860101905b611445575b5050505090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff849101917f30313233343536373839616263646566000000000000000000000000000000008282061a8353049182156114a157919082611439565b61143e565b91600101916113fe565b91906064600291049101916113f3565b600491939204910191386113e8565b600891939204910191386113db565b601091939204910191386113cc565b602091939204910191386113ba565b6040935081049150386113a1565b90916115168184611616565b60058110156115e7571590816115c4575b506115bc57600091829160405161157b8161095860208201947f1626ba7e00000000000000000000000000000000000000000000000000000000998a87526024840152604060448401526064830190611353565b51915afa90611588611287565b826115b0575b8261159857505090565b90915060208180518101031261010a57602001511490565b8051602014925061158e565b505050600190565b905073ffffffffffffffffffffffffffffffffffffffff80841691161438611527565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b90604181511460001461164457611640916020820151906060604084015193015160001a9061164e565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116116de5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156116d157815173ffffffffffffffffffffffffffffffffffffffff8116156116cb579190565b50600190565b50604051903d90823e3d90fd5b5050505060009060039056fea164736f6c6343000812000a1c598bb5ad0b99c0f07235c1bd7327884bf9a74c9454c3d2a937fbe8336d071b000000000000000000000000acd08d6714adba531beff582e6fd5da1afd6bc650000000000000000000000000000000000000000000000000000000000ed4e000000000000000000000000000000000000000000000000000000000066b65abd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000680000000000000000000000007ff62f59e3e89ea34163ea1458eebcc81177cfb6000000000000000000000000001bb66636dcd149a1a2ba8c50e408bddd80279c000000000000000000000000890db8a597940165901372dd7db61c9f246e2147
Deployed ByteCode
0x608080604052600436101561001357600080fd5b60003560e01c9081630b219c6314611121575080632f661946146110e057806341966664146110c4578063425e705e1461107357806358ad5a8b146110225780635dff1c2a14610597578063757dc92d14610556578063a85adeab1461051b578063aad83ff2146104ff578063c884ef83146104b3578063d934bcc014610462578063ebf0c71714610427578063ece531321461010f5763fc0c546a146100b957600080fd5b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000007ff62f59e3e89ea34163ea1458eebcc81177cfb6168152f35b600080fd5b3461010a5760208060031936011261010a5761012961115a565b90610132611232565b7f0000000000000000000000000000000000000000000000000000000066b65abd4211156103e3576040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff928316928282602481875afa9182156103d7576000926103a8575b5081156103645761029d906000806040519261025384610245888a8301947fa9059cbb0000000000000000000000000000000000000000000000000000000086527f000000000000000000000000890db8a597940165901372dd7db61c9f246e214716602484016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03601f198101865285611199565b604051936102608561117d565b8785527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656488860152519082895af1610296611287565b90866112b7565b8051806102d7575b847f7ca3046ca99d7152bf8cb59d68d9a4f131c6b0dadfd2307f65609db067d5259a8585604051908152a26001600055005b8184918101031261010a5782015180159081150361010a576102fa5783806102a5565b6084826040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6064836040519062461bcd60e51b82526004820152601960248201527f416972677261623a206e6f7468696e6720746f20647261696e000000000000006044820152fd5b9091508281813d83116103d0575b6103c08183611199565b8101031261010a575190846101b6565b503d6103b6565b6040513d6000823e3d90fd5b6064906040519062461bcd60e51b82526004820152601560248201527f416972677261623a206e6f742066696e697368656400000000000000000000006044820152fd5b3461010a57600060031936011261010a5760206040517f1c598bb5ad0b99c0f07235c1bd7327884bf9a74c9454c3d2a937fbe8336d071b8152f35b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000acd08d6714adba531beff582e6fd5da1afd6bc65168152f35b3461010a57602060031936011261010a5773ffffffffffffffffffffffffffffffffffffffff6104e161115a565b166000526001602052602060ff604060002054166040519015158152f35b3461010a57600060031936011261010a57602060405160688152f35b3461010a57600060031936011261010a5760206040517f0000000000000000000000000000000000000000000000000000000066b65abd8152f35b3461010a57600060031936011261010a57602060405163ffffffff7f0000000000000000000000000000000000000000000000000000000000000068168152f35b3461010a5760e060031936011261010a576004356bffffffffffffffffffffffff8116810361010a576024359073ffffffffffffffffffffffffffffffffffffffff8216820361010a5767ffffffffffffffff806044351161010a5736602360443501121561010a5780604435600401351161010a573660246044356004013560051b60443501011161010a5760643581811161010a573660238201121561010a5780600401359082821161010a57366024838301011161010a5760c4359083821161010a573660238301121561010a5761067f61068a9236906024816004013591016111d8565b9260243692016111d8565b90608435421015610fde577f0000000000000000000000000000000000000000000000000000000000ed4e008015908115610fc7575b5015610f83573360405193606085019085821090821117610f5457604052602a84526040366020860137835115610f255760306020850153835160011015610f25576078602185015360295b60018111610eb15750610e6d576108eb92610850607761072d60a435611378565b610738608435611378565b946040519586926020610754818601988981519384920161120f565b8401927f3b000000000000000000000000000000000000000000000000000000000000009384602082015261079382518093602060218501910161120f565b018360218201526107ae82518093602060228501910161120f565b018260228201526107c982518093602060238501910161120f565b019060238201527f6c6576656c3a706c75732b6c6976656e6573733b636974697a656e736869705f60248201527f6e6f743a3b7265736964656e63795f6e6f743a63642c63752c67622c69722c6b60448201527f702c6d6c2c6d6d2c73732c73792c75732c7965000000000000000000000000006064820152036057810185520183611199565b6108c2603a61085f8451611378565b936040519384916108b360208401977f19457468657265756d205369676e6564204d6573736167653a0a00000000000089526108a4815180926020898901910161120f565b8401915180938684019061120f565b0103601a810184520182611199565b5190207f000000000000000000000000acd08d6714adba531beff582e6fd5da1afd6bc6561150a565b15610e29577f0000000000000000000000000000000000000000000000000000000066b65abd4211610de55733600052600160205260ff60406000205416610da1576040805133602082019081526bffffffffffffffffffffffff84169282019290925261096681606081015b03601f198101835282611199565b51902060405160208101918252602081526109808161117d565b5190206040519061099d60206044356004013560051b0183611199565b60443560048101358352602401602083015b60246044356004013560051b60443501018210610d91575050916000925b8251841015610a685760208460051b8401015190818110600014610a575760005260205260406000205b927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610a2857600101926109cd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b9060005260205260406000206109f7565b84907f1c598bb5ad0b99c0f07235c1bd7327884bf9a74c9454c3d2a937fbe8336d071b03610d4d57610a98611232565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260208160248173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000007ff62f59e3e89ea34163ea1458eebcc81177cfb6165afa9081156103d757600091610d1b575b506bffffffffffffffffffffffff831611610cd757336000526001602052604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff604051917f748bb5e80000000000000000000000000000000000000000000000000000000083523360048401521660248201526bffffffffffffffffffffffff8216604482015263ffffffff807f00000000000000000000000000000000000000000000000000000000000000681660648301527f000000000000000000000000000000000000000000000000000000000000000016608482015260208160a481600073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000001bb66636dcd149a1a2ba8c50e408bddd80279c165af19081156103d757600091610ca5575b506bffffffffffffffffffffffff6040519216825260208201527f9923b4306c6c030f2bdfbf156517d5983b87e15b96176da122cd4f2effa4ba7b60403392a26001600055005b90506020813d602011610ccf575b81610cc060209383611199565b8101031261010a575182610c5e565b3d9150610cb3565b606460405162461bcd60e51b815260206004820152601d60248201527f416972677261623a20696e73756666696369656e742062616c616e63650000006044820152fd5b90506020813d602011610d45575b81610d3660209383611199565b8101031261010a575183610b12565b3d9150610d29565b606460405162461bcd60e51b815260206004820152601460248201527f416972677261623a206e6f7420696e20747265650000000000000000000000006044820152fd5b81358152602091820191016109af565b606460405162461bcd60e51b815260206004820152601860248201527f416972677261623a20616c726561647920636c61696d656400000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601160248201527f416972677261623a2066696e69736865640000000000000000000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152601460248201527f416972677261623a20496e76616c6964204b59430000000000000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b906010600f82161015610f25578451821015610f25577f3031323334353637383961626364656600000000000000000000000000000000600f82161a6020838701015360041c908015610a28577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0161070c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b606460405162461bcd60e51b815260206004820152601e60248201527f416972677261623a204b5943206e6f7420726563656e7420656e6f75676800006044820152fd5b905060a435908101809111610a28574210866106c0565b606460405162461bcd60e51b815260206004820152601c60248201527f416972677261623a204b5943206e6f206c6f6e6765722076616c6964000000006044820152fd5b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000001bb66636dcd149a1a2ba8c50e408bddd80279c168152f35b3461010a57600060031936011261010a57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000890db8a597940165901372dd7db61c9f246e2147168152f35b3461010a57600060031936011261010a57602060405160678152f35b3461010a57600060031936011261010a57602060405163ffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461010a57600060031936011261010a576020907f0000000000000000000000000000000000000000000000000000000000ed4e008152f35b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361010a57565b6040810190811067ffffffffffffffff821117610f5457604052565b90601f601f19910116810190811067ffffffffffffffff821117610f5457604052565b67ffffffffffffffff8111610f5457601f01601f191660200190565b9291926111e4826111bc565b916111f26040519384611199565b82948184528183011161010a578281602093846000960137010152565b60005b8381106112225750506000910152565b8181015183820152602001611212565b600260005414611243576002600055565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b3d156112b2573d90611298826111bc565b916112a66040519384611199565b82523d6000602084013e565b606090565b9192901561131857508151156112cb575090565b3b156112d45790565b606460405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b82519091501561132b5750805190602001fd5b61134f9060405191829162461bcd60e51b8352602060048401526024830190611353565b0390fd5b90601f19601f6020936113718151809281875287808801910161120f565b0116010190565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000808210156114fc575b506d04ee2d6d415b85acef8100000000808310156114ed575b50662386f26fc10000808310156114de575b506305f5e100808310156114cf575b50612710808310156114c0575b5060648210156114b0575b600a809210156114a6575b60019081602181860195601f1961142d611417896111bc565b986114256040519a8b611199565b808a526111bc565b01366020890137860101905b611445575b5050505090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff849101917f30313233343536373839616263646566000000000000000000000000000000008282061a8353049182156114a157919082611439565b61143e565b91600101916113fe565b91906064600291049101916113f3565b600491939204910191386113e8565b600891939204910191386113db565b601091939204910191386113cc565b602091939204910191386113ba565b6040935081049150386113a1565b90916115168184611616565b60058110156115e7571590816115c4575b506115bc57600091829160405161157b8161095860208201947f1626ba7e00000000000000000000000000000000000000000000000000000000998a87526024840152604060448401526064830190611353565b51915afa90611588611287565b826115b0575b8261159857505090565b90915060208180518101031261010a57602001511490565b8051602014925061158e565b505050600190565b905073ffffffffffffffffffffffffffffffffffffffff80841691161438611527565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b90604181511460001461164457611640916020820151906060604084015193015160001a9061164e565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116116de5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156116d157815173ffffffffffffffffffffffffffffffffffffffff8116156116cb579190565b50600190565b50604051903d90823e3d90fd5b5050505060009060039056fea164736f6c6343000812000a