Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60e06040 | 16962341 | 479 days ago | IN | Create: SegmentManagement | 0 ETH | 0.08927197 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
SegmentManagement
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 10 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol"; import "./Auth.sol"; import "./Constants.sol"; import "./VaultFactory.sol"; import "./interfaces/ISegmentManagement.sol"; pragma solidity 0.8.17; contract SegmentManagement is Auth, VaultFactory, ReentrancyGuardUpgradeable, UUPSUpgradeable, ISegmentManagement { IgNFT public immutable gNFT; IComptroller public immutable TONPOUND_COMPTROLLER; uint256 private _totalInactiveSegments; bytes32 private _airdropMerkleRoot; mapping(bytes32 => bool) private _discountUsed; function initialize(address vault_, address manager_, address pauser_) external initializer { if (vault_ == address(0)) revert ZeroAddress(); __Auth_init(manager_, pauser_); __VaultFactory_init(vault_); __UUPSUpgradeable_init(); } function mint(address[] memory markets) external whenNotPaused nonReentrant { _checkLiquidity(markets, IgNFT.TokenType.Topaz); _mintInternal(msg.sender, IgNFT.TokenType.Topaz, 0, 0); } function mint( address[] memory markets, IgNFT.TokenType tokenType, uint256[] calldata proofIds ) external whenNotPaused nonReentrant { _checkTokenType(tokenType, proofIds); _checkLiquidity(markets, tokenType); _mintInternal(msg.sender, tokenType, 0, 0); } function _mintInternal( address to, IgNFT.TokenType tokenType, uint48 completionTimestamp, uint8 segments ) internal { IgNFT.TokenData memory tokenData = IgNFT.TokenData({ slot0: IgNFT.Slot0({ tokenType: tokenType, activeSegment: segments, voteWeight: uint8(_getTypeParameter(tokenType, Constants.ParameterType.VoteWeight)), rewardWeight: uint8( _getTypeParameter(tokenType, Constants.ParameterType.RewardWeight) ), usedForMint: false, completionTimestamp: completionTimestamp, lockedMarket: address(0) }), slot1: IgNFT.Slot1({lockedVaultShares: 0}) }); _totalInactiveSegments += Constants.SEGMENTS_NUMBER - segments; gNFT.mint(to, tokenData); } function _checkTokenType(IgNFT.TokenType tokenType, uint256[] calldata proofIds) internal { IgNFT.Slot0 memory data0; uint256 numTopaz; uint256 numEmerald; uint256 numDiamond; uint256 len = proofIds.length; uint256 proofId; uint256 requiredTopazes = _getTypeParameter( tokenType, Constants.ParameterType.RequiredTopazes ); uint256 requiredEmeralds = _getTypeParameter( tokenType, Constants.ParameterType.RequiredEmeralds ); uint256 requiredDiamonds = _getTypeParameter( tokenType, Constants.ParameterType.RequiredDiamonds ); for (uint256 i; i < len; ) { proofId = proofIds[i]; _requireOwnership(proofId); data0 = _getSlot0(proofId); if (data0.activeSegment != Constants.SEGMENTS_NUMBER) { revert InvalidSegmentsNumber(); } unchecked { if (!data0.usedForMint) { bool used = false; if (data0.tokenType == IgNFT.TokenType.Topaz && numTopaz < requiredTopazes) { numTopaz++; used = true; } else if ( data0.tokenType == IgNFT.TokenType.Emerald && numEmerald < requiredEmeralds ) { numEmerald++; used = true; } else if (numDiamond < requiredDiamonds) { numDiamond++; used = true; } if (used) { data0.usedForMint = true; _updateSlot0(proofId, data0); } } i++; } } if ( numTopaz < requiredTopazes || numEmerald < requiredEmeralds || numDiamond < requiredDiamonds ) revert MintingRequirementsNotMet(); } function _checkLiquidity(address[] memory markets, IgNFT.TokenType tokenType) internal { IOracle oracle = _getOracle(); IComptroller comptroller = TONPOUND_COMPTROLLER; uint256 liquidityValue = _getTypeParameter( tokenType, Constants.ParameterType.MintingLiquidity ); uint256 len = markets.length; uint256 totalValue; address market; for (uint256 i; i < len; ) { market = markets[i]; _checkMarketListed(market, comptroller); totalValue += _quoteLiquiditySingle( market, oracle, ICToken(market).balanceOf(msg.sender), false ); if (totalValue >= liquidityValue) { return; } unchecked { i++; } } revert FailedLiquidityCheck(); } function _checkMarketListed(address market, IComptroller comptroller) internal view { if (!comptroller.markets(market).isListed) { revert InvalidMarket(); } } function _quoteLiquiditySingle( address market, IOracle oracle, uint256 amount, bool reverse ) internal returns (uint256) { uint256 eval = oracle.getEvaluation(market, amount, reverse); if (eval == 0) revert OracleFailed(); return eval; } function getActivationPrice( uint256 tokenId, uint8 segmentsToOpen, bool discounted ) external view returns (uint256) { IgNFT.Slot0 memory data0 = _getSlot0(tokenId); if (Constants.SEGMENTS_NUMBER - data0.activeSegment < segmentsToOpen) revert InvalidSegmentsNumber(); return _getActivationPrice(data0, segmentsToOpen, _totalInactiveSegments, discounted); } function _getActivationPrice( IgNFT.Slot0 memory data0, uint8 numberOfSegments, uint256 totalInactiveSegments, bool discounted ) internal view returns (uint256) { uint256 avgPrice; if (totalInactiveSegments > 0) { try TPI().getCirculatingSupply() returns (uint256 supply) { avgPrice = MathUpgradeable.min(supply / totalInactiveSegments, Constants.ACTIVATION_MAX_PRICE); } catch {} } avgPrice = MathUpgradeable.max(avgPrice, Constants.ACTIVATION_MIN_PRICE) * numberOfSegments; if (discounted) { avgPrice = (avgPrice * Constants.AIRDROP_DISCOUNT_NOMINATOR) / Constants.AIRDROP_DISCOUNT_DENOMINATOR; } uint256 typeNominator = _getTypeParameter( data0.tokenType, Constants.ParameterType.ActivationNominator ); return (avgPrice * typeNominator); } function activateSegments( uint256 tokenId, uint8 segments, address market ) external whenNotPaused validUser(msg.sender) nonReentrant { _requireOwnership(tokenId); _activateSegmentsInternal(tokenId, segments, market, msg.sender, false); } function activateSegmentWithProof( uint256 tokenId, address account, uint256 nonce, bytes32[] memory proof, address market ) external whenNotPaused validUser(account) nonReentrant { (bytes32 leaf, bytes32 root) = _validateProof(account, nonce, proof); _activateSegmentsInternal(tokenId, 1, market, account, true); emit Discounted(leaf, root); } function _activateSegmentsInternal( uint256 tokenId, uint8 segments, address market, address account, bool discounted ) internal { IgNFT.Slot0 memory data0 = _getSlot0(tokenId); uint8 availableSegments = Constants.SEGMENTS_NUMBER - data0.activeSegment; if (availableSegments == 0) { revert AlreadyFullyActivated(); } else if (segments > availableSegments) { revert ExceedingMaxSegments(); } else if (segments == availableSegments) { data0 = _completeSegments(tokenId, data0, market, account); } uint256 totalInactive = _totalInactiveSegments; uint256 activationPrice = _getActivationPrice(data0, segments, totalInactive, discounted); uint8 newSegment; unchecked { newSegment = data0.activeSegment + segments; data0.activeSegment = newSegment; _totalInactiveSegments = totalInactive - segments; } _updateSlot0(tokenId, data0); TPI().transferFrom(msg.sender, Constants.DEAD_ADDRESS, activationPrice); emit ActivatedSegments(tokenId, newSegment); } function _validateProof( address account, uint256 nonce, bytes32[] memory proof ) internal returns (bytes32, bytes32) { bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(account, nonce)))); if (_discountUsed[leaf]) revert DiscountUsed(); _discountUsed[leaf] = true; bytes32 root = _airdropMerkleRoot; if (!MerkleProofUpgradeable.verify(proof, root, leaf)) revert InvalidProof(); return (leaf, root); } function _completeSegments( uint256 tokenId, IgNFT.Slot0 memory data0, address market, address account ) internal returns (IgNFT.Slot0 memory) { if (!_treasuryReleased()) { if (market == address(0)) revert MarketForLockNotSpecified(); uint256 liquidity = _getTypeParameter( data0.tokenType, Constants.ParameterType.RewardsLiquidity ); (data0) = _lockLiquidityInternal(tokenId, data0, market, account, liquidity); } _getTreasury().registerTokenId(tokenId, true); data0.completionTimestamp = uint48(block.timestamp); emit TokenCompleted(tokenId, msg.sender); return data0; } function _treasuryReleased() internal view returns (bool) { return _getTreasury().rewardsClaimRemaining() == 0; } function _lockLiquidityInternal( uint256 tokenId, IgNFT.Slot0 memory data0, address market, address account, uint256 value ) internal returns (IgNFT.Slot0 memory) { if (value > 0) { uint256 amountToLock = _quoteLiquiditySingle(market, _getOracle(), value, true); uint256 vaultShares = _vaultLock(tokenId, market, amountToLock, account); data0.lockedMarket = market; IgNFT.Slot1 memory data1 = _getSlot1(tokenId); data1.lockedVaultShares = vaultShares; _updateSlot1(tokenId, data1); } _getTreasury().registerTokenId(tokenId, true); return (data0); } function lockLiquidity(uint256 tokenId, address market) external whenNotPaused nonReentrant { _requireOwnership(tokenId); if (!_treasuryReleased()) { IgNFT.TokenData memory data = _getTokenData(tokenId); if (data.slot1.lockedVaultShares > 0) revert TokenAlreadyLocked(); if (market == address(0)) revert MarketForLockNotSpecified(); uint256 liquidity = _getTypeParameter( data.slot0.tokenType, Constants.ParameterType.RewardsLiquidity ); _lockLiquidityInternal(tokenId, data.slot0, market, msg.sender, liquidity); } _getTreasury().registerTokenId(tokenId, true); } function unlockLiquidity(uint256 tokenId) external whenNotPaused nonReentrant { _requireOwnership(tokenId); ITreasury treasury = _getTreasury(); if (treasury.rewardsClaimRemaining() > 0) { treasury.registerTokenId(tokenId, false); } _unlockLiquidityInternal(tokenId, msg.sender); } function _unlockLiquidityInternal(uint256 tokenId, address account) internal { IgNFT.Slot0 memory data0 = _getSlot0(tokenId); IgNFT.Slot1 memory data1 = _getSlot1(tokenId); _vaultUnlock(tokenId, data0.lockedMarket, data1.lockedVaultShares, account); data0.lockedMarket = address(0); data1.lockedVaultShares = 0; _updateSlot0(tokenId, data0); _updateSlot1(tokenId, data1); } function quoteLiquidityForLock( address market, IgNFT.TokenType tokenType ) external view returns (uint256) { uint256 liquidity = _getTypeParameter(tokenType, Constants.ParameterType.RewardsLiquidity); return _getOracle().getEvaluationStored(market, liquidity, true); } function _getTokenData(uint256 tokenId) internal view returns (IgNFT.TokenData memory) { return gNFT.getTokenData(tokenId); } function _getSlot0(uint256 tokenId) internal view returns (IgNFT.Slot0 memory) { return gNFT.getTokenSlot0(tokenId); } function _getSlot1(uint256 tokenId) internal view returns (IgNFT.Slot1 memory) { return gNFT.getTokenSlot1(tokenId); } function _updateSlot0(uint256 tokenId, IgNFT.Slot0 memory data) internal { gNFT.updateTokenDataSlot0(tokenId, data); } function _updateSlot1(uint256 tokenId, IgNFT.Slot1 memory data) internal { gNFT.updateTokenDataSlot1(tokenId, data); } function _requireOwnership(uint256 tokenId) internal view { if (IERC721Upgradeable(address(gNFT)).ownerOf(tokenId) != msg.sender) revert InvalidTokenOwnership(tokenId); } function _getTypeParameter( IgNFT.TokenType col, Constants.ParameterType row ) internal pure returns (uint256) { uint256 param = Constants.TYPE_PARAMETERS(uint256(col), uint256(row)); if ( row == Constants.ParameterType.RewardsLiquidity || row == Constants.ParameterType.MintingLiquidity ) { unchecked { param *= Constants.EXP_LIQUIDITY; } } return param; } function _getOracle() internal view returns (IOracle) { return IOracle(TONPOUND_COMPTROLLER.oracle()); } function _getTreasury() internal view returns (ITreasury) { return ITreasury(TONPOUND_COMPTROLLER.treasury()); } function TPI() public view override returns (ITPIToken) { return ITPIToken(TONPOUND_COMPTROLLER.getCompAddress()); } function setMerkleRoot(bytes32 root) external onlyRole(MANAGER_ROLE) { emit AirdropMerkleRootChanged(_airdropMerkleRoot, root); _airdropMerkleRoot = root; } function updateVaultImplementation( address implementation ) external onlyRole(Constants.DEFAULT_ADMIN_ROLE) { _updateImplementation(implementation); } function _authorizeUpgrade( address newImplementation ) internal override onlyRole(Constants.DEFAULT_ADMIN_ROLE) {} /// @custom:oz-upgrades-unsafe-allow constructor constructor(address gnft_, address comptroller_) VaultFactory() { if (gnft_ == address(0) || comptroller_ == address(0)) revert ZeroAddress(); TONPOUND_COMPTROLLER = IComptroller(comptroller_); gNFT = IgNFT(gnft_); _disableInitializers(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.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: * * ``` * 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}: * * ``` * 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. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } 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(IAccessControlUpgradeable).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 ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.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()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @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.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/Clones.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library ClonesUpgradeable { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create(0, 0x09, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create2(0, 0x09, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(add(ptr, 0x38), deployer) mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff) mstore(add(ptr, 0x14), implementation) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73) mstore(add(ptr, 0x58), salt) mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37)) predicted := keccak256(add(ptr, 0x43), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/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 MerkleProofUpgradeable { /** * @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) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: UNLICENSED import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "./interfaces/IAuth.sol"; pragma solidity ^0.8.4; abstract contract Auth is AccessControlUpgradeable, PausableUpgradeable, IAuth { bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE"); bytes32 public constant BLACKLISTED_ROLE = keccak256("VALIDATOR_ROLE"); function __Auth_init(address manager_, address pauser_) internal onlyInitializing { if (manager_ == address(0) || pauser_ == address(0)) revert ZeroAddress(); __AccessControl_init(); __Pausable_init(); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(MANAGER_ROLE, manager_); _setupRole(PAUSER_ROLE, pauser_); _setRoleAdmin(BLACKLISTED_ROLE, MANAGER_ROLE); } modifier validUser(address account) { if (hasRole(BLACKLISTED_ROLE, account)) revert BlacklistedUser(account); _; } function isValidUser(address account) external view returns (bool) { return !hasRole(BLACKLISTED_ROLE, account); } function isAdmin(address user) external view returns (bool) { return hasRole(DEFAULT_ADMIN_ROLE, user); } function setPause(bool newState) external onlyRole(PAUSER_ROLE) { newState ? _pause() : _unpause(); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; library Constants { // gNFT constants uint8 internal constant VOTE_WEIGHT_TOPAZ = 1; uint8 internal constant VOTE_WEIGHT_EMERALD = 2; uint8 internal constant VOTE_WEIGHT_DIAMOND = 3; uint8 internal constant REWARD_WEIGHT_TOPAZ = 1; uint8 internal constant REWARD_WEIGHT_EMERALD = 11; uint8 internal constant REWARD_WEIGHT_DIAMOND = 120; uint8 internal constant LIQUIDITY_FOR_MINTING_TOPAZ = 1; // mul by EXP_1E20 uint8 internal constant LIQUIDITY_FOR_MINTING_EMERALD = 1; // mul by EXP_1E20 uint8 internal constant LIQUIDITY_FOR_MINTING_DIAMOND = 1; // mul by EXP_1E20 uint8 internal constant ACTIVATION_TOPAZ_NOMINATOR = 1; uint8 internal constant ACTIVATION_EMERALD_NOMINATOR = 10; uint8 internal constant ACTIVATION_DIAMOND_NOMINATOR = 100; uint8 internal constant LIQUIDITY_FOR_REWARDS_TOPAZ = 1; // mul by EXP_1E20 uint8 internal constant LIQUIDITY_FOR_REWARDS_EMERALD = 0; // mul by EXP_1E20 uint8 internal constant LIQUIDITY_FOR_REWARDS_DIAMOND = 0; // mul by EXP_1E20 uint8 internal constant REQUIRE_TOPAZES_FOR_TOPAZ = 0; uint8 internal constant REQUIRE_TOPAZES_FOR_EMERALD = 10; uint8 internal constant REQUIRE_TOPAZES_FOR_DIAMOND = 10; uint8 internal constant REQUIRE_EMERALDS_FOR_TOPAZ = 0; uint8 internal constant REQUIRE_EMERALDS_FOR_EMERALD = 0; uint8 internal constant REQUIRE_EMERALDS_FOR_DIAMOND = 1; uint8 internal constant REQUIRE_DIAMONDS_FOR_TOPAZ = 0; uint8 internal constant REQUIRE_DIAMONDS_FOR_EMERALD = 0; uint8 internal constant REQUIRE_DIAMONDS_FOR_DIAMOND = 0; uint8 internal constant SEGMENTS_NUMBER = 12; uint256 internal constant REWARD_ACCUMULATING_PERIOD = 365 days; uint256 internal constant ACTIVATION_MIN_PRICE = 1000e18; uint256 internal constant ACTIVATION_MAX_PRICE = 5000e18; uint256 internal constant ACTIVATION_DENOMINATOR = 1; uint256 internal constant AIRDROP_DISCOUNT_NOMINATOR = 0; uint256 internal constant AIRDROP_DISCOUNT_DENOMINATOR = 1e6; uint256 internal constant EXP_ORACLE = 1e18; uint256 internal constant EXP_LIQUIDITY = 1e20; string internal constant BASE_URI = "https://tonpound.com/api/token-data/metadata/"; //@notice uint8 parameters packed into bytes constant bytes internal constant M = hex"010203010b78010101010a64010000000a0a000001000000"; // Treasury constants uint256 internal constant EXP_REWARD_PER_SHARE = 1e12; uint256 internal constant REWARD_PER_SHARE_MULTIPLIER = 1e12; uint256 internal constant MAX_RESERVE_BPS = 5e3; uint256 internal constant DENOM_BPS = 1e4; // Common constants uint256 internal constant DEFAULT_DECIMALS = 18; bytes32 internal constant DEFAULT_ADMIN_ROLE = 0x00; address internal constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD; function TYPE_PARAMETERS(uint256 col, uint256 row) internal pure returns (uint8) { unchecked { return uint8(M[row * 3 + col]); } } enum ParameterType { VoteWeight, RewardWeight, MintingLiquidity, ActivationNominator, RewardsLiquidity, RequiredTopazes, RequiredEmeralds, RequiredDiamonds } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; /// @title Interface for Auth contract, which is a part of gNFT token /// @notice Authorization model is based on AccessControl and Pausable contracts from OpenZeppelin: /// (https://docs.openzeppelin.com/contracts/4.x/api/access#AccessControl) and /// (https://docs.openzeppelin.com/contracts/4.x/api/security#Pausable) /// Blacklisting implemented with BLACKLISTED_ROLE, managed by MANAGER_ROLE interface IAuth { /// @notice Revert reason for unwanted input zero addresses error ZeroAddress(); /// @notice Revert reason for protected functions being called by blacklisted address error BlacklistedUser(address account); /// @notice Check for admin role /// @param user User to check for role bearing /// @return True if user has the DEFAULT_ADMIN_ROLE role function isAdmin(address user) external view returns (bool); /// @notice Check for not being in blacklist /// @param user User to check for /// @return True if user is not blacklisted function isValidUser(address user) external view returns (bool); /// @notice Control function of OpenZeppelin's Pausable contract /// Restricted to PAUSER_ROLE bearers only /// @param newState New boolean status for affected whenPaused/whenNotPaused functions function setPause(bool newState) external; }
// SPDX-License-Identifier: UNLICENSED import "./ICToken.sol"; pragma solidity ^0.8.4; /// @title Partial interface for Tonpound Comptroller contract /// @notice Based on Comptroller from Compound Finance with different governance model /// (https://docs.compound.finance/v2/comptroller/) /// Modified Comptroller stores gNFT and Treasury addresses /// Unmodified descriptions are copied from Compound Finance GitHub repo: /// (https://github.com/compound-finance/compound-protocol/blob/v2.8.1/contracts/Comptroller.sol) interface IComptroller { /// @notice Returns whether the given account is entered in the given asset /// @param account The address of the account to check /// @param market The market(cToken) to check /// @return True if the account is in the asset, otherwise false function checkMembership(address account, address market) external view returns (bool); /// @notice Claim all rewards accrued by the holders /// @param holders The addresses to claim for /// @param markets The list of markets to claim in /// @param bor Whether or not to claim rewards earned by borrowing /// @param sup Whether or not to claim rewards earned by supplying function claimComp( address[] memory holders, address[] memory markets, bool bor, bool sup ) external; /// @notice Returns rewards accrued but not yet transferred to the user /// @param account User address to get accrued rewards for /// @return Value stored in compAccrued[account] mapping function compAccrued(address account) external view returns (uint256); /// @notice Add assets to be included in account liquidity calculation /// @param markets The list of addresses of the markets to be enabled /// @return Success indicator for whether each corresponding market was entered function enterMarkets(address[] memory markets) external returns (uint256[] memory); /// @notice Determine the current account liquidity wrt collateral requirements /// @return err (possible error code (semi-opaque) /// liquidity account liquidity in excess of collateral requirements /// shortfall account shortfall below collateral requirements) function getAccountLiquidity( address account ) external view returns (uint256 err, uint256 liquidity, uint256 shortfall); /// @notice Return all of the markets /// @dev The automatic getter may be used to access an individual market. /// @return The list of market addresses function getAllMarkets() external view returns (address[] memory); /// @notice Returns the assets an account has entered /// @param account The address of the account to pull assets for /// @return A dynamic list with the assets the account has entered function getAssetsIn(address account) external view returns (address[] memory); /// @notice Return the address of the TPI token /// @return The address of TPI function getCompAddress() external view returns (address); /// @notice Return the address of the governance gNFT token /// @return The address of gNFT function gNFT() external view returns (address); /// @notice View function to read 'markets' mapping separately /// @return Market structure without nested 'accountMembership' function markets(address market) external view returns (Market calldata); /// @notice Return the address of the system Oracle /// @return The address of Oracle function oracle() external view returns (address); /// @notice Return the address of the Treasury /// @return The address of Treasury function treasury() external view returns (address); struct Market { bool isListed; uint256 collateralFactorMantissa; bool isComped; } }
// SPDX-License-Identifier: UNLICENSED import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; pragma solidity ^0.8.4; /// @title Partial interface for Tonpound cToken market /// @notice Extension of IERC20 standard interface from OpenZeppelin /// (https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#IERC20) interface ICToken is IERC20MetadataUpgradeable { /** * @notice Accrues interest and reduces reserves by transferring to admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves() external returns (uint256); /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external returns (uint256); /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() external returns (uint256); /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() external view returns (uint256); /** * @notice Underlying asset for this CToken */ function underlying() external view returns (address); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; import "./ISegmentManagement.sol"; /// @title gNFT governance token for Tonpound protocol /// @notice Built on ERC721Votes extension from OpenZeppelin Upgradeable library /// (https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#ERC721Votes) /// Supports Permit approvals (see IERC721Permit.sol) and Multicall /// (https://docs.openzeppelin.com/contracts/4.x/api/utils#Multicall) interface IgNFT { /// @notice Revert reason for unauthorized access to protected functions error Auth(); /// @notice Revert reason for protected functions being called by blacklisted address error BlacklistedUser(address account); /// @notice Revert reason for accessing protected functions during pause error Paused(); /// @notice Revert reason for unwanted input zero addresses error ZeroAddress(); /// @notice Emitted during minting /// @param tokenId tokenId of minted token /// @param data Metadata of minted token event MintData(uint256 tokenId, TokenData data); /// @notice Emitted during slot0 of metadata updating /// @param tokenId tokenId of updated token /// @param data New Slot0 of metadata of updated token event UpdatedTokenDataSlot0(uint256 tokenId, Slot0 data); /// @notice Emitted during slot1 of metadata updating /// @param tokenId tokenId of updated token /// @param data New Slot1 of metadata of updated token event UpdatedTokenDataSlot1(uint256 tokenId, Slot1 data); /// @notice View method to read SegmentManagement contract address /// @return Address of SegmentManagement contract function SEGMENT_MANAGEMENT() external view returns (ISegmentManagement); /// @notice View method to get total vote weight of minted tokens, /// only gNFTs with fully activated segments participates in the voting /// @return Value of Votes._getTotalSupply(), i.e. latest total checkpoints function getTotalVotePower() external view returns (uint256); /// @notice View method to read 'tokenDataById' mapping of extended token metadata /// @param tokenId tokenId to read mapping for /// @return Stored value of 'tokenDataById[tokenId]' of IgNFT.TokenData type function getTokenData(uint256 tokenId) external view returns (TokenData memory); /// @notice View method to read first slot of extended token metadata /// @param tokenId tokenId to read mapping for /// @return Stored value of 'tokenDataById[tokenId].slot0' of IgNFT.Slot0 type function getTokenSlot0(uint256 tokenId) external view returns (Slot0 memory); /// @notice View method to read second slot of extended token metadata /// @param tokenId tokenId to read mapping for /// @return Stored value of 'tokenDataById[tokenId].slot1' of IgNFT.Slot1 type function getTokenSlot1(uint256 tokenId) external view returns (Slot1 memory); /// @notice Minting new gNFT token /// Restricted only to SEGMENT_MANAGEMENT contract /// @param to Address of recipient /// @param data Parameters of new token to be minted function mint(address to, TokenData memory data) external; /// @notice Update IgNFT.Slot0 parameters of IgNFT.TokenData of a token /// Restricted only to SEGMENT_MANAGEMENT contract /// @param tokenId Token to be updated /// @param data Slot0 structure to update existed function updateTokenDataSlot0(uint256 tokenId, Slot0 memory data) external; /// @notice Update IgNFT.Slot1 parameters of IgNFT.TokenData of a token /// Restricted only to SEGMENT_MANAGEMENT contract /// @param tokenId Token to be updated /// @param data Slot1 structure to update existed function updateTokenDataSlot1(uint256 tokenId, Slot1 memory data) external; struct TokenData { Slot0 slot0; Slot1 slot1; } struct Slot0 { TokenType tokenType; uint8 activeSegment; uint8 voteWeight; uint8 rewardWeight; bool usedForMint; uint48 completionTimestamp; address lockedMarket; } struct Slot1 { uint256 lockedVaultShares; } enum TokenType { Topaz, Emerald, Diamond } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; /// @title Partial interface for Oracle contract /// @notice Based on PriceOracle from Compound Finance /// (https://github.com/compound-finance/compound-protocol/blob/v2.8.1/contracts/PriceOracle.sol) interface IOracle { /// @notice Get the underlying price of a market(cToken) asset /// @param market The market to get the underlying price of /// @return The underlying asset price mantissa (scaled by 1e18). /// Zero means the price is unavailable. function getUnderlyingPrice(address market) external view returns (uint256); /// @notice Evaluates input amount according to stored price, accrues interest /// @param cToken Market to evaluate /// @param amount Amount of tokens to evaluate according to 'reverse' order /// @param reverse Order of evaluation /// @return Depending on 'reverse' order: /// false - return USD amount equal to 'amount' of 'cToken' /// true - return cTokens equal to 'amount' of USD function getEvaluation(address cToken, uint256 amount, bool reverse) external returns (uint256); /// @notice Evaluates input amount according to stored price, doesn't accrue interest /// @param cToken Market to evaluate /// @param amount Amount of tokens to evaluate according to 'reverse' order /// @param reverse Order of evaluation /// @return Depending on 'reverse' order: /// false - return USD amount equal to 'amount' of 'cToken' /// true - return cTokens equal to 'amount' of USD function getEvaluationStored( address cToken, uint256 amount, bool reverse ) external view returns (uint256); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; import "./IgNFT.sol"; import "./IComptroller.sol"; import "./ITPIToken.sol"; import "./ITreasury.sol"; import "./IOracle.sol"; /// @title Segment management contract for gNFT governance token for Tonpound protocol interface ISegmentManagement { /// @notice Revert reason for activating segments for a fully activated token error AlreadyFullyActivated(); /// @notice Revert reason for repeating discount activation error DiscountUsed(); /// @notice Revert reason for minting over the max segment number error ExceedingMaxSegments(); /// @notice Revert reason for minting without liquidity in Tonpound protocol error FailedLiquidityCheck(); /// @notice Revert reason for minting token with a market without membership error InvalidMarket(); /// @notice Revert reason for activating segment with invalid Merkle proof for given account error InvalidProof(); /// @notice Revert reason for activating more segments than available error InvalidSegmentsNumber(); /// @notice Revert reason for operating tokens without ownership error InvalidTokenOwnership(uint256 tokenId); /// @notice Revert reason for activating last segment without specified liquidity for lock error MarketForLockNotSpecified(); /// @notice Revert reason for minting high tier gNFT without providing proof of ownership error MintingRequirementsNotMet(); /// @notice Revert reason for zero returned price from Oracle contract error OracleFailed(); /// @notice Revert reason for trying to lock already locked token error TokenAlreadyLocked(); /// @notice Emitted during NFT segments activation /// @param tokenId tokenId of activated token /// @param segment New active segment after performed activation event ActivatedSegments(uint256 indexed tokenId, uint8 segment); /// @notice Emitted after the last segment of gNFT token is activated /// @param tokenId tokenId of completed token /// @param user Address of the user who completed the token event TokenCompleted(uint256 indexed tokenId, address indexed user); /// @notice Emitted when whitelisted users activate their segments with discount /// @param leaf Leaf of Merkle tree being used in activation /// @param root Root of Merkle tree being used in activation event Discounted(bytes32 leaf, bytes32 root); /// @notice Emitted to notify about airdrop Merkle root change /// @param oldRoot Old root /// @param newRoot New updated root to be used after this tx event AirdropMerkleRootChanged(bytes32 oldRoot, bytes32 newRoot); /// @notice View method to read Tonpound Comptroller address /// @return Address of Tonpound Comptroller contract function TONPOUND_COMPTROLLER() external view returns (IComptroller); /// @notice View method to read gNFT /// @return Address of gNFT contract function gNFT() external view returns (IgNFT); /// @notice View method to read Tonpound TPI token /// @return Address of TPI token contract function TPI() external view returns (ITPIToken); /// @notice View method to get price in TPI tokens to activate segments of gNFT token /// @param tokenId tokenId of the token to activate segments of /// @param segmentsToOpen Number of segments to activate, fails if this number exceeds available segments /// @param discounted Whether the user is eligible for activation discount /// @return Price in TPI tokens to be burned from caller to activate specified number of segments function getActivationPrice( uint256 tokenId, uint8 segmentsToOpen, bool discounted ) external view returns (uint256); /// @notice View method to get amount of liquidity to be provided for lock in order to /// complete last segment and make gNFT eligible for reward distribution in Treasury /// @param market Tonpound Comptroller market (cToken) to be locked /// @param tokenType Type of token to quote lock for /// @return Amount of specified market tokens to be provided for lock function quoteLiquidityForLock( address market, IgNFT.TokenType tokenType ) external view returns (uint256); /// @notice Minting new gNFT token with zero active segments and no voting power /// Minter must have total assets in Tonpound protocol over the threshold nominated in USD /// @param markets User provided markets of Tonpound Comptroller to be checked for liquidity function mint(address[] memory markets) external; /// @notice Minting new gNFT token of given type with zero active segments and no voting power /// Minter must have assets in given markets of Tonpound protocol over the threshold in USD /// Minter must own number of fully activated lower tier gNFTs to mint Emerald or Diamond /// @param markets User provided markets of Tonpound Comptroller to be checked for liquidity /// @param tokenType Token type to mint: Topaz, Emerald, or Diamond /// @param proofIds List of tokenIds to be checked for ownership, activation, and type function mint( address[] memory markets, IgNFT.TokenType tokenType, uint256[] calldata proofIds ) external; /// @notice Activating number of segments of given gNFT token /// Caller must be the owner, token may be completed with this function if /// caller provides enough liquidity for lock in specified Tonpound 'market' /// @param tokenId tokenId to be activated for number of segments /// @param segments Number of segments to be activated, must not exceed available segments of tokenId /// @param market Optional address of Tonpound market to lock liquidity in order to complete gNFT function activateSegments(uint256 tokenId, uint8 segments, address market) external; /// @notice Activating 1 segment of given gNFT token /// Caller must provide valid Merkle proof, token may be completed with this function if /// 'account' provides enough liquidity for lock in specified Tonpound 'market' /// @param tokenId tokenId to be activated for a single segment /// @param account Address of whitelisted account, which is included in leaf of Merkle tree /// @param nonce Nonce parameter included in leaf of Merkle tree /// @param proof bytes32[] array of Merkle tree proof for whitelisted account /// @param market Optional address of Tonpound market to lock liquidity in order to complete gNFT function activateSegmentWithProof( uint256 tokenId, address account, uint256 nonce, bytes32[] memory proof, address market ) external; /// @notice Unlocking liquidity of a fully activated gNFT /// Caller must be the owner. If function is called before start of reward claiming, /// the given tokenId is de-registered in Treasury contract and stops acquiring rewards /// Any rewards acquired before unlocking will be available once claiming starts /// @param tokenId tokenId to unlock liquidity for function unlockLiquidity(uint256 tokenId) external; /// @notice Locking liquidity of a fully activated gNFT (reverting result of unlockLiquidity()) /// Caller must be the owner. If function is called before start of reward claiming, /// the given tokenId is registered in Treasury contract and starts acquiring rewards /// Any rewards acquired before remains accounted and will be available once claiming starts /// @param tokenId tokenId to lock liquidity for /// @param market Address of Tonpound market to lock liquidity in function lockLiquidity(uint256 tokenId, address market) external; /// @notice Updating Merkle root for whitelisting airdropped accounts /// Restricted to MANAGER_ROLE bearers only /// @param root New root of Merkle tree of whitelisted addresses function setMerkleRoot(bytes32 root) external; }
// SPDX-License-Identifier: UNLICENSED import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; pragma solidity ^0.8.4; /// @title Partial interface for Tonpound TPI token /// @notice Extension of IERC20 standard interface from OpenZeppelin /// (https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#IERC20) interface ITPIToken is IERC20Upgradeable { /// @notice View function to get current active circulating supply, /// used to calculate price of gNFT segment activation /// @return Total supply without specific TPI storing address, e.g. vesting function getCirculatingSupply() external view returns (uint256); /// @notice Function to be used for gNFT segment activation /// @param account Address, whose token to be burned /// @param amount Amount to be burned function burnFrom(address account, uint256 amount) external; }
// SPDX-License-Identifier: UNLICENSED import "./IComptroller.sol"; import "./IgNFT.sol"; import "./IAuth.sol"; pragma solidity ^0.8.4; /// @title Interface for Tonpound Treasury contract, which is a part of gNFT token /// @notice Authorization model is based on AccessControl and Pausable contracts from OpenZeppelin: /// (https://docs.openzeppelin.com/contracts/4.x/api/access#AccessControl) and /// (https://docs.openzeppelin.com/contracts/4.x/api/security#Pausable) /// Blacklisting implemented with BLACKLISTED_ROLE, managed by MANAGER_ROLE interface ITreasury { /// @notice Revert reason for unauthorized access to protected functions error Auth(); /// @notice Revert reason claiming rewards before start of claiming period error ClaimingNotStarted(); /// @notice Revert reason claiming unregistered reward token error InvalidRewardToken(); /// @notice Revert reason for distributing rewards in unsupported reward token error InvalidMarket(); /// @notice Revert reason for setting too high parameter value error InvalidParameter(); /// @notice Revert reason for claiming reward for not-owned gNFT token error InvalidTokenOwnership(); /// @notice Revert reason for accessing protected functions during pause error Paused(); /// @notice Revert reason for unwanted input zero addresses error ZeroAddress(); /// @notice Emitted in governance function when reserveBPS variable is updated event ReserveFactorUpdated(uint256 oldValue, uint256 newValue); /// @notice Emitted in governance function when reserveFund variable is updated event ReserveFundUpdated(address oldValue, address newValue); /// @notice View method to read all supported reward tokens /// @return Array of addresses of registered reward tokens function getRewardTokens() external view returns (address[] memory); /// @notice View method to read number of supported reward tokens /// @return Number of registered reward tokens function getRewardTokensLength() external view returns (uint256); /// @notice View method to read a single reward token address /// @param index Index of reward token in array to return /// @return Address of reward token at given index in array function getRewardTokensAtIndex(uint256 index) external view returns (address); /// @notice View method to read 'lastClaimForTokenId' mapping /// storing 'rewardPerShare' parameter for 'tokenId' /// from time of registration or last claiming event /// @param rewardToken Address of reward token to read mapping for /// @param tokenId gNFT tokenId to read mapping for /// @return Stored value of 'lastClaimForTokenId[rewardToken][tokenId]', /// last claim value of reward per share multiplied by REWARD_PER_SHARE_MULTIPLIER = 1e12 function lastClaimForTokenId( address rewardToken, uint256 tokenId ) external view returns (uint256); /// @notice View method to get pending rewards for given /// reward token and gNFT token, contains fixed part for /// de-registered tokens and calculated part of distributed rewards /// @param rewardToken Address of reward token to calculate pending rewards /// @param tokenId gNFT tokenId to calculate pending rewards for /// @return Value of rewards in rewardToken that would be claimed if claim is available function pendingReward(address rewardToken, uint256 tokenId) external view returns (uint256); /// @notice View method to read 'registeredTokenIds' mapping of /// tracked registered gNFT tokens /// @param tokenId tokenId of gNFT token to read /// @return Stored bool value of 'registeredTokenIds[tokenId]', true if registered function registeredTokenIds(uint256 tokenId) external view returns (bool); /// @notice View method to read 'rewardPerShare' mapping of /// tracked balances of Treasury contract to properly distribute rewards /// @param rewardToken Address of reward token to read mapping for /// @return Stored value of 'rewardPerShare[rewardToken]', /// reward per share multiplied by REWARD_PER_SHARE_MULTIPLIER = 1e12 function rewardPerShare(address rewardToken) external view returns (uint256); /// @notice View method to read 'rewardBalance' mapping of distributed rewards /// in specified rewardToken stored to properly account fresh rewards /// @param rewardToken Address of reward token to read mapping for /// @return Stored value of 'rewardBalance[rewardToken]' function rewardBalance(address rewardToken) external view returns (uint256); /// @notice View method to get the remaining time until start of claiming period /// @return Seconds until claiming is available, zero if claiming has started function rewardsClaimRemaining() external view returns (uint256); /// @notice View method to read Tonpound Comptroller address /// @return Address of Tonpound Comptroller contract function TONPOUND_COMPTROLLER() external view returns (IComptroller); /// @notice View method to read total weight of registered gNFT tokens, /// eligible for rewards distribution /// @return Stored value of 'totalRegisteredWeight' function totalRegisteredWeight() external view returns (uint256); /// @notice Register and distribute incoming rewards in form of all tokens /// supported by the Tonpound Comptroller contract /// Rewards must be re-distributed if there's no users to receive at the moment function distributeRewards() external; /// @notice Register and distribute incoming rewards in form of underlying of 'market' /// Market address must be listed in the Tonpound Comptroller /// Rewards must be re-distributed if there's no users to receive at the moment /// @param market Address of market cToken to try to distribute function distributeReward(address market) external; /// @notice Claim all supported pending rewards for given gNFT token /// Claimable only after rewardsClaimRemaining() == 0 and /// only by the owner of given tokenId /// @param tokenId gNFT tokenId to claim rewards for function claimRewards(uint256 tokenId) external; /// @notice Claim pending rewards for given gNFT token in form of single 'rewardToken' /// Claimable only after rewardsClaimRemaining() == 0 and /// only by the owner of given tokenId /// @param tokenId gNFT tokenId to claim rewards for /// @param rewardToken Address of reward token to claim rewards in function claimReward(uint256 tokenId, address rewardToken) external; /// @notice Register or de-register tokenId for rewards distribution /// De-registering saves acquired rewards in fixed part for claiming when available /// Restricted for gNFT contract only /// @param tokenId gNFT tokenId to update registration status for /// @param state New boolean registration status function registerTokenId(uint256 tokenId, bool state) external; /// @notice Updating reserveBPS factor for reserve fund part of rewards /// @param newFactor New value to be less than 5000 function setReserveFactor(uint256 newFactor) external; /// @notice Updating reserve fund address /// @param newFund New address to receive future reserve rewards function setReserveFund(address newFund) external; struct RewardInfo { address market; uint256 amount; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "./ISegmentManagement.sol"; /// @title Interface for Tonpound gNFT Vault contract, which is a part of gNFT token /// @notice VaultFactory is called by VaultFactory contract to store underlying Tonpound liquidity tokens /// Vault contract is based on ERC4626 Vault from OpenZeppelin's library: /// (https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#ERC4626) interface IVault { /// @notice Revert reason for unauthorized access to protected functions error Auth(); /// @notice Revert reason for unwanted input zero addresses error ZeroAddress(); /// @notice Emitted when problem in TPI calculation arises event NotEnoughTPI(); /// @notice Emitted with each deposit act /// @param tokenId Deposit is linked to gNFT tokenId /// @param assets Tonpound market cToken amount being deposited /// @param shares Equivalent amount of shares calculated at the moment event Deposited(uint256 tokenId, uint256 assets, uint256 shares); /// @notice Emitted with each withdraw act /// @param tokenId Withdraw is linked to gNFT tokenId /// @param shares Amount of shares to be withdrawn /// @param assets Market cToken amount calculated at the moment event Withdrawn(uint256 tokenId, uint256 shares, uint256 assets); /// @notice Method to be called by VaultFactory when locking is requested by gNFT /// @param tokenId gNFT tokenId to deposit for /// @param assets Amount of Tonpound market tokens to be deposited /// @return shares Amount of shares acquired from 'assets' amount function deposit(uint256 tokenId, uint256 assets) external returns (uint256 shares); /// @notice Method to be called by VaultFactory when unlocking is requested by gNFT /// @param tokenId gNFT tokenId to withdraw for /// @param shares Amount of Vault shares to be redeemed /// @return assets Amount of assets acquired from 'shares' amount function withdraw( uint256 tokenId, uint256 shares, address receiver ) external returns (uint256 assets); /// @notice View method to get shares from assets /// @param assets Amount of underlying asset tokens /// @return shares Amount of shares to be acquired from 'assets' function convertToShares(uint256 assets) external view returns (uint256 shares); /// @notice View method to get assets from shares /// @param shares Amount of Vault shares /// @return assets Amount of underlying assets to be acquired from 'shares' function convertToAssets(uint256 shares) external view returns (uint256 assets); /// @notice View method to get total stored assets /// @return Underlying assets balance of Vault contract function totalAssets() external view returns (uint256); /// @notice View method to get total shares /// @return Total amount of minted Vault shares function totalShares() external view returns (uint256); /// @notice View method to get underlying asset address /// @return Address of Tonpound market used as storing asset function market() external view returns (IERC20Upgradeable); /// @notice View method to get Tonpound gNFT SegmentManagement contract /// @return Address of SegmentManagement contract, which has access to restricted functions function factory() external view returns (ISegmentManagement); /// @notice View method to get TPI reward per share /// @return Stored accumulated TPI reward per share function accRewardPerShare() external view returns (uint256); /// @notice View method to get stored TPI rewards /// @return Total amount of TPI rewards stored with the last update function totalTPIStored() external view returns (uint256); /// @notice View method to get already paid TPI /// @return Total amount of TPI rewards paid to unlocked gNFTs function rewardPaid() external view returns (uint256); /// @notice View method to get Vault shares by gNFT tokenID /// @return Amount of shares in the Vault function sharesByID(uint256) external view returns (uint256); /// @notice View method to get reward debt by gNFT tokenID, /// i.e. accRewardPerShare at the moment of balance update /// Can be negative, so rewards are claimable even after shares withdrawal /// @return rewardDebt = SUM_OF (sharesDiff * accRewardPerShare)_i function rewardDebtByID(uint256) external view returns (int256); /// @notice Restricted initializer to be called right after Vault creation /// @param market Address of Tonpound market used as storing asset function initialize(address market) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; import "./IgNFT.sol"; import "./ITPIToken.sol"; import "./IVault.sol"; /// @title Interface for VaultFactory contract, which is a part of SegmentManagement of Tonpound gNFT token /// @notice VaultFactory is a factory contract to store liquidity tokens in individual Vaults, /// since Tonpound market tokens are rebasing ERC20 and TPI rewards are accrued per holder /// Based on EIP-1167 Minimal Proxy implementation from OpenZeppelin: /// (https://docs.openzeppelin.com/contracts/4.x/api/proxy#Clones) interface IVaultFactory { /// @notice Revert reason for unauthorized access to protected functions error Auth(); /// @notice Revert reason for trying to lock not supported Tonpound market error NotSupported(); /// @notice Revert reason for updating implementation for address without bytecode error WrongImplementation(); /// @notice Emitted with a creation of a new Vault contract to store Tonpound liquidity tokens /// @param market Address of Tonpound liquidity token /// @param instance Address of Vault contract to store 'market' tokens /// @param implementation Address of used implementation of Vault contract event MarketAdded(address market, address instance, address implementation); /// @notice Emitted when gNFT contract requests a lock of liquidity /// @param tokenId gNFT tokenId to lock for /// @param market Address of Tonpound market locked /// @param assets Amount of Tonpound market tokens locked /// @param shares Amount of shares acquired in corresponding Vault event Locked(uint256 indexed tokenId, address market, uint256 assets, uint256 shares); /// @notice Emitted when gNFT contract requests an unlock of liquidity /// @param tokenId gNFT tokenId to unlock for /// @param market Address of Tonpound market unlocked /// @param assets Amount of Tonpound market tokens unlocked /// @param shares Amount of Vault shares unlocked /// @param receiver Address of receiver of unlocked liquidity event Unlocked( uint256 indexed tokenId, address market, uint256 assets, uint256 shares, address indexed receiver ); /// @notice View method to read Vault by Tonpound market /// @param market Address of Tonpound market to be get Vault for /// @return Vault address storing 'market' tokens (zero if not created yet) function vaultsByMarket(address market) external view returns (IVault); /// @notice View method to get all supported markets /// @return Array of supported markets, which have deployed Vaults function allMarkets() external view returns (address[] memory); /// @notice View method to get supported market at index /// @return Address of supported market at index in all markets array function marketAt(uint256 index) external view returns (address); /// @notice View method to get number of supported numbers /// @return Length of supported markets array function marketsLength() external view returns (uint256); /// @notice View method to check if market is supported /// @return True if market is supported and has Vault, False - if not function marketSupported(address market) external view returns (bool); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "./Constants.sol"; import "./interfaces/IVaultFactory.sol"; abstract contract VaultFactory is Initializable, IVaultFactory { using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; IVault public vaultImplementation; EnumerableSetUpgradeable.AddressSet private _markets; mapping(address => IVault) public vaultsByMarket; function __VaultFactory_init(address vault_) internal onlyInitializing { vaultImplementation = IVault(vault_); } function _getVault(address market) internal returns (IVault) { IVault vault; if (market == _getTPIAddress()) revert NotSupported(); if (_markets.add(market)) { address implementation = address(vaultImplementation); vault = IVault(ClonesUpgradeable.clone(implementation)); vault.initialize(market); vaultsByMarket[market] = vault; emit MarketAdded(market, address(vault), implementation); } else { vault = vaultsByMarket[market]; } return vault; } function _vaultLock( uint256 tokenId, address market, uint256 assets, address sender ) internal returns (uint256) { IVault vault = _getVault(market); uint256 shares = vault.deposit(tokenId, assets); SafeERC20Upgradeable.safeTransferFrom( IERC20Upgradeable(market), sender, address(vault), assets ); emit Locked(tokenId, market, assets, shares); return shares; } function _vaultUnlock( uint256 tokenId, address market, uint256 shares, address receiver ) internal returns (uint256) { IVault vault = _getVault(market); uint256 assets = vault.withdraw(tokenId, shares, receiver); emit Unlocked(tokenId, market, assets, shares, receiver); return assets; } function allMarkets() external view returns (address[] memory) { return _markets.values(); } function marketAt(uint256 index) external view returns (address) { return _markets.at(index); } function marketsLength() external view returns (uint256) { return _markets.length(); } function marketSupported(address market) external view returns (bool) { return _markets.contains(market); } function _getTPIAddress() internal view virtual returns (address) {} function _updateImplementation(address implementation) internal { if (!AddressUpgradeable.isContract(implementation)) revert WrongImplementation(); vaultImplementation = IVault(implementation); } /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } }
{ "optimizer": { "enabled": true, "runs": 10 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"gnft_","type":"address"},{"internalType":"address","name":"comptroller_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyFullyActivated","type":"error"},{"inputs":[],"name":"Auth","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"BlacklistedUser","type":"error"},{"inputs":[],"name":"DiscountUsed","type":"error"},{"inputs":[],"name":"ExceedingMaxSegments","type":"error"},{"inputs":[],"name":"FailedLiquidityCheck","type":"error"},{"inputs":[],"name":"InvalidMarket","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"InvalidSegmentsNumber","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"InvalidTokenOwnership","type":"error"},{"inputs":[],"name":"MarketForLockNotSpecified","type":"error"},{"inputs":[],"name":"MintingRequirementsNotMet","type":"error"},{"inputs":[],"name":"NotSupported","type":"error"},{"inputs":[],"name":"OracleFailed","type":"error"},{"inputs":[],"name":"TokenAlreadyLocked","type":"error"},{"inputs":[],"name":"WrongImplementation","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"segment","type":"uint8"}],"name":"ActivatedSegments","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"oldRoot","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"newRoot","type":"bytes32"}],"name":"AirdropMerkleRootChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"leaf","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"root","type":"bytes32"}],"name":"Discounted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Locked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"address","name":"instance","type":"address"},{"indexed":false,"internalType":"address","name":"implementation","type":"address"}],"name":"MarketAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","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":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"TokenCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"}],"name":"Unlocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"BLACKLISTED_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":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TONPOUND_COMPTROLLER","outputs":[{"internalType":"contract IComptroller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TPI","outputs":[{"internalType":"contract ITPIToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"market","type":"address"}],"name":"activateSegmentWithProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint8","name":"segments","type":"uint8"},{"internalType":"address","name":"market","type":"address"}],"name":"activateSegments","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gNFT","outputs":[{"internalType":"contract IgNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint8","name":"segmentsToOpen","type":"uint8"},{"internalType":"bool","name":"discounted","type":"bool"}],"name":"getActivationPrice","outputs":[{"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":[{"internalType":"address","name":"vault_","type":"address"},{"internalType":"address","name":"manager_","type":"address"},{"internalType":"address","name":"pauser_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isValidUser","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"market","type":"address"}],"name":"lockLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"marketAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"marketSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"},{"internalType":"enum IgNFT.TokenType","name":"tokenType","type":"uint8"},{"internalType":"uint256[]","name":"proofIds","type":"uint256[]"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum IgNFT.TokenType","name":"tokenType","type":"uint8"}],"name":"quoteLiquidityForLock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"bytes32","name":"root","type":"bytes32"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newState","type":"bool"}],"name":"setPause","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":"uint256","name":"tokenId","type":"uint256"}],"name":"unlockLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"updateVaultImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"vaultImplementation","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"vaultsByMarket","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60e0604052306080523480156200001557600080fd5b50604051620042a4380380620042a4833981016040819052620000389162000183565b62000042620000a4565b6001600160a01b03821615806200006057506001600160a01b038116155b156200007f5760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0380821660c052821660a0526200009c620000a4565b5050620001bb565b600054610100900460ff1615620001115760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116101562000164576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146200017e57600080fd5b919050565b600080604083850312156200019757600080fd5b620001a28362000166565b9150620001b26020840162000166565b90509250929050565b60805160a05160c05161405062000254600039600081816103cb01528181610da601528181611a4901528181611c99015261222b0152600081816101f60152818161175c0152818161188001528181611b1101528181611e7e01528181612439015281816127b4015261283c01526000818161085b0152818161089b015281816109340152818161097401526109ec01526140506000f3fe6080604052600436106101aa5760003560e01c806301ffc9a7146101af57806314b8194c146101e4578063174ef86a14610225578063248a9ca31461024757806324d7806c146102755780632f2ff15d14610295578063343a5962146102b557806336568abe146102d55780633659cfe6146102f5578063375a7cba146103155780634f1ef2861461033757806352d1902d1461034a5780635c975abb1461035f57806362b199c514610377578063684fe77914610399578063700cd58a146103b95780637394507e146103ed5780637cb647591461040d5780638efb3f4f1461042d57806391d148541461046357806396e83924146104835780639b5d2e78146104a3578063a217fddf146104b8578063a42fd192146104cd578063a5402544146104ed578063bba48a9014610502578063bd075b8414610522578063bedb86fb14610542578063c0c53b8b14610562578063c772356914610582578063cc10b9b3146105a2578063cd170311146105c2578063d547741f146105e2578063e63ab1e914610602578063ec87621c14610624578063f3c5400614610646578063f3c95c6014610666575b600080fd5b3480156101bb57600080fd5b506101cf6101ca3660046133a5565b610686565b60405190151581526020015b60405180910390f35b3480156101f057600080fd5b506102187f000000000000000000000000000000000000000000000000000000000000000081565b6040516101db91906133cf565b34801561023157600080fd5b50610245610240366004613403565b6106bd565b005b34801561025357600080fd5b50610267610262366004613420565b6106d5565b6040519081526020016101db565b34801561028157600080fd5b506101cf610290366004613403565b6106ea565b3480156102a157600080fd5b506102456102b0366004613439565b6106f6565b3480156102c157600080fd5b506102456102d03660046134d2565b610717565b3480156102e157600080fd5b506102456102f0366004613439565b6107d7565b34801561030157600080fd5b50610245610310366004613403565b610851565b34801561032157600080fd5b5061032a610919565b6040516101db91906135a0565b6102456103453660046135ed565b61092a565b34801561035657600080fd5b506102676109df565b34801561036b57600080fd5b5060975460ff166101cf565b34801561038357600080fd5b50610267600080516020613f5483398151915281565b3480156103a557600080fd5b506102456103b43660046136a3565b610a8d565b3480156103c557600080fd5b506102187f000000000000000000000000000000000000000000000000000000000000000081565b3480156103f957600080fd5b50610245610408366004613439565b610afd565b34801561041957600080fd5b50610245610428366004613420565b610c15565b34801561043957600080fd5b50610218610448366004613403565b60cc602052600090815260409020546001600160a01b031681565b34801561046f57600080fd5b506101cf61047e366004613439565b610c71565b34801561048f57600080fd5b5061024561049e366004613420565b610c9c565b3480156104af57600080fd5b50610218610da2565b3480156104c457600080fd5b50610267600081565b3480156104d957600080fd5b506102676104e83660046136f3565b610e26565b3480156104f957600080fd5b50610267610e85565b34801561050e57600080fd5b5060c954610218906001600160a01b031681565b34801561052e57600080fd5b5061024561053d366004613799565b610e91565b34801561054e57600080fd5b5061024561055d3660046137cd565b610ec4565b34801561056e57600080fd5b5061024561057d3660046137ea565b610ef1565b34801561058e57600080fd5b5061024561059d366004613827565b611045565b3480156105ae57600080fd5b506102676105bd3660046138cf565b611077565b3480156105ce57600080fd5b506101cf6105dd366004613403565b611108565b3480156105ee57600080fd5b506102456105fd366004613439565b611115565b34801561060e57600080fd5b50610267600080516020613fd483398151915281565b34801561063057600080fd5b50610267600080516020613fb483398151915281565b34801561065257600080fd5b50610218610661366004613420565b611131565b34801561067257600080fd5b506101cf610681366004613403565b61113e565b60006001600160e01b03198216637965db0b60e01b14806106b757506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006106c88161115f565b6106d182611169565b5050565b60009081526065602052604090206001015490565b60006106b78183610c71565b6106ff826106d5565b6107088161115f565b61071283836111b1565b505050565b61071f611237565b83610738600080516020613f5483398151915282610c71565b1561076157806040516339edf4c360e11b815260040161075891906133cf565b60405180910390fd5b61076961127f565b6000806107778787876112d8565b9150915061078a886001868a60016113b4565b60408051838152602081018390527f7d85331eec197ef05ed037cf88fe5937a220c6b65b6ea665bbf09736aef62c47910160405180910390a150506107cf600160cd55565b505050505050565b6001600160a01b03811633146108475760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610758565b6106d18282611536565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036108995760405162461bcd60e51b8152600401610758906138fd565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108cb61159d565b6001600160a01b0316146108f15760405162461bcd60e51b815260040161075890613937565b6108fa816115b9565b60408051600080825260208201909252610916918391906115c4565b50565b606061092560ca61172f565b905090565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036109725760405162461bcd60e51b8152600401610758906138fd565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166109a461159d565b6001600160a01b0316146109ca5760405162461bcd60e51b815260040161075890613937565b6109d3826115b9565b6106d1828260016115c4565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610a7a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608401610758565b50600080516020613f9483398151915290565b610a95611237565b33610aae600080516020613f5483398151915282610c71565b15610ace57806040516339edf4c360e11b815260040161075891906133cf565b610ad661127f565b610adf8461173c565b610aed8484843360006113b4565b610af7600160cd55565b50505050565b610b05611237565b610b0d61127f565b610b168261173c565b610b1e6117f1565b610ba3576000610b2d83611862565b60208101515190915015610b5457604051637cca156760e11b815260040160405180910390fd5b6001600160a01b038216610b7b57604051631c0eb28960e11b815260040160405180910390fd5b805151600090610b8c9060046118f4565b9050610b9f848360000151853385611970565b5050505b610bab611a45565b6001600160a01b031663c1450c7e8360016040518363ffffffff1660e01b8152600401610bd9929190613971565b600060405180830381600087803b158015610bf357600080fd5b505af1158015610c07573d6000803e3d6000fd5b505050506106d1600160cd55565b600080516020613fb4833981519152610c2d8161115f565b6101645460408051918252602082018490527f341ccafbcebf06bf65a4c2db1a85106ad3c0d9421c1f3207d7d1f76791e479c9910160405180910390a15061016455565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610ca4611237565b610cac61127f565b610cb58161173c565b6000610cbf611a45565b90506000816001600160a01b0316634579661d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d259190613981565b1115610d8d576040516360a2863f60e11b81526001600160a01b0382169063c1450c7e90610d5a908590600090600401613971565b600060405180830381600087803b158015610d7457600080fd5b505af1158015610d88573d6000803e3d6000fd5b505050505b610d978233611aa5565b50610916600160cd55565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639d1b5a0a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092591906139a5565b600080610e3285611af3565b90508360ff168160200151600c610e4991906139d8565b60ff161015610e6b57604051637142e1e560e11b815260040160405180910390fd5b610e7a81856101635486611b84565b9150505b9392505050565b600061092560ca611c81565b610e99611237565b610ea161127f565b610eac816000611c8b565b610eba336000806000611db6565b610916600160cd55565b600080516020613fd4833981519152610edc8161115f565b81610ee9576106d1611eee565b6106d1611f3a565b600054610100900460ff1615808015610f115750600054600160ff909116105b80610f325750610f2030611f77565b158015610f32575060005460ff166001145b610f955760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610758565b6000805460ff191660011790558015610fb8576000805461ff0019166101001790555b6001600160a01b038416610fdf5760405163d92e233d60e01b815260040160405180910390fd5b610fe98383611f86565b610ff284612059565b610ffa612080565b8015610af7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b61104d611237565b61105561127f565b6110608383836120a7565b61106a8484611c8b565b610aed3384600080611db6565b6000806110858360046118f4565b905061108f612227565b6001600160a01b031663ad3d19d5858360016040518463ffffffff1660e01b81526004016110bf939291906139f1565b602060405180830381865afa1580156110dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111009190613981565b949350505050565b60006106b760ca83612287565b61111e826106d5565b6111278161115f565b6107128383611536565b60006106b760ca8361229c565b6000611158600080516020613f5483398151915283610c71565b1592915050565b61091681336122a8565b61117281611f77565b61118f57604051630747d8c560e31b815260040160405180910390fd5b60c980546001600160a01b0319166001600160a01b0392909216919091179055565b6111bb8282610c71565b6106d15760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556111f33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60975460ff161561127d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610758565b565b600260cd54036112d15760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610758565b600260cd55565b604080516001600160a01b03851660208201529081018390526000908190819060600160408051601f198184030181528282528051602091820120908301520160408051601f198184030181529181528151602092830120600081815261016590935291205490915060ff161561136257604051637242b99b60e11b815260040160405180910390fd5b600081815261016560205260409020805460ff191660011790556101645461138b858284612301565b6113a8576040516309bde33960e01b815260040160405180910390fd5b90969095509350505050565b60006113bf86611af3565b905060008160200151600c6113d491906139d8565b90508060ff166000036113fa57604051630ec173f160e21b815260040160405180910390fd5b8060ff168660ff16111561142157604051633bf077a560e11b815260040160405180910390fd5b8060ff168660ff160361143d5761143a87838787612317565b91505b61016354600061144f84898488611b84565b60208501805160ff908b018181169092528a168403610163559091506114758a86612422565b61147d610da2565b6001600160a01b03166323b872dd3361dead856040518463ffffffff1660e01b81526004016114ae93929190613a14565b6020604051808303816000875af11580156114cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f19190613a43565b5060405160ff821681528a907fa07fb4b6c67d359d0ff55194b0ae712344245d43c9ab85ccbab7a56c2c26067a9060200160405180910390a250505050505050505050565b6115408282610c71565b156106d15760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020613f94833981519152546001600160a01b031690565b60006106d18161115f565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156115f7576107128361249e565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611651575060408051601f3d908101601f1916820190925261164e91810190613981565b60015b6116b45760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610758565b600080516020613f9483398151915281146117235760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610758565b50610712838383612538565b60606000610e7e8361255d565b6040516331a9108f60e11b81526004810182905233906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa1580156117a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c791906139a5565b6001600160a01b0316146109165760405163d6c86cb560e01b815260048101829052602401610758565b60006117fb611a45565b6001600160a01b0316634579661d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611838573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185c9190613981565b15919050565b61186a613334565b60405163b09afec160e01b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b09afec19060240161010060405180830381865afa1580156118d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b79190613b73565b60008061192384600281111561190c5761190c613bd0565b84600781111561191e5761191e613bd0565b6125b9565b60ff169050600483600781111561193c5761193c613bd0565b14806119595750600283600781111561195757611957613bd0565b145b15610e7e5768056bc75e2d63100000029392505050565b611978613367565b81156119d35760006119948561198c612227565b85600161260f565b905060006119a4888784886126b1565b6001600160a01b03871660c0890152905060006119c089612789565b82815290506119cf898261281f565b5050505b6119db611a45565b6001600160a01b031663c1450c7e8760016040518363ffffffff1660e01b8152600401611a09929190613971565b600060405180830381600087803b158015611a2357600080fd5b505af1158015611a37573d6000803e3d6000fd5b509698975050505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b6000611ab083611af3565b90506000611abd84612789565b9050611ad3848360c00151836000015186612873565b50600060c083018190528152611ae98483612422565b610af7848261281f565b611afb613367565b604051637cdc4c2f60e11b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f9b8985e9060240160e060405180830381865afa158015611b60573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b79190613be6565b6000808315611c1457611b95610da2565b6001600160a01b0316632b112e496040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611bee575060408051601f3d908101601f19168201909252611beb91810190613981565b60015b15611c1457611c10611c008683613c02565b69010f0cf064dd59200000612951565b9150505b8460ff16611c2b82683635c9adc5dea00000612967565b611c359190613c24565b90508215611c5957620f4240611c4c600083613c24565b611c569190613c02565b90505b6000611c6a876000015160036118f4565b9050611c768183613c24565b979650505050505050565b60006106b7825490565b6000611c95612227565b90507f00000000000000000000000000000000000000000000000000000000000000006000611cc58460026118f4565b8551909150600080805b83811015611d9c57888181518110611ce957611ce9613c3b565b60200260200101519150611cfd8287612976565b611d768288846001600160a01b03166370a08231336040518263ffffffff1660e01b8152600401611d2e91906133cf565b602060405180830381865afa158015611d4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d6f9190613981565b600061260f565b611d809084613c51565b9250848310611d9457505050505050505050565b600101611ccf565b506040516374c9171160e01b815260040160405180910390fd5b60408051610120810182526000918190810180876002811115611ddb57611ddb613bd0565b81526020018560ff168152602001611df48860006118f4565b60ff168152602001611e078860016118f4565b60ff1681526000602080830182905265ffffffffffff89166040808501919091526060909301829052928452815180840190925281529101529050611e4d82600c6139d8565b60ff166101636000828254611e629190613c51565b909155505060405163ce3f506f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ce3f506f90611eb59088908590600401613d07565b600060405180830381600087803b158015611ecf57600080fd5b505af1158015611ee3573d6000803e3d6000fd5b505050505050505050565b611ef6612a01565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051611f3091906133cf565b60405180910390a1565b611f42611237565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611f233390565b6001600160a01b03163b151590565b600054610100900460ff16611fad5760405162461bcd60e51b815260040161075890613d3c565b6001600160a01b0382161580611fca57506001600160a01b038116155b15611fe85760405163d92e233d60e01b815260040160405180910390fd5b611ff0612080565b611ff8612a4a565b612003600033612a79565b61201b600080516020613fb483398151915283612a79565b612033600080516020613fd483398151915282612a79565b6106d1600080516020613f54833981519152600080516020613fb4833981519152612a83565b600054610100900460ff1661118f5760405162461bcd60e51b815260040161075890613d3c565b600054610100900460ff1661127d5760405162461bcd60e51b815260040161075890613d3c565b6120af613367565b600080808481806120c18a60056118f4565b905060006120d08b60066118f4565b905060006120df8c60076118f4565b905060005b858110156121e3578b8b828181106120fe576120fe613c3b565b9050602002013594506121108561173c565b61211985611af3565b6020810151909a5060ff16600c1461214457604051637142e1e560e11b815260040160405180910390fd5b89608001516121db576000808b51600281111561216357612163613bd0565b14801561216f5750848a105b1561218057506001988901986121c2565b60018b51600281111561219557612195613bd0565b1480156121a157508389105b156121b257506001978801976121c2565b828810156121c257506001968701965b80156121d957600160808c01526121d9868c612422565b505b6001016120e4565b50828810806121f157508187105b806121fb57508086105b15612219576040516309a734db60e31b815260040160405180910390fd5b505050505050505050505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b6000610e7e836001600160a01b038416612ad6565b6000610e7e8383612aee565b6122b28282610c71565b6106d1576122bf81612b18565b6122ca836020612b2a565b6040516020016122db929190613dab565b60408051601f198184030181529082905262461bcd60e51b825261075891600401613e1a565b60008261230e8584612cc5565b14949350505050565b61231f613367565b6123276117f1565b612376576001600160a01b03831661235257604051631c0eb28960e11b815260040160405180910390fd5b6000612363856000015160046118f4565b90506123728686868685611970565b9450505b61237e611a45565b6001600160a01b031663c1450c7e8660016040518363ffffffff1660e01b81526004016123ac929190613971565b600060405180830381600087803b1580156123c657600080fd5b505af11580156123da573d6000803e3d6000fd5b50505065ffffffffffff421660a086015250604051339086907fe7e38e098beb1732df08ee49549910543e4ecb953da8d895cb6a19ef0a76fb7590600090a350919392505050565b60405163d4bef91b60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d4bef91b906124709085908590600401613e4d565b600060405180830381600087803b15801561248a57600080fd5b505af11580156107cf573d6000803e3d6000fd5b6124a781611f77565b6125095760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610758565b600080516020613f9483398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61254183612d12565b60008251118061254e5750805b1561071257610af78383612d52565b6060816000018054806020026020016040519081016040528092919081815260200182805480156125ad57602002820191906000526020600020905b815481526020019060010190808311612599575b50505050509050919050565b600060405180604001604052806018815260200174010203010b78010101010a64010000000a0a00000160581b815250838360030201815181106125ff576125ff613c3b565b016020015160f81c905092915050565b600080846001600160a01b031663616b3c278786866040518463ffffffff1660e01b8152600401612642939291906139f1565b6020604051808303816000875af1158015612661573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126859190613981565b9050806000036126a8576040516391248c2f60e01b815260040160405180910390fd5b95945050505050565b6000806126bd85612e3b565b604051631c57762b60e31b815260048101889052602481018690529091506000906001600160a01b0383169063e2bbb158906044016020604051808303816000875af1158015612711573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127359190613981565b905061274386858488612f80565b867fdb9f4f483629adc742ab3c617347f30d312040977540207f893353c316e41e6587878460405161277793929190613e62565b60405180910390a29695505050505050565b60408051602081018252600081529051632e6faca960e11b8152600481018390526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635cdf595290602401602060405180830381865afa1580156127fb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b79190613e83565b6040516351d53f8560e11b815260048101839052815160248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a3aa7f0a90604401612470565b60008061287f85612e3b565b604051630ad58d2f60e01b815260048101889052602481018690526001600160a01b038581166044830152919250600091831690630ad58d2f906064016020604051808303816000875af11580156128db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ff9190613981565b9050836001600160a01b0316877f9be1e46e992af75de5e2885a61decbd9d034da8f92db4912730192a7f358c07088848960405161293f93929190613e62565b60405180910390a39695505050505050565b60008183106129605781610e7e565b5090919050565b60008183116129605781610e7e565b604051638e8f294b60e01b81526001600160a01b03821690638e8f294b906129a29085906004016133cf565b606060405180830381865afa1580156129bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e39190613e9f565b516106d157604051639db8d5b160e01b815260040160405180910390fd5b60975460ff1661127d5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610758565b600054610100900460ff16612a715760405162461bcd60e51b815260040161075890613d3c565b61127d612fd8565b6106d182826111b1565b6000612a8e836106d5565b600084815260656020526040808220600101859055519192508391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b60009081526001919091016020526040902054151590565b6000826000018281548110612b0557612b05613c3b565b9060005260206000200154905092915050565b60606106b76001600160a01b03831660145b60606000612b39836002613c24565b612b44906002613c51565b6001600160401b03811115612b5b57612b5b613469565b6040519080825280601f01601f191660200182016040528015612b85576020820181803683370190505b509050600360fc1b81600081518110612ba057612ba0613c3b565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612bcf57612bcf613c3b565b60200101906001600160f81b031916908160001a9053506000612bf3846002613c24565b612bfe906001613c51565b90505b6001811115612c76576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612c3257612c32613c3b565b1a60f81b828281518110612c4857612c48613c3b565b60200101906001600160f81b031916908160001a90535060049490941c93612c6f81613f07565b9050612c01565b508315610e7e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610758565b600081815b8451811015612d0a57612cf682868381518110612ce957612ce9613c3b565b602002602001015161300b565b915080612d0281613f1e565b915050612cca565b509392505050565b612d1b8161249e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060612d5d83611f77565b612db85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610758565b600080846001600160a01b031684604051612dd39190613f37565b600060405180830381855af49150503d8060008114612e0e576040519150601f19603f3d011682016040523d82523d6000602084013e612e13565b606091505b50915091506126a88282604051806060016040528060278152602001613ff46027913961303a565b6000806001600160a01b038316612e6557604051630280e1e560e61b815260040160405180910390fd5b612e7060ca84613053565b15612f605760c9546001600160a01b0316612e8a81613068565b60405163189acdbd60e31b81529092506001600160a01b0383169063c4d66de890612eb99087906004016133cf565b600060405180830381600087803b158015612ed357600080fd5b505af1158015612ee7573d6000803e3d6000fd5b505050506001600160a01b03848116600081815260cc602090815260409182902080548786166001600160a01b031990911681179091558251938452908301529183168183015290517f78081ad49eb559c54c054262ee36c97f89c82901fb5dd734427fe3a664d14c8a9181900360600190a1506106b7565b50506001600160a01b03908116600090815260cc60205260409020541690565b610af7846323b872dd60e01b858585604051602401612fa193929190613a14565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613102565b600054610100900460ff16612fff5760405162461bcd60e51b815260040161075890613d3c565b6097805460ff19169055565b6000818310613027576000828152602084905260409020610e7e565b6000838152602083905260409020610e7e565b60608315613049575081610e7e565b610e7e83836131d4565b6000610e7e836001600160a01b0384166131fe565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b0381166130fd5760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610758565b919050565b6000613157826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132489092919063ffffffff16565b80519091501561071257808060200190518101906131759190613a43565b6107125760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610758565b8151156131e45781518083602001fd5b8060405162461bcd60e51b81526004016107589190613e1a565b600061320a8383612ad6565b613240575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106b7565b5060006106b7565b6060611100848460008585600080866001600160a01b0316858760405161326f9190613f37565b60006040518083038185875af1925050503d80600081146132ac576040519150601f19603f3d011682016040523d82523d6000602084013e6132b1565b606091505b5091509150611c76878383876060831561332a578251600003613323576132d785611f77565b6133235760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610758565b5081611100565b61110083836131d4565b6040518060400160405280613347613367565b81526020016133626040518060200160405280600081525090565b905290565b6040805160e08101909152806000815260006020820181905260408201819052606082018190526080820181905260a0820181905260c09091015290565b6000602082840312156133b757600080fd5b81356001600160e01b031981168114610e7e57600080fd5b6001600160a01b0391909116815260200190565b6001600160a01b038116811461091657600080fd5b80356130fd816133e3565b60006020828403121561341557600080fd5b8135610e7e816133e3565b60006020828403121561343257600080fd5b5035919050565b6000806040838503121561344c57600080fd5b82359150602083013561345e816133e3565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156134a7576134a7613469565b604052919050565b60006001600160401b038211156134c8576134c8613469565b5060051b60200190565b600080600080600060a086880312156134ea57600080fd5b853594506020808701356134fd816133e3565b94506040870135935060608701356001600160401b0381111561351f57600080fd5b8701601f8101891361353057600080fd5b803561354361353e826134af565b61347f565b81815260059190911b8201830190838101908b83111561356257600080fd5b928401925b8284101561358057833582529284019290840190613567565b8096505050505050613594608087016133f8565b90509295509295909350565b6020808252825182820181905260009190848201906040850190845b818110156135e15783516001600160a01b0316835292840192918401916001016135bc565b50909695505050505050565b6000806040838503121561360057600080fd5b823561360b816133e3565b91506020838101356001600160401b038082111561362857600080fd5b818601915086601f83011261363c57600080fd5b81358181111561364e5761364e613469565b613660601f8201601f1916850161347f565b9150808252878482850101111561367657600080fd5b80848401858401376000848284010152508093505050509250929050565b60ff8116811461091657600080fd5b6000806000606084860312156136b857600080fd5b8335925060208401356136ca81613694565b915060408401356136da816133e3565b809150509250925092565b801515811461091657600080fd5b60008060006060848603121561370857600080fd5b83359250602084013561371a81613694565b915060408401356136da816136e5565b600082601f83011261373b57600080fd5b8135602061374b61353e836134af565b82815260059290921b8401810191818101908684111561376a57600080fd5b8286015b8481101561378e578035613781816133e3565b835291830191830161376e565b509695505050505050565b6000602082840312156137ab57600080fd5b81356001600160401b038111156137c157600080fd5b6111008482850161372a565b6000602082840312156137df57600080fd5b8135610e7e816136e5565b6000806000606084860312156137ff57600080fd5b833561380a816133e3565b925060208401356136ca816133e3565b6003811061091657600080fd5b6000806000806060858703121561383d57600080fd5b84356001600160401b038082111561385457600080fd5b6138608883890161372a565b9550602087013591506138728261381a565b9093506040860135908082111561388857600080fd5b818701915087601f83011261389c57600080fd5b8135818111156138ab57600080fd5b8860208260051b85010111156138c057600080fd5b95989497505060200194505050565b600080604083850312156138e257600080fd5b82356138ed816133e3565b9150602083013561345e8161381a565b6020808252602c90820152600080516020613f7483398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020613f7483398151915260408201526b6163746976652070726f787960a01b606082015260800190565b9182521515602082015260400190565b60006020828403121561399357600080fd5b5051919050565b80516130fd816133e3565b6000602082840312156139b757600080fd5b8151610e7e816133e3565b634e487b7160e01b600052601160045260246000fd5b60ff82811682821603908111156106b7576106b76139c2565b6001600160a01b0393909316835260208301919091521515604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b80516130fd816136e5565b600060208284031215613a5557600080fd5b8151610e7e816136e5565b805165ffffffffffff811681146130fd57600080fd5b600060e08284031215613a8857600080fd5b60405160e081016001600160401b0381118282101715613aaa57613aaa613469565b80604052508091508251613abd8161381a565b81526020830151613acd81613694565b60208201526040830151613ae081613694565b60408201526060830151613af381613694565b6060820152613b0460808401613a38565b6080820152613b1560a08401613a60565b60a0820152613b2660c0840161399a565b60c08201525092915050565b600060208284031215613b4457600080fd5b604051602081016001600160401b0381118282101715613b6657613b66613469565b6040529151825250919050565b60006101008284031215613b8657600080fd5b604080519081016001600160401b0381118282101715613ba857613ba8613469565b604052613bb58484613a76565b8152613bc48460e08501613b32565b60208201529392505050565b634e487b7160e01b600052602160045260246000fd5b600060e08284031215613bf857600080fd5b610e7e8383613a76565b600082613c1f57634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176106b7576106b76139c2565b634e487b7160e01b600052603260045260246000fd5b808201808211156106b7576106b76139c2565b805160038110613c8457634e487b7160e01b600052602160045260246000fd5b8083525060ff60208201511660208301526040810151613ca9604084018260ff169052565b506060810151613cbe606084018260ff169052565b506080810151613cd2608084018215159052565b5060a0810151613cec60a084018265ffffffffffff169052565b5060c081015161071260c08401826001600160a01b03169052565b6001600160a01b03831681528151610120820190613d29906020840190613c64565b6020830151516101008301529392505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60005b83811015613da2578181015183820152602001613d8a565b50506000910152565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613ddd816017850160208801613d87565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613e0e816028840160208801613d87565b01602801949350505050565b6020815260008251806020840152613e39816040850160208701613d87565b601f01601f19169190910160400192915050565b8281526101008101610e7e6020830184613c64565b6001600160a01b039390931683526020830191909152604082015260600190565b600060208284031215613e9557600080fd5b610e7e8383613b32565b600060608284031215613eb157600080fd5b604051606081016001600160401b0381118282101715613ed357613ed3613469565b6040528251613ee1816136e5565b8152602083810151908201526040830151613efb816136e5565b60408201529392505050565b600081613f1657613f166139c2565b506000190190565b600060018201613f3057613f306139c2565b5060010190565b60008251613f49818460208701613d87565b919091019291505056fe21702c8af46127c7fa207f89d0b0a8441bb32959a0ac7df790e9ab1a25c9892646756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0865d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201b407a8117fecb0323db86e19d8414ecd396eee769775d1011ca4e0b74886cb664736f6c634300081100330000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a80000000000000000000000001775286cbe9db126a95abf52c58a3214fca26803
Deployed Bytecode
0x6080604052600436106101aa5760003560e01c806301ffc9a7146101af57806314b8194c146101e4578063174ef86a14610225578063248a9ca31461024757806324d7806c146102755780632f2ff15d14610295578063343a5962146102b557806336568abe146102d55780633659cfe6146102f5578063375a7cba146103155780634f1ef2861461033757806352d1902d1461034a5780635c975abb1461035f57806362b199c514610377578063684fe77914610399578063700cd58a146103b95780637394507e146103ed5780637cb647591461040d5780638efb3f4f1461042d57806391d148541461046357806396e83924146104835780639b5d2e78146104a3578063a217fddf146104b8578063a42fd192146104cd578063a5402544146104ed578063bba48a9014610502578063bd075b8414610522578063bedb86fb14610542578063c0c53b8b14610562578063c772356914610582578063cc10b9b3146105a2578063cd170311146105c2578063d547741f146105e2578063e63ab1e914610602578063ec87621c14610624578063f3c5400614610646578063f3c95c6014610666575b600080fd5b3480156101bb57600080fd5b506101cf6101ca3660046133a5565b610686565b60405190151581526020015b60405180910390f35b3480156101f057600080fd5b506102187f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a881565b6040516101db91906133cf565b34801561023157600080fd5b50610245610240366004613403565b6106bd565b005b34801561025357600080fd5b50610267610262366004613420565b6106d5565b6040519081526020016101db565b34801561028157600080fd5b506101cf610290366004613403565b6106ea565b3480156102a157600080fd5b506102456102b0366004613439565b6106f6565b3480156102c157600080fd5b506102456102d03660046134d2565b610717565b3480156102e157600080fd5b506102456102f0366004613439565b6107d7565b34801561030157600080fd5b50610245610310366004613403565b610851565b34801561032157600080fd5b5061032a610919565b6040516101db91906135a0565b6102456103453660046135ed565b61092a565b34801561035657600080fd5b506102676109df565b34801561036b57600080fd5b5060975460ff166101cf565b34801561038357600080fd5b50610267600080516020613f5483398151915281565b3480156103a557600080fd5b506102456103b43660046136a3565b610a8d565b3480156103c557600080fd5b506102187f0000000000000000000000001775286cbe9db126a95abf52c58a3214fca2680381565b3480156103f957600080fd5b50610245610408366004613439565b610afd565b34801561041957600080fd5b50610245610428366004613420565b610c15565b34801561043957600080fd5b50610218610448366004613403565b60cc602052600090815260409020546001600160a01b031681565b34801561046f57600080fd5b506101cf61047e366004613439565b610c71565b34801561048f57600080fd5b5061024561049e366004613420565b610c9c565b3480156104af57600080fd5b50610218610da2565b3480156104c457600080fd5b50610267600081565b3480156104d957600080fd5b506102676104e83660046136f3565b610e26565b3480156104f957600080fd5b50610267610e85565b34801561050e57600080fd5b5060c954610218906001600160a01b031681565b34801561052e57600080fd5b5061024561053d366004613799565b610e91565b34801561054e57600080fd5b5061024561055d3660046137cd565b610ec4565b34801561056e57600080fd5b5061024561057d3660046137ea565b610ef1565b34801561058e57600080fd5b5061024561059d366004613827565b611045565b3480156105ae57600080fd5b506102676105bd3660046138cf565b611077565b3480156105ce57600080fd5b506101cf6105dd366004613403565b611108565b3480156105ee57600080fd5b506102456105fd366004613439565b611115565b34801561060e57600080fd5b50610267600080516020613fd483398151915281565b34801561063057600080fd5b50610267600080516020613fb483398151915281565b34801561065257600080fd5b50610218610661366004613420565b611131565b34801561067257600080fd5b506101cf610681366004613403565b61113e565b60006001600160e01b03198216637965db0b60e01b14806106b757506301ffc9a760e01b6001600160e01b03198316145b92915050565b60006106c88161115f565b6106d182611169565b5050565b60009081526065602052604090206001015490565b60006106b78183610c71565b6106ff826106d5565b6107088161115f565b61071283836111b1565b505050565b61071f611237565b83610738600080516020613f5483398151915282610c71565b1561076157806040516339edf4c360e11b815260040161075891906133cf565b60405180910390fd5b61076961127f565b6000806107778787876112d8565b9150915061078a886001868a60016113b4565b60408051838152602081018390527f7d85331eec197ef05ed037cf88fe5937a220c6b65b6ea665bbf09736aef62c47910160405180910390a150506107cf600160cd55565b505050505050565b6001600160a01b03811633146108475760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610758565b6106d18282611536565b6001600160a01b037f0000000000000000000000003853abd4560e0590eb92cfed9c9a132e35c6a53a1630036108995760405162461bcd60e51b8152600401610758906138fd565b7f0000000000000000000000003853abd4560e0590eb92cfed9c9a132e35c6a53a6001600160a01b03166108cb61159d565b6001600160a01b0316146108f15760405162461bcd60e51b815260040161075890613937565b6108fa816115b9565b60408051600080825260208201909252610916918391906115c4565b50565b606061092560ca61172f565b905090565b6001600160a01b037f0000000000000000000000003853abd4560e0590eb92cfed9c9a132e35c6a53a1630036109725760405162461bcd60e51b8152600401610758906138fd565b7f0000000000000000000000003853abd4560e0590eb92cfed9c9a132e35c6a53a6001600160a01b03166109a461159d565b6001600160a01b0316146109ca5760405162461bcd60e51b815260040161075890613937565b6109d3826115b9565b6106d1828260016115c4565b6000306001600160a01b037f0000000000000000000000003853abd4560e0590eb92cfed9c9a132e35c6a53a1614610a7a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608401610758565b50600080516020613f9483398151915290565b610a95611237565b33610aae600080516020613f5483398151915282610c71565b15610ace57806040516339edf4c360e11b815260040161075891906133cf565b610ad661127f565b610adf8461173c565b610aed8484843360006113b4565b610af7600160cd55565b50505050565b610b05611237565b610b0d61127f565b610b168261173c565b610b1e6117f1565b610ba3576000610b2d83611862565b60208101515190915015610b5457604051637cca156760e11b815260040160405180910390fd5b6001600160a01b038216610b7b57604051631c0eb28960e11b815260040160405180910390fd5b805151600090610b8c9060046118f4565b9050610b9f848360000151853385611970565b5050505b610bab611a45565b6001600160a01b031663c1450c7e8360016040518363ffffffff1660e01b8152600401610bd9929190613971565b600060405180830381600087803b158015610bf357600080fd5b505af1158015610c07573d6000803e3d6000fd5b505050506106d1600160cd55565b600080516020613fb4833981519152610c2d8161115f565b6101645460408051918252602082018490527f341ccafbcebf06bf65a4c2db1a85106ad3c0d9421c1f3207d7d1f76791e479c9910160405180910390a15061016455565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610ca4611237565b610cac61127f565b610cb58161173c565b6000610cbf611a45565b90506000816001600160a01b0316634579661d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d259190613981565b1115610d8d576040516360a2863f60e11b81526001600160a01b0382169063c1450c7e90610d5a908590600090600401613971565b600060405180830381600087803b158015610d7457600080fd5b505af1158015610d88573d6000803e3d6000fd5b505050505b610d978233611aa5565b50610916600160cd55565b60007f0000000000000000000000001775286cbe9db126a95abf52c58a3214fca268036001600160a01b0316639d1b5a0a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092591906139a5565b600080610e3285611af3565b90508360ff168160200151600c610e4991906139d8565b60ff161015610e6b57604051637142e1e560e11b815260040160405180910390fd5b610e7a81856101635486611b84565b9150505b9392505050565b600061092560ca611c81565b610e99611237565b610ea161127f565b610eac816000611c8b565b610eba336000806000611db6565b610916600160cd55565b600080516020613fd4833981519152610edc8161115f565b81610ee9576106d1611eee565b6106d1611f3a565b600054610100900460ff1615808015610f115750600054600160ff909116105b80610f325750610f2030611f77565b158015610f32575060005460ff166001145b610f955760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610758565b6000805460ff191660011790558015610fb8576000805461ff0019166101001790555b6001600160a01b038416610fdf5760405163d92e233d60e01b815260040160405180910390fd5b610fe98383611f86565b610ff284612059565b610ffa612080565b8015610af7576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b61104d611237565b61105561127f565b6110608383836120a7565b61106a8484611c8b565b610aed3384600080611db6565b6000806110858360046118f4565b905061108f612227565b6001600160a01b031663ad3d19d5858360016040518463ffffffff1660e01b81526004016110bf939291906139f1565b602060405180830381865afa1580156110dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111009190613981565b949350505050565b60006106b760ca83612287565b61111e826106d5565b6111278161115f565b6107128383611536565b60006106b760ca8361229c565b6000611158600080516020613f5483398151915283610c71565b1592915050565b61091681336122a8565b61117281611f77565b61118f57604051630747d8c560e31b815260040160405180910390fd5b60c980546001600160a01b0319166001600160a01b0392909216919091179055565b6111bb8282610c71565b6106d15760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556111f33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60975460ff161561127d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610758565b565b600260cd54036112d15760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610758565b600260cd55565b604080516001600160a01b03851660208201529081018390526000908190819060600160408051601f198184030181528282528051602091820120908301520160408051601f198184030181529181528151602092830120600081815261016590935291205490915060ff161561136257604051637242b99b60e11b815260040160405180910390fd5b600081815261016560205260409020805460ff191660011790556101645461138b858284612301565b6113a8576040516309bde33960e01b815260040160405180910390fd5b90969095509350505050565b60006113bf86611af3565b905060008160200151600c6113d491906139d8565b90508060ff166000036113fa57604051630ec173f160e21b815260040160405180910390fd5b8060ff168660ff16111561142157604051633bf077a560e11b815260040160405180910390fd5b8060ff168660ff160361143d5761143a87838787612317565b91505b61016354600061144f84898488611b84565b60208501805160ff908b018181169092528a168403610163559091506114758a86612422565b61147d610da2565b6001600160a01b03166323b872dd3361dead856040518463ffffffff1660e01b81526004016114ae93929190613a14565b6020604051808303816000875af11580156114cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f19190613a43565b5060405160ff821681528a907fa07fb4b6c67d359d0ff55194b0ae712344245d43c9ab85ccbab7a56c2c26067a9060200160405180910390a250505050505050505050565b6115408282610c71565b156106d15760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020613f94833981519152546001600160a01b031690565b60006106d18161115f565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156115f7576107128361249e565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611651575060408051601f3d908101601f1916820190925261164e91810190613981565b60015b6116b45760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610758565b600080516020613f9483398151915281146117235760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610758565b50610712838383612538565b60606000610e7e8361255d565b6040516331a9108f60e11b81526004810182905233906001600160a01b037f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a81690636352211e90602401602060405180830381865afa1580156117a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c791906139a5565b6001600160a01b0316146109165760405163d6c86cb560e01b815260048101829052602401610758565b60006117fb611a45565b6001600160a01b0316634579661d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611838573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185c9190613981565b15919050565b61186a613334565b60405163b09afec160e01b8152600481018390527f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a86001600160a01b03169063b09afec19060240161010060405180830381865afa1580156118d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b79190613b73565b60008061192384600281111561190c5761190c613bd0565b84600781111561191e5761191e613bd0565b6125b9565b60ff169050600483600781111561193c5761193c613bd0565b14806119595750600283600781111561195757611957613bd0565b145b15610e7e5768056bc75e2d63100000029392505050565b611978613367565b81156119d35760006119948561198c612227565b85600161260f565b905060006119a4888784886126b1565b6001600160a01b03871660c0890152905060006119c089612789565b82815290506119cf898261281f565b5050505b6119db611a45565b6001600160a01b031663c1450c7e8760016040518363ffffffff1660e01b8152600401611a09929190613971565b600060405180830381600087803b158015611a2357600080fd5b505af1158015611a37573d6000803e3d6000fd5b509698975050505050505050565b60007f0000000000000000000000001775286cbe9db126a95abf52c58a3214fca268036001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b6000611ab083611af3565b90506000611abd84612789565b9050611ad3848360c00151836000015186612873565b50600060c083018190528152611ae98483612422565b610af7848261281f565b611afb613367565b604051637cdc4c2f60e11b8152600481018390527f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a86001600160a01b03169063f9b8985e9060240160e060405180830381865afa158015611b60573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b79190613be6565b6000808315611c1457611b95610da2565b6001600160a01b0316632b112e496040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611bee575060408051601f3d908101601f19168201909252611beb91810190613981565b60015b15611c1457611c10611c008683613c02565b69010f0cf064dd59200000612951565b9150505b8460ff16611c2b82683635c9adc5dea00000612967565b611c359190613c24565b90508215611c5957620f4240611c4c600083613c24565b611c569190613c02565b90505b6000611c6a876000015160036118f4565b9050611c768183613c24565b979650505050505050565b60006106b7825490565b6000611c95612227565b90507f0000000000000000000000001775286cbe9db126a95abf52c58a3214fca268036000611cc58460026118f4565b8551909150600080805b83811015611d9c57888181518110611ce957611ce9613c3b565b60200260200101519150611cfd8287612976565b611d768288846001600160a01b03166370a08231336040518263ffffffff1660e01b8152600401611d2e91906133cf565b602060405180830381865afa158015611d4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d6f9190613981565b600061260f565b611d809084613c51565b9250848310611d9457505050505050505050565b600101611ccf565b506040516374c9171160e01b815260040160405180910390fd5b60408051610120810182526000918190810180876002811115611ddb57611ddb613bd0565b81526020018560ff168152602001611df48860006118f4565b60ff168152602001611e078860016118f4565b60ff1681526000602080830182905265ffffffffffff89166040808501919091526060909301829052928452815180840190925281529101529050611e4d82600c6139d8565b60ff166101636000828254611e629190613c51565b909155505060405163ce3f506f60e01b81526001600160a01b037f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a8169063ce3f506f90611eb59088908590600401613d07565b600060405180830381600087803b158015611ecf57600080fd5b505af1158015611ee3573d6000803e3d6000fd5b505050505050505050565b611ef6612a01565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051611f3091906133cf565b60405180910390a1565b611f42611237565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611f233390565b6001600160a01b03163b151590565b600054610100900460ff16611fad5760405162461bcd60e51b815260040161075890613d3c565b6001600160a01b0382161580611fca57506001600160a01b038116155b15611fe85760405163d92e233d60e01b815260040160405180910390fd5b611ff0612080565b611ff8612a4a565b612003600033612a79565b61201b600080516020613fb483398151915283612a79565b612033600080516020613fd483398151915282612a79565b6106d1600080516020613f54833981519152600080516020613fb4833981519152612a83565b600054610100900460ff1661118f5760405162461bcd60e51b815260040161075890613d3c565b600054610100900460ff1661127d5760405162461bcd60e51b815260040161075890613d3c565b6120af613367565b600080808481806120c18a60056118f4565b905060006120d08b60066118f4565b905060006120df8c60076118f4565b905060005b858110156121e3578b8b828181106120fe576120fe613c3b565b9050602002013594506121108561173c565b61211985611af3565b6020810151909a5060ff16600c1461214457604051637142e1e560e11b815260040160405180910390fd5b89608001516121db576000808b51600281111561216357612163613bd0565b14801561216f5750848a105b1561218057506001988901986121c2565b60018b51600281111561219557612195613bd0565b1480156121a157508389105b156121b257506001978801976121c2565b828810156121c257506001968701965b80156121d957600160808c01526121d9868c612422565b505b6001016120e4565b50828810806121f157508187105b806121fb57508086105b15612219576040516309a734db60e31b815260040160405180910390fd5b505050505050505050505050565b60007f0000000000000000000000001775286cbe9db126a95abf52c58a3214fca268036001600160a01b0316637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e02573d6000803e3d6000fd5b6000610e7e836001600160a01b038416612ad6565b6000610e7e8383612aee565b6122b28282610c71565b6106d1576122bf81612b18565b6122ca836020612b2a565b6040516020016122db929190613dab565b60408051601f198184030181529082905262461bcd60e51b825261075891600401613e1a565b60008261230e8584612cc5565b14949350505050565b61231f613367565b6123276117f1565b612376576001600160a01b03831661235257604051631c0eb28960e11b815260040160405180910390fd5b6000612363856000015160046118f4565b90506123728686868685611970565b9450505b61237e611a45565b6001600160a01b031663c1450c7e8660016040518363ffffffff1660e01b81526004016123ac929190613971565b600060405180830381600087803b1580156123c657600080fd5b505af11580156123da573d6000803e3d6000fd5b50505065ffffffffffff421660a086015250604051339086907fe7e38e098beb1732df08ee49549910543e4ecb953da8d895cb6a19ef0a76fb7590600090a350919392505050565b60405163d4bef91b60e01b81526001600160a01b037f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a8169063d4bef91b906124709085908590600401613e4d565b600060405180830381600087803b15801561248a57600080fd5b505af11580156107cf573d6000803e3d6000fd5b6124a781611f77565b6125095760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610758565b600080516020613f9483398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61254183612d12565b60008251118061254e5750805b1561071257610af78383612d52565b6060816000018054806020026020016040519081016040528092919081815260200182805480156125ad57602002820191906000526020600020905b815481526020019060010190808311612599575b50505050509050919050565b600060405180604001604052806018815260200174010203010b78010101010a64010000000a0a00000160581b815250838360030201815181106125ff576125ff613c3b565b016020015160f81c905092915050565b600080846001600160a01b031663616b3c278786866040518463ffffffff1660e01b8152600401612642939291906139f1565b6020604051808303816000875af1158015612661573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126859190613981565b9050806000036126a8576040516391248c2f60e01b815260040160405180910390fd5b95945050505050565b6000806126bd85612e3b565b604051631c57762b60e31b815260048101889052602481018690529091506000906001600160a01b0383169063e2bbb158906044016020604051808303816000875af1158015612711573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127359190613981565b905061274386858488612f80565b867fdb9f4f483629adc742ab3c617347f30d312040977540207f893353c316e41e6587878460405161277793929190613e62565b60405180910390a29695505050505050565b60408051602081018252600081529051632e6faca960e11b8152600481018390526001600160a01b037f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a81690635cdf595290602401602060405180830381865afa1580156127fb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b79190613e83565b6040516351d53f8560e11b815260048101839052815160248201527f0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a86001600160a01b03169063a3aa7f0a90604401612470565b60008061287f85612e3b565b604051630ad58d2f60e01b815260048101889052602481018690526001600160a01b038581166044830152919250600091831690630ad58d2f906064016020604051808303816000875af11580156128db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ff9190613981565b9050836001600160a01b0316877f9be1e46e992af75de5e2885a61decbd9d034da8f92db4912730192a7f358c07088848960405161293f93929190613e62565b60405180910390a39695505050505050565b60008183106129605781610e7e565b5090919050565b60008183116129605781610e7e565b604051638e8f294b60e01b81526001600160a01b03821690638e8f294b906129a29085906004016133cf565b606060405180830381865afa1580156129bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e39190613e9f565b516106d157604051639db8d5b160e01b815260040160405180910390fd5b60975460ff1661127d5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610758565b600054610100900460ff16612a715760405162461bcd60e51b815260040161075890613d3c565b61127d612fd8565b6106d182826111b1565b6000612a8e836106d5565b600084815260656020526040808220600101859055519192508391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b60009081526001919091016020526040902054151590565b6000826000018281548110612b0557612b05613c3b565b9060005260206000200154905092915050565b60606106b76001600160a01b03831660145b60606000612b39836002613c24565b612b44906002613c51565b6001600160401b03811115612b5b57612b5b613469565b6040519080825280601f01601f191660200182016040528015612b85576020820181803683370190505b509050600360fc1b81600081518110612ba057612ba0613c3b565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612bcf57612bcf613c3b565b60200101906001600160f81b031916908160001a9053506000612bf3846002613c24565b612bfe906001613c51565b90505b6001811115612c76576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612c3257612c32613c3b565b1a60f81b828281518110612c4857612c48613c3b565b60200101906001600160f81b031916908160001a90535060049490941c93612c6f81613f07565b9050612c01565b508315610e7e5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610758565b600081815b8451811015612d0a57612cf682868381518110612ce957612ce9613c3b565b602002602001015161300b565b915080612d0281613f1e565b915050612cca565b509392505050565b612d1b8161249e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060612d5d83611f77565b612db85760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610758565b600080846001600160a01b031684604051612dd39190613f37565b600060405180830381855af49150503d8060008114612e0e576040519150601f19603f3d011682016040523d82523d6000602084013e612e13565b606091505b50915091506126a88282604051806060016040528060278152602001613ff46027913961303a565b6000806001600160a01b038316612e6557604051630280e1e560e61b815260040160405180910390fd5b612e7060ca84613053565b15612f605760c9546001600160a01b0316612e8a81613068565b60405163189acdbd60e31b81529092506001600160a01b0383169063c4d66de890612eb99087906004016133cf565b600060405180830381600087803b158015612ed357600080fd5b505af1158015612ee7573d6000803e3d6000fd5b505050506001600160a01b03848116600081815260cc602090815260409182902080548786166001600160a01b031990911681179091558251938452908301529183168183015290517f78081ad49eb559c54c054262ee36c97f89c82901fb5dd734427fe3a664d14c8a9181900360600190a1506106b7565b50506001600160a01b03908116600090815260cc60205260409020541690565b610af7846323b872dd60e01b858585604051602401612fa193929190613a14565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613102565b600054610100900460ff16612fff5760405162461bcd60e51b815260040161075890613d3c565b6097805460ff19169055565b6000818310613027576000828152602084905260409020610e7e565b6000838152602083905260409020610e7e565b60608315613049575081610e7e565b610e7e83836131d4565b6000610e7e836001600160a01b0384166131fe565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b0381166130fd5760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610758565b919050565b6000613157826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166132489092919063ffffffff16565b80519091501561071257808060200190518101906131759190613a43565b6107125760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610758565b8151156131e45781518083602001fd5b8060405162461bcd60e51b81526004016107589190613e1a565b600061320a8383612ad6565b613240575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106b7565b5060006106b7565b6060611100848460008585600080866001600160a01b0316858760405161326f9190613f37565b60006040518083038185875af1925050503d80600081146132ac576040519150601f19603f3d011682016040523d82523d6000602084013e6132b1565b606091505b5091509150611c76878383876060831561332a578251600003613323576132d785611f77565b6133235760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610758565b5081611100565b61110083836131d4565b6040518060400160405280613347613367565b81526020016133626040518060200160405280600081525090565b905290565b6040805160e08101909152806000815260006020820181905260408201819052606082018190526080820181905260a0820181905260c09091015290565b6000602082840312156133b757600080fd5b81356001600160e01b031981168114610e7e57600080fd5b6001600160a01b0391909116815260200190565b6001600160a01b038116811461091657600080fd5b80356130fd816133e3565b60006020828403121561341557600080fd5b8135610e7e816133e3565b60006020828403121561343257600080fd5b5035919050565b6000806040838503121561344c57600080fd5b82359150602083013561345e816133e3565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156134a7576134a7613469565b604052919050565b60006001600160401b038211156134c8576134c8613469565b5060051b60200190565b600080600080600060a086880312156134ea57600080fd5b853594506020808701356134fd816133e3565b94506040870135935060608701356001600160401b0381111561351f57600080fd5b8701601f8101891361353057600080fd5b803561354361353e826134af565b61347f565b81815260059190911b8201830190838101908b83111561356257600080fd5b928401925b8284101561358057833582529284019290840190613567565b8096505050505050613594608087016133f8565b90509295509295909350565b6020808252825182820181905260009190848201906040850190845b818110156135e15783516001600160a01b0316835292840192918401916001016135bc565b50909695505050505050565b6000806040838503121561360057600080fd5b823561360b816133e3565b91506020838101356001600160401b038082111561362857600080fd5b818601915086601f83011261363c57600080fd5b81358181111561364e5761364e613469565b613660601f8201601f1916850161347f565b9150808252878482850101111561367657600080fd5b80848401858401376000848284010152508093505050509250929050565b60ff8116811461091657600080fd5b6000806000606084860312156136b857600080fd5b8335925060208401356136ca81613694565b915060408401356136da816133e3565b809150509250925092565b801515811461091657600080fd5b60008060006060848603121561370857600080fd5b83359250602084013561371a81613694565b915060408401356136da816136e5565b600082601f83011261373b57600080fd5b8135602061374b61353e836134af565b82815260059290921b8401810191818101908684111561376a57600080fd5b8286015b8481101561378e578035613781816133e3565b835291830191830161376e565b509695505050505050565b6000602082840312156137ab57600080fd5b81356001600160401b038111156137c157600080fd5b6111008482850161372a565b6000602082840312156137df57600080fd5b8135610e7e816136e5565b6000806000606084860312156137ff57600080fd5b833561380a816133e3565b925060208401356136ca816133e3565b6003811061091657600080fd5b6000806000806060858703121561383d57600080fd5b84356001600160401b038082111561385457600080fd5b6138608883890161372a565b9550602087013591506138728261381a565b9093506040860135908082111561388857600080fd5b818701915087601f83011261389c57600080fd5b8135818111156138ab57600080fd5b8860208260051b85010111156138c057600080fd5b95989497505060200194505050565b600080604083850312156138e257600080fd5b82356138ed816133e3565b9150602083013561345e8161381a565b6020808252602c90820152600080516020613f7483398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020613f7483398151915260408201526b6163746976652070726f787960a01b606082015260800190565b9182521515602082015260400190565b60006020828403121561399357600080fd5b5051919050565b80516130fd816133e3565b6000602082840312156139b757600080fd5b8151610e7e816133e3565b634e487b7160e01b600052601160045260246000fd5b60ff82811682821603908111156106b7576106b76139c2565b6001600160a01b0393909316835260208301919091521515604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b80516130fd816136e5565b600060208284031215613a5557600080fd5b8151610e7e816136e5565b805165ffffffffffff811681146130fd57600080fd5b600060e08284031215613a8857600080fd5b60405160e081016001600160401b0381118282101715613aaa57613aaa613469565b80604052508091508251613abd8161381a565b81526020830151613acd81613694565b60208201526040830151613ae081613694565b60408201526060830151613af381613694565b6060820152613b0460808401613a38565b6080820152613b1560a08401613a60565b60a0820152613b2660c0840161399a565b60c08201525092915050565b600060208284031215613b4457600080fd5b604051602081016001600160401b0381118282101715613b6657613b66613469565b6040529151825250919050565b60006101008284031215613b8657600080fd5b604080519081016001600160401b0381118282101715613ba857613ba8613469565b604052613bb58484613a76565b8152613bc48460e08501613b32565b60208201529392505050565b634e487b7160e01b600052602160045260246000fd5b600060e08284031215613bf857600080fd5b610e7e8383613a76565b600082613c1f57634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176106b7576106b76139c2565b634e487b7160e01b600052603260045260246000fd5b808201808211156106b7576106b76139c2565b805160038110613c8457634e487b7160e01b600052602160045260246000fd5b8083525060ff60208201511660208301526040810151613ca9604084018260ff169052565b506060810151613cbe606084018260ff169052565b506080810151613cd2608084018215159052565b5060a0810151613cec60a084018265ffffffffffff169052565b5060c081015161071260c08401826001600160a01b03169052565b6001600160a01b03831681528151610120820190613d29906020840190613c64565b6020830151516101008301529392505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60005b83811015613da2578181015183820152602001613d8a565b50506000910152565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351613ddd816017850160208801613d87565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613e0e816028840160208801613d87565b01602801949350505050565b6020815260008251806020840152613e39816040850160208701613d87565b601f01601f19169190910160400192915050565b8281526101008101610e7e6020830184613c64565b6001600160a01b039390931683526020830191909152604082015260600190565b600060208284031215613e9557600080fd5b610e7e8383613b32565b600060608284031215613eb157600080fd5b604051606081016001600160401b0381118282101715613ed357613ed3613469565b6040528251613ee1816136e5565b8152602083810151908201526040830151613efb816136e5565b60408201529392505050565b600081613f1657613f166139c2565b506000190190565b600060018201613f3057613f306139c2565b5060010190565b60008251613f49818460208701613d87565b919091019291505056fe21702c8af46127c7fa207f89d0b0a8441bb32959a0ac7df790e9ab1a25c9892646756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0865d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201b407a8117fecb0323db86e19d8414ecd396eee769775d1011ca4e0b74886cb664736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a80000000000000000000000001775286cbe9db126a95abf52c58a3214fca26803
-----Decoded View---------------
Arg [0] : gnft_ (address): 0x2e86fA4440d93b1BFfEa5cA673314ef54216D0a8
Arg [1] : comptroller_ (address): 0x1775286Cbe9db126a95AbF52c58a3214FCA26803
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000002e86fa4440d93b1bffea5ca673314ef54216d0a8
Arg [1] : 0000000000000000000000001775286cbe9db126a95abf52c58a3214fca26803
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.