Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
FxUSD
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity =0.8.20; import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable-v4/access/AccessControlUpgradeable.sol"; import { ERC20PermitUpgradeable } from "@openzeppelin/contracts-upgradeable-v4/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable-v4/token/ERC20/utils/SafeERC20Upgradeable.sol"; import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable-v4/token/ERC20/IERC20Upgradeable.sol"; import { EnumerableSetUpgradeable } from "@openzeppelin/contracts-upgradeable-v4/utils/structs/EnumerableSetUpgradeable.sol"; import { IFxFractionalTokenV2 } from "../../interfaces/f(x)/IFxFractionalTokenV2.sol"; import { IFxMarketV2 } from "../../interfaces/f(x)/IFxMarketV2.sol"; import { IFxTreasuryV2 } from "../../interfaces/f(x)/IFxTreasuryV2.sol"; import { IFxUSD } from "../../interfaces/f(x)/IFxUSD.sol"; import { IFxShareableRebalancePool } from "../../interfaces/f(x)/IFxShareableRebalancePool.sol"; contract FxUSD is AccessControlUpgradeable, ERC20PermitUpgradeable, IFxUSD { using SafeERC20Upgradeable for IERC20Upgradeable; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; /************* * Constants * *************/ /// @dev The precision used to compute nav. uint256 private constant PRECISION = 1e18; /*********** * Structs * ***********/ /// @param fToken The address of Fractional Token. /// @param treasury The address of treasury contract. /// @param market The address of market contract. /// @param mintCap The maximum amount of fToken can be minted. /// @param managed The amount of fToken managed in this contract. struct FxMarketStruct { address fToken; address treasury; address market; uint256 mintCap; uint256 managed; } /************* * Variables * *************/ /// @notice Mapping from base token address to metadata. mapping(address => FxMarketStruct) public markets; /// @dev The list of supported base tokens. EnumerableSetUpgradeable.AddressSet private supportedTokens; /// @dev The list of supported rebalance pools. EnumerableSetUpgradeable.AddressSet private supportedPools; /************* * Modifiers * *************/ modifier onlySupportedMarket(address _baseToken) { _checkBaseToken(_baseToken); _; } modifier onlySupportedPool(address _pool) { if (!supportedPools.contains(_pool)) revert ErrorUnsupportedRebalancePool(); _; } modifier onlyMintableMarket(address _baseToken, bool isMint) { _checkMarketMintable(_baseToken, isMint); _; } /*************** * Constructor * ***************/ function initialize(string memory _name, string memory _symbol) external initializer { __Context_init(); __ERC165_init(); __AccessControl_init(); __ERC20_init(_name, _symbol); __ERC20Permit_init(_name); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); } /************************* * Public View Functions * *************************/ /// @inheritdoc IFxUSD function getMarkets() external view override returns (address[] memory _tokens) { uint256 _numMarkets = supportedTokens.length(); _tokens = new address[](_numMarkets); for (uint256 i = 0; i < _numMarkets; ++i) { _tokens[i] = supportedTokens.at(i); } } /// @inheritdoc IFxUSD function getRebalancePools() external view override returns (address[] memory _pools) { uint256 _numPools = supportedPools.length(); _pools = new address[](_numPools); for (uint256 i = 0; i < _numPools; ++i) { _pools[i] = supportedPools.at(i); } } /// @inheritdoc IFxUSD function nav() external view override returns (uint256 _nav) { uint256 _numMarkets = supportedTokens.length(); uint256 _supply = totalSupply(); if (_supply == 0) return PRECISION; for (uint256 i = 0; i < _numMarkets; i++) { address _baseToken = supportedTokens.at(i); address _fToken = markets[_baseToken].fToken; uint256 _fnav = IFxFractionalTokenV2(_fToken).nav(); _nav += _fnav * markets[_baseToken].managed; } _nav /= _supply; } /// @inheritdoc IFxUSD function isUnderCollateral() public view override returns (bool) { uint256 _numMarkets = supportedTokens.length(); for (uint256 i = 0; i < _numMarkets; i++) { address _baseToken = supportedTokens.at(i); address _treasury = markets[_baseToken].treasury; if (IFxTreasuryV2(_treasury).isUnderCollateral()) return true; } return false; } /**************************** * Public Mutated Functions * ****************************/ /// @inheritdoc IFxUSD function wrap( address _baseToken, uint256 _amount, address _receiver ) external override onlySupportedMarket(_baseToken) onlyMintableMarket(_baseToken, false) { if (isUnderCollateral()) revert ErrorUnderCollateral(); address _fToken = markets[_baseToken].fToken; IERC20Upgradeable(_fToken).safeTransferFrom(_msgSender(), address(this), _amount); _mintShares(_baseToken, _receiver, _amount); emit Wrap(_baseToken, _msgSender(), _receiver, _amount); } /// @inheritdoc IFxUSD function wrapFrom( address _pool, uint256 _amount, address _receiver ) external override onlySupportedPool(_pool) { if (isUnderCollateral()) revert ErrorUnderCollateral(); address _baseToken = IFxShareableRebalancePool(_pool).baseToken(); _checkBaseToken(_baseToken); _checkMarketMintable(_baseToken, false); IFxShareableRebalancePool(_pool).withdrawFrom(_msgSender(), _amount, address(this)); _mintShares(_baseToken, _receiver, _amount); emit Wrap(_baseToken, _msgSender(), _receiver, _amount); } /// @inheritdoc IFxUSD function mint( address _baseToken, uint256 _amountIn, address _receiver, uint256 _minOut ) external override onlySupportedMarket(_baseToken) onlyMintableMarket(_baseToken, true) returns (uint256 _amountOut) { if (isUnderCollateral()) revert ErrorUnderCollateral(); address _fToken = markets[_baseToken].fToken; _amountOut = _mintFToken(_baseToken, _fToken, _amountIn, _minOut); _mintShares(_baseToken, _receiver, _amountOut); emit Wrap(_baseToken, _msgSender(), _receiver, _amountOut); } /// @inheritdoc IFxUSD function earn( address _pool, uint256 _amount, address _receiver ) external override onlySupportedPool(_pool) { if (isUnderCollateral()) revert ErrorUnderCollateral(); address _baseToken = IFxShareableRebalancePool(_pool).baseToken(); _checkBaseToken(_baseToken); _burnShares(_baseToken, _msgSender(), _amount); emit Unwrap(_baseToken, _msgSender(), _receiver, _amount); _deposit(markets[_baseToken].fToken, _pool, _receiver, _amount); } /// @inheritdoc IFxUSD function mintAndEarn( address _pool, uint256 _amountIn, address _receiver, uint256 _minOut ) external override onlySupportedPool(_pool) returns (uint256 _amountOut) { if (isUnderCollateral()) revert ErrorUnderCollateral(); address _baseToken = IFxShareableRebalancePool(_pool).baseToken(); _checkBaseToken(_baseToken); _checkMarketMintable(_baseToken, true); address _fToken = markets[_baseToken].fToken; _amountOut = _mintFToken(_baseToken, _fToken, _amountIn, _minOut); _deposit(_fToken, _pool, _receiver, _amountOut); } /// @inheritdoc IFxUSD function redeem( address _baseToken, uint256 _amountIn, address _receiver, uint256 _minOut ) external override onlySupportedMarket(_baseToken) returns (uint256 _amountOut, uint256 _bonusOut) { if (isUnderCollateral()) revert ErrorUnderCollateral(); address _market = markets[_baseToken].market; address _fToken = markets[_baseToken].fToken; uint256 _balance = IERC20Upgradeable(_fToken).balanceOf(address(this)); (_amountOut, _bonusOut) = IFxMarketV2(_market).redeemFToken(_amountIn, _receiver, _minOut); // the real amount of fToken redeemed _amountIn = _balance - IERC20Upgradeable(_fToken).balanceOf(address(this)); _burnShares(_baseToken, _msgSender(), _amountIn); emit Unwrap(_baseToken, _msgSender(), _receiver, _amountIn); } /// @inheritdoc IFxUSD function autoRedeem( uint256 _amountIn, address _receiver, uint256[] memory _minOuts ) external override returns ( address[] memory _baseTokens, uint256[] memory _amountOuts, uint256[] memory _bonusOuts ) { uint256 _numMarkets = supportedTokens.length(); if (_minOuts.length != _numMarkets) revert ErrorLengthMismatch(); _baseTokens = new address[](_numMarkets); _amountOuts = new uint256[](_numMarkets); _bonusOuts = new uint256[](_numMarkets); uint256[] memory _supplies = new uint256[](_numMarkets); bool _isUnderCollateral = false; for (uint256 i = 0; i < _numMarkets; i++) { _baseTokens[i] = supportedTokens.at(i); _supplies[i] = markets[_baseTokens[i]].managed; address _treasury = markets[_baseTokens[i]].treasury; if (IFxTreasuryV2(_treasury).isUnderCollateral()) _isUnderCollateral = true; } uint256 _supply = totalSupply(); _burn(_msgSender(), _amountIn); if (_isUnderCollateral) { // redeem proportionally for (uint256 i = 0; i < _numMarkets; i++) { _amountOuts[i] = (_supplies[i] * _amountIn) / _supply; } } else { // redeem by sorted fToken amounts while (_amountIn > 0) { unchecked { uint256 maxSupply = _supplies[0]; uint256 maxIndex = 0; for (uint256 i = 1; i < _numMarkets; i++) { if (_supplies[i] > maxSupply) { maxSupply = _supplies[i]; maxIndex = i; } } if (_amountIn > maxSupply) _amountOuts[maxIndex] = maxSupply; else _amountOuts[maxIndex] = _amountIn; _supplies[maxIndex] -= _amountOuts[maxIndex]; _amountIn -= _amountOuts[maxIndex]; } } } for (uint256 i = 0; i < _numMarkets; i++) { if (_amountOuts[i] == 0) continue; emit Unwrap(_baseTokens[i], _msgSender(), _receiver, _amountOuts[i]); markets[_baseTokens[i]].managed -= _amountOuts[i]; address _market = markets[_baseTokens[i]].market; (_amountOuts[i], _bonusOuts[i]) = IFxMarketV2(_market).redeemFToken(_amountOuts[i], _receiver, _minOuts[i]); } } /************************ * Restricted Functions * ************************/ /// @notice Update the mint capacity of the base token. /// @param _baseToken The address of base token of the market. /// @param _newCap The value of current mint capacity. function updateMintCap(address _baseToken, uint256 _newCap) external onlyRole(DEFAULT_ADMIN_ROLE) { if (!supportedTokens.contains(_baseToken)) revert ErrorUnsupportedMarket(); uint256 _oldCap = markets[_baseToken].mintCap; markets[_baseToken].mintCap = _newCap; emit UpdateMintCap(_baseToken, _oldCap, _newCap); } /// @notice Add a new market to fxUSD. /// @param _market The address of market contract. /// @param _mintCap The mint capacity of the market. function addMarket(address _market, uint256 _mintCap) external onlyRole(DEFAULT_ADMIN_ROLE) { address _baseToken = IFxMarketV2(_market).baseToken(); address _treasury = IFxMarketV2(_market).treasury(); address _fToken = IFxMarketV2(_market).fToken(); if (supportedTokens.contains(_baseToken)) revert ErrorMarketAlreadySupported(); supportedTokens.add(_baseToken); markets[_baseToken] = FxMarketStruct(_fToken, _treasury, _market, _mintCap, 0); IERC20Upgradeable(_baseToken).safeApprove(_market, type(uint256).max); emit AddMarket(_baseToken, _mintCap); } /// @notice Add new supported rebalance pools to fxUSD. /// @param _pools The list of rebalance pools. function addRebalancePools(address[] memory _pools) external onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < _pools.length; ++i) { address _baseToken = IFxShareableRebalancePool(_pools[i]).baseToken(); _checkBaseToken(_baseToken); if (supportedPools.add(_pools[i])) { emit AddRebalancePool(_baseToken, _pools[i]); } } } /// @notice Add new supported rebalance pools to fxUSD. /// @param _pools The list of rebalance pools. function removeRebalancePools(address[] memory _pools) external onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < _pools.length; ++i) { address _baseToken = IFxShareableRebalancePool(_pools[i]).baseToken(); if (supportedPools.remove(_pools[i])) { emit RemoveRebalancePool(_baseToken, _pools[i]); } } } /********************** * Internal Functions * **********************/ /// @dev Internal function to check base token. /// @param _baseToken The address of the base token. function _checkBaseToken(address _baseToken) private view { if (!supportedTokens.contains(_baseToken)) revert ErrorUnsupportedMarket(); } /// @dev Internal function to check market. /// @param _baseToken The address of the base token. /// @param _checkCollateralRatio Whether to check collateral ratio. function _checkMarketMintable(address _baseToken, bool _checkCollateralRatio) private view { address _treasury = markets[_baseToken].treasury; if (_checkCollateralRatio) { uint256 _collateralRatio = IFxTreasuryV2(_treasury).collateralRatio(); uint256 _stabilityRatio = IFxMarketV2(markets[_baseToken].market).stabilityRatio(); // not allow to mint when collateral ratio <= stability ratio if (_collateralRatio <= _stabilityRatio) revert ErrorMarketInStabilityMode(); } // not allow to mint when price is invalid if (!IFxTreasuryV2(_treasury).isBaseTokenPriceValid()) revert ErrorMarketWithInvalidPrice(); } /// @dev Internal function to mint fToken. /// @param _baseToken The address of the base token. /// @param _fToken The address of the corresponding fToken. /// @param _amountIn The amount of base token to use. /// @param _minOut The minimum amount of fxUSD should receive. /// @return _amountOut The amount of fxUSD received by the receiver. function _mintFToken( address _baseToken, address _fToken, uint256 _amountIn, uint256 _minOut ) private returns (uint256 _amountOut) { address _market = markets[_baseToken].market; uint256 _mintCap = markets[_baseToken].mintCap; IERC20Upgradeable(_baseToken).safeTransferFrom(_msgSender(), address(this), _amountIn); uint256 _balance = IERC20Upgradeable(_baseToken).balanceOf(address(this)); // @note approved in `addMarket`. _amountOut = IFxMarketV2(_market).mintFToken(_amountIn, address(this), _minOut); if (IERC20Upgradeable(_fToken).totalSupply() > _mintCap) revert ErrorExceedMintCap(); // refund exceeding base token uint256 _baseTokenUsed = _balance - IERC20Upgradeable(_baseToken).balanceOf(address(this)); if (_baseTokenUsed < _amountIn) { unchecked { IERC20Upgradeable(_baseToken).safeTransfer(_msgSender(), _amountIn - _baseTokenUsed); } } } /// @dev Internal function to mint fxUSD. /// @param _baseToken The address of the base token. /// @param _receiver The address of fxUSD recipient. /// @param _amount The amount of fxUSD to mint. function _mintShares( address _baseToken, address _receiver, uint256 _amount ) private { unchecked { markets[_baseToken].managed += _amount; } _mint(_receiver, _amount); } /// @dev Internal function to burn fxUSD. /// @param _baseToken The address of the base token. /// @param _owner The address of fxUSD owner. /// @param _amount The amount of fxUSD to burn. function _burnShares( address _baseToken, address _owner, uint256 _amount ) private { uint256 _managed = markets[_baseToken].managed; if (_amount > _managed) revert ErrorInsufficientLiquidity(); unchecked { markets[_baseToken].managed -= _amount; } _burn(_owner, _amount); } /// @dev Internal function to deposit fToken to rebalance pool. /// @param _fToken the address of fToken. /// @param _pool The address of rebalance pool. /// @param _receiver The address of rebalance pool share recipient. /// @param _amount The amount of fToken to deposit. function _deposit( address _fToken, address _pool, address _receiver, uint256 _amount ) internal { IERC20Upgradeable(_fToken).safeApprove(_pool, 0); IERC20Upgradeable(_fToken).safeApprove(_pool, _amount); IFxShareableRebalancePool(_pool).deposit(_amount, _receiver); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract 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.9.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.0; interface IERC5267Upgradeable { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (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] * ```solidity * 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.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) 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[45] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.0; import "./IERC20PermitUpgradeable.sol"; import "../ERC20Upgradeable.sol"; import "../../../utils/cryptography/ECDSAUpgradeable.sol"; import "../../../utils/cryptography/EIP712Upgradeable.sol"; import "../../../utils/CountersUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation 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. * * _Available since v3.4._ * * @custom:storage-size 51 */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping(address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); } function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } /** * @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/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.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/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; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(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)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ 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"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ 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"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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 * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [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://consensys.net/diligence/blog/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.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; 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 v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../StringsUpgradeable.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.8; import "./ECDSAUpgradeable.sol"; import "../../interfaces/IERC5267Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * _Available since v3.4._ * * @custom:storage-size 52 */ abstract contract EIP712Upgradeable is Initializable, IERC5267Upgradeable { bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /// @custom:oz-renamed-from _HASHED_NAME bytes32 private _hashedName; /// @custom:oz-renamed-from _HASHED_VERSION bytes32 private _hashedVersion; string private _name; string private _version; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { _name = name; _version = version; // Reset prior values in storage if upgrading _hashedName = 0; _hashedVersion = 0; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(); } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {EIP-5267}. * * _Available since v4.9._ */ function eip712Domain() public view virtual override returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized // and the EIP712 domain is not reliable, as it will be missing name and version. require(_hashedName == 0 && _hashedVersion == 0, "EIP712: Uninitialized"); return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Name() internal virtual view returns (string memory) { return _name; } /** * @dev The version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712Version() internal virtual view returns (string memory) { return _version; } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead. */ function _EIP712NameHash() internal view returns (bytes32) { string memory name = _EIP712Name(); if (bytes(name).length > 0) { return keccak256(bytes(name)); } else { // If the name is empty, the contract may have been upgraded without initializing the new storage. // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design. bytes32 hashedName = _hashedName; if (hashedName != 0) { return hashedName; } else { return keccak256(""); } } } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead. */ function _EIP712VersionHash() internal view returns (bytes32) { string memory version = _EIP712Version(); if (bytes(version).length > 0) { return keccak256(bytes(version)); } else { // If the version is empty, the contract may have been upgraded without initializing the new storage. // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design. bytes32 hashedVersion = _hashedVersion; if (hashedVersion != 0) { return hashedVersion; } else { return keccak256(""); } } } /** * @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[48] private __gap; }
// 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.9.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) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMathUpgradeable { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; import "./math/SignedMathUpgradeable.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 `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, 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); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library 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: MIT pragma solidity ^0.8.0; interface IFxBoostableRebalancePool { /********** * Events * **********/ /// @notice Emitted when user deposit asset into this contract. /// @param owner The address of asset owner. /// @param reciever The address of receiver of the asset in this contract. /// @param amount The amount of asset deposited. event Deposit(address indexed owner, address indexed reciever, uint256 amount); /// @notice Emitted when the amount of deposited asset changed due to liquidation or deposit or unlock. /// @param owner The address of asset owner. /// @param newDeposit The new amount of deposited asset. /// @param loss The amount of asset used by liquidation. event UserDepositChange(address indexed owner, uint256 newDeposit, uint256 loss); /// @notice Emitted when user withdraw asset. /// @param owner The address of asset owner. /// @param reciever The address of receiver of the asset. /// @param amount The amount of token to withdraw. event Withdraw(address indexed owner, address indexed reciever, uint256 amount); /// @notice Emitted when liquidation happens. /// @param liquidated The amount of asset liquidated. /// @param baseGained The amount of base token gained. event Liquidate(uint256 liquidated, uint256 baseGained); /// @notice Emitted when the address of reward wrapper is updated. /// @param oldWrapper The address of previous reward wrapper. /// @param newWrapper The address of current reward wrapper. event UpdateWrapper(address indexed oldWrapper, address indexed newWrapper); /// @notice Emitted when the liquidatable collateral ratio is updated. /// @param oldRatio The previous liquidatable collateral ratio. /// @param newRatio The current liquidatable collateral ratio. event UpdateLiquidatableCollateralRatio(uint256 oldRatio, uint256 newRatio); /********** * Errors * **********/ /// @dev Thrown then the src token mismatched. error ErrorWrapperSrcMismatch(); /// @dev Thrown then the dst token mismatched. error ErrorWrapperDstMismatch(); /// @dev Thrown when the deposited amount is zero. error DepositZeroAmount(); /// @dev Thrown when the withdrawn amount is zero. error WithdrawZeroAmount(); /// @dev Thrown the cannot liquidate. error CannotLiquidate(); /************************* * Public View Functions * *************************/ /// @notice Return the address of treasury contract. function treasury() external view returns (address); /// @notice Return the address of market contract. function market() external view returns (address); /// @notice Return the address of base token. function baseToken() external view returns (address); /// @notice Return the address of underlying token of this contract. function asset() external view returns (address); /// @notice Return the total amount of asset deposited to this contract. function totalSupply() external view returns (uint256); /// @notice Return the amount of deposited asset for some specific user. /// @param account The address of user to query. function balanceOf(address account) external view returns (uint256); /// @notice Return the current boost ratio for some specific user. /// @param account The address of user to query, multiplied by 1e18. function getBoostRatio(address account) external view returns (uint256); /**************************** * Public Mutated Functions * ****************************/ /// @notice Deposit some asset to this contract. /// @dev Use `amount=uint256(-1)` if you want to deposit all asset held. /// @param amount The amount of asset to deposit. /// @param receiver The address of recipient for the deposited asset. function deposit(uint256 amount, address receiver) external; /// @notice Withdraw asset from this contract. function withdraw(uint256 amount, address receiver) external; /// @notice Liquidate asset for base token. /// @param maxAmount The maximum amount of asset to liquidate. /// @param minBaseOut The minimum amount of base token should receive. /// @return liquidated The amount of asset liquidated. /// @return baseOut The amount of base token received. function liquidate(uint256 maxAmount, uint256 minBaseOut) external returns (uint256 liquidated, uint256 baseOut); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IFxFractionalTokenV2 { /********** * Errors * **********/ /// @dev Thrown when caller is not treasury contract. error ErrorCallerIsNotTreasury(); /************************* * Public View Functions * *************************/ /// @notice Return the net asset value for the token, multipled by 1e18. function nav() external view returns (uint256); /**************************** * Public Mutated Functions * ****************************/ /// @notice Mint some token to someone. /// @param to The address of recipient. /// @param amount The amount of token to mint. function mint(address to, uint256 amount) external; /// @notice Burn some token from someone. /// @param from The address of owner to burn. /// @param amount The amount of token to burn. function burn(address from, uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IFxMarketV2 { /********** * Events * **********/ /// @notice Emitted when fToken is minted. /// @param owner The address of base token owner. /// @param recipient The address of receiver for fToken or xToken. /// @param baseTokenIn The amount of base token deposited. /// @param fTokenOut The amount of fToken minted. /// @param mintFee The amount of mint fee charged. event MintFToken( address indexed owner, address indexed recipient, uint256 baseTokenIn, uint256 fTokenOut, uint256 mintFee ); /// @notice Emitted when xToken is minted. /// @param owner The address of base token owner. /// @param recipient The address of receiver for fToken or xToken. /// @param baseTokenIn The amount of base token deposited. /// @param xTokenOut The amount of xToken minted. /// @param bonus The amount of base token as bonus. /// @param mintFee The amount of mint fee charged. event MintXToken( address indexed owner, address indexed recipient, uint256 baseTokenIn, uint256 xTokenOut, uint256 bonus, uint256 mintFee ); /// @notice Emitted when someone redeem base token with fToken or xToken. /// @param owner The address of fToken and xToken owner. /// @param recipient The address of receiver for base token. /// @param fTokenBurned The amount of fToken burned. /// @param baseTokenOut The amount of base token redeemed. /// @param bonus The amount of base token as bonus. /// @param redeemFee The amount of redeem fee charged. event RedeemFToken( address indexed owner, address indexed recipient, uint256 fTokenBurned, uint256 baseTokenOut, uint256 bonus, uint256 redeemFee ); /// @notice Emitted when someone redeem base token with fToken or xToken. /// @param owner The address of fToken and xToken owner. /// @param recipient The address of receiver for base token. /// @param xTokenBurned The amount of xToken burned. /// @param baseTokenOut The amount of base token redeemed. /// @param redeemFee The amount of redeem fee charged. event RedeemXToken( address indexed owner, address indexed recipient, uint256 xTokenBurned, uint256 baseTokenOut, uint256 redeemFee ); /// @notice Emitted when the fee ratio for minting fToken is updated. /// @param defaultFeeRatio The new default fee ratio, multipled by 1e18. /// @param extraFeeRatio The new extra fee ratio, multipled by 1e18. event UpdateMintFeeRatioFToken(uint256 defaultFeeRatio, int256 extraFeeRatio); /// @notice Emitted when the fee ratio for minting xToken is updated. /// @param defaultFeeRatio The new default fee ratio, multipled by 1e18. /// @param extraFeeRatio The new extra fee ratio, multipled by 1e18. event UpdateMintFeeRatioXToken(uint256 defaultFeeRatio, int256 extraFeeRatio); /// @notice Emitted when the fee ratio for redeeming fToken is updated. /// @param defaultFeeRatio The new default fee ratio, multipled by 1e18. /// @param extraFeeRatio The new extra fee ratio, multipled by 1e18. event UpdateRedeemFeeRatioFToken(uint256 defaultFeeRatio, int256 extraFeeRatio); /// @notice Emitted when the fee ratio for redeeming xToken is updated. /// @param defaultFeeRatio The new default fee ratio, multipled by 1e18. /// @param extraFeeRatio The new extra fee ratio, multipled by 1e18. event UpdateRedeemFeeRatioXToken(uint256 defaultFeeRatio, int256 extraFeeRatio); /// @notice Emitted when the stability ratio is updated. /// @param oldRatio The previous collateral ratio to enter stability mode, multiplied by 1e18. /// @param newRatio The current collateral ratio to enter stability mode, multiplied by 1e18. event UpdateStabilityRatio(uint256 oldRatio, uint256 newRatio); /// @notice Emitted when the platform contract is updated. /// @param oldPlatform The address of previous platform contract. /// @param newPlatform The address of current platform contract. event UpdatePlatform(address indexed oldPlatform, address indexed newPlatform); /// @notice Emitted when the reserve pool contract is updated. /// @param oldReservePool The address of previous reserve pool contract. /// @param newReservePool The address of current reserve pool contract. event UpdateReservePool(address indexed oldReservePool, address indexed newReservePool); /// @notice Emitted when the RebalancePoolRegistry contract is updated. /// @param oldRegistry The address of previous RebalancePoolRegistry contract. /// @param newRegistry The address of current RebalancePoolRegistry contract. event UpdateRebalancePoolRegistry(address indexed oldRegistry, address indexed newRegistry); /// @notice Pause or unpause mint. /// @param oldStatus The previous status for mint. /// @param newStatus The current status for mint. event UpdateMintStatus(bool oldStatus, bool newStatus); /// @notice Pause or unpause redeem. /// @param oldStatus The previous status for redeem. /// @param newStatus The current status for redeem. event UpdateRedeemStatus(bool oldStatus, bool newStatus); /// @notice Pause or unpause fToken mint in stability mode. /// @param oldStatus The previous status for mint. /// @param newStatus The current status for mint. event UpdateFTokenMintStatusInStabilityMode(bool oldStatus, bool newStatus); /// @notice Pause or unpause xToken redeem in stability mode. /// @param oldStatus The previous status for redeem. /// @param newStatus The current status for redeem. event UpdateXTokenRedeemStatusInStabilityMode(bool oldStatus, bool newStatus); /********** * Errors * **********/ /// @dev Thrown when the caller if not fUSD contract. error ErrorCallerNotFUSD(); /// @dev Thrown when token mint is paused. error ErrorMintPaused(); /// @dev Thrown when fToken mint is paused in stability mode. error ErrorFTokenMintPausedInStabilityMode(); /// @dev Thrown when mint with zero amount base token. error ErrorMintZeroAmount(); /// @dev Thrown when the amount of fToken is not enough. error ErrorInsufficientFTokenOutput(); /// @dev Thrown when the amount of xToken is not enough. error ErrorInsufficientXTokenOutput(); /// @dev Thrown when token redeem is paused. error ErrorRedeemPaused(); /// @dev Thrown when xToken redeem is paused in stability mode. error ErrorXTokenRedeemPausedInStabilityMode(); /// @dev Thrown when redeem with zero amount fToken or xToken. error ErrorRedeemZeroAmount(); /// @dev Thrown when the amount of base token is not enough. error ErrorInsufficientBaseOutput(); /// @dev Thrown when the stability ratio is too large. error ErrorStabilityRatioTooLarge(); /// @dev Thrown when the default fee is too large. error ErrorDefaultFeeTooLarge(); /// @dev Thrown when the delta fee is too small. error ErrorDeltaFeeTooSmall(); /// @dev Thrown when the sum of default fee and delta fee is too large. error ErrorTotalFeeTooLarge(); /// @dev Thrown when the given address is zero. error ErrorZeroAddress(); /************************* * Public View Functions * *************************/ /// @notice The address of Treasury contract. function treasury() external view returns (address); /// @notice Return the address of base token. function baseToken() external view returns (address); /// @notice Return the address fractional base token. function fToken() external view returns (address); /// @notice Return the address leveraged base token. function xToken() external view returns (address); /// @notice Return the collateral ratio to enter stability mode, multiplied by 1e18. function stabilityRatio() external view returns (uint256); /**************************** * Public Mutated Functions * ****************************/ /// @notice Mint some fToken with some base token. /// @param baseIn The amount of wrapped value of base token supplied, use `uint256(-1)` to supply all base token. /// @param recipient The address of receiver for fToken. /// @param minFTokenMinted The minimum amount of fToken should be received. /// @return fTokenMinted The amount of fToken should be received. function mintFToken( uint256 baseIn, address recipient, uint256 minFTokenMinted ) external returns (uint256 fTokenMinted); /// @notice Mint some xToken with some base token. /// @param baseIn The amount of wrapped value of base token supplied, use `uint256(-1)` to supply all base token. /// @param recipient The address of receiver for xToken. /// @param minXTokenMinted The minimum amount of xToken should be received. /// @return xTokenMinted The amount of xToken should be received. /// @return bonus The amount of wrapped value of base token as bonus. function mintXToken( uint256 baseIn, address recipient, uint256 minXTokenMinted ) external returns (uint256 xTokenMinted, uint256 bonus); /// @notice Redeem base token with fToken. /// @param fTokenIn the amount of fToken to redeem, use `uint256(-1)` to redeem all fToken. /// @param recipient The address of receiver for base token. /// @param minBaseOut The minimum amount of wrapped value of base token should be received. /// @return baseOut The amount of wrapped value of base token should be received. /// @return bonus The amount of wrapped value of base token as bonus. function redeemFToken( uint256 fTokenIn, address recipient, uint256 minBaseOut ) external returns (uint256 baseOut, uint256 bonus); /// @notice Redeem base token with xToken. /// @param xTokenIn the amount of xToken to redeem, use `uint256(-1)` to redeem all xToken. /// @param recipient The address of receiver for base token. /// @param minBaseOut The minimum amount of wrapped value of base token should be received. /// @return baseOut The amount of wrapped value of base token should be received. function redeemXToken( uint256 xTokenIn, address recipient, uint256 minBaseOut ) external returns (uint256 baseOut); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { IFxBoostableRebalancePool } from "./IFxBoostableRebalancePool.sol"; interface IFxShareableRebalancePool is IFxBoostableRebalancePool { /********** * Events * **********/ /// @notice Emitted when one user share votes to another user. /// @param owner The address of votes owner. /// @param staker The address of staker to share votes. event ShareVote(address indexed owner, address indexed staker); /// @notice Emitted when the owner cancel sharing to some staker. /// @param owner The address of votes owner. /// @param staker The address of staker to cancel votes share. event CancelShareVote(address indexed owner, address indexed staker); /// @notice Emitted when staker accept the vote sharing. /// @param staker The address of the staker. /// @param oldOwner The address of the previous vote sharing owner. /// @param newOwner The address of the current vote sharing owner. event AcceptSharedVote(address indexed staker, address indexed oldOwner, address indexed newOwner); /********** * Errors * **********/ /// @dev Thrown when caller shares votes to self. error ErrorSelfSharingIsNotAllowed(); /// @dev Thrown when a staker with shared votes try to share its votes to others. error ErrorCascadedSharingIsNotAllowed(); /// @dev Thrown when staker try to accept non-allowed vote sharing. error ErrorVoteShareNotAllowed(); /// @dev Thrown when staker try to reject a non-existed vote sharing. error ErrorNoAcceptedSharedVote(); /// @dev Thrown when the staker has ability to share ve balance. error ErrorVoteOwnerCannotStake(); /// @dev Thrown when staker try to accept twice. error ErrorRepeatAcceptSharedVote(); /************************* * Public View Functions * *************************/ /// @notice Return the owner of votes of some staker. /// @param account The address of user to query. function getStakerVoteOwner(address account) external view returns (address); /**************************** * Public Mutated Functions * ****************************/ /// @notice Withdraw asset from this contract on behalf of someone function withdrawFrom( address owner, uint256 amount, address receiver ) external; /// @notice Owner changes the vote sharing state for some user. /// @param staker The address of user to change. function toggleVoteSharing(address staker) external; /// @notice Staker accepts the vote sharing. /// @param newOwner The address of the owner of the votes. function acceptSharedVote(address newOwner) external; /// @notice Staker reject the current vote sharing. function rejectSharedVote() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IFxTreasuryV2 { /********** * Events * **********/ /// @notice Emitted when the platform contract is updated. /// @param oldPlatform The address of previous platform contract. /// @param newPlatform The address of current platform contract. event UpdatePlatform(address indexed oldPlatform, address indexed newPlatform); /// @notice Emitted when the RebalancePoolSplitter contract is updated. /// @param oldRebalancePoolSplitter The address of previous RebalancePoolSplitter contract. /// @param newRebalancePoolSplitter The address of current RebalancePoolSplitter. event UpdateRebalancePoolSplitter(address indexed oldRebalancePoolSplitter, address indexed newRebalancePoolSplitter); /// @notice Emitted when the price oracle contract is updated. /// @param oldPriceOracle The address of previous price oracle. /// @param newPriceOracle The address of current price oracle. event UpdatePriceOracle(address indexed oldPriceOracle, address indexed newPriceOracle); /// @notice Emitted when the strategy contract is updated. /// @param oldStrategy The address of previous strategy. /// @param newStrategy The address of current strategy. event UpdateStrategy(address indexed oldStrategy, address indexed newStrategy); /// @notice Emitted when the base token cap is updated. /// @param oldBaseTokenCap The value of previous base token cap. /// @param newBaseTokenCap The value of current base token cap. event UpdateBaseTokenCap(uint256 oldBaseTokenCap, uint256 newBaseTokenCap); /// @notice Emitted when the EMA sample interval is updated. /// @param oldSampleInterval The value of previous EMA sample interval. /// @param newSampleInterval The value of current EMA sample interval. event UpdateEMASampleInterval(uint256 oldSampleInterval, uint256 newSampleInterval); /// @notice Emitted when the reference price is updated. /// @param oldPrice The value of previous reference price. /// @param newPrice The value of current reference price. event Settle(uint256 oldPrice, uint256 newPrice); /// @notice Emitted when the ratio for rebalance pool is updated. /// @param oldRatio The value of the previous ratio, multipled by 1e9. /// @param newRatio The value of the current ratio, multipled by 1e9. event UpdateRebalancePoolRatio(uint256 oldRatio, uint256 newRatio); /// @notice Emitted when the ratio for harvester is updated. /// @param oldRatio The value of the previous ratio, multipled by 1e9. /// @param newRatio The value of the current ratio, multipled by 1e9. event UpdateHarvesterRatio(uint256 oldRatio, uint256 newRatio); /// @notice Emitted when someone harvest pending stETH rewards. /// @param caller The address of caller. /// @param totalRewards The amount of total harvested rewards. /// @param rebalancePoolRewards The amount of harvested rewards distributed to stability pool. /// @param harvestBounty The amount of harvested rewards distributed to caller as harvest bounty. event Harvest(address indexed caller, uint256 totalRewards, uint256 rebalancePoolRewards, uint256 harvestBounty); /********** * Errors * **********/ /// @dev Thrown when the collateral ratio is smaller than 100%. error ErrorCollateralRatioTooSmall(); /// @dev Thrown when mint exceed total capacity. error ErrorExceedTotalCap(); /// @dev Thrown when the oracle price is invalid. error ErrorInvalidOraclePrice(); /// @dev Thrown when the twap price is invalid. error ErrorInvalidTwapPrice(); /// @dev Thrown when initialize protocol twice. error ErrorProtocolInitialized(); /// @dev Thrown when the initial amount of base token is not enough. error ErrorInsufficientInitialBaseToken(); /// @dev Thrown when current is under collateral. error ErrorUnderCollateral(); /// @dev Thrown when the sample internal for EMA is too small. error ErrorEMASampleIntervalTooSmall(); /// @dev Thrown when the expense ratio exceeds `MAX_REBALANCE_POOL_RATIO`. error ErrorRebalancePoolRatioTooLarge(); /// @dev Thrown when the harvester ratio exceeds `MAX_HARVESTER_RATIO`. error ErrorHarvesterRatioTooLarge(); /// @dev Thrown when the given address is zero. error ErrorZeroAddress(); /********* * Enums * *********/ enum Action { None, MintFToken, MintXToken, RedeemFToken, RedeemXToken } /************************* * Public View Functions * *************************/ /// @notice Return the address of base token. function baseToken() external view returns (address); /// @notice Return the address fractional base token. function fToken() external view returns (address); /// @notice Return the address leveraged base token. function xToken() external view returns (address); /// @notice The reference base token price. function referenceBaseTokenPrice() external view returns (uint256); /// @notice The current base token price. function currentBaseTokenPrice() external view returns (uint256); /// @notice Return whether the price is valid. function isBaseTokenPriceValid() external view returns (bool); /// @notice Return the total amount of underlying value of base token deposited. function totalBaseToken() external view returns (uint256); /// @notice Return the address of strategy contract. function strategy() external view returns (address); /// @notice Return the total amount of base token managed by strategy. function strategyUnderlying() external view returns (uint256); /// @notice Return the current collateral ratio of fToken, multipled by 1e18. function collateralRatio() external view returns (uint256); /// @notice Return whether the system is under collateral. function isUnderCollateral() external view returns (bool); /// @notice Compute the amount of base token needed to reach the new collateral ratio. /// @param newCollateralRatio The target collateral ratio, multipled by 1e18. /// @return maxBaseIn The amount of underlying value of base token needed. /// @return maxFTokenMintable The amount of fToken can be minted. function maxMintableFToken(uint256 newCollateralRatio) external view returns (uint256 maxBaseIn, uint256 maxFTokenMintable); /// @notice Compute the amount of base token needed to reach the new collateral ratio. /// @param newCollateralRatio The target collateral ratio, multipled by 1e18. /// @return maxBaseIn The amount of underlying value of base token needed. /// @return maxXTokenMintable The amount of xToken can be minted. function maxMintableXToken(uint256 newCollateralRatio) external view returns (uint256 maxBaseIn, uint256 maxXTokenMintable); /// @notice Compute the amount of fToken needed to reach the new collateral ratio. /// @param newCollateralRatio The target collateral ratio, multipled by 1e18. /// @return maxBaseOut The amount of underlying value of base token redeemed. /// @return maxFTokenRedeemable The amount of fToken needed. function maxRedeemableFToken(uint256 newCollateralRatio) external view returns (uint256 maxBaseOut, uint256 maxFTokenRedeemable); /// @notice Compute the amount of xToken needed to reach the new collateral ratio. /// @param newCollateralRatio The target collateral ratio, multipled by 1e18. /// @return maxBaseOut The amount of underlying value of base token redeemed. /// @return maxXTokenRedeemable The amount of xToken needed. function maxRedeemableXToken(uint256 newCollateralRatio) external view returns (uint256 maxBaseOut, uint256 maxXTokenRedeemable); /// @notice Return the exponential moving average of the leverage ratio. function leverageRatio() external view returns (uint256); /// @notice Convert underlying token amount to wrapped token amount. /// @param amount The underlying token amount. function getWrapppedValue(uint256 amount) external view returns (uint256); /// @notice Convert wrapped token amount to underlying token amount. /// @param amount The wrapped token amount. function getUnderlyingValue(uint256 amount) external view returns (uint256); /// @notice Return the fee ratio distributed to rebalance pool, multipled by 1e9. function getRebalancePoolRatio() external view returns (uint256); /// @notice Return the fee ratio distributed to harvester, multipled by 1e9. function getHarvesterRatio() external view returns (uint256); /**************************** * Public Mutated Functions * ****************************/ /// @notice Initialize the protocol. /// @param baseIn The amount of underlying value of the base token used to initialize. function initializeProtocol(uint256 baseIn) external returns (uint256 fTokenOut, uint256 xTokenOut); /// @notice Mint fToken with some base token. /// @param baseIn The amount of underlying value of base token deposited. /// @param recipient The address of receiver. /// @return fTokenOut The amount of fToken minted. function mintFToken(uint256 baseIn, address recipient) external returns (uint256 fTokenOut); /// @notice Mint xToken with some base token. /// @param baseIn The amount of underlying value of base token deposited. /// @param recipient The address of receiver. /// @return xTokenOut The amount of xToken minted. function mintXToken(uint256 baseIn, address recipient) external returns (uint256 xTokenOut); /// @notice Redeem fToken and xToken to base tokne. /// @param fTokenIn The amount of fToken to redeem. /// @param xTokenIn The amount of xToken to redeem. /// @param owner The owner of the fToken or xToken. /// @param baseOut The amount of underlying value of base token redeemed. function redeem( uint256 fTokenIn, uint256 xTokenIn, address owner ) external returns (uint256 baseOut); /// @notice Settle the nav of base token, fToken and xToken. function settle() external; /// @notice Transfer some base token to strategy contract. /// @param amount The amount of token to transfer. function transferToStrategy(uint256 amount) external; /// @notice Notify base token profit from strategy contract. /// @param amount The amount of base token. function notifyStrategyProfit(uint256 amount) external; /// @notice Harvest pending rewards to stability pool. function harvest() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IFxUSD { /********** * Events * **********/ /// @notice Emitted when a new market is added. /// @param baseToken The address of base token of the market. /// @param mintCap The mint capacity of the market. event AddMarket(address indexed baseToken, uint256 mintCap); /// @notice Emitted when the mint capacity is updated. /// @param baseToken The address of base token of the market. /// @param oldCap The value of previous mint capacity. /// @param newCap The value of current mint capacity. event UpdateMintCap(address indexed baseToken, uint256 oldCap, uint256 newCap); /// @notice Emitted when a new rebalance pool is added. /// @param baseToken The address of base token of the market. /// @param pool The address of the rebalance pool. event AddRebalancePool(address indexed baseToken, address indexed pool); /// @notice Emitted when a new rebalance pool is removed. /// @param baseToken The address of base token of the market. /// @param pool The address of the rebalance pool. event RemoveRebalancePool(address indexed baseToken, address indexed pool); /// @notice Emitted when someone wrap fToken as fxUSD. /// @param baseToken The address of base token of the market. /// @param owner The address of fToken owner. /// @param receiver The address of fxUSD recipient. /// @param amount The amount of fxUSD minted. event Wrap(address indexed baseToken, address indexed owner, address indexed receiver, uint256 amount); /// @notice Emitted when someone unwrap fxUSD as fToken. /// @param baseToken The address of base token of the market. /// @param owner The address of fxUSD owner. /// @param receiver The address of base token recipient. /// @param amount The amount of fxUSD burned. event Unwrap(address indexed baseToken, address indexed owner, address indexed receiver, uint256 amount); /********** * Errors * **********/ /// @dev Thrown when someone tries to interact with unsupported market. error ErrorUnsupportedMarket(); /// @dev Thrown when someone tries to interact with unsupported rebalance pool. error ErrorUnsupportedRebalancePool(); /// @dev Thrown when someone tries to interact with market in stability mode. error ErrorMarketInStabilityMode(); /// @dev Thrown when someone tries to interact with market has invalid price. error ErrorMarketWithInvalidPrice(); /// @dev Thrown when someone tries to add a supported market. error ErrorMarketAlreadySupported(); /// @dev Thrown when the total supply of fToken exceed mint capacity. error ErrorExceedMintCap(); /// @dev Thrown when the amount of fToken is not enough for redeem. error ErrorInsufficientLiquidity(); /// @dev Thrown when current is under collateral. error ErrorUnderCollateral(); /// @dev Thrown when the length of two arrays is mismatch. error ErrorLengthMismatch(); /************************* * Public View Functions * *************************/ /// @notice Return the list of supported markets. function getMarkets() external view returns (address[] memory); /// @notice Return the list of supported rebalance pools. function getRebalancePools() external view returns (address[] memory); /// @notice Return the nav of fxUSD. function nav() external view returns (uint256); /// @notice Return whether the system is under collateral. function isUnderCollateral() external view returns (bool); /**************************** * Public Mutated Functions * ****************************/ /// @notice Wrap fToken to fxUSD. /// @param baseToken The address of corresponding base token. /// @param amount The amount of fToken to wrap. /// @param receiver The address of fxUSD recipient. function wrap( address baseToken, uint256 amount, address receiver ) external; /// @notice Wrap fToken from rebalance pool to fxUSD. /// @param pool The address of rebalance pool. /// @param amount The amount of fToken to wrap. /// @param receiver The address of fxUSD recipient. function wrapFrom( address pool, uint256 amount, address receiver ) external; /// @notice Mint fxUSD with base token. /// @param baseToken The address of the base token. /// @param amountIn The amount of base token to use. /// @param receiver The address of fxUSD recipient. /// @param minOut The minimum amount of fxUSD should receive. /// @return amountOut The amount of fxUSD received by the receiver. function mint( address baseToken, uint256 amountIn, address receiver, uint256 minOut ) external returns (uint256 amountOut); /// @notice Deposit fxUSD to rebalance pool. /// @param pool The address of rebalance pool. /// @param amount The amount of fxUSD to use. /// @param receiver The address of rebalance pool share recipient. function earn( address pool, uint256 amount, address receiver ) external; /// @notice Mint fxUSD with base token and deposit to rebalance pool. /// @param pool The address of rebalance pool. /// @param amountIn The amount of base token to use. /// @param receiver The address of rebalance pool recipient. /// @param minOut The minimum amount of rebalance pool shares should receive. /// @return amountOut The amount of rebalance pool shares received by the receiver. function mintAndEarn( address pool, uint256 amountIn, address receiver, uint256 minOut ) external returns (uint256 amountOut); /// @notice Redeem fxUSD to base token. /// @param baseToken The address of the base token. /// @param amountIn The amount of fxUSD to redeem. /// @param receiver The address of base token recipient. /// @param minOut The minimum amount of base token should receive. /// @return amountOut The amount of base token received by the receiver. /// @return bonusOut The amount of bonus base token received by the receiver. function redeem( address baseToken, uint256 amountIn, address receiver, uint256 minOut ) external returns (uint256 amountOut, uint256 bonusOut); /// @notice Redeem fxUSD to base token optimally. /// @param amountIn The amount of fxUSD to redeem. /// @param receiver The address of base token recipient. /// @param minOuts The list of minimum amount of base token should receive. /// @return baseTokens The list of base token received by the receiver. /// @return amountOuts The list of amount of base token received by the receiver. /// @return bonusOuts The list of amount of bonus base token received by the receiver. function autoRedeem( uint256 amountIn, address receiver, uint256[] memory minOuts ) external returns ( address[] memory baseTokens, uint256[] memory amountOuts, uint256[] memory bonusOuts ); }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "shanghai", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"ErrorExceedMintCap","type":"error"},{"inputs":[],"name":"ErrorInsufficientLiquidity","type":"error"},{"inputs":[],"name":"ErrorLengthMismatch","type":"error"},{"inputs":[],"name":"ErrorMarketAlreadySupported","type":"error"},{"inputs":[],"name":"ErrorMarketInStabilityMode","type":"error"},{"inputs":[],"name":"ErrorMarketWithInvalidPrice","type":"error"},{"inputs":[],"name":"ErrorUnderCollateral","type":"error"},{"inputs":[],"name":"ErrorUnsupportedMarket","type":"error"},{"inputs":[],"name":"ErrorUnsupportedRebalancePool","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintCap","type":"uint256"}],"name":"AddMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"AddRebalancePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"}],"name":"RemoveRebalancePool","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":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unwrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"oldCap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCap","type":"uint256"}],"name":"UpdateMintCap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"baseToken","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Wrap","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"uint256","name":"_mintCap","type":"uint256"}],"name":"addMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"}],"name":"addRebalancePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256[]","name":"_minOuts","type":"uint256[]"}],"name":"autoRedeem","outputs":[{"internalType":"address[]","name":"_baseTokens","type":"address[]"},{"internalType":"uint256[]","name":"_amountOuts","type":"uint256[]"},{"internalType":"uint256[]","name":"_bonusOuts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"earn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarkets","outputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRebalancePools","outputs":[{"internalType":"address[]","name":"_pools","type":"address[]"}],"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":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isUnderCollateral","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"markets","outputs":[{"internalType":"address","name":"fToken","type":"address"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"market","type":"address"},{"internalType":"uint256","name":"mintCap","type":"uint256"},{"internalType":"uint256","name":"managed","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"mintAndEarn","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nav","outputs":[{"internalType":"uint256","name":"_nav","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"_amountOut","type":"uint256"},{"internalType":"uint256","name":"_bonusOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"}],"name":"removeRebalancePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_newCap","type":"uint256"}],"name":"updateMintCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_baseToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"wrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"wrapFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561000f575f80fd5b506144648061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610234575f3560e01c80634cd88b7611610135578063a5f879ca116100b4578063d505accf11610079578063d505accf14610548578063d547741f1461055b578063dd62ed3e1461056e578063ec2c901614610581578063f3f094a114610589575f80fd5b8063a5f879ca146104fd578063a9059cbb14610510578063b8452aa914610523578063c1590cd714610538578063cdc6c7cc14610540575f80fd5b80638e8f294b116100fa5780638e8f294b1461044457806391d14854146104c857806395d89b41146104db578063a217fddf146104e3578063a457c2d7146104ea575f80fd5b80634cd88b76146103c85780635c15155e146103db57806370a08231146103ee5780637ecebe001461041657806384b0196e14610429575f80fd5b8063313ce567116101c15780633bb03e2d116101865780633bb03e2d146103695780633c173a4f1461037c578063468a0efd1461038f57806346c55f80146103a257806347b2795c146103b5575f80fd5b8063313ce567146103195780633644e5151461032857806336568abe1461033057806339509351146103435780633a4639e114610356575f80fd5b806318160ddd1161020757806318160ddd146102aa5780631a3dde45146102bc57806323b872dd146102d1578063248a9ca3146102e45780632f2ff15d14610306575f80fd5b806301ffc9a71461023857806306fdde0314610260578063095ea7b31461027557806316c4033514610288575b5f80fd5b61024b610246366004613ab2565b6105b1565b60405190151581526020015b60405180910390f35b6102686105e7565b6040516102579190613b26565b61024b610283366004613b4c565b610677565b61029b610296366004613bdc565b61068e565b60405161025793929190613cf9565b6099545b604051908152602001610257565b6102cf6102ca366004613d3b565b610d95565b005b61024b6102df366004613dc4565b610ed2565b6102ae6102f2366004613e02565b5f9081526065602052604090206001015490565b6102cf610314366004613e19565b610ef5565b60405160128152602001610257565b6102ae610f19565b6102cf61033e366004613e19565b610f27565b61024b610351366004613b4c565b610faa565b6102cf610364366004613e47565b610fcb565b6102ae610377366004613e86565b61116b565b6102ae61038a366004613e86565b611273565b6102cf61039d366004613e47565b611348565b6102cf6103b0366004613b4c565b611494565b6102cf6103c3366004613d3b565b61152a565b6102cf6103d6366004613f36565b611659565b6102cf6103e9366004613e47565b611792565b6102ae6103fc366004613f95565b6001600160a01b03165f9081526097602052604090205490565b6102ae610424366004613f95565b611860565b61043161187d565b6040516102579796959493929190613fb0565b61048f610452366004613f95565b6101306020525f9081526040902080546001820154600283015460038401546004909401546001600160a01b039384169492841693909116919085565b604080516001600160a01b039687168152948616602086015292909416918301919091526060820152608081019190915260a001610257565b61024b6104d6366004613e19565b611916565b610268611940565b6102ae5f81565b61024b6104f8366004613b4c565b61194f565b6102cf61050b366004613b4c565b6119c9565b61024b61051e366004613b4c565b611c20565b61052b611c2d565b604051610257919061401f565b6102ae611cd6565b61024b611dfc565b6102cf610556366004614031565b611ecf565b6102cf610569366004613e19565b612030565b6102ae61057c3660046140a2565b612054565b61052b61207e565b61059c610597366004613e86565b612122565b60408051928352602083019190915201610257565b5f6001600160e01b03198216637965db0b60e01b14806105e157506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060609a80546105f6906140ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610622906140ce565b801561066d5780601f106106445761010080835404028352916020019161066d565b820191905f5260205f20905b81548152906001019060200180831161065057829003601f168201915b5050505050905090565b5f3361068481858561233b565b5060019392505050565b60608060605f61069f61013161245e565b9050808551146106c257604051637326389560e01b815260040160405180910390fd5b806001600160401b038111156106da576106da613b76565b604051908082528060200260200182016040528015610703578160200160208202803683370190505b509350806001600160401b0381111561071e5761071e613b76565b604051908082528060200260200182016040528015610747578160200160208202803683370190505b509250806001600160401b0381111561076257610762613b76565b60405190808252806020026020018201604052801561078b578160200160208202803683370190505b5091505f816001600160401b038111156107a7576107a7613b76565b6040519080825280602002602001820160405280156107d0578160200160208202803683370190505b5090505f805b8381101561094e576107ea61013182612467565b8782815181106107fc576107fc614100565b60200260200101906001600160a01b031690816001600160a01b0316815250506101305f88838151811061083257610832614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015483828151811061086f5761086f614100565b6020026020010181815250505f6101305f89848151811061089257610892614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206001015f9054906101000a90046001600160a01b03169050806001600160a01b031663cdc6c7cc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561090d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109319190614114565b1561093b57600192505b508061094681614147565b9150506107d6565b505f61095960995490565b9050610965338b612479565b81156109da575f5b848110156109d457818b85838151811061098957610989614100565b602002602001015161099b919061415f565b6109a59190614176565b8782815181106109b7576109b7614100565b6020908102919091010152806109cc81614147565b91505061096d565b50610b05565b8915610b05575f835f815181106109f3576109f3614100565b602002602001015190505f80600190505b86811015610a555782868281518110610a1f57610a1f614100565b60200260200101511115610a4d57858181518110610a3f57610a3f614100565b602002602001015192508091505b600101610a04565b50818c1115610a825781888281518110610a7157610a71614100565b602002602001018181525050610aa2565b8b888281518110610a9557610a95614100565b6020026020010181815250505b878181518110610ab457610ab4614100565b6020026020010151858281518110610ace57610ace614100565b602002602001018181510391508181525050878181518110610af257610af2614100565b60200260200101518c039b5050506109da565b5f5b84811015610d8757868181518110610b2157610b21614100565b60200260200101515f0315610d75576001600160a01b038a16336001600160a01b0316898381518110610b5657610b56614100565b60200260200101516001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8a8581518110610b9a57610b9a614100565b6020026020010151604051610bb191815260200190565b60405180910390a4868181518110610bcb57610bcb614100565b60200260200101516101305f8a8481518110610be957610be9614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015f828254610c219190614195565b925050819055505f6101305f8a8481518110610c3f57610c3f614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206002015f9054906101000a90046001600160a01b03169050806001600160a01b031663d0ce98fa898481518110610c9f57610c9f614100565b60200260200101518d8d8681518110610cba57610cba614100565b60200260200101516040518463ffffffff1660e01b8152600401610cfa939291909283526001600160a01b03919091166020830152604082015260600190565b60408051808303815f875af1158015610d15573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d3991906141a8565b898481518110610d4b57610d4b614100565b60200260200101898581518110610d6457610d64614100565b602090810291909101019190915252505b80610d7f81614147565b915050610b07565b505050505093509350939050565b5f610d9f816125ab565b5f5b8251811015610ecd575f838281518110610dbd57610dbd614100565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e00573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e2491906141ca565b9050610e2f816125b8565b610e5d848381518110610e4457610e44614100565b60200260200101516101336125e190919063ffffffff16565b15610ebc57838281518110610e7457610e74614100565b60200260200101516001600160a01b0316816001600160a01b03167fab3eb4272572b64f7ef5518a913a482ba7dae0fd1b51b7557e7429d8000dabe360405160405180910390a35b50610ec681614147565b9050610da1565b505050565b5f33610edf8582856125f5565b610eea85858561266d565b506001949350505050565b5f82815260656020526040902060010154610f0f816125ab565b610ecd8383612816565b5f610f2261289b565b905090565b6001600160a01b0381163314610f9c5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610fa682826128a4565b5050565b5f33610684818585610fbc8383612054565b610fc691906141e5565b61233b565b82610fd86101338261290a565b610ff557604051630a5af2b960e41b815260040160405180910390fd5b610ffd611dfc565b1561101b57604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611058573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061107c91906141ca565b9050611087816125b8565b611091815f61292b565b6001600160a01b03851663e162402f336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018790523060448201526064015f604051808303815f87803b1580156110ec575f80fd5b505af11580156110fe573d5f803e3d5ffd5b5050505061110d818486612ad2565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78760405161115c91815260200190565b60405180910390a45050505050565b5f846111796101338261290a565b61119657604051630a5af2b960e41b815260040160405180910390fd5b61119e611dfc565b156111bc57604051635cbe463960e01b815260040160405180910390fd5b5f866001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111f9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061121d91906141ca565b9050611228816125b8565b61123381600161292b565b6001600160a01b038082165f90815261013060205260409020541661125a82828988612afd565b935061126881898887612d31565b505050949350505050565b5f8461127e816125b8565b85600161128b828261292b565b611293611dfc565b156112b157604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038089165f9081526101306020526040902054166112d889828a89612afd565b94506112e5898887612ad2565b6001600160a01b038716336001600160a01b03168a6001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78860405161133491815260200190565b60405180910390a450505050949350505050565b826113556101338261290a565b61137257604051630a5af2b960e41b815260040160405180910390fd5b61137a611dfc565b1561139857604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113d5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113f991906141ca565b9050611404816125b8565b61140f813386612dbc565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8760405161145e91815260200190565b60405180910390a46001600160a01b038082165f908152610130602052604090205461148d9116868587612d31565b5050505050565b5f61149e816125ab565b6114aa6101318461290a565b6114c7576040516338453dd760e01b815260040160405180910390fd5b6001600160a01b0383165f8181526101306020908152604091829020600301805490869055825181815291820186905292917f8b7ffd801f5f56da3dab6179fa82d8dcfa0aef7edfa3d5a5c895b1c2ed4c2982910160405180910390a250505050565b5f611534816125ab565b5f5b8251811015610ecd575f83828151811061155257611552614100565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611595573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115b991906141ca565b90506115e98483815181106115d0576115d0614100565b6020026020010151610133612e2590919063ffffffff16565b156116485783828151811061160057611600614100565b60200260200101516001600160a01b0316816001600160a01b03167f37ef9fb84c18a8c84c537c46b4201d2c1f95d1c059a56ea05cf00c518b21689260405160405180910390a35b5061165281614147565b9050611536565b5f54610100900460ff161580801561167757505f54600160ff909116105b806116905750303b15801561169057505f5460ff166001145b6116f35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610f93565b5f805460ff191660011790558015611714575f805461ff0019166101001790555b61171c612e39565b611724612e39565b61172c612e39565b6117368383612e61565b61173f83612e91565b6117495f33612816565b8015610ecd575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b8261179c816125b8565b835f6117a8828261292b565b6117b0611dfc565b156117ce57604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038681165f9081526101306020526040902054166117f581333089612eda565b611800878688612ad2565b6001600160a01b038516336001600160a01b0316886001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78960405161184f91815260200190565b60405180910390a450505050505050565b6001600160a01b0381165f90815260fd60205260408120546105e1565b5f6060805f805f606060c9545f801b148015611899575060ca54155b6118dd5760405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b6044820152606401610f93565b6118e5612f45565b6118ed612f54565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f9182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060609b80546105f6906140ce565b5f338161195c8286612054565b9050838110156119bc5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610f93565b610eea828686840361233b565b5f6119d3816125ab565b5f836001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a10573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a3491906141ca565b90505f846001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a73573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a9791906141ca565b90505f856001600160a01b031663a8694e576040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ad6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611afa91906141ca565b9050611b086101318461290a565b15611b2657604051639d80f21f60e01b815260040160405180910390fd5b611b32610131846125e1565b506040805160a0810182526001600160a01b03808416825284811660208084019182528a8316848601908152606085018b81525f608087018181528b8716808352610130909552979020955186549086166001600160a01b031991821617875593516001870180549187169186169190911790559051600286018054919095169316929092179092555160038301559151600490910155611bd590875f19612f63565b826001600160a01b03167f7db2b525ddc969d78e5db660ace79ab264aff9c141437a4b78a87f2aeb39ee8d86604051611c1091815260200190565b60405180910390a2505050505050565b5f3361068481858561266d565b60605f611c3b61013361245e565b9050806001600160401b03811115611c5557611c55613b76565b604051908082528060200260200182016040528015611c7e578160200160208202803683370190505b5091505f5b81811015611cd157611c9761013382612467565b838281518110611ca957611ca9614100565b6001600160a01b0390921660209283029190910190910152611cca81614147565b9050611c83565b505090565b5f80611ce361013161245e565b90505f611cef60995490565b9050805f03611d0857670de0b6b3a76400009250505090565b5f5b82811015611dea575f611d1f61013183612467565b6001600160a01b038082165f9081526101306020908152604080832054815163c1590cd760e01b81529151959650909316939192849263c1590cd7926004808401939192918290030181865afa158015611d7b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d9f91906141f8565b6001600160a01b0384165f9081526101306020526040902060040154909150611dc8908261415f565b611dd290886141e5565b96505050508080611de290614147565b915050611d0a565b50611df58184614176565b9250505090565b5f80611e0961013161245e565b90505f5b81811015611ec7575f611e2261013183612467565b6001600160a01b038082165f9081526101306020908152604091829020600101548251633371b1f360e21b8152925194955090921692839263cdc6c7cc92600480820193918290030181865afa158015611e7e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ea29190614114565b15611eb257600194505050505090565b50508080611ebf90614147565b915050611e0d565b505f91505090565b83421115611f1f5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610f93565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611f4d8c613076565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f611fa78261309d565b90505f611fb6828787876130c9565b9050896001600160a01b0316816001600160a01b0316146120195760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610f93565b6120248a8a8a61233b565b50505050505050505050565b5f8281526065602052604090206001015461204a816125ab565b610ecd83836128a4565b6001600160a01b039182165f90815260986020908152604080832093909416825291909152205490565b60605f61208c61013161245e565b9050806001600160401b038111156120a6576120a6613b76565b6040519080825280602002602001820160405280156120cf578160200160208202803683370190505b5091505f5b81811015611cd1576120e861013182612467565b8382815181106120fa576120fa614100565b6001600160a01b039092166020928302919091019091015261211b81614147565b90506120d4565b5f808561212e816125b8565b612136611dfc565b1561215457604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038781165f90815261013060205260408082206002810154905491516370a0823160e01b81523060048201529084169391909116919082906370a0823190602401602060405180830381865afa1580156121b7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121db91906141f8565b6040516368674c7d60e11b8152600481018b90526001600160a01b038a81166024830152604482018a90529192509084169063d0ce98fa9060640160408051808303815f875af1158015612231573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061225591906141a8565b6040516370a0823160e01b815230600482015291975095506001600160a01b038316906370a0823190602401602060405180830381865afa15801561229c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122c091906141f8565b6122ca9082614195565b98506122d78a338b612dbc565b6001600160a01b038816336001600160a01b03168b6001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8c60405161232691815260200190565b60405180910390a45050505094509492505050565b6001600160a01b03831661239d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610f93565b6001600160a01b0382166123fe5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610f93565b6001600160a01b038381165f8181526098602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b5f6105e1825490565b5f61247283836130f1565b9392505050565b6001600160a01b0382166124d95760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610f93565b6001600160a01b0382165f908152609760205260409020548181101561254c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610f93565b6001600160a01b0383165f8181526097602090815260408083208686039055609980548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6125b58133613117565b50565b6125c46101318261290a565b6125b5576040516338453dd760e01b815260040160405180910390fd5b5f612472836001600160a01b038416613170565b5f6126008484612054565b90505f198114612667578181101561265a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610f93565b612667848484840361233b565b50505050565b6001600160a01b0383166126d15760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610f93565b6001600160a01b0382166127335760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610f93565b6001600160a01b0383165f90815260976020526040902054818110156127aa5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610f93565b6001600160a01b038085165f8181526097602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906128099086815260200190565b60405180910390a3612667565b6128208282611916565b610fa6575f8281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556128573390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f610f226131bc565b6128ae8282611916565b15610fa6575f8281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381165f9081526001830160205260408120541515612472565b6001600160a01b038083165f9081526101306020526040902060010154168115612a55575f816001600160a01b031663b4eae1cb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561298c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129b091906141f8565b6001600160a01b038086165f90815261013060209081526040808320600201548151630cf0b5b360e41b815291519596509294929093169263cf0b5b3092600480830193928290030181865afa158015612a0c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a3091906141f8565b9050808211612a52576040516319168f7960e21b815260040160405180910390fd5b50505b806001600160a01b0316639e3ad8716040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a91573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ab59190614114565b610ecd57604051631d05894b60e31b815260040160405180910390fd5b6001600160a01b0383165f90815261013060205260409020600401805482019055610ecd828261322f565b6001600160a01b038481165f81815261013060205260408120600281015460039091015491931691612b3190333088612eda565b6040516370a0823160e01b81523060048201525f906001600160a01b038916906370a0823190602401602060405180830381865afa158015612b75573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b9991906141f8565b6040516364c9b4c360e01b815260048101889052306024820152604481018790529091506001600160a01b038416906364c9b4c3906064016020604051808303815f875af1158015612bed573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c1191906141f8565b935081876001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c50573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c7491906141f8565b1115612c9357604051630788a88760e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f906001600160a01b038a16906370a0823190602401602060405180830381865afa158015612cd7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612cfb91906141f8565b612d059083614195565b905086811015612d2557612d256001600160a01b038a1633838a036132ee565b50505050949350505050565b612d456001600160a01b038516845f612f63565b612d596001600160a01b0385168483612f63565b604051636e553f6560e01b8152600481018290526001600160a01b038381166024830152841690636e553f65906044015f604051808303815f87803b158015612da0575f80fd5b505af1158015612db2573d5f803e3d5ffd5b5050505050505050565b6001600160a01b0383165f908152610130602052604090206004015480821115612df95760405163b268a92160e01b815260040160405180910390fd5b6001600160a01b0384165f90815261013060205260409020600401805483900390556126678383612479565b5f612472836001600160a01b03841661331e565b5f54610100900460ff16612e5f5760405162461bcd60e51b8152600401610f939061420f565b565b5f54610100900460ff16612e875760405162461bcd60e51b8152600401610f939061420f565b610fa68282613401565b5f54610100900460ff16612eb75760405162461bcd60e51b8152600401610f939061420f565b6125b581604051806040016040528060018152602001603160f81b815250613440565b6040516001600160a01b03808516602483015283166044820152606481018290526126679085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261348d565b606060cb80546105f6906140ce565b606060cc80546105f6906140ce565b801580612fdb5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612fb5573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fd991906141f8565b155b6130465760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610f93565b6040516001600160a01b038316602482015260448101829052610ecd90849063095ea7b360e01b90606401612f0e565b6001600160a01b0381165f90815260fd602052604090208054600181018255905b50919050565b5f6105e16130a961289b565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f6130d887878787613560565b915091506130e58161361d565b5090505b949350505050565b5f825f01828154811061310657613106614100565b905f5260205f200154905092915050565b6131218282611916565b610fa65761312e81613766565b613139836020613778565b60405160200161314a92919061425a565b60408051601f198184030181529082905262461bcd60e51b8252610f9391600401613b26565b5f8181526001830160205260408120546131b557508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556105e1565b505f6105e1565b5f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6131e661390d565b6131ee613965565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b0382166132855760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610f93565b8060995f82825461329691906141e5565b90915550506001600160a01b0382165f818152609760209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6040516001600160a01b038316602482015260448101829052610ecd90849063a9059cbb60e01b90606401612f0e565b5f81815260018301602052604081205480156133f8575f613340600183614195565b85549091505f9061335390600190614195565b90508181146133b2575f865f01828154811061337157613371614100565b905f5260205f200154905080875f01848154811061339157613391614100565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806133c3576133c36142ce565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506105e1565b5f9150506105e1565b5f54610100900460ff166134275760405162461bcd60e51b8152600401610f939061420f565b609a613433838261432f565b50609b610ecd828261432f565b5f54610100900460ff166134665760405162461bcd60e51b8152600401610f939061420f565b60cb613472838261432f565b5060cc61347f828261432f565b50505f60c981905560ca5550565b5f6134e1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166139959092919063ffffffff16565b905080515f14806135015750808060200190518101906135019190614114565b610ecd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f93565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561359557505f90506003613614565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156135e6573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b03811661360e575f60019250925050613614565b91505f90505b94509492505050565b5f816004811115613630576136306143ea565b036136385750565b600181600481111561364c5761364c6143ea565b036136995760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610f93565b60028160048111156136ad576136ad6143ea565b036136fa5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610f93565b600381600481111561370e5761370e6143ea565b036125b55760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610f93565b60606105e16001600160a01b03831660145b60605f61378683600261415f565b6137919060026141e5565b6001600160401b038111156137a8576137a8613b76565b6040519080825280601f01601f1916602001820160405280156137d2576020820181803683370190505b509050600360fc1b815f815181106137ec576137ec614100565b60200101906001600160f81b03191690815f1a905350600f60fb1b8160018151811061381a5761381a614100565b60200101906001600160f81b03191690815f1a9053505f61383c84600261415f565b6138479060016141e5565b90505b60018111156138be576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061387b5761387b614100565b1a60f81b82828151811061389157613891614100565b60200101906001600160f81b03191690815f1a90535060049490941c936138b7816143fe565b905061384a565b5083156124725760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610f93565b5f80613917612f45565b80519091501561392e578051602090910120919050565b60c954801561393d5792915050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709250505090565b5f8061396f612f54565b805190915015613986578051602090910120919050565b60ca54801561393d5792915050565b60606130e984845f85855f80866001600160a01b031685876040516139ba9190614413565b5f6040518083038185875af1925050503d805f81146139f4576040519150601f19603f3d011682016040523d82523d5f602084013e6139f9565b606091505b5091509150613a0a87838387613a15565b979650505050505050565b60608315613a835782515f03613a7c576001600160a01b0385163b613a7c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f93565b50816130e9565b6130e98383815115613a985781518083602001fd5b8060405162461bcd60e51b8152600401610f939190613b26565b5f60208284031215613ac2575f80fd5b81356001600160e01b031981168114612472575f80fd5b5f5b83811015613af3578181015183820152602001613adb565b50505f910152565b5f8151808452613b12816020860160208601613ad9565b601f01601f19169290920160200192915050565b602081525f6124726020830184613afb565b6001600160a01b03811681146125b5575f80fd5b5f8060408385031215613b5d575f80fd5b8235613b6881613b38565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715613bb257613bb2613b76565b604052919050565b5f6001600160401b03821115613bd257613bd2613b76565b5060051b60200190565b5f805f60608486031215613bee575f80fd5b83359250602080850135613c0181613b38565b925060408501356001600160401b03811115613c1b575f80fd5b8501601f81018713613c2b575f80fd5b8035613c3e613c3982613bba565b613b8a565b81815260059190911b82018301908381019089831115613c5c575f80fd5b928401925b82841015613c7a57833582529284019290840190613c61565b80955050505050509250925092565b5f8151808452602080850194508084015f5b83811015613cc05781516001600160a01b031687529582019590820190600101613c9b565b509495945050505050565b5f8151808452602080850194508084015f5b83811015613cc057815187529582019590820190600101613cdd565b606081525f613d0b6060830186613c89565b8281036020840152613d1d8186613ccb565b90508281036040840152613d318185613ccb565b9695505050505050565b5f6020808385031215613d4c575f80fd5b82356001600160401b03811115613d61575f80fd5b8301601f81018513613d71575f80fd5b8035613d7f613c3982613bba565b81815260059190911b82018301908381019087831115613d9d575f80fd5b928401925b82841015613a0a578335613db581613b38565b82529284019290840190613da2565b5f805f60608486031215613dd6575f80fd5b8335613de181613b38565b92506020840135613df181613b38565b929592945050506040919091013590565b5f60208284031215613e12575f80fd5b5035919050565b5f8060408385031215613e2a575f80fd5b823591506020830135613e3c81613b38565b809150509250929050565b5f805f60608486031215613e59575f80fd5b8335613e6481613b38565b9250602084013591506040840135613e7b81613b38565b809150509250925092565b5f805f8060808587031215613e99575f80fd5b8435613ea481613b38565b9350602085013592506040850135613ebb81613b38565b9396929550929360600135925050565b5f82601f830112613eda575f80fd5b81356001600160401b03811115613ef357613ef3613b76565b613f06601f8201601f1916602001613b8a565b818152846020838601011115613f1a575f80fd5b816020850160208301375f918101602001919091529392505050565b5f8060408385031215613f47575f80fd5b82356001600160401b0380821115613f5d575f80fd5b613f6986838701613ecb565b93506020850135915080821115613f7e575f80fd5b50613f8b85828601613ecb565b9150509250929050565b5f60208284031215613fa5575f80fd5b813561247281613b38565b60ff60f81b8816815260e060208201525f613fce60e0830189613afb565b8281036040840152613fe08189613afb565b606084018890526001600160a01b038716608085015260a0840186905283810360c085015290506140118185613ccb565b9a9950505050505050505050565b602081525f6124726020830184613c89565b5f805f805f805f60e0888a031215614047575f80fd5b873561405281613b38565b9650602088013561406281613b38565b95506040880135945060608801359350608088013560ff81168114614085575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f80604083850312156140b3575f80fd5b82356140be81613b38565b91506020830135613e3c81613b38565b600181811c908216806140e257607f821691505b60208210810361309757634e487b7160e01b5f52602260045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215614124575f80fd5b81518015158114612472575f80fd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161415857614158614133565b5060010190565b80820281158282048414176105e1576105e1614133565b5f8261419057634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156105e1576105e1614133565b5f80604083850312156141b9575f80fd5b505080516020909101519092909150565b5f602082840312156141da575f80fd5b815161247281613b38565b808201808211156105e1576105e1614133565b5f60208284031215614208575f80fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f8351614291816017850160208801613ad9565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516142c2816028840160208801613ad9565b01602801949350505050565b634e487b7160e01b5f52603160045260245ffd5b601f821115610ecd575f81815260208120601f850160051c810160208610156143085750805b601f850160051c820191505b8181101561432757828155600101614314565b505050505050565b81516001600160401b0381111561434857614348613b76565b61435c8161435684546140ce565b846142e2565b602080601f83116001811461438f575f84156143785750858301515b5f19600386901b1c1916600185901b178555614327565b5f85815260208120601f198616915b828110156143bd5788860151825594840194600190910190840161439e565b50858210156143da57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52602160045260245ffd5b5f8161440c5761440c614133565b505f190190565b5f8251614424818460208701613ad9565b919091019291505056fea264697066735822122074e09bbc13f6cb26a52a4917272373da47f25553af331500f62a1b0068817f1864736f6c63430008140033
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610234575f3560e01c80634cd88b7611610135578063a5f879ca116100b4578063d505accf11610079578063d505accf14610548578063d547741f1461055b578063dd62ed3e1461056e578063ec2c901614610581578063f3f094a114610589575f80fd5b8063a5f879ca146104fd578063a9059cbb14610510578063b8452aa914610523578063c1590cd714610538578063cdc6c7cc14610540575f80fd5b80638e8f294b116100fa5780638e8f294b1461044457806391d14854146104c857806395d89b41146104db578063a217fddf146104e3578063a457c2d7146104ea575f80fd5b80634cd88b76146103c85780635c15155e146103db57806370a08231146103ee5780637ecebe001461041657806384b0196e14610429575f80fd5b8063313ce567116101c15780633bb03e2d116101865780633bb03e2d146103695780633c173a4f1461037c578063468a0efd1461038f57806346c55f80146103a257806347b2795c146103b5575f80fd5b8063313ce567146103195780633644e5151461032857806336568abe1461033057806339509351146103435780633a4639e114610356575f80fd5b806318160ddd1161020757806318160ddd146102aa5780631a3dde45146102bc57806323b872dd146102d1578063248a9ca3146102e45780632f2ff15d14610306575f80fd5b806301ffc9a71461023857806306fdde0314610260578063095ea7b31461027557806316c4033514610288575b5f80fd5b61024b610246366004613ab2565b6105b1565b60405190151581526020015b60405180910390f35b6102686105e7565b6040516102579190613b26565b61024b610283366004613b4c565b610677565b61029b610296366004613bdc565b61068e565b60405161025793929190613cf9565b6099545b604051908152602001610257565b6102cf6102ca366004613d3b565b610d95565b005b61024b6102df366004613dc4565b610ed2565b6102ae6102f2366004613e02565b5f9081526065602052604090206001015490565b6102cf610314366004613e19565b610ef5565b60405160128152602001610257565b6102ae610f19565b6102cf61033e366004613e19565b610f27565b61024b610351366004613b4c565b610faa565b6102cf610364366004613e47565b610fcb565b6102ae610377366004613e86565b61116b565b6102ae61038a366004613e86565b611273565b6102cf61039d366004613e47565b611348565b6102cf6103b0366004613b4c565b611494565b6102cf6103c3366004613d3b565b61152a565b6102cf6103d6366004613f36565b611659565b6102cf6103e9366004613e47565b611792565b6102ae6103fc366004613f95565b6001600160a01b03165f9081526097602052604090205490565b6102ae610424366004613f95565b611860565b61043161187d565b6040516102579796959493929190613fb0565b61048f610452366004613f95565b6101306020525f9081526040902080546001820154600283015460038401546004909401546001600160a01b039384169492841693909116919085565b604080516001600160a01b039687168152948616602086015292909416918301919091526060820152608081019190915260a001610257565b61024b6104d6366004613e19565b611916565b610268611940565b6102ae5f81565b61024b6104f8366004613b4c565b61194f565b6102cf61050b366004613b4c565b6119c9565b61024b61051e366004613b4c565b611c20565b61052b611c2d565b604051610257919061401f565b6102ae611cd6565b61024b611dfc565b6102cf610556366004614031565b611ecf565b6102cf610569366004613e19565b612030565b6102ae61057c3660046140a2565b612054565b61052b61207e565b61059c610597366004613e86565b612122565b60408051928352602083019190915201610257565b5f6001600160e01b03198216637965db0b60e01b14806105e157506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060609a80546105f6906140ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610622906140ce565b801561066d5780601f106106445761010080835404028352916020019161066d565b820191905f5260205f20905b81548152906001019060200180831161065057829003601f168201915b5050505050905090565b5f3361068481858561233b565b5060019392505050565b60608060605f61069f61013161245e565b9050808551146106c257604051637326389560e01b815260040160405180910390fd5b806001600160401b038111156106da576106da613b76565b604051908082528060200260200182016040528015610703578160200160208202803683370190505b509350806001600160401b0381111561071e5761071e613b76565b604051908082528060200260200182016040528015610747578160200160208202803683370190505b509250806001600160401b0381111561076257610762613b76565b60405190808252806020026020018201604052801561078b578160200160208202803683370190505b5091505f816001600160401b038111156107a7576107a7613b76565b6040519080825280602002602001820160405280156107d0578160200160208202803683370190505b5090505f805b8381101561094e576107ea61013182612467565b8782815181106107fc576107fc614100565b60200260200101906001600160a01b031690816001600160a01b0316815250506101305f88838151811061083257610832614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015483828151811061086f5761086f614100565b6020026020010181815250505f6101305f89848151811061089257610892614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206001015f9054906101000a90046001600160a01b03169050806001600160a01b031663cdc6c7cc6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561090d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109319190614114565b1561093b57600192505b508061094681614147565b9150506107d6565b505f61095960995490565b9050610965338b612479565b81156109da575f5b848110156109d457818b85838151811061098957610989614100565b602002602001015161099b919061415f565b6109a59190614176565b8782815181106109b7576109b7614100565b6020908102919091010152806109cc81614147565b91505061096d565b50610b05565b8915610b05575f835f815181106109f3576109f3614100565b602002602001015190505f80600190505b86811015610a555782868281518110610a1f57610a1f614100565b60200260200101511115610a4d57858181518110610a3f57610a3f614100565b602002602001015192508091505b600101610a04565b50818c1115610a825781888281518110610a7157610a71614100565b602002602001018181525050610aa2565b8b888281518110610a9557610a95614100565b6020026020010181815250505b878181518110610ab457610ab4614100565b6020026020010151858281518110610ace57610ace614100565b602002602001018181510391508181525050878181518110610af257610af2614100565b60200260200101518c039b5050506109da565b5f5b84811015610d8757868181518110610b2157610b21614100565b60200260200101515f0315610d75576001600160a01b038a16336001600160a01b0316898381518110610b5657610b56614100565b60200260200101516001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8a8581518110610b9a57610b9a614100565b6020026020010151604051610bb191815260200190565b60405180910390a4868181518110610bcb57610bcb614100565b60200260200101516101305f8a8481518110610be957610be9614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206004015f828254610c219190614195565b925050819055505f6101305f8a8481518110610c3f57610c3f614100565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f206002015f9054906101000a90046001600160a01b03169050806001600160a01b031663d0ce98fa898481518110610c9f57610c9f614100565b60200260200101518d8d8681518110610cba57610cba614100565b60200260200101516040518463ffffffff1660e01b8152600401610cfa939291909283526001600160a01b03919091166020830152604082015260600190565b60408051808303815f875af1158015610d15573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d3991906141a8565b898481518110610d4b57610d4b614100565b60200260200101898581518110610d6457610d64614100565b602090810291909101019190915252505b80610d7f81614147565b915050610b07565b505050505093509350939050565b5f610d9f816125ab565b5f5b8251811015610ecd575f838281518110610dbd57610dbd614100565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e00573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e2491906141ca565b9050610e2f816125b8565b610e5d848381518110610e4457610e44614100565b60200260200101516101336125e190919063ffffffff16565b15610ebc57838281518110610e7457610e74614100565b60200260200101516001600160a01b0316816001600160a01b03167fab3eb4272572b64f7ef5518a913a482ba7dae0fd1b51b7557e7429d8000dabe360405160405180910390a35b50610ec681614147565b9050610da1565b505050565b5f33610edf8582856125f5565b610eea85858561266d565b506001949350505050565b5f82815260656020526040902060010154610f0f816125ab565b610ecd8383612816565b5f610f2261289b565b905090565b6001600160a01b0381163314610f9c5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610fa682826128a4565b5050565b5f33610684818585610fbc8383612054565b610fc691906141e5565b61233b565b82610fd86101338261290a565b610ff557604051630a5af2b960e41b815260040160405180910390fd5b610ffd611dfc565b1561101b57604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611058573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061107c91906141ca565b9050611087816125b8565b611091815f61292b565b6001600160a01b03851663e162402f336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018790523060448201526064015f604051808303815f87803b1580156110ec575f80fd5b505af11580156110fe573d5f803e3d5ffd5b5050505061110d818486612ad2565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78760405161115c91815260200190565b60405180910390a45050505050565b5f846111796101338261290a565b61119657604051630a5af2b960e41b815260040160405180910390fd5b61119e611dfc565b156111bc57604051635cbe463960e01b815260040160405180910390fd5b5f866001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111f9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061121d91906141ca565b9050611228816125b8565b61123381600161292b565b6001600160a01b038082165f90815261013060205260409020541661125a82828988612afd565b935061126881898887612d31565b505050949350505050565b5f8461127e816125b8565b85600161128b828261292b565b611293611dfc565b156112b157604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038089165f9081526101306020526040902054166112d889828a89612afd565b94506112e5898887612ad2565b6001600160a01b038716336001600160a01b03168a6001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78860405161133491815260200190565b60405180910390a450505050949350505050565b826113556101338261290a565b61137257604051630a5af2b960e41b815260040160405180910390fd5b61137a611dfc565b1561139857604051635cbe463960e01b815260040160405180910390fd5b5f846001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113d5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113f991906141ca565b9050611404816125b8565b61140f813386612dbc565b6001600160a01b038316336001600160a01b0316826001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8760405161145e91815260200190565b60405180910390a46001600160a01b038082165f908152610130602052604090205461148d9116868587612d31565b5050505050565b5f61149e816125ab565b6114aa6101318461290a565b6114c7576040516338453dd760e01b815260040160405180910390fd5b6001600160a01b0383165f8181526101306020908152604091829020600301805490869055825181815291820186905292917f8b7ffd801f5f56da3dab6179fa82d8dcfa0aef7edfa3d5a5c895b1c2ed4c2982910160405180910390a250505050565b5f611534816125ab565b5f5b8251811015610ecd575f83828151811061155257611552614100565b60200260200101516001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611595573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115b991906141ca565b90506115e98483815181106115d0576115d0614100565b6020026020010151610133612e2590919063ffffffff16565b156116485783828151811061160057611600614100565b60200260200101516001600160a01b0316816001600160a01b03167f37ef9fb84c18a8c84c537c46b4201d2c1f95d1c059a56ea05cf00c518b21689260405160405180910390a35b5061165281614147565b9050611536565b5f54610100900460ff161580801561167757505f54600160ff909116105b806116905750303b15801561169057505f5460ff166001145b6116f35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610f93565b5f805460ff191660011790558015611714575f805461ff0019166101001790555b61171c612e39565b611724612e39565b61172c612e39565b6117368383612e61565b61173f83612e91565b6117495f33612816565b8015610ecd575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b8261179c816125b8565b835f6117a8828261292b565b6117b0611dfc565b156117ce57604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038681165f9081526101306020526040902054166117f581333089612eda565b611800878688612ad2565b6001600160a01b038516336001600160a01b0316886001600160a01b03167fbfa61fc27bb37f6f94529a9d0f81f1cc1a422648a9febe15aa90d13c33ed9ad78960405161184f91815260200190565b60405180910390a450505050505050565b6001600160a01b0381165f90815260fd60205260408120546105e1565b5f6060805f805f606060c9545f801b148015611899575060ca54155b6118dd5760405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b6044820152606401610f93565b6118e5612f45565b6118ed612f54565b604080515f80825260208201909252600f60f81b9b939a50919850469750309650945092509050565b5f9182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060609b80546105f6906140ce565b5f338161195c8286612054565b9050838110156119bc5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610f93565b610eea828686840361233b565b5f6119d3816125ab565b5f836001600160a01b031663c55dae636040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a10573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a3491906141ca565b90505f846001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a73573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a9791906141ca565b90505f856001600160a01b031663a8694e576040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ad6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611afa91906141ca565b9050611b086101318461290a565b15611b2657604051639d80f21f60e01b815260040160405180910390fd5b611b32610131846125e1565b506040805160a0810182526001600160a01b03808416825284811660208084019182528a8316848601908152606085018b81525f608087018181528b8716808352610130909552979020955186549086166001600160a01b031991821617875593516001870180549187169186169190911790559051600286018054919095169316929092179092555160038301559151600490910155611bd590875f19612f63565b826001600160a01b03167f7db2b525ddc969d78e5db660ace79ab264aff9c141437a4b78a87f2aeb39ee8d86604051611c1091815260200190565b60405180910390a2505050505050565b5f3361068481858561266d565b60605f611c3b61013361245e565b9050806001600160401b03811115611c5557611c55613b76565b604051908082528060200260200182016040528015611c7e578160200160208202803683370190505b5091505f5b81811015611cd157611c9761013382612467565b838281518110611ca957611ca9614100565b6001600160a01b0390921660209283029190910190910152611cca81614147565b9050611c83565b505090565b5f80611ce361013161245e565b90505f611cef60995490565b9050805f03611d0857670de0b6b3a76400009250505090565b5f5b82811015611dea575f611d1f61013183612467565b6001600160a01b038082165f9081526101306020908152604080832054815163c1590cd760e01b81529151959650909316939192849263c1590cd7926004808401939192918290030181865afa158015611d7b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d9f91906141f8565b6001600160a01b0384165f9081526101306020526040902060040154909150611dc8908261415f565b611dd290886141e5565b96505050508080611de290614147565b915050611d0a565b50611df58184614176565b9250505090565b5f80611e0961013161245e565b90505f5b81811015611ec7575f611e2261013183612467565b6001600160a01b038082165f9081526101306020908152604091829020600101548251633371b1f360e21b8152925194955090921692839263cdc6c7cc92600480820193918290030181865afa158015611e7e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ea29190614114565b15611eb257600194505050505090565b50508080611ebf90614147565b915050611e0d565b505f91505090565b83421115611f1f5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610f93565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611f4d8c613076565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f611fa78261309d565b90505f611fb6828787876130c9565b9050896001600160a01b0316816001600160a01b0316146120195760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610f93565b6120248a8a8a61233b565b50505050505050505050565b5f8281526065602052604090206001015461204a816125ab565b610ecd83836128a4565b6001600160a01b039182165f90815260986020908152604080832093909416825291909152205490565b60605f61208c61013161245e565b9050806001600160401b038111156120a6576120a6613b76565b6040519080825280602002602001820160405280156120cf578160200160208202803683370190505b5091505f5b81811015611cd1576120e861013182612467565b8382815181106120fa576120fa614100565b6001600160a01b039092166020928302919091019091015261211b81614147565b90506120d4565b5f808561212e816125b8565b612136611dfc565b1561215457604051635cbe463960e01b815260040160405180910390fd5b6001600160a01b038781165f90815261013060205260408082206002810154905491516370a0823160e01b81523060048201529084169391909116919082906370a0823190602401602060405180830381865afa1580156121b7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121db91906141f8565b6040516368674c7d60e11b8152600481018b90526001600160a01b038a81166024830152604482018a90529192509084169063d0ce98fa9060640160408051808303815f875af1158015612231573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061225591906141a8565b6040516370a0823160e01b815230600482015291975095506001600160a01b038316906370a0823190602401602060405180830381865afa15801561229c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122c091906141f8565b6122ca9082614195565b98506122d78a338b612dbc565b6001600160a01b038816336001600160a01b03168b6001600160a01b03167fe173a76508f1af24a0f4f1e0ea3192eb6bbb92d750ad178d4dffe6048d63248d8c60405161232691815260200190565b60405180910390a45050505094509492505050565b6001600160a01b03831661239d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610f93565b6001600160a01b0382166123fe5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610f93565b6001600160a01b038381165f8181526098602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b5f6105e1825490565b5f61247283836130f1565b9392505050565b6001600160a01b0382166124d95760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610f93565b6001600160a01b0382165f908152609760205260409020548181101561254c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610f93565b6001600160a01b0383165f8181526097602090815260408083208686039055609980548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6125b58133613117565b50565b6125c46101318261290a565b6125b5576040516338453dd760e01b815260040160405180910390fd5b5f612472836001600160a01b038416613170565b5f6126008484612054565b90505f198114612667578181101561265a5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610f93565b612667848484840361233b565b50505050565b6001600160a01b0383166126d15760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610f93565b6001600160a01b0382166127335760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610f93565b6001600160a01b0383165f90815260976020526040902054818110156127aa5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610f93565b6001600160a01b038085165f8181526097602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906128099086815260200190565b60405180910390a3612667565b6128208282611916565b610fa6575f8281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556128573390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f610f226131bc565b6128ae8282611916565b15610fa6575f8281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0381165f9081526001830160205260408120541515612472565b6001600160a01b038083165f9081526101306020526040902060010154168115612a55575f816001600160a01b031663b4eae1cb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561298c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129b091906141f8565b6001600160a01b038086165f90815261013060209081526040808320600201548151630cf0b5b360e41b815291519596509294929093169263cf0b5b3092600480830193928290030181865afa158015612a0c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a3091906141f8565b9050808211612a52576040516319168f7960e21b815260040160405180910390fd5b50505b806001600160a01b0316639e3ad8716040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a91573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612ab59190614114565b610ecd57604051631d05894b60e31b815260040160405180910390fd5b6001600160a01b0383165f90815261013060205260409020600401805482019055610ecd828261322f565b6001600160a01b038481165f81815261013060205260408120600281015460039091015491931691612b3190333088612eda565b6040516370a0823160e01b81523060048201525f906001600160a01b038916906370a0823190602401602060405180830381865afa158015612b75573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b9991906141f8565b6040516364c9b4c360e01b815260048101889052306024820152604481018790529091506001600160a01b038416906364c9b4c3906064016020604051808303815f875af1158015612bed573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c1191906141f8565b935081876001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c50573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c7491906141f8565b1115612c9357604051630788a88760e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f906001600160a01b038a16906370a0823190602401602060405180830381865afa158015612cd7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612cfb91906141f8565b612d059083614195565b905086811015612d2557612d256001600160a01b038a1633838a036132ee565b50505050949350505050565b612d456001600160a01b038516845f612f63565b612d596001600160a01b0385168483612f63565b604051636e553f6560e01b8152600481018290526001600160a01b038381166024830152841690636e553f65906044015f604051808303815f87803b158015612da0575f80fd5b505af1158015612db2573d5f803e3d5ffd5b5050505050505050565b6001600160a01b0383165f908152610130602052604090206004015480821115612df95760405163b268a92160e01b815260040160405180910390fd5b6001600160a01b0384165f90815261013060205260409020600401805483900390556126678383612479565b5f612472836001600160a01b03841661331e565b5f54610100900460ff16612e5f5760405162461bcd60e51b8152600401610f939061420f565b565b5f54610100900460ff16612e875760405162461bcd60e51b8152600401610f939061420f565b610fa68282613401565b5f54610100900460ff16612eb75760405162461bcd60e51b8152600401610f939061420f565b6125b581604051806040016040528060018152602001603160f81b815250613440565b6040516001600160a01b03808516602483015283166044820152606481018290526126679085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261348d565b606060cb80546105f6906140ce565b606060cc80546105f6906140ce565b801580612fdb5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612fb5573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fd991906141f8565b155b6130465760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610f93565b6040516001600160a01b038316602482015260448101829052610ecd90849063095ea7b360e01b90606401612f0e565b6001600160a01b0381165f90815260fd602052604090208054600181018255905b50919050565b5f6105e16130a961289b565b8360405161190160f01b8152600281019290925260228201526042902090565b5f805f6130d887878787613560565b915091506130e58161361d565b5090505b949350505050565b5f825f01828154811061310657613106614100565b905f5260205f200154905092915050565b6131218282611916565b610fa65761312e81613766565b613139836020613778565b60405160200161314a92919061425a565b60408051601f198184030181529082905262461bcd60e51b8252610f9391600401613b26565b5f8181526001830160205260408120546131b557508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556105e1565b505f6105e1565b5f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6131e661390d565b6131ee613965565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b0382166132855760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610f93565b8060995f82825461329691906141e5565b90915550506001600160a01b0382165f818152609760209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6040516001600160a01b038316602482015260448101829052610ecd90849063a9059cbb60e01b90606401612f0e565b5f81815260018301602052604081205480156133f8575f613340600183614195565b85549091505f9061335390600190614195565b90508181146133b2575f865f01828154811061337157613371614100565b905f5260205f200154905080875f01848154811061339157613391614100565b5f918252602080832090910192909255918252600188019052604090208390555b85548690806133c3576133c36142ce565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f9055600193505050506105e1565b5f9150506105e1565b5f54610100900460ff166134275760405162461bcd60e51b8152600401610f939061420f565b609a613433838261432f565b50609b610ecd828261432f565b5f54610100900460ff166134665760405162461bcd60e51b8152600401610f939061420f565b60cb613472838261432f565b5060cc61347f828261432f565b50505f60c981905560ca5550565b5f6134e1826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166139959092919063ffffffff16565b905080515f14806135015750808060200190518101906135019190614114565b610ecd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f93565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561359557505f90506003613614565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156135e6573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b03811661360e575f60019250925050613614565b91505f90505b94509492505050565b5f816004811115613630576136306143ea565b036136385750565b600181600481111561364c5761364c6143ea565b036136995760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610f93565b60028160048111156136ad576136ad6143ea565b036136fa5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610f93565b600381600481111561370e5761370e6143ea565b036125b55760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610f93565b60606105e16001600160a01b03831660145b60605f61378683600261415f565b6137919060026141e5565b6001600160401b038111156137a8576137a8613b76565b6040519080825280601f01601f1916602001820160405280156137d2576020820181803683370190505b509050600360fc1b815f815181106137ec576137ec614100565b60200101906001600160f81b03191690815f1a905350600f60fb1b8160018151811061381a5761381a614100565b60200101906001600160f81b03191690815f1a9053505f61383c84600261415f565b6138479060016141e5565b90505b60018111156138be576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061387b5761387b614100565b1a60f81b82828151811061389157613891614100565b60200101906001600160f81b03191690815f1a90535060049490941c936138b7816143fe565b905061384a565b5083156124725760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610f93565b5f80613917612f45565b80519091501561392e578051602090910120919050565b60c954801561393d5792915050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4709250505090565b5f8061396f612f54565b805190915015613986578051602090910120919050565b60ca54801561393d5792915050565b60606130e984845f85855f80866001600160a01b031685876040516139ba9190614413565b5f6040518083038185875af1925050503d805f81146139f4576040519150601f19603f3d011682016040523d82523d5f602084013e6139f9565b606091505b5091509150613a0a87838387613a15565b979650505050505050565b60608315613a835782515f03613a7c576001600160a01b0385163b613a7c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f93565b50816130e9565b6130e98383815115613a985781518083602001fd5b8060405162461bcd60e51b8152600401610f939190613b26565b5f60208284031215613ac2575f80fd5b81356001600160e01b031981168114612472575f80fd5b5f5b83811015613af3578181015183820152602001613adb565b50505f910152565b5f8151808452613b12816020860160208601613ad9565b601f01601f19169290920160200192915050565b602081525f6124726020830184613afb565b6001600160a01b03811681146125b5575f80fd5b5f8060408385031215613b5d575f80fd5b8235613b6881613b38565b946020939093013593505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715613bb257613bb2613b76565b604052919050565b5f6001600160401b03821115613bd257613bd2613b76565b5060051b60200190565b5f805f60608486031215613bee575f80fd5b83359250602080850135613c0181613b38565b925060408501356001600160401b03811115613c1b575f80fd5b8501601f81018713613c2b575f80fd5b8035613c3e613c3982613bba565b613b8a565b81815260059190911b82018301908381019089831115613c5c575f80fd5b928401925b82841015613c7a57833582529284019290840190613c61565b80955050505050509250925092565b5f8151808452602080850194508084015f5b83811015613cc05781516001600160a01b031687529582019590820190600101613c9b565b509495945050505050565b5f8151808452602080850194508084015f5b83811015613cc057815187529582019590820190600101613cdd565b606081525f613d0b6060830186613c89565b8281036020840152613d1d8186613ccb565b90508281036040840152613d318185613ccb565b9695505050505050565b5f6020808385031215613d4c575f80fd5b82356001600160401b03811115613d61575f80fd5b8301601f81018513613d71575f80fd5b8035613d7f613c3982613bba565b81815260059190911b82018301908381019087831115613d9d575f80fd5b928401925b82841015613a0a578335613db581613b38565b82529284019290840190613da2565b5f805f60608486031215613dd6575f80fd5b8335613de181613b38565b92506020840135613df181613b38565b929592945050506040919091013590565b5f60208284031215613e12575f80fd5b5035919050565b5f8060408385031215613e2a575f80fd5b823591506020830135613e3c81613b38565b809150509250929050565b5f805f60608486031215613e59575f80fd5b8335613e6481613b38565b9250602084013591506040840135613e7b81613b38565b809150509250925092565b5f805f8060808587031215613e99575f80fd5b8435613ea481613b38565b9350602085013592506040850135613ebb81613b38565b9396929550929360600135925050565b5f82601f830112613eda575f80fd5b81356001600160401b03811115613ef357613ef3613b76565b613f06601f8201601f1916602001613b8a565b818152846020838601011115613f1a575f80fd5b816020850160208301375f918101602001919091529392505050565b5f8060408385031215613f47575f80fd5b82356001600160401b0380821115613f5d575f80fd5b613f6986838701613ecb565b93506020850135915080821115613f7e575f80fd5b50613f8b85828601613ecb565b9150509250929050565b5f60208284031215613fa5575f80fd5b813561247281613b38565b60ff60f81b8816815260e060208201525f613fce60e0830189613afb565b8281036040840152613fe08189613afb565b606084018890526001600160a01b038716608085015260a0840186905283810360c085015290506140118185613ccb565b9a9950505050505050505050565b602081525f6124726020830184613c89565b5f805f805f805f60e0888a031215614047575f80fd5b873561405281613b38565b9650602088013561406281613b38565b95506040880135945060608801359350608088013560ff81168114614085575f80fd5b9699959850939692959460a0840135945060c09093013592915050565b5f80604083850312156140b3575f80fd5b82356140be81613b38565b91506020830135613e3c81613b38565b600181811c908216806140e257607f821691505b60208210810361309757634e487b7160e01b5f52602260045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215614124575f80fd5b81518015158114612472575f80fd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161415857614158614133565b5060010190565b80820281158282048414176105e1576105e1614133565b5f8261419057634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156105e1576105e1614133565b5f80604083850312156141b9575f80fd5b505080516020909101519092909150565b5f602082840312156141da575f80fd5b815161247281613b38565b808201808211156105e1576105e1614133565b5f60208284031215614208575f80fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f8351614291816017850160208801613ad9565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516142c2816028840160208801613ad9565b01602801949350505050565b634e487b7160e01b5f52603160045260245ffd5b601f821115610ecd575f81815260208120601f850160051c810160208610156143085750805b601f850160051c820191505b8181101561432757828155600101614314565b505050505050565b81516001600160401b0381111561434857614348613b76565b61435c8161435684546140ce565b846142e2565b602080601f83116001811461438f575f84156143785750858301515b5f19600386901b1c1916600185901b178555614327565b5f85815260208120601f198616915b828110156143bd5788860151825594840194600190910190840161439e565b50858210156143da57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52602160045260245ffd5b5f8161440c5761440c614133565b505f190190565b5f8251614424818460208701613ad9565b919091019291505056fea264697066735822122074e09bbc13f6cb26a52a4917272373da47f25553af331500f62a1b0068817f1864736f6c63430008140033
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.