Overview
CRO Balance
0 CRO
CRO Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
PositionManager
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 1 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/IRouter.sol"; import "./interfaces/IVault.sol"; import "./interfaces/IOrderBook.sol"; import "../peripherals/interfaces/ITimelock.sol"; import "./BasePositionManager.sol"; import "./interfaces/ICircuitBreaker.sol"; contract PositionManager is BasePositionManager { using SafeERC20Upgradeable for IERC20Upgradeable; address public orderBook; bool public inLegacyMode; bool public shouldValidateIncreaseOrder; mapping (address => bool) public isOrderKeeper; mapping (address => bool) public isPartner; mapping (address => bool) public isLiquidator; ICircuitBreaker public circuitBreaker; event SetOrderKeeper(address indexed account, bool isActive); event SetLiquidator(address indexed account, bool isActive); event SetPartner(address account, bool isActive); event SetInLegacyMode(bool inLegacyMode); event SetShouldValidateIncreaseOrder(bool shouldValidateIncreaseOrder); modifier onlyOrderKeeper() { require(isOrderKeeper[msg.sender], "PositionManager: forbidden"); _; } modifier onlyLiquidator() { require(isLiquidator[msg.sender], "PositionManager: forbidden"); _; } modifier onlyPartnersOrLegacyMode() { require(isPartner[msg.sender] || inLegacyMode, "PositionManager: forbidden"); _; } function setCircuitBreaker(ICircuitBreaker _circuitBreaker) external onlyAdmin { circuitBreaker = _circuitBreaker; } function initialize( address _vault, address _router, address _shortsTracker, address _weth, uint256 _depositFee, address _orderBook ) public initializer { __BasePositionManager_init(_vault, _router, _shortsTracker, _weth, _depositFee); orderBook = _orderBook; shouldValidateIncreaseOrder = true; } function setOrderKeeper(address _account, bool _isActive) external onlyAdmin { isOrderKeeper[_account] = _isActive; emit SetOrderKeeper(_account, _isActive); } function setLiquidator(address _account, bool _isActive) external onlyAdmin { isLiquidator[_account] = _isActive; emit SetLiquidator(_account, _isActive); } function setPartner(address _account, bool _isActive) external onlyAdmin { isPartner[_account] = _isActive; emit SetPartner(_account, _isActive); } function setInLegacyMode(bool _inLegacyMode) external onlyAdmin { inLegacyMode = _inLegacyMode; emit SetInLegacyMode(_inLegacyMode); } function setShouldValidateIncreaseOrder(bool _shouldValidateIncreaseOrder) external onlyAdmin { shouldValidateIncreaseOrder = _shouldValidateIncreaseOrder; emit SetShouldValidateIncreaseOrder(_shouldValidateIncreaseOrder); } function increasePosition( address[] memory _path, address _indexToken, uint256 _amountIn, uint256 _minOut, uint256 _sizeDelta, bool _isLong, uint256 _price ) external nonReentrant onlyPartnersOrLegacyMode { require(_path.length == 1 || _path.length == 2, "PositionManager: invalid _path.length"); if (_amountIn > 0) { if (_path.length == 1) { IRouter(router).pluginTransfer(_path[0], msg.sender, address(this), _amountIn); } else { IRouter(router).pluginTransfer(_path[0], msg.sender, vault, _amountIn); _amountIn = _swap(_path, _minOut, address(this)); } uint256 afterFeeAmount = _collectFees(msg.sender, _path, _amountIn, _indexToken, _isLong, _sizeDelta); IERC20Upgradeable(_path[_path.length - 1]).safeTransfer(vault, afterFeeAmount); } _increasePosition(msg.sender, _path[_path.length - 1], _indexToken, _sizeDelta, _isLong, _price); } function increasePositionETH( address[] memory _path, address _indexToken, uint256 _minOut, uint256 _sizeDelta, bool _isLong, uint256 _price ) external payable nonReentrant onlyPartnersOrLegacyMode { require(_path.length == 1 || _path.length == 2, "PositionManager: invalid _path.length"); require(_path[0] == weth, "PositionManager: invalid _path"); if (msg.value > 0) { _transferInETH(); uint256 _amountIn = msg.value; if (_path.length > 1) { IERC20Upgradeable(weth).safeTransfer(vault, msg.value); _amountIn = _swap(_path, _minOut, address(this)); } uint256 afterFeeAmount = _collectFees(msg.sender, _path, _amountIn, _indexToken, _isLong, _sizeDelta); IERC20Upgradeable(_path[_path.length - 1]).safeTransfer(vault, afterFeeAmount); } _increasePosition(msg.sender, _path[_path.length - 1], _indexToken, _sizeDelta, _isLong, _price); } function decreasePosition( address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver, uint256 _price ) external nonReentrant onlyPartnersOrLegacyMode { _decreasePosition(msg.sender, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, _receiver, _price); } function decreasePositionETH( address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address payable _receiver, uint256 _price ) external nonReentrant onlyPartnersOrLegacyMode { require(_collateralToken == weth, "PositionManager: invalid _collateralToken"); (uint256 amountOut,) = _decreasePosition(msg.sender, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, address(this), _price); _transferOutETHWithGasLimitIgnoreFail(amountOut, _receiver); } function decreasePositionAndSwap( address[] memory _path, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver, uint256 _price, uint256 _minOut ) external nonReentrant onlyPartnersOrLegacyMode { require(_path.length == 2, "PositionManager: invalid _path.length"); (uint256 amount,) = _decreasePosition(msg.sender, _path[0], _indexToken, _collateralDelta, _sizeDelta, _isLong, address(this), _price); IERC20Upgradeable(_path[0]).safeTransfer(vault, amount); _swap(_path, _minOut, _receiver); } function decreasePositionAndSwapETH( address[] memory _path, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address payable _receiver, uint256 _price, uint256 _minOut ) external nonReentrant onlyPartnersOrLegacyMode { require(_path.length == 2, "PositionManager: invalid _path.length"); require(_path[_path.length - 1] == weth, "PositionManager: invalid _path"); (uint256 amount,) = _decreasePosition(msg.sender, _path[0], _indexToken, _collateralDelta, _sizeDelta, _isLong, address(this), _price); IERC20Upgradeable(_path[0]).safeTransfer(vault, amount); uint256 amountOut = _swap(_path, _minOut, address(this)); _transferOutETHWithGasLimitIgnoreFail(amountOut, _receiver); } function liquidatePosition( address _account, address _collateralToken, address _indexToken, bool _isLong, address _feeReceiver ) external nonReentrant onlyLiquidator { address _vault = vault; address timelock = IVault(_vault).gov(); (uint256 size, , , , , , , ) = IVault(vault).getPosition(_account, _collateralToken, _indexToken, _isLong); uint256 markPrice = _isLong ? IVault(_vault).getMinPrice(_indexToken) : IVault(_vault).getMaxPrice(_indexToken); // should be called strictly before position is updated in Vault IShortsTracker(shortsTracker).updateGlobalShortData(_account, _collateralToken, _indexToken, _isLong, size, markPrice, false); ITimelock(timelock).enableLeverage(_vault); IVault(_vault).liquidatePosition(_account, _collateralToken, _indexToken, _isLong, _feeReceiver); ITimelock(timelock).disableLeverage(_vault); } function executeSwapOrder(address _account, uint256 _orderIndex, address payable _feeReceiver) external onlyOrderKeeper { IOrderBook(orderBook).executeSwapOrder(_account, _orderIndex, _feeReceiver); } function executeIncreaseOrder(address _account, uint256 _orderIndex, address payable _feeReceiver) external onlyOrderKeeper { _validateIncreaseOrder(_account, _orderIndex); address _vault = vault; address timelock = IVault(_vault).gov(); ( /*address purchaseToken*/, /*uint256 purchaseTokenAmount*/, address collateralToken, address indexToken, uint256 sizeDelta, bool isLong, /*uint256 triggerPrice*/, /*bool triggerAboveThreshold*/, /*uint256 executionFee*/ ) = IOrderBook(orderBook).getIncreaseOrder(_account, _orderIndex); circuitBreaker.validateCircuitBreaker(indexToken, sizeDelta, isLong); uint256 markPrice = isLong ? IVault(_vault).getMaxPrice(indexToken) : IVault(_vault).getMinPrice(indexToken); // should be called strictly before position is updated in Vault IShortsTracker(shortsTracker).updateGlobalShortData(_account, collateralToken, indexToken, isLong, sizeDelta, markPrice, true); ITimelock(timelock).enableLeverage(_vault); IOrderBook(orderBook).executeIncreaseOrder(_account, _orderIndex, _feeReceiver); ITimelock(timelock).disableLeverage(_vault); } function executeDecreaseOrder(address _account, uint256 _orderIndex, address payable _feeReceiver) external onlyOrderKeeper { address _vault = vault; address timelock = IVault(_vault).gov(); ( address collateralToken, /*uint256 collateralDelta*/, address indexToken, uint256 sizeDelta, bool isLong, /*uint256 triggerPrice*/, /*bool triggerAboveThreshold*/, /*uint256 executionFee*/ ) = IOrderBook(orderBook).getDecreaseOrder(_account, _orderIndex); uint256 markPrice = isLong ? IVault(_vault).getMinPrice(indexToken) : IVault(_vault).getMaxPrice(indexToken); // should be called strictly before position is updated in Vault IShortsTracker(shortsTracker).updateGlobalShortData(_account, collateralToken, indexToken, isLong, sizeDelta, markPrice, false); ITimelock(timelock).enableLeverage(_vault); IOrderBook(orderBook).executeDecreaseOrder(_account, _orderIndex, _feeReceiver); ITimelock(timelock).disableLeverage(_vault); } function _validateIncreaseOrder(address _account, uint256 _orderIndex) internal view { ( address _purchaseToken, uint256 _purchaseTokenAmount, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong, , // triggerPrice , // triggerAboveThreshold // executionFee ) = IOrderBook(orderBook).getIncreaseOrder(_account, _orderIndex); _validateMaxGlobalSize(_indexToken, _isLong, _sizeDelta); if (!shouldValidateIncreaseOrder) { return; } // shorts are okay if (!_isLong) { return; } // if the position size is not increasing, this is a collateral deposit require(_sizeDelta > 0, "PositionManager: long deposit"); IVault _vault = IVault(vault); (uint256 size, uint256 collateral, , , , , , ) = _vault.getPosition(_account, _collateralToken, _indexToken, _isLong); // if there is no existing position, do not charge a fee if (size == 0) { return; } uint256 nextSize = size + _sizeDelta; uint256 collateralDelta = _vault.tokenToUsdMin(_purchaseToken, _purchaseTokenAmount); uint256 nextCollateral = collateral + collateralDelta; uint256 prevLeverage = size * BASIS_POINTS_DIVISOR / collateral; // allow for a maximum of a increasePositionBufferBps decrease since there might be some swap fees taken from the collateral uint256 nextLeverageWithBuffer = nextSize * (BASIS_POINTS_DIVISOR + increasePositionBufferBps) / nextCollateral; require(nextLeverageWithBuffer >= prevLeverage, "PositionManager: long leverage decrease"); } function _transferOutETHWithGasLimitIgnoreFail(uint256 _amountOut, address payable _receiver) internal { IWETH(weth).withdraw(_amountOut); // use `send` instead of `transfer` to not revert whole transaction in case ETH transfer was failed // it has limit of 2300 gas // this is to avoid front-running _receiver.send(_amountOut); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(account), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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] * ``` * 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 Internal function that returns the initialized version. Returns `_initialized` */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Internal function that returns the initialized version. Returns `_initializing` */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20PermitUpgradeable { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../extensions/draft-IERC20PermitUpgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20PermitUpgradeable token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; pragma solidity ^0.8.0; abstract contract Governable is Initializable { address public gov; event UpdateGov(address gov); function __Governable_init() internal onlyInitializing { gov = msg.sender; } modifier onlyGov() { require(msg.sender == gov, "Governable: forbidden"); _; } function setGov(address _gov) external onlyGov { require(_gov != address(0), "Governable: zero address"); gov = _gov; emit UpdateGov(gov); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "../tokens/interfaces/IWETH.sol"; import "./interfaces/IRouter.sol"; import "./interfaces/IVault.sol"; import "./interfaces/IShortsTracker.sol"; import "./interfaces/IOrderBook.sol"; import "./interfaces/IBasePositionManager.sol"; import "../access/Governable.sol"; import "../peripherals/interfaces/ITimelock.sol"; import "../referrals/interfaces/IReferralManager.sol"; abstract contract BasePositionManager is IBasePositionManager, ReentrancyGuardUpgradeable, Governable { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressUpgradeable for address payable; uint256 public constant BASIS_POINTS_DIVISOR = 10000; address public admin; address public feeAdmin; address public vault; address public shortsTracker; address public router; address public weth; // to prevent using the deposit and withdrawal of collateral as a zero fee swap, // there is a small depositFee charged if a collateral deposit results in the decrease // of leverage for an existing position // increasePositionBufferBps allows for a small amount of decrease of leverage uint256 public depositFee; uint256 public increasePositionBufferBps; address public referralStorage; mapping (address => uint256) public feeReserves; mapping (address => uint256) public override maxGlobalLongSizes; mapping (address => uint256) public override maxGlobalShortSizes; event SetDepositFee(uint256 depositFee); event SetIncreasePositionBufferBps(uint256 increasePositionBufferBps); event SetReferralManager(address referralManager); event SetAdmin(address admin); event SetFeeAdmin(address feeAdmin); event WithdrawFees(address token, address receiver, uint256 amount); event SetMaxGlobalSizes( address[] tokens, uint256[] longSizes, uint256[] shortSizes ); modifier onlyAdmin() { require(msg.sender == admin, "BasePositionManager: forbidden"); _; } modifier onlyFeeAdmin() { require(msg.sender == feeAdmin || msg.sender == admin, "BasePositionManager: feeAdmin or admin role is required"); _; } function __BasePositionManager_init( address _vault, address _router, address _shortsTracker, address _weth, uint256 _depositFee ) internal onlyInitializing { __Governable_init(); __ReentrancyGuard_init(); vault = _vault; router = _router; weth = _weth; depositFee = _depositFee; shortsTracker = _shortsTracker; increasePositionBufferBps = 100; admin = msg.sender; } receive() external payable { require(msg.sender == weth, "BasePositionManager: invalid sender"); } function setAdmin(address _admin) external onlyGov { require(_admin != address(0), "BasePositionManager: zero address"); admin = _admin; emit SetAdmin(_admin); } function setFeeAdmin(address _feeAdmin) external onlyAdmin { feeAdmin = _feeAdmin; emit SetFeeAdmin(_feeAdmin); } function setDepositFee(uint256 _depositFee) external onlyAdmin { depositFee = _depositFee; emit SetDepositFee(_depositFee); } function setIncreasePositionBufferBps(uint256 _increasePositionBufferBps) external onlyAdmin { increasePositionBufferBps = _increasePositionBufferBps; emit SetIncreasePositionBufferBps(_increasePositionBufferBps); } function setReferralManager(address _referralManager) external onlyAdmin { referralStorage = _referralManager; emit SetReferralManager(_referralManager); } function setMaxGlobalSizes( address[] memory _tokens, uint256[] memory _longSizes, uint256[] memory _shortSizes ) external onlyAdmin { for (uint256 i = 0; i < _tokens.length; i++) { address token = _tokens[i]; maxGlobalLongSizes[token] = _longSizes[i]; maxGlobalShortSizes[token] = _shortSizes[i]; } emit SetMaxGlobalSizes(_tokens, _longSizes, _shortSizes); } function withdrawFees(address _token, address _receiver) external onlyFeeAdmin { uint256 amount = feeReserves[_token]; if (amount == 0) { return; } feeReserves[_token] = 0; IERC20Upgradeable(_token).safeTransfer(_receiver, amount); emit WithdrawFees(_token, _receiver, amount); } function approve(address _token, address _spender, uint256 _amount) external onlyGov { IERC20Upgradeable(_token).approve(_spender, _amount); } function sendValue(address payable _receiver, uint256 _amount) external onlyGov { _receiver.sendValue(_amount); } function _validateMaxGlobalSize(address _indexToken, bool _isLong, uint256 _sizeDelta) internal view { if (_sizeDelta == 0) { return; } if (_isLong) { uint256 maxGlobalLongSize = maxGlobalLongSizes[_indexToken]; if (maxGlobalLongSize > 0 && IVault(vault).guaranteedUsd(_indexToken) + _sizeDelta > maxGlobalLongSize) { revert("BasePositionManager: max global longs exceeded"); } } else { uint256 maxGlobalShortSize = maxGlobalShortSizes[_indexToken]; if (maxGlobalShortSize > 0 && IVault(vault).globalShortSizes(_indexToken) + _sizeDelta > maxGlobalShortSize) { revert("BasePositionManager: max global shorts exceeded"); } } } function _increasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong, uint256 _price) internal returns (uint256) { address _vault = vault; uint256 markPrice = _isLong ? IVault(_vault).getMaxPrice(_indexToken) : IVault(_vault).getMinPrice(_indexToken); if (_isLong) { require(markPrice <= _price, "BasePositionManager: mark price higher than limit"); } else { require(markPrice >= _price, "BasePositionManager: mark price lower than limit"); } _validateMaxGlobalSize(_indexToken, _isLong, _sizeDelta); address timelock = IVault(_vault).gov(); // should be called strictly before position is updated in Vault IShortsTracker(shortsTracker).updateGlobalShortData(_account, _collateralToken, _indexToken, _isLong, _sizeDelta, markPrice, true); ITimelock(timelock).enableLeverage(_vault); IRouter(router).pluginIncreasePosition(_account, _collateralToken, _indexToken, _sizeDelta, _isLong); ITimelock(timelock).disableLeverage(_vault); return markPrice; } function _decreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver, uint256 _price) internal returns (uint256, uint256) { address _vault = vault; uint256 markPrice = _isLong ? IVault(_vault).getMinPrice(_indexToken) : IVault(_vault).getMaxPrice(_indexToken); if (_isLong) { require(markPrice >= _price, "BasePositionManager: mark price lower than limit"); } else { require(markPrice <= _price, "BasePositionManager: mark price higher than limit"); } address timelock = IVault(_vault).gov(); // should be called strictly before position is updated in Vault IShortsTracker(shortsTracker).updateGlobalShortData(_account, _collateralToken, _indexToken, _isLong, _sizeDelta, markPrice, false); ITimelock(timelock).enableLeverage(_vault); uint256 amountOut = IRouter(router).pluginDecreasePosition(_account, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, _receiver); ITimelock(timelock).disableLeverage(_vault); return (amountOut, markPrice); } function _swap(address[] memory _path, uint256 _minOut, address _receiver) internal returns (uint256) { if (_path.length == 2) { return _vaultSwap(_path[0], _path[1], _minOut, _receiver); } revert("BasePositionManager: invalid _path.length"); } function _vaultSwap(address _tokenIn, address _tokenOut, uint256 _minOut, address _receiver) internal returns (uint256) { uint256 amountOut = IVault(vault).swap(_tokenIn, _tokenOut, _receiver); require(amountOut >= _minOut, "BasePositionManager: insufficient amountOut"); return amountOut; } function _transferInETH() internal { if (msg.value != 0) { IWETH(weth).deposit{value: msg.value}(); } } function _transferInETH(uint _amount) internal { if (_amount != 0) { IWETH(weth).deposit{value: _amount}(); } } function _collectFees( address _account, address[] memory _path, uint256 _amountIn, address _indexToken, bool _isLong, uint256 _sizeDelta ) internal returns (uint256) { bool shouldDeductFee = _shouldDeductFee( _account, _path, _amountIn, _indexToken, _isLong, _sizeDelta ); if (shouldDeductFee) { uint256 afterFeeAmount = _amountIn * (BASIS_POINTS_DIVISOR - depositFee) / BASIS_POINTS_DIVISOR; uint256 feeAmount = _amountIn - afterFeeAmount; address feeToken = _path[_path.length - 1]; feeReserves[feeToken] = feeReserves[feeToken] + feeAmount; return afterFeeAmount; } return _amountIn; } function _shouldDeductFee( address _account, address[] memory _path, uint256 _amountIn, address _indexToken, bool _isLong, uint256 _sizeDelta ) internal view returns (bool) { // if the position is a short, do not charge a fee if (!_isLong) { return false; } // if the position size is not increasing, this is a collateral deposit if (_sizeDelta == 0) { return true; } address collateralToken = _path[_path.length - 1]; IVault _vault = IVault(vault); (uint256 size, uint256 collateral, , , , , , ) = _vault.getPosition(_account, collateralToken, _indexToken, _isLong); // if there is no existing position, do not charge a fee if (size == 0) { return false; } uint256 nextSize = size + _sizeDelta; uint256 collateralDelta = _vault.tokenToUsdMin(collateralToken, _amountIn); uint256 nextCollateral = collateral + collateralDelta; uint256 prevLeverage = size * BASIS_POINTS_DIVISOR / collateral; // allow for a maximum of a increasePositionBufferBps decrease since there might be some swap fees taken from the collateral uint256 nextLeverage = nextSize * (BASIS_POINTS_DIVISOR + increasePositionBufferBps) / nextCollateral; // deduct a fee if the leverage is decreased return nextLeverage < prevLeverage; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IBasePositionManager { function maxGlobalLongSizes(address _token) external view returns (uint256); function maxGlobalShortSizes(address _token) external view returns (uint256); function feeReserves(address _token) external returns (uint256); function withdrawFees(address _token, address _receiver) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; interface ICircuitBreaker { function pauseStartTime(address _token) external returns (uint); function pauseEndTime(address _token) external returns (uint); function maxLongToShortRatio(address _token) external returns (uint); function maxShortToLongRatio(address _token) external returns (uint); function oiRatioCheckThreshold(address _token) external returns (uint); function validateCircuitBreaker(address _indexToken, uint _sizeDelta, bool _isLong) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IOrderBook { function getSwapOrder(address _account, uint256 _orderIndex) external view returns ( address path0, address path1, address path2, uint256 amountIn, uint256 minOut, uint256 triggerRatio, bool triggerAboveThreshold, bool shouldUnwrap, uint256 executionFee ); function getIncreaseOrder(address _account, uint256 _orderIndex) external view returns ( address purchaseToken, uint256 purchaseTokenAmount, address collateralToken, address indexToken, uint256 sizeDelta, bool isLong, uint256 triggerPrice, bool triggerAboveThreshold, uint256 executionFee ); function getDecreaseOrder(address _account, uint256 _orderIndex) external view returns ( address collateralToken, uint256 collateralDelta, address indexToken, uint256 sizeDelta, bool isLong, uint256 triggerPrice, bool triggerAboveThreshold, uint256 executionFee ); function executeSwapOrder(address, uint256, address payable) external; function executeDecreaseOrder(address, uint256, address payable) external; function executeIncreaseOrder(address, uint256, address payable) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IRouter { function addPlugin(address _plugin) external; function pluginTransfer(address _token, address _account, address _receiver, uint256 _amount) external; function pluginIncreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong) external; function pluginDecreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver) external returns (uint256); function swap(address[] memory _path, uint256 _amountIn, uint256 _minOut, address _receiver) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IShortsTracker { function isGlobalShortDataReady() external view returns (bool); function globalShortAveragePrices(address _token) external view returns (uint256); function getNextGlobalShortData( address _account, address _collateralToken, address _indexToken, uint256 _nextPrice, uint256 _sizeDelta, bool _isIncrease ) external view returns (uint256, uint256); function updateGlobalShortData( address _account, address _collateralToken, address _indexToken, bool _isLong, uint256 _sizeDelta, uint256 _markPrice, bool _isIncrease ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IVaultUtils.sol"; import "../../referrals/interfaces/IReferralManager.sol"; interface IVault { function isInitialized() external view returns (bool); function isSwapEnabled() external view returns (bool); function isLeverageEnabled() external view returns (bool); function setReferralManager(IReferralManager _referralManager) external; function setVaultUtils(IVaultUtils _vaultUtils) external; function setError(uint256 _errorCode, string calldata _error) external; function router() external view returns (address); function usdg() external view returns (address); function gov() external view returns (address); function maxLeverage() external view returns (uint256); function minProfitTime() external view returns (uint256); function hasDynamicFees() external view returns (bool); function fundingInterval() external view returns (uint256); function totalTokenWeights() external view returns (uint256); function getTargetUsdgAmount(address _token) external view returns (uint256); function inManagerMode() external view returns (bool); function inPrivateLiquidationMode() external view returns (bool); function maxGasPrice() external view returns (uint256); function approvedRouters(address _account, address _router) external view returns (bool); function isLiquidator(address _account) external view returns (bool); function isManager(address _account) external view returns (bool); function minProfitBasisPoints(address _token) external view returns (uint256); function tokenBalances(address _token) external view returns (uint256); function lastFundingTimes(address _token) external view returns (uint256); function setMaxLeverage(uint256 _maxLeverage) external; function setInManagerMode(bool _inManagerMode) external; function setManager(address _manager, bool _isManager) external; function setIsSwapEnabled(bool _isSwapEnabled) external; function setIsLeverageEnabled(bool _isLeverageEnabled) external; function setMaxGasPrice(uint256 _maxGasPrice) external; function setUsdgAmount(address _token, uint256 _amount) external; function setBufferAmount(address _token, uint256 _amount) external; function setMaxGlobalShortSize(address _token, uint256 _amount) external; function setInPrivateLiquidationMode(bool _inPrivateLiquidationMode) external; function setLiquidator(address _liquidator, bool _isActive) external; function setFundingRate(uint256 _fundingInterval, uint256 _fundingRateFactor, uint256 _stableFundingRateFactor) external; function setFees( uint256 _taxBasisPoints, uint256 _stableTaxBasisPoints, uint256 _mintBurnFeeBasisPoints, uint256 _swapFeeBasisPoints, uint256 _stableSwapFeeBasisPoints, uint256 _marginFeeBasisPoints, uint256 _dynLiquidationFeeBasisPoints, uint256 _fixedLiquidationFeeUsd, uint256 _minProfitTime, bool _hasDynamicFees ) external; function setTokenConfig( address _token, uint256 _tokenDecimals, uint256 _redemptionBps, uint256 _minProfitBps, uint256 _maxUsdgAmount, bool _isStable, bool _isShortable ) external; function setPriceFeed(address _priceFeed) external; function setFeeAdmin(address _feeAdmin) external; function withdrawFees(address _token, address _receiver) external returns (uint256); function directPoolDeposit(address _token) external; function buyUSDG(address _token, address _receiver) external returns (uint256); function sellUSDG(address _token, address _receiver) external returns (uint256); function swap(address _tokenIn, address _tokenOut, address _receiver) external returns (uint256); function increasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong) external; function decreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver) external returns (uint256); function validateLiquidation(address _account, address _collateralToken, address _indexToken, bool _isLong, bool _raise) external view returns (uint256, uint256); function liquidatePosition(address _account, address _collateralToken, address _indexToken, bool _isLong, address _feeReceiver) external; function tokenToUsdMin(address _token, uint256 _tokenAmount) external view returns (uint256); function priceFeed() external view returns (address); function fundingRateFactor() external view returns (uint256); function stableFundingRateFactor() external view returns (uint256); function cumulativeFundingRates(address _token) external view returns (uint256); function getNextFundingRate(address _token) external view returns (uint256); function getFeeBasisPoints(address _token, uint256 _usdgDelta, uint256 _feeBasisPoints, uint256 _taxBasisPoints, bool _increment) external view returns (uint256); function fixedLiquidationFeeUsd() external view returns (uint256); function dynLiquidationFeeBasisPoints() external view returns (uint256); function taxBasisPoints() external view returns (uint256); function stableTaxBasisPoints() external view returns (uint256); function mintBurnFeeBasisPoints() external view returns (uint256); function swapFeeBasisPoints() external view returns (uint256); function stableSwapFeeBasisPoints() external view returns (uint256); function marginFeeBasisPoints() external view returns (uint256); function whitelistedTokens(uint256 _index) external view returns (address); function isWhitelistedToken(address _token) external view returns (bool); function whitelistedTokenCount() external view returns (uint256); function stableTokens(address _token) external view returns (bool); function shortableTokens(address _token) external view returns (bool); function feeReserves(address _token) external view returns (uint256); function globalShortSizes(address _token) external view returns (uint256); function globalShortAveragePrices(address _token) external view returns (uint256); function maxGlobalShortSizes(address _token) external view returns (uint256); function tokenDecimals(address _token) external view returns (uint256); function tokenWeights(address _token) external view returns (uint256); function guaranteedUsd(address _token) external view returns (uint256); function poolAmounts(address _token) external view returns (uint256); function bufferAmounts(address _token) external view returns (uint256); function reservedAmounts(address _token) external view returns (uint256); function usdgAmounts(address _token) external view returns (uint256); function maxUsdgAmounts(address _token) external view returns (uint256); function getRedemptionAmount(address _token, uint256 _usdgAmount) external view returns (uint256); function getMaxPrice(address _token) external view returns (uint256); function getMinPrice(address _token) external view returns (uint256); function getDelta(address _indexToken, uint256 _size, uint256 _averagePrice, bool _isLong, uint256 _lastIncreasedTime) external view returns (bool, uint256); function getPosition(address _account, address _collateralToken, address _indexToken, bool _isLong) external view returns (uint256, uint256, uint256, uint256, uint256, uint256, bool, uint256); function transferOutTokens(address[] calldata _tokens, uint[] calldata _amounts, address _receiver) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IVaultUtils { function updateCumulativeFundingRate(address _collateralToken, address _indexToken) external returns (bool); function validateIncreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong) external view; function validateDecreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver) external view; function validateLiquidation(address _account, address _collateralToken, address _indexToken, bool _isLong, bool _raise) external view returns (uint256, uint256); function validateLiquidationForBot(address _account, address _collateralToken, address _indexToken, bool _isLong, bool _raise) external view returns (uint256, uint256); function getLiquidationFee(uint256 remainingCollateralUsd) external view returns (uint256); function getEntryFundingRate(address _collateralToken, address _indexToken, bool _isLong) external view returns (uint256); function getPositionFee(uint256 _sizeDelta) external view returns (uint256); function getPositionFeeForBot(uint256 _sizeDelta) external view returns (uint256); function getFundingFee(address _account, address _collateralToken, address _indexToken, bool _isLong, uint256 _size, uint256 _entryFundingRate) external view returns (uint256); function getBuyUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) external view returns (uint256); function getSellUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) external view returns (uint256); function getSwapFeeBasisPoints(address _tokenIn, address _tokenOut, uint256 _usdgAmount) external view returns (uint256); function getFeeBasisPoints(address _token, uint256 _usdgDelta, uint256 _feeBasisPoints, uint256 _taxBasisPoints, bool _increment) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ITimelock { function setAdmin(address _admin) external; function enableLeverage(address _vault) external; function disableLeverage(address _vault) external; function setIsLeverageEnabled(address _vault, bool _isLeverageEnabled) external; function signalSetGov(address _target, address _gov) external; function marginFeeBasisPoints() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; struct ReferralPositionFee { uint feeForPoolAmount; uint feeForPoolUsd; uint rebateAmount; uint rebateUsd; } struct ReferralInfo { bytes32 code; address affiliate; bool isActive; Tier tier; } struct Tier { uint256 id; uint256 rebate; uint256 discount; } interface IReferralManager { function codeOwners(bytes32 _code) external view returns (address); function getReferralInfoByTrader(address _trader) external view returns (ReferralInfo memory); function getReferralInfoByCode(bytes32 _code) external view returns (ReferralInfo memory); function getReferralInfoByAffiliate(address _affiliate) external view returns (ReferralInfo memory); function setTraderReferralCode(address _trader, bytes32 _code) external; function setTraderReferralCodeByUser(bytes32 _code) external; function setTier(uint256 _tierId, uint256 _rebate, uint256 _discount) external; function setAffiliateTier(address _referrer, uint256 _tierId) external; function getAffiliateReward(address _affiliate) external view returns (address[] memory, uint256[] memory); function claimAffiliateReward() external; function discountPositionFee( address _trader, address _token, uint256 _tokenPrice, uint256 _positionFeeUsd, uint256 _sizeDelta ) external returns (ReferralPositionFee memory fee); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH is IERC20 { function deposit() external payable; function withdraw(uint) external; }
{ "optimizer": { "enabled": true, "runs": 1 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"SetAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"depositFee","type":"uint256"}],"name":"SetDepositFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeAdmin","type":"address"}],"name":"SetFeeAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"inLegacyMode","type":"bool"}],"name":"SetInLegacyMode","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"increasePositionBufferBps","type":"uint256"}],"name":"SetIncreasePositionBufferBps","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SetLiquidator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"longSizes","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"shortSizes","type":"uint256[]"}],"name":"SetMaxGlobalSizes","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SetOrderKeeper","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SetPartner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"referralManager","type":"address"}],"name":"SetReferralManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"shouldValidateIncreaseOrder","type":"bool"}],"name":"SetShouldValidateIncreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gov","type":"address"}],"name":"UpdateGov","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawFees","type":"event"},{"inputs":[],"name":"BASIS_POINTS_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"circuitBreaker","outputs":[{"internalType":"contract ICircuitBreaker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"decreasePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"decreasePositionAndSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"decreasePositionAndSwapETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"decreasePositionETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeDecreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeIncreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeSwapOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"inLegacyMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"increasePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"increasePositionBufferBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"increasePositionETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_vault","type":"address"},{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_shortsTracker","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"uint256","name":"_depositFee","type":"uint256"},{"internalType":"address","name":"_orderBook","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isLiquidator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isOrderKeeper","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isPartner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_feeReceiver","type":"address"}],"name":"liquidatePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxGlobalLongSizes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxGlobalShortSizes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"orderBook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralStorage","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sendValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICircuitBreaker","name":"_circuitBreaker","type":"address"}],"name":"setCircuitBreaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositFee","type":"uint256"}],"name":"setDepositFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeAdmin","type":"address"}],"name":"setFeeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_inLegacyMode","type":"bool"}],"name":"setInLegacyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_increasePositionBufferBps","type":"uint256"}],"name":"setIncreasePositionBufferBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setLiquidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_longSizes","type":"uint256[]"},{"internalType":"uint256[]","name":"_shortSizes","type":"uint256[]"}],"name":"setMaxGlobalSizes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setOrderKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setPartner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referralManager","type":"address"}],"name":"setReferralManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldValidateIncreaseOrder","type":"bool"}],"name":"setShouldValidateIncreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shortsTracker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"shouldValidateIncreaseOrder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"withdrawFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
608060405234801561001057600080fd5b50614a58806100206000396000f3fe6080604052600436106102265760003560e01c80626cc35e1461029d57806307c7edc3146102d35780631045c74e146102f357806311d9444a1461032e578063126082cf1461034e57806312d43a511461036457806316efd941146103845780631b904359146103a45780631ce9cb8f146103c45780631e261538146103f157806321acf65914610411578063233bfe3b1461043157806324a084df146104515780633039e37f1461047157806330a402c0146104915780633833f5f5146104b15780633fc8cef3146104f1578063430ed37c146105115780634453a374146105315780634584bd4b14610551578063490ae21014610572578063529a356f1461059257806353c425c1146105c25780635fc8500e146105e2578063657bc5d01461060257806367a52793146106225780636eb2d03114610638578063704b6c0214610658578063776af5ba1461067857806382beee89146106985780638c0f9aac146106b857806390205d8c146106e85780639698d25a1461070857806398d1e03a146107355780639c95332f1461074b578063b32755de1461076b578063b7ddc9921461077e578063c5f3a4c41461079e578063cfad57a2146107be578063d38ab519146107de578063d4ca83f9146107fe578063de2ea9481461081f578063e1f21c671461083f578063ef12c67e1461085f578063f25552781461087f578063f851a4401461089f578063f887ea40146108bf578063fbfa77cf146108df57600080fd5b36610298576039546001600160a01b031633146102965760405162461bcd60e51b815260206004820152602360248201527f42617365506f736974696f6e4d616e616765723a20696e76616c69642073656e6044820152623232b960e91b60648201526084015b60405180910390fd5b005b600080fd5b3480156102a957600080fd5b50603c546102bd906001600160a01b031681565b6040516102ca9190613d53565b60405180910390f35b3480156102df57600080fd5b506102966102ee366004613d7f565b6108ff565b3480156102ff57600080fd5b5061032061030e366004613dc1565b603e6020526000908152604090205481565b6040519081526020016102ca565b34801561033a57600080fd5b50610296610349366004613d7f565b610999565b34801561035a57600080fd5b5061032061271081565b34801561037057600080fd5b506033546102bd906001600160a01b031681565b34801561039057600080fd5b506044546102bd906001600160a01b031681565b3480156103b057600080fd5b506102966103bf366004613dec565b610d49565b3480156103d057600080fd5b506103206103df366004613dc1565b603d6020526000908152604090205481565b3480156103fd57600080fd5b5061029661040c366004613e09565b610dc9565b34801561041d57600080fd5b5061029661042c366004613e09565b610e53565b34801561043d57600080fd5b5061029661044c366004613e42565b610ee0565b34801561045d57600080fd5b5061029661046c366004613e5b565b610f3f565b34801561047d57600080fd5b5061029661048c366004613f64565b610f80565b34801561049d57600080fd5b506035546102bd906001600160a01b031681565b3480156104bd57600080fd5b506104e16104cc366004613dc1565b60416020526000908152604090205460ff1681565b60405190151581526020016102ca565b3480156104fd57600080fd5b506039546102bd906001600160a01b031681565b34801561051d57600080fd5b5061029661052c366004613fff565b6110f3565b34801561053d57600080fd5b5061029661054c366004613e09565b6111d6565b34801561055d57600080fd5b506040546104e190600160a81b900460ff1681565b34801561057e57600080fd5b5061029661058d366004613e42565b611258565b34801561059e57600080fd5b506104e16105ad366004613dc1565b60436020526000908152604090205460ff1681565b3480156105ce57600080fd5b506102966105dd36600461407a565b6112b7565b3480156105ee57600080fd5b506102966105fd366004613f64565b6113fb565b34801561060e57600080fd5b506037546102bd906001600160a01b031681565b34801561062e57600080fd5b50610320603a5481565b34801561064457600080fd5b50610296610653366004613dc1565b6114bb565b34801561066457600080fd5b50610296610673366004613dc1565b611530565b34801561068457600080fd5b506040546102bd906001600160a01b031681565b3480156106a457600080fd5b506102966106b3366004613dc1565b611605565b3480156106c457600080fd5b506104e16106d3366004613dc1565b60426020526000908152604090205460ff1681565b3480156106f457600080fd5b50610296610703366004613fff565b611651565b34801561071457600080fd5b50610320610723366004613dc1565b603f6020526000908152604090205481565b34801561074157600080fd5b50610320603b5481565b34801561075757600080fd5b50610296610766366004613dec565b6116b7565b6102966107793660046140f3565b61172c565b34801561078a57600080fd5b50610296610799366004614172565b6118cd565b3480156107aa57600080fd5b506102966107b9366004613dc1565b611af5565b3480156107ca57600080fd5b506102966107d9366004613dc1565b611b6a565b3480156107ea57600080fd5b506102966107f9366004613d7f565b611c31565b34801561080a57600080fd5b506040546104e190600160a01b900460ff1681565b34801561082b57600080fd5b5061029661083a3660046141e5565b611fc3565b34801561084b57600080fd5b5061029661085a366004614256565b612395565b34801561086b57600080fd5b5061029661087a3660046142f2565b612436565b34801561088b57600080fd5b5061029661089a366004614379565b612558565b3480156108ab57600080fd5b506034546102bd906001600160a01b031681565b3480156108cb57600080fd5b506038546102bd906001600160a01b031681565b3480156108eb57600080fd5b506036546102bd906001600160a01b031681565b3360009081526041602052604090205460ff1661092e5760405162461bcd60e51b815260040161028d906143a7565b6040805490516307c7edc360e01b81526001600160a01b03909116906307c7edc390610962908690869086906004016143db565b600060405180830381600087803b15801561097c57600080fd5b505af1158015610990573d6000803e3d6000fd5b50505050505050565b3360009081526041602052604090205460ff166109c85760405162461bcd60e51b815260040161028d906143a7565b603654604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a51916004808201926020929091908290030181865afa158015610a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3b91906143fe565b604080549051630130197760e11b81529192506000918291829182916001600160a01b03169063026032ee90610a77908c908c9060040161441b565b61010060405180830381865afa158015610a95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab99190614434565b505050945094509450509350600081610b3e57604051637092736960e11b81526001600160a01b0388169063e124e6d290610af8908790600401613d53565b602060405180830381865afa158015610b15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3991906144bc565b610bab565b6040516340d3096b60e11b81526001600160a01b038816906381a612d690610b6a908790600401613d53565b602060405180830381865afa158015610b87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bab91906144bc565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90610be9908d908990899088908a9089906000906004016144d5565b600060405180830381600087803b158015610c0357600080fd5b505af1158015610c17573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0389169250636d63c1d09150610c47908a90600401613d53565b600060405180830381600087803b158015610c6157600080fd5b505af1158015610c75573d6000803e3d6000fd5b50506040805490516308eca22560e11b81526001600160a01b0390911692506311d9444a9150610cad908d908d908d906004016143db565b600060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b505060405163d3c87bbb60e01b81526001600160a01b038916925063d3c87bbb9150610d0b908a90600401613d53565b600060405180830381600087803b158015610d2557600080fd5b505af1158015610d39573d6000803e3d6000fd5b5050505050505050505050505050565b6034546001600160a01b03163314610d735760405162461bcd60e51b815260040161028d90614516565b60408054821515600160a81b0260ff60a81b19909116178155517fa956222e37fe025ff51e5440ac729a9bd417ff91e485e14dcffa2c0ba8894f4090610dbe90831515815260200190565b60405180910390a150565b6034546001600160a01b03163314610df35760405162461bcd60e51b815260040161028d90614516565b6001600160a01b038216600081815260416020908152604091829020805460ff191685151590811790915591519182527f1d5bc0255b943d6a5b5279e8a55d74d620baccbceecb25e87a3558f14c4c118e91015b60405180910390a25050565b6034546001600160a01b03163314610e7d5760405162461bcd60e51b815260040161028d90614516565b6001600160a01b038216600081815260426020908152604091829020805460ff19168515159081179091558251938452908301527fa4e46c70ff429a91de7d1716d736e877c7cca1c22ac850b23d242530dd95e474910160405180910390a15050565b6034546001600160a01b03163314610f0a5760405162461bcd60e51b815260040161028d90614516565b603b8190556040518181527f21167d0d4661af93817ebce920f18986eed3d75d5e1c03f2aed05efcbafbc45290602001610dbe565b6033546001600160a01b03163314610f695760405162461bcd60e51b815260040161028d9061454d565b610f7c6001600160a01b03831682612679565b5050565b610f88612794565b3360009081526042602052604090205460ff1680610faf5750604054600160a01b900460ff165b610fcb5760405162461bcd60e51b815260040161028d906143a7565b8751600214610fec5760405162461bcd60e51b815260040161028d9061457c565b60395488516001600160a01b0390911690899061100b906001906145d7565b8151811061101b5761101b6145f0565b60200260200101516001600160a01b0316146110495760405162461bcd60e51b815260040161028d90614606565b6000611075338a600081518110611062576110626145f0565b60200260200101518a8a8a8a308a6127ed565b5090506110c5603660009054906101000a90046001600160a01b0316828b6000815181106110a5576110a56145f0565b60200260200101516001600160a01b0316612bb69092919063ffffffff16565b60006110d28a8430612c0c565b90506110de8186612cbf565b50506110e960018055565b5050505050505050565b6110fb612794565b3360009081526042602052604090205460ff16806111225750604054600160a01b900460ff165b61113e5760405162461bcd60e51b815260040161028d906143a7565b6039546001600160a01b038881169116146111ad5760405162461bcd60e51b815260206004820152602960248201527f506f736974696f6e4d616e616765723a20696e76616c6964205f636f6c6c617460448201526832b930b62a37b5b2b760b91b606482015260840161028d565b60006111bf33898989898930896127ed565b5090506111cc8184612cbf565b5061099060018055565b6034546001600160a01b031633146112005760405162461bcd60e51b815260040161028d90614516565b6001600160a01b038216600081815260436020908152604091829020805460ff191685151590811790915591519182527f8c0d56805c3b43d441481229dc64bee168253ffe4305f37ab7cfe63b1c4268c69101610e47565b6034546001600160a01b031633146112825760405162461bcd60e51b815260040161028d90614516565b603a8190556040518181527f974fd3c1fcb4653dfc4fb740c4c692cd212d55c28f163f310128cb64d830067590602001610dbe565b600054610100900460ff16158080156112d75750600054600160ff909116105b806112f857506112e630612d4c565b1580156112f8575060005460ff166001145b61135b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161028d565b6000805460ff19166001179055801561137e576000805461ff0019166101001790555b61138b8787878787612d5b565b60408054600161ff0160a01b0319166001600160a01b03841617600160a81b1790558015610990576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b611403612794565b3360009081526042602052604090205460ff168061142a5750604054600160a01b900460ff165b6114465760405162461bcd60e51b815260040161028d906143a7565b87516002146114675760405162461bcd60e51b815260040161028d9061457c565b6000611480338a600081518110611062576110626145f0565b5090506114b0603660009054906101000a90046001600160a01b0316828b6000815181106110a5576110a56145f0565b6110de898386612c0c565b6034546001600160a01b031633146114e55760405162461bcd60e51b815260040161028d90614516565b603580546001600160a01b0319166001600160a01b0383161790556040517f26cb770c9a24026a0c99d6be6fa7fb963470f03731f629156bbdf1baecae595890610dbe908390613d53565b6033546001600160a01b0316331461155a5760405162461bcd60e51b815260040161028d9061454d565b6001600160a01b0381166115ba5760405162461bcd60e51b815260206004820152602160248201527f42617365506f736974696f6e4d616e616765723a207a65726f206164647265736044820152607360f81b606482015260840161028d565b603480546001600160a01b0319166001600160a01b0383161790556040517f5a272403b402d892977df56625f4164ccaf70ca3863991c43ecfe76a6905b0a190610dbe908390613d53565b6034546001600160a01b0316331461162f5760405162461bcd60e51b815260040161028d90614516565b604480546001600160a01b0319166001600160a01b0392909216919091179055565b611659612794565b3360009081526042602052604090205460ff16806116805750604054600160a01b900460ff165b61169c5760405162461bcd60e51b815260040161028d906143a7565b6116ac33888888888888886127ed565b505061099060018055565b6034546001600160a01b031633146116e15760405162461bcd60e51b815260040161028d90614516565b60408054821515600160a01b0260ff60a01b19909116178155517feac6b3611e79ff0d8ea5daa8439f6b1ab7eea4ebf95f1dd360417f712c3fc30490610dbe90831515815260200190565b611734612794565b3360009081526042602052604090205460ff168061175b5750604054600160a01b900460ff165b6117775760405162461bcd60e51b815260040161028d906143a7565b855160011480611788575085516002145b6117a45760405162461bcd60e51b815260040161028d9061457c565b60395486516001600160a01b039091169087906000906117c6576117c66145f0565b60200260200101516001600160a01b0316146117f45760405162461bcd60e51b815260040161028d90614606565b341561188757611802612df6565b85513490600110156118395760365460395461182b916001600160a01b03918216911634612bb6565b611836878630612c0c565b90505b60006118493389848a888a612e62565b9050611884603660009054906101000a90046001600160a01b0316828a60018c5161187491906145d7565b815181106110a5576110a56145f0565b50505b6118bb33876001895161189a91906145d7565b815181106118aa576118aa6145f0565b602002602001015187868686612f43565b506118c560018055565b505050505050565b6118d5612794565b3360009081526042602052604090205460ff16806118fc5750604054600160a01b900460ff165b6119185760405162461bcd60e51b815260040161028d906143a7565b865160011480611929575086516002145b6119455760405162461bcd60e51b815260040161028d9061457c565b8415611ac15786516001036119dd5760385487516001600160a01b0390911690631b82787890899060009061197c5761197c6145f0565b60200260200101513330896040518563ffffffff1660e01b81526004016119a6949392919061463d565b600060405180830381600087803b1580156119c057600080fd5b505af11580156119d4573d6000803e3d6000fd5b50505050611a84565b60385487516001600160a01b0390911690631b827878908990600090611a0557611a056145f0565b602002602001015133603660009054906101000a90046001600160a01b0316896040518563ffffffff1660e01b8152600401611a44949392919061463d565b600060405180830381600087803b158015611a5e57600080fd5b505af1158015611a72573d6000803e3d6000fd5b50505050611a81878530612c0c565b94505b6000611a943389888a8789612e62565b9050611abf603660009054906101000a90046001600160a01b0316828a60018c5161187491906145d7565b505b6111cc338860018a51611ad491906145d7565b81518110611ae457611ae46145f0565b602002602001015188868686612f43565b6034546001600160a01b03163314611b1f5760405162461bcd60e51b815260040161028d90614516565b603c80546001600160a01b0319166001600160a01b0383161790556040517f57202bce87a87010e83825477a341d777f701216d3e2a3b4642c72d9e8a9319890610dbe908390613d53565b6033546001600160a01b03163314611b945760405162461bcd60e51b815260040161028d9061454d565b6001600160a01b038116611be55760405162461bcd60e51b8152602060048201526018602482015277476f7665726e61626c653a207a65726f206164647265737360401b604482015260640161028d565b603380546001600160a01b0319166001600160a01b0383169081179091556040517fe24c39186e9137521953beaa8446e71f55b8f12296984f9d4273ceb1af728d9091610dbe91613d53565b3360009081526041602052604090205460ff16611c605760405162461bcd60e51b815260040161028d906143a7565b611c6a83836132ab565b603654604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a51916004808201926020929091908290030181865afa158015611cb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cdd91906143fe565b60408054905163d3bab1d160e01b81529192506000918291829182916001600160a01b03169063d3bab1d190611d19908c908c9060040161441b565b61012060405180830381865afa158015611d37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5b9190614667565b505060448054604051637ebea3e360e01b81526001600160a01b0380881660048301526024820187905285151593820193909352969c50949a5092985090965050169250637ebea3e39150606401600060405180830381600087803b158015611dc357600080fd5b505af1158015611dd7573d6000803e3d6000fd5b50505050600081611e54576040516340d3096b60e11b81526001600160a01b038816906381a612d690611e0e908790600401613d53565b602060405180830381865afa158015611e2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4f91906144bc565b611ec1565b604051637092736960e11b81526001600160a01b0388169063e124e6d290611e80908790600401613d53565b602060405180830381865afa158015611e9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec191906144bc565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90611eff908d908990899088908a9089906001906004016144d5565b600060405180830381600087803b158015611f1957600080fd5b505af1158015611f2d573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0389169250636d63c1d09150611f5d908a90600401613d53565b600060405180830381600087803b158015611f7757600080fd5b505af1158015611f8b573d6000803e3d6000fd5b505060408054905163d38ab51960e01b81526001600160a01b03909116925063d38ab5199150610cad908d908d908d906004016143db565b611fcb612794565b3360009081526043602052604090205460ff16611ffa5760405162461bcd60e51b815260040161028d906143a7565b603654604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a51916004808201926020929091908290030181865afa158015612049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206d91906143fe565b603654604051634a3f088d60e01b81529192506000916001600160a01b0390911690634a3f088d906120a9908b908b908b908b90600401614703565b61010060405180830381865afa1580156120c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120eb919061472d565b50505050505050905060008561216d57604051637092736960e11b81526001600160a01b0385169063e124e6d290612127908a90600401613d53565b602060405180830381865afa158015612144573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216891906144bc565b6121da565b6040516340d3096b60e11b81526001600160a01b038516906381a612d690612199908a90600401613d53565b602060405180830381865afa1580156121b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121da91906144bc565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90612218908c908c908c908c90899089906000906004016144d5565b600060405180830381600087803b15801561223257600080fd5b505af1158015612246573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0386169250636d63c1d09150612276908790600401613d53565b600060405180830381600087803b15801561229057600080fd5b505af11580156122a4573d6000803e3d6000fd5b5050604051631bc5d52960e31b81526001600160a01b038c811660048301528b811660248301528a81166044830152891515606483015288811660848301528716925063de2ea948915060a401600060405180830381600087803b15801561230b57600080fd5b505af115801561231f573d6000803e3d6000fd5b505060405163d3c87bbb60e01b81526001600160a01b038616925063d3c87bbb915061234f908790600401613d53565b600060405180830381600087803b15801561236957600080fd5b505af115801561237d573d6000803e3d6000fd5b505050505050505061238e60018055565b5050505050565b6033546001600160a01b031633146123bf5760405162461bcd60e51b815260040161028d9061454d565b60405163095ea7b360e01b81526001600160a01b0384169063095ea7b3906123ed908590859060040161441b565b6020604051808303816000875af115801561240c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612430919061477f565b50505050565b6034546001600160a01b031633146124605760405162461bcd60e51b815260040161028d90614516565b60005b8351811015612517576000848281518110612480576124806145f0565b6020026020010151905083828151811061249c5761249c6145f0565b6020026020010151603e6000836001600160a01b03166001600160a01b03168152602001908152602001600020819055508282815181106124df576124df6145f0565b6020908102919091018101516001600160a01b039092166000908152603f90915260409020558061250f8161479c565b915050612463565b507fae32d569b058895b9620d6552b09aaffedc9a6f396be4d595a224ad09f8b213983838360405161254b939291906147f0565b60405180910390a1505050565b6035546001600160a01b031633148061257b57506034546001600160a01b031633145b6125e75760405162461bcd60e51b815260206004820152603760248201527f42617365506f736974696f6e4d616e616765723a2066656541646d696e206f726044820152760818591b5a5b881c9bdb19481a5cc81c995c5d5a5c9959604a1b606482015260840161028d565b6001600160a01b0382166000908152603d60205260408120549081900361260d57505050565b6001600160a01b0383166000818152603d6020526040812055612631908383612bb6565b604080516001600160a01b038086168252841660208201529081018290527f4f1b51dd7a2fcb861aa2670f668be66835c4ee12b4bbbf037e4d0018f39819e49060600161254b565b804710156126c95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161028d565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612716576040519150601f19603f3d011682016040523d82523d6000602084013e61271b565b606091505b505090508061278f5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b606482015260840161028d565b505050565b6002600154036127e65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161028d565b6002600155565b60365460009081906001600160a01b0316818661287657604051637092736960e11b81526001600160a01b0383169063e124e6d290612830908d90600401613d53565b602060405180830381865afa15801561284d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061287191906144bc565b6128e3565b6040516340d3096b60e11b81526001600160a01b038316906381a612d6906128a2908d90600401613d53565b602060405180830381865afa1580156128bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e391906144bc565b90508615612910578481101561290b5760405162461bcd60e51b815260040161028d9061485b565b612930565b848111156129305760405162461bcd60e51b815260040161028d90614899565b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b8152600401602060405180830381865afa158015612970573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299491906143fe565b9050603760009054906101000a90046001600160a01b03166001600160a01b031663f3238cec8e8e8e8c8e8860006040518863ffffffff1660e01b81526004016129e497969594939291906144d5565b600060405180830381600087803b1580156129fe57600080fd5b505af1158015612a12573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0384169250636d63c1d09150612a42908690600401613d53565b600060405180830381600087803b158015612a5c57600080fd5b505af1158015612a70573d6000803e3d6000fd5b505050506000603860009054906101000a90046001600160a01b03166001600160a01b0316632662166b8f8f8f8f8f8f8f6040518863ffffffff1660e01b8152600401612afd97969594939291906001600160a01b0397881681529587166020870152938616604086015260608501929092526080840152151560a083015290911660c082015260e00190565b6020604051808303816000875af1158015612b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4091906144bc565b60405163d3c87bbb60e01b81529091506001600160a01b0383169063d3c87bbb90612b6f908790600401613d53565b600060405180830381600087803b158015612b8957600080fd5b505af1158015612b9d573d6000803e3d6000fd5b5092975093955050505050509850989650505050505050565b61278f8363a9059cbb60e01b8484604051602401612bd592919061441b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526135a3565b60008351600203612c5e57612c5784600081518110612c2d57612c2d6145f0565b602002602001015185600181518110612c4857612c486145f0565b60200260200101518585613675565b9050612cb8565b60405162461bcd60e51b815260206004820152602960248201527f42617365506f736974696f6e4d616e616765723a20696e76616c6964205f70616044820152680e8d05cd8cadccee8d60bb1b606482015260840161028d565b9392505050565b603954604051632e1a7d4d60e01b8152600481018490526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015612d0557600080fd5b505af1158015612d19573d6000803e3d6000fd5b50506040516001600160a01b038416925084156108fc02915084906000818181858888f150505050505050565b60018055565b6001600160a01b03163b151590565b600054610100900460ff16612d825760405162461bcd60e51b815260040161028d906148d8565b612d8a61376a565b612d926137a5565b603680546001600160a01b03199081166001600160a01b03978816179091556038805482169587169590951790945560398054851692861692909217909155603a5560378054831691909316179091556064603b5560348054339216919091179055565b3415612e6057603960009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015612e4c57600080fd5b505af115801561238e573d6000803e3d6000fd5b565b600080612e738888888888886137d4565b90508015612f34576000612710603a54612710612e9091906145d7565b612e9a9089614923565b612ea4919061493a565b90506000612eb282896145d7565b905060008960018b51612ec591906145d7565b81518110612ed557612ed56145f0565b6020026020010151905081603d6000836001600160a01b03166001600160a01b0316815260200190815260200160002054612f10919061495c565b6001600160a01b039091166000908152603d6020526040902055509150612f399050565b859150505b9695505050505050565b6036546000906001600160a01b03168184612fca576040516340d3096b60e11b81526001600160a01b038316906381a612d690612f84908a90600401613d53565b602060405180830381865afa158015612fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc591906144bc565b613037565b604051637092736960e11b81526001600160a01b0383169063e124e6d290612ff6908a90600401613d53565b602060405180830381865afa158015613013573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303791906144bc565b90508415613064578381111561305f5760405162461bcd60e51b815260040161028d90614899565b613084565b838110156130845760405162461bcd60e51b815260040161028d9061485b565b61308f8786886139a6565b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f391906143fe565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90613131908d908d908d908c908e908a906001906004016144d5565b600060405180830381600087803b15801561314b57600080fd5b505af115801561315f573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0384169250636d63c1d0915061318f908690600401613d53565b600060405180830381600087803b1580156131a957600080fd5b505af11580156131bd573d6000803e3d6000fd5b5050603854604051630f8ee8bb60e11b81526001600160a01b038e811660048301528d811660248301528c81166044830152606482018c90528a151560848301529091169250631f1dd176915060a401600060405180830381600087803b15801561322757600080fd5b505af115801561323b573d6000803e3d6000fd5b505060405163d3c87bbb60e01b81526001600160a01b038416925063d3c87bbb915061326b908690600401613d53565b600060405180830381600087803b15801561328557600080fd5b505af1158015613299573d6000803e3d6000fd5b50939c9b505050505050505050505050565b60408054905163d3bab1d160e01b8152600091829182918291829182916001600160a01b039091169063d3bab1d1906132ea908b908b9060040161441b565b61012060405180830381865afa158015613308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332c9190614667565b5050509550955095509550955095506133468382846139a6565b604054600160a81b900460ff16613361575050505050505050565b80613370575050505050505050565b600082116133c05760405162461bcd60e51b815260206004820152601d60248201527f506f736974696f6e4d616e616765723a206c6f6e67206465706f736974000000604482015260640161028d565b603654604051634a3f088d60e01b81526001600160a01b039091169060009081908390634a3f088d906133fd908e908b908b908a90600401614703565b61010060405180830381865afa15801561341b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343f919061472d565b505050505050915091508160000361345e575050505050505050505050565b600061346a868461495c565b90506000846001600160a01b0316630a48d5a98c8c6040518363ffffffff1660e01b815260040161349c92919061441b565b602060405180830381865afa1580156134b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134dd91906144bc565b905060006134eb828561495c565b90506000846134fc61271088614923565b613506919061493a565b9050600082603b5461271061351b919061495c565b6135259087614923565b61352f919061493a565b9050818110156135915760405162461bcd60e51b815260206004820152602760248201527f506f736974696f6e4d616e616765723a206c6f6e67206c6576657261676520646044820152666563726561736560c81b606482015260840161028d565b50505050505050505050505050505050565b60006135f8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ba69092919063ffffffff16565b80519091501561278f5780806020019051810190613616919061477f565b61278f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161028d565b603654604051634998b10960e11b81526001600160a01b0386811660048301528581166024830152838116604483015260009283929116906393316212906064016020604051808303816000875af11580156136d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136f991906144bc565b90508381101561375f5760405162461bcd60e51b815260206004820152602b60248201527f42617365506f736974696f6e4d616e616765723a20696e73756666696369656e60448201526a1d08185b5bdd5b9d13dd5d60aa1b606482015260840161028d565b90505b949350505050565b600054610100900460ff166137915760405162461bcd60e51b815260040161028d906148d8565b603380546001600160a01b03191633179055565b600054610100900460ff166137cc5760405162461bcd60e51b815260040161028d906148d8565b612e60613bb5565b6000826137e357506000612f39565b816000036137f357506001612f39565b6000866001885161380491906145d7565b81518110613814576138146145f0565b6020908102919091010151603654604051634a3f088d60e01b81529192506001600160a01b03169060009081908390634a3f088d9061385d908e9088908d908d90600401614703565b61010060405180830381865afa15801561387b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061389f919061472d565b50505050505091509150816000036138be576000945050505050612f39565b60006138ca878461495c565b90506000846001600160a01b0316630a48d5a9878d6040518363ffffffff1660e01b81526004016138fc92919061441b565b602060405180830381865afa158015613919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061393d91906144bc565b9050600061394b828561495c565b905060008461395c61271088614923565b613966919061493a565b9050600082603b5461271061397b919061495c565b6139859087614923565b61398f919061493a565b919091109f9e505050505050505050505050505050565b806000036139b357505050565b8115613aaf576001600160a01b0383166000908152603e60205260409020548015801590613a5d575060365460405163783a2b6760e11b8152829184916001600160a01b039091169063f07456ce90613a10908990600401613d53565b602060405180830381865afa158015613a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a5191906144bc565b613a5b919061495c565b115b156124305760405162461bcd60e51b815260206004820152602e60248201526000805160206149e383398151915260448201526d1b1bdb99dcc8195e18d95959195960921b606482015260840161028d565b6001600160a01b0383166000908152603f60205260409020548015801590613b53575060365460405163114f1b5560e31b8152829184916001600160a01b0390911690638a78daa890613b06908990600401613d53565b602060405180830381865afa158015613b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b4791906144bc565b613b51919061495c565b115b156124305760405162461bcd60e51b815260206004820152602f60248201526000805160206149e383398151915260448201526e1cda1bdc9d1cc8195e18d959591959608a1b606482015260840161028d565b60606137628484600085613bdc565b600054610100900460ff16612d465760405162461bcd60e51b815260040161028d906148d8565b606082471015613c3d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161028d565b600080866001600160a01b03168587604051613c599190614993565b60006040518083038185875af1925050503d8060008114613c96576040519150601f19603f3d011682016040523d82523d6000602084013e613c9b565b606091505b5091509150613cac87838387613cb7565b979650505050505050565b60608315613d24578251600003613d1d57613cd185612d4c565b613d1d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161028d565b5081613762565b6137628383815115613d395781518083602001fd5b8060405162461bcd60e51b815260040161028d91906149af565b6001600160a01b0391909116815260200190565b6001600160a01b0381168114613d7c57600080fd5b50565b600080600060608486031215613d9457600080fd5b8335613d9f81613d67565b9250602084013591506040840135613db681613d67565b809150509250925092565b600060208284031215613dd357600080fd5b8135612cb881613d67565b8015158114613d7c57600080fd5b600060208284031215613dfe57600080fd5b8135612cb881613dde565b60008060408385031215613e1c57600080fd5b8235613e2781613d67565b91506020830135613e3781613dde565b809150509250929050565b600060208284031215613e5457600080fd5b5035919050565b60008060408385031215613e6e57600080fd5b8235613e7981613d67565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613ec557613ec5613e87565b604052919050565b60006001600160401b03821115613ee657613ee6613e87565b5060051b60200190565b600082601f830112613f0157600080fd5b81356020613f16613f1183613ecd565b613e9d565b82815260059290921b84018101918181019086841115613f3557600080fd5b8286015b84811015613f59578035613f4c81613d67565b8352918301918301613f39565b509695505050505050565b600080600080600080600080610100898b031215613f8157600080fd5b88356001600160401b03811115613f9757600080fd5b613fa38b828c01613ef0565b9850506020890135613fb481613d67565b965060408901359550606089013594506080890135613fd281613dde565b935060a0890135613fe281613d67565b979a969950949793969295929450505060c08201359160e0013590565b600080600080600080600060e0888a03121561401a57600080fd5b873561402581613d67565b9650602088013561403581613d67565b95506040880135945060608801359350608088013561405381613dde565b925060a088013561406381613d67565b8092505060c0880135905092959891949750929550565b60008060008060008060c0878903121561409357600080fd5b863561409e81613d67565b955060208701356140ae81613d67565b945060408701356140be81613d67565b935060608701356140ce81613d67565b92506080870135915060a08701356140e581613d67565b809150509295509295509295565b60008060008060008060c0878903121561410c57600080fd5b86356001600160401b0381111561412257600080fd5b61412e89828a01613ef0565b965050602087013561413f81613d67565b94506040870135935060608701359250608087013561415d81613dde565b8092505060a087013590509295509295509295565b600080600080600080600060e0888a03121561418d57600080fd5b87356001600160401b038111156141a357600080fd5b6141af8a828b01613ef0565b97505060208801356141c081613d67565b955060408801359450606088013593506080880135925060a088013561406381613dde565b600080600080600060a086880312156141fd57600080fd5b853561420881613d67565b9450602086013561421881613d67565b9350604086013561422881613d67565b9250606086013561423881613dde565b9150608086013561424881613d67565b809150509295509295909350565b60008060006060848603121561426b57600080fd5b833561427681613d67565b9250602084013561428681613d67565b929592945050506040919091013590565b600082601f8301126142a857600080fd5b813560206142b8613f1183613ecd565b82815260059290921b840181019181810190868411156142d757600080fd5b8286015b84811015613f5957803583529183019183016142db565b60008060006060848603121561430757600080fd5b83356001600160401b038082111561431e57600080fd5b61432a87838801613ef0565b9450602086013591508082111561434057600080fd5b61434c87838801614297565b9350604086013591508082111561436257600080fd5b5061436f86828701614297565b9150509250925092565b6000806040838503121561438c57600080fd5b823561439781613d67565b91506020830135613e3781613d67565b6020808252601a90820152792837b9b4ba34b7b726b0b730b3b2b91d103337b93134b23232b760311b604082015260600190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b60006020828403121561441057600080fd5b8151612cb881613d67565b6001600160a01b03929092168252602082015260400190565b600080600080600080600080610100898b03121561445157600080fd5b885161445c81613d67565b60208a015160408b0151919950975061447481613d67565b60608a015160808b0151919750955061448c81613dde565b60a08a015160c08b015191955093506144a481613dde565b8092505060e089015190509295985092959890939650565b6000602082840312156144ce57600080fd5b5051919050565b6001600160a01b03978816815295871660208701529390951660408501529015156060840152608083015260a082019290925290151560c082015260e00190565b6020808252601e908201527f42617365506f736974696f6e4d616e616765723a20666f7262696464656e0000604082015260600190565b60208082526015908201527423b7bb32b93730b136329d103337b93134b23232b760591b604082015260600190565b60208082526025908201527f506f736974696f6e4d616e616765723a20696e76616c6964205f706174682e6c6040820152640cadccee8d60db1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b818103818111156145ea576145ea6145c1565b92915050565b634e487b7160e01b600052603260045260246000fd5b6020808252601e908201527f506f736974696f6e4d616e616765723a20696e76616c6964205f706174680000604082015260600190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b60008060008060008060008060006101208a8c03121561468657600080fd5b895161469181613d67565b60208b015160408c0151919a5098506146a981613d67565b60608b01519097506146ba81613d67565b60808b015160a08c015191975095506146d281613dde565b60c08b015160e08c015191955093506146ea81613dde565b809250506101008a015190509295985092959850929598565b6001600160a01b039485168152928416602084015292166040820152901515606082015260800190565b600080600080600080600080610100898b03121561474a57600080fd5b885197506020890151965060408901519550606089015194506080890151935060a0890151925060c08901516144a481613dde565b60006020828403121561479157600080fd5b8151612cb881613dde565b6000600182016147ae576147ae6145c1565b5060010190565b600081518084526020808501945080840160005b838110156147e5578151875295820195908201906001016147c9565b509495945050505050565b606080825284519082018190526000906020906080840190828801845b828110156148325781516001600160a01b03168452928401929084019060010161480d565b5050508381038285015261484681876147b5565b9150508281036040840152612f3981856147b5565b6020808252603090820152600080516020614a0383398151915260408201526f1b1bddd95c881d1a185b881b1a5b5a5d60821b606082015260800190565b6020808252603190820152600080516020614a038339815191526040820152701a1a59da195c881d1a185b881b1a5b5a5d607a1b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80820281158282048414176145ea576145ea6145c1565b60008261495757634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156145ea576145ea6145c1565b60005b8381101561498a578181015183820152602001614972565b50506000910152565b600082516149a581846020870161496f565b9190910192915050565b60208152600082518060208401526149ce81604085016020870161496f565b601f01601f1916919091016040019291505056fe42617365506f736974696f6e4d616e616765723a206d617820676c6f62616c2042617365506f736974696f6e4d616e616765723a206d61726b20707269636520a2646970667358221220f1213cf35497830a65033e71a3b72267da1d2a001323aab13e4ccf45f120c64264736f6c63430008110033
Deployed Bytecode
0x6080604052600436106102265760003560e01c80626cc35e1461029d57806307c7edc3146102d35780631045c74e146102f357806311d9444a1461032e578063126082cf1461034e57806312d43a511461036457806316efd941146103845780631b904359146103a45780631ce9cb8f146103c45780631e261538146103f157806321acf65914610411578063233bfe3b1461043157806324a084df146104515780633039e37f1461047157806330a402c0146104915780633833f5f5146104b15780633fc8cef3146104f1578063430ed37c146105115780634453a374146105315780634584bd4b14610551578063490ae21014610572578063529a356f1461059257806353c425c1146105c25780635fc8500e146105e2578063657bc5d01461060257806367a52793146106225780636eb2d03114610638578063704b6c0214610658578063776af5ba1461067857806382beee89146106985780638c0f9aac146106b857806390205d8c146106e85780639698d25a1461070857806398d1e03a146107355780639c95332f1461074b578063b32755de1461076b578063b7ddc9921461077e578063c5f3a4c41461079e578063cfad57a2146107be578063d38ab519146107de578063d4ca83f9146107fe578063de2ea9481461081f578063e1f21c671461083f578063ef12c67e1461085f578063f25552781461087f578063f851a4401461089f578063f887ea40146108bf578063fbfa77cf146108df57600080fd5b36610298576039546001600160a01b031633146102965760405162461bcd60e51b815260206004820152602360248201527f42617365506f736974696f6e4d616e616765723a20696e76616c69642073656e6044820152623232b960e91b60648201526084015b60405180910390fd5b005b600080fd5b3480156102a957600080fd5b50603c546102bd906001600160a01b031681565b6040516102ca9190613d53565b60405180910390f35b3480156102df57600080fd5b506102966102ee366004613d7f565b6108ff565b3480156102ff57600080fd5b5061032061030e366004613dc1565b603e6020526000908152604090205481565b6040519081526020016102ca565b34801561033a57600080fd5b50610296610349366004613d7f565b610999565b34801561035a57600080fd5b5061032061271081565b34801561037057600080fd5b506033546102bd906001600160a01b031681565b34801561039057600080fd5b506044546102bd906001600160a01b031681565b3480156103b057600080fd5b506102966103bf366004613dec565b610d49565b3480156103d057600080fd5b506103206103df366004613dc1565b603d6020526000908152604090205481565b3480156103fd57600080fd5b5061029661040c366004613e09565b610dc9565b34801561041d57600080fd5b5061029661042c366004613e09565b610e53565b34801561043d57600080fd5b5061029661044c366004613e42565b610ee0565b34801561045d57600080fd5b5061029661046c366004613e5b565b610f3f565b34801561047d57600080fd5b5061029661048c366004613f64565b610f80565b34801561049d57600080fd5b506035546102bd906001600160a01b031681565b3480156104bd57600080fd5b506104e16104cc366004613dc1565b60416020526000908152604090205460ff1681565b60405190151581526020016102ca565b3480156104fd57600080fd5b506039546102bd906001600160a01b031681565b34801561051d57600080fd5b5061029661052c366004613fff565b6110f3565b34801561053d57600080fd5b5061029661054c366004613e09565b6111d6565b34801561055d57600080fd5b506040546104e190600160a81b900460ff1681565b34801561057e57600080fd5b5061029661058d366004613e42565b611258565b34801561059e57600080fd5b506104e16105ad366004613dc1565b60436020526000908152604090205460ff1681565b3480156105ce57600080fd5b506102966105dd36600461407a565b6112b7565b3480156105ee57600080fd5b506102966105fd366004613f64565b6113fb565b34801561060e57600080fd5b506037546102bd906001600160a01b031681565b34801561062e57600080fd5b50610320603a5481565b34801561064457600080fd5b50610296610653366004613dc1565b6114bb565b34801561066457600080fd5b50610296610673366004613dc1565b611530565b34801561068457600080fd5b506040546102bd906001600160a01b031681565b3480156106a457600080fd5b506102966106b3366004613dc1565b611605565b3480156106c457600080fd5b506104e16106d3366004613dc1565b60426020526000908152604090205460ff1681565b3480156106f457600080fd5b50610296610703366004613fff565b611651565b34801561071457600080fd5b50610320610723366004613dc1565b603f6020526000908152604090205481565b34801561074157600080fd5b50610320603b5481565b34801561075757600080fd5b50610296610766366004613dec565b6116b7565b6102966107793660046140f3565b61172c565b34801561078a57600080fd5b50610296610799366004614172565b6118cd565b3480156107aa57600080fd5b506102966107b9366004613dc1565b611af5565b3480156107ca57600080fd5b506102966107d9366004613dc1565b611b6a565b3480156107ea57600080fd5b506102966107f9366004613d7f565b611c31565b34801561080a57600080fd5b506040546104e190600160a01b900460ff1681565b34801561082b57600080fd5b5061029661083a3660046141e5565b611fc3565b34801561084b57600080fd5b5061029661085a366004614256565b612395565b34801561086b57600080fd5b5061029661087a3660046142f2565b612436565b34801561088b57600080fd5b5061029661089a366004614379565b612558565b3480156108ab57600080fd5b506034546102bd906001600160a01b031681565b3480156108cb57600080fd5b506038546102bd906001600160a01b031681565b3480156108eb57600080fd5b506036546102bd906001600160a01b031681565b3360009081526041602052604090205460ff1661092e5760405162461bcd60e51b815260040161028d906143a7565b6040805490516307c7edc360e01b81526001600160a01b03909116906307c7edc390610962908690869086906004016143db565b600060405180830381600087803b15801561097c57600080fd5b505af1158015610990573d6000803e3d6000fd5b50505050505050565b3360009081526041602052604090205460ff166109c85760405162461bcd60e51b815260040161028d906143a7565b603654604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a51916004808201926020929091908290030181865afa158015610a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3b91906143fe565b604080549051630130197760e11b81529192506000918291829182916001600160a01b03169063026032ee90610a77908c908c9060040161441b565b61010060405180830381865afa158015610a95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab99190614434565b505050945094509450509350600081610b3e57604051637092736960e11b81526001600160a01b0388169063e124e6d290610af8908790600401613d53565b602060405180830381865afa158015610b15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3991906144bc565b610bab565b6040516340d3096b60e11b81526001600160a01b038816906381a612d690610b6a908790600401613d53565b602060405180830381865afa158015610b87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bab91906144bc565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90610be9908d908990899088908a9089906000906004016144d5565b600060405180830381600087803b158015610c0357600080fd5b505af1158015610c17573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0389169250636d63c1d09150610c47908a90600401613d53565b600060405180830381600087803b158015610c6157600080fd5b505af1158015610c75573d6000803e3d6000fd5b50506040805490516308eca22560e11b81526001600160a01b0390911692506311d9444a9150610cad908d908d908d906004016143db565b600060405180830381600087803b158015610cc757600080fd5b505af1158015610cdb573d6000803e3d6000fd5b505060405163d3c87bbb60e01b81526001600160a01b038916925063d3c87bbb9150610d0b908a90600401613d53565b600060405180830381600087803b158015610d2557600080fd5b505af1158015610d39573d6000803e3d6000fd5b5050505050505050505050505050565b6034546001600160a01b03163314610d735760405162461bcd60e51b815260040161028d90614516565b60408054821515600160a81b0260ff60a81b19909116178155517fa956222e37fe025ff51e5440ac729a9bd417ff91e485e14dcffa2c0ba8894f4090610dbe90831515815260200190565b60405180910390a150565b6034546001600160a01b03163314610df35760405162461bcd60e51b815260040161028d90614516565b6001600160a01b038216600081815260416020908152604091829020805460ff191685151590811790915591519182527f1d5bc0255b943d6a5b5279e8a55d74d620baccbceecb25e87a3558f14c4c118e91015b60405180910390a25050565b6034546001600160a01b03163314610e7d5760405162461bcd60e51b815260040161028d90614516565b6001600160a01b038216600081815260426020908152604091829020805460ff19168515159081179091558251938452908301527fa4e46c70ff429a91de7d1716d736e877c7cca1c22ac850b23d242530dd95e474910160405180910390a15050565b6034546001600160a01b03163314610f0a5760405162461bcd60e51b815260040161028d90614516565b603b8190556040518181527f21167d0d4661af93817ebce920f18986eed3d75d5e1c03f2aed05efcbafbc45290602001610dbe565b6033546001600160a01b03163314610f695760405162461bcd60e51b815260040161028d9061454d565b610f7c6001600160a01b03831682612679565b5050565b610f88612794565b3360009081526042602052604090205460ff1680610faf5750604054600160a01b900460ff165b610fcb5760405162461bcd60e51b815260040161028d906143a7565b8751600214610fec5760405162461bcd60e51b815260040161028d9061457c565b60395488516001600160a01b0390911690899061100b906001906145d7565b8151811061101b5761101b6145f0565b60200260200101516001600160a01b0316146110495760405162461bcd60e51b815260040161028d90614606565b6000611075338a600081518110611062576110626145f0565b60200260200101518a8a8a8a308a6127ed565b5090506110c5603660009054906101000a90046001600160a01b0316828b6000815181106110a5576110a56145f0565b60200260200101516001600160a01b0316612bb69092919063ffffffff16565b60006110d28a8430612c0c565b90506110de8186612cbf565b50506110e960018055565b5050505050505050565b6110fb612794565b3360009081526042602052604090205460ff16806111225750604054600160a01b900460ff165b61113e5760405162461bcd60e51b815260040161028d906143a7565b6039546001600160a01b038881169116146111ad5760405162461bcd60e51b815260206004820152602960248201527f506f736974696f6e4d616e616765723a20696e76616c6964205f636f6c6c617460448201526832b930b62a37b5b2b760b91b606482015260840161028d565b60006111bf33898989898930896127ed565b5090506111cc8184612cbf565b5061099060018055565b6034546001600160a01b031633146112005760405162461bcd60e51b815260040161028d90614516565b6001600160a01b038216600081815260436020908152604091829020805460ff191685151590811790915591519182527f8c0d56805c3b43d441481229dc64bee168253ffe4305f37ab7cfe63b1c4268c69101610e47565b6034546001600160a01b031633146112825760405162461bcd60e51b815260040161028d90614516565b603a8190556040518181527f974fd3c1fcb4653dfc4fb740c4c692cd212d55c28f163f310128cb64d830067590602001610dbe565b600054610100900460ff16158080156112d75750600054600160ff909116105b806112f857506112e630612d4c565b1580156112f8575060005460ff166001145b61135b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161028d565b6000805460ff19166001179055801561137e576000805461ff0019166101001790555b61138b8787878787612d5b565b60408054600161ff0160a01b0319166001600160a01b03841617600160a81b1790558015610990576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b611403612794565b3360009081526042602052604090205460ff168061142a5750604054600160a01b900460ff165b6114465760405162461bcd60e51b815260040161028d906143a7565b87516002146114675760405162461bcd60e51b815260040161028d9061457c565b6000611480338a600081518110611062576110626145f0565b5090506114b0603660009054906101000a90046001600160a01b0316828b6000815181106110a5576110a56145f0565b6110de898386612c0c565b6034546001600160a01b031633146114e55760405162461bcd60e51b815260040161028d90614516565b603580546001600160a01b0319166001600160a01b0383161790556040517f26cb770c9a24026a0c99d6be6fa7fb963470f03731f629156bbdf1baecae595890610dbe908390613d53565b6033546001600160a01b0316331461155a5760405162461bcd60e51b815260040161028d9061454d565b6001600160a01b0381166115ba5760405162461bcd60e51b815260206004820152602160248201527f42617365506f736974696f6e4d616e616765723a207a65726f206164647265736044820152607360f81b606482015260840161028d565b603480546001600160a01b0319166001600160a01b0383161790556040517f5a272403b402d892977df56625f4164ccaf70ca3863991c43ecfe76a6905b0a190610dbe908390613d53565b6034546001600160a01b0316331461162f5760405162461bcd60e51b815260040161028d90614516565b604480546001600160a01b0319166001600160a01b0392909216919091179055565b611659612794565b3360009081526042602052604090205460ff16806116805750604054600160a01b900460ff165b61169c5760405162461bcd60e51b815260040161028d906143a7565b6116ac33888888888888886127ed565b505061099060018055565b6034546001600160a01b031633146116e15760405162461bcd60e51b815260040161028d90614516565b60408054821515600160a01b0260ff60a01b19909116178155517feac6b3611e79ff0d8ea5daa8439f6b1ab7eea4ebf95f1dd360417f712c3fc30490610dbe90831515815260200190565b611734612794565b3360009081526042602052604090205460ff168061175b5750604054600160a01b900460ff165b6117775760405162461bcd60e51b815260040161028d906143a7565b855160011480611788575085516002145b6117a45760405162461bcd60e51b815260040161028d9061457c565b60395486516001600160a01b039091169087906000906117c6576117c66145f0565b60200260200101516001600160a01b0316146117f45760405162461bcd60e51b815260040161028d90614606565b341561188757611802612df6565b85513490600110156118395760365460395461182b916001600160a01b03918216911634612bb6565b611836878630612c0c565b90505b60006118493389848a888a612e62565b9050611884603660009054906101000a90046001600160a01b0316828a60018c5161187491906145d7565b815181106110a5576110a56145f0565b50505b6118bb33876001895161189a91906145d7565b815181106118aa576118aa6145f0565b602002602001015187868686612f43565b506118c560018055565b505050505050565b6118d5612794565b3360009081526042602052604090205460ff16806118fc5750604054600160a01b900460ff165b6119185760405162461bcd60e51b815260040161028d906143a7565b865160011480611929575086516002145b6119455760405162461bcd60e51b815260040161028d9061457c565b8415611ac15786516001036119dd5760385487516001600160a01b0390911690631b82787890899060009061197c5761197c6145f0565b60200260200101513330896040518563ffffffff1660e01b81526004016119a6949392919061463d565b600060405180830381600087803b1580156119c057600080fd5b505af11580156119d4573d6000803e3d6000fd5b50505050611a84565b60385487516001600160a01b0390911690631b827878908990600090611a0557611a056145f0565b602002602001015133603660009054906101000a90046001600160a01b0316896040518563ffffffff1660e01b8152600401611a44949392919061463d565b600060405180830381600087803b158015611a5e57600080fd5b505af1158015611a72573d6000803e3d6000fd5b50505050611a81878530612c0c565b94505b6000611a943389888a8789612e62565b9050611abf603660009054906101000a90046001600160a01b0316828a60018c5161187491906145d7565b505b6111cc338860018a51611ad491906145d7565b81518110611ae457611ae46145f0565b602002602001015188868686612f43565b6034546001600160a01b03163314611b1f5760405162461bcd60e51b815260040161028d90614516565b603c80546001600160a01b0319166001600160a01b0383161790556040517f57202bce87a87010e83825477a341d777f701216d3e2a3b4642c72d9e8a9319890610dbe908390613d53565b6033546001600160a01b03163314611b945760405162461bcd60e51b815260040161028d9061454d565b6001600160a01b038116611be55760405162461bcd60e51b8152602060048201526018602482015277476f7665726e61626c653a207a65726f206164647265737360401b604482015260640161028d565b603380546001600160a01b0319166001600160a01b0383169081179091556040517fe24c39186e9137521953beaa8446e71f55b8f12296984f9d4273ceb1af728d9091610dbe91613d53565b3360009081526041602052604090205460ff16611c605760405162461bcd60e51b815260040161028d906143a7565b611c6a83836132ab565b603654604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a51916004808201926020929091908290030181865afa158015611cb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cdd91906143fe565b60408054905163d3bab1d160e01b81529192506000918291829182916001600160a01b03169063d3bab1d190611d19908c908c9060040161441b565b61012060405180830381865afa158015611d37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5b9190614667565b505060448054604051637ebea3e360e01b81526001600160a01b0380881660048301526024820187905285151593820193909352969c50949a5092985090965050169250637ebea3e39150606401600060405180830381600087803b158015611dc357600080fd5b505af1158015611dd7573d6000803e3d6000fd5b50505050600081611e54576040516340d3096b60e11b81526001600160a01b038816906381a612d690611e0e908790600401613d53565b602060405180830381865afa158015611e2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4f91906144bc565b611ec1565b604051637092736960e11b81526001600160a01b0388169063e124e6d290611e80908790600401613d53565b602060405180830381865afa158015611e9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec191906144bc565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90611eff908d908990899088908a9089906001906004016144d5565b600060405180830381600087803b158015611f1957600080fd5b505af1158015611f2d573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0389169250636d63c1d09150611f5d908a90600401613d53565b600060405180830381600087803b158015611f7757600080fd5b505af1158015611f8b573d6000803e3d6000fd5b505060408054905163d38ab51960e01b81526001600160a01b03909116925063d38ab5199150610cad908d908d908d906004016143db565b611fcb612794565b3360009081526043602052604090205460ff16611ffa5760405162461bcd60e51b815260040161028d906143a7565b603654604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a51916004808201926020929091908290030181865afa158015612049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206d91906143fe565b603654604051634a3f088d60e01b81529192506000916001600160a01b0390911690634a3f088d906120a9908b908b908b908b90600401614703565b61010060405180830381865afa1580156120c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120eb919061472d565b50505050505050905060008561216d57604051637092736960e11b81526001600160a01b0385169063e124e6d290612127908a90600401613d53565b602060405180830381865afa158015612144573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216891906144bc565b6121da565b6040516340d3096b60e11b81526001600160a01b038516906381a612d690612199908a90600401613d53565b602060405180830381865afa1580156121b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121da91906144bc565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90612218908c908c908c908c90899089906000906004016144d5565b600060405180830381600087803b15801561223257600080fd5b505af1158015612246573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0386169250636d63c1d09150612276908790600401613d53565b600060405180830381600087803b15801561229057600080fd5b505af11580156122a4573d6000803e3d6000fd5b5050604051631bc5d52960e31b81526001600160a01b038c811660048301528b811660248301528a81166044830152891515606483015288811660848301528716925063de2ea948915060a401600060405180830381600087803b15801561230b57600080fd5b505af115801561231f573d6000803e3d6000fd5b505060405163d3c87bbb60e01b81526001600160a01b038616925063d3c87bbb915061234f908790600401613d53565b600060405180830381600087803b15801561236957600080fd5b505af115801561237d573d6000803e3d6000fd5b505050505050505061238e60018055565b5050505050565b6033546001600160a01b031633146123bf5760405162461bcd60e51b815260040161028d9061454d565b60405163095ea7b360e01b81526001600160a01b0384169063095ea7b3906123ed908590859060040161441b565b6020604051808303816000875af115801561240c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612430919061477f565b50505050565b6034546001600160a01b031633146124605760405162461bcd60e51b815260040161028d90614516565b60005b8351811015612517576000848281518110612480576124806145f0565b6020026020010151905083828151811061249c5761249c6145f0565b6020026020010151603e6000836001600160a01b03166001600160a01b03168152602001908152602001600020819055508282815181106124df576124df6145f0565b6020908102919091018101516001600160a01b039092166000908152603f90915260409020558061250f8161479c565b915050612463565b507fae32d569b058895b9620d6552b09aaffedc9a6f396be4d595a224ad09f8b213983838360405161254b939291906147f0565b60405180910390a1505050565b6035546001600160a01b031633148061257b57506034546001600160a01b031633145b6125e75760405162461bcd60e51b815260206004820152603760248201527f42617365506f736974696f6e4d616e616765723a2066656541646d696e206f726044820152760818591b5a5b881c9bdb19481a5cc81c995c5d5a5c9959604a1b606482015260840161028d565b6001600160a01b0382166000908152603d60205260408120549081900361260d57505050565b6001600160a01b0383166000818152603d6020526040812055612631908383612bb6565b604080516001600160a01b038086168252841660208201529081018290527f4f1b51dd7a2fcb861aa2670f668be66835c4ee12b4bbbf037e4d0018f39819e49060600161254b565b804710156126c95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161028d565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612716576040519150601f19603f3d011682016040523d82523d6000602084013e61271b565b606091505b505090508061278f5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b606482015260840161028d565b505050565b6002600154036127e65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161028d565b6002600155565b60365460009081906001600160a01b0316818661287657604051637092736960e11b81526001600160a01b0383169063e124e6d290612830908d90600401613d53565b602060405180830381865afa15801561284d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061287191906144bc565b6128e3565b6040516340d3096b60e11b81526001600160a01b038316906381a612d6906128a2908d90600401613d53565b602060405180830381865afa1580156128bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e391906144bc565b90508615612910578481101561290b5760405162461bcd60e51b815260040161028d9061485b565b612930565b848111156129305760405162461bcd60e51b815260040161028d90614899565b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b8152600401602060405180830381865afa158015612970573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299491906143fe565b9050603760009054906101000a90046001600160a01b03166001600160a01b031663f3238cec8e8e8e8c8e8860006040518863ffffffff1660e01b81526004016129e497969594939291906144d5565b600060405180830381600087803b1580156129fe57600080fd5b505af1158015612a12573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0384169250636d63c1d09150612a42908690600401613d53565b600060405180830381600087803b158015612a5c57600080fd5b505af1158015612a70573d6000803e3d6000fd5b505050506000603860009054906101000a90046001600160a01b03166001600160a01b0316632662166b8f8f8f8f8f8f8f6040518863ffffffff1660e01b8152600401612afd97969594939291906001600160a01b0397881681529587166020870152938616604086015260608501929092526080840152151560a083015290911660c082015260e00190565b6020604051808303816000875af1158015612b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4091906144bc565b60405163d3c87bbb60e01b81529091506001600160a01b0383169063d3c87bbb90612b6f908790600401613d53565b600060405180830381600087803b158015612b8957600080fd5b505af1158015612b9d573d6000803e3d6000fd5b5092975093955050505050509850989650505050505050565b61278f8363a9059cbb60e01b8484604051602401612bd592919061441b565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526135a3565b60008351600203612c5e57612c5784600081518110612c2d57612c2d6145f0565b602002602001015185600181518110612c4857612c486145f0565b60200260200101518585613675565b9050612cb8565b60405162461bcd60e51b815260206004820152602960248201527f42617365506f736974696f6e4d616e616765723a20696e76616c6964205f70616044820152680e8d05cd8cadccee8d60bb1b606482015260840161028d565b9392505050565b603954604051632e1a7d4d60e01b8152600481018490526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015612d0557600080fd5b505af1158015612d19573d6000803e3d6000fd5b50506040516001600160a01b038416925084156108fc02915084906000818181858888f150505050505050565b60018055565b6001600160a01b03163b151590565b600054610100900460ff16612d825760405162461bcd60e51b815260040161028d906148d8565b612d8a61376a565b612d926137a5565b603680546001600160a01b03199081166001600160a01b03978816179091556038805482169587169590951790945560398054851692861692909217909155603a5560378054831691909316179091556064603b5560348054339216919091179055565b3415612e6057603960009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015612e4c57600080fd5b505af115801561238e573d6000803e3d6000fd5b565b600080612e738888888888886137d4565b90508015612f34576000612710603a54612710612e9091906145d7565b612e9a9089614923565b612ea4919061493a565b90506000612eb282896145d7565b905060008960018b51612ec591906145d7565b81518110612ed557612ed56145f0565b6020026020010151905081603d6000836001600160a01b03166001600160a01b0316815260200190815260200160002054612f10919061495c565b6001600160a01b039091166000908152603d6020526040902055509150612f399050565b859150505b9695505050505050565b6036546000906001600160a01b03168184612fca576040516340d3096b60e11b81526001600160a01b038316906381a612d690612f84908a90600401613d53565b602060405180830381865afa158015612fa1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc591906144bc565b613037565b604051637092736960e11b81526001600160a01b0383169063e124e6d290612ff6908a90600401613d53565b602060405180830381865afa158015613013573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303791906144bc565b90508415613064578381111561305f5760405162461bcd60e51b815260040161028d90614899565b613084565b838110156130845760405162461bcd60e51b815260040161028d9061485b565b61308f8786886139a6565b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f391906143fe565b603754604051633cc8e33b60e21b81529192506001600160a01b03169063f3238cec90613131908d908d908d908c908e908a906001906004016144d5565b600060405180830381600087803b15801561314b57600080fd5b505af115801561315f573d6000803e3d6000fd5b50506040516306d63c1d60e41b81526001600160a01b0384169250636d63c1d0915061318f908690600401613d53565b600060405180830381600087803b1580156131a957600080fd5b505af11580156131bd573d6000803e3d6000fd5b5050603854604051630f8ee8bb60e11b81526001600160a01b038e811660048301528d811660248301528c81166044830152606482018c90528a151560848301529091169250631f1dd176915060a401600060405180830381600087803b15801561322757600080fd5b505af115801561323b573d6000803e3d6000fd5b505060405163d3c87bbb60e01b81526001600160a01b038416925063d3c87bbb915061326b908690600401613d53565b600060405180830381600087803b15801561328557600080fd5b505af1158015613299573d6000803e3d6000fd5b50939c9b505050505050505050505050565b60408054905163d3bab1d160e01b8152600091829182918291829182916001600160a01b039091169063d3bab1d1906132ea908b908b9060040161441b565b61012060405180830381865afa158015613308573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332c9190614667565b5050509550955095509550955095506133468382846139a6565b604054600160a81b900460ff16613361575050505050505050565b80613370575050505050505050565b600082116133c05760405162461bcd60e51b815260206004820152601d60248201527f506f736974696f6e4d616e616765723a206c6f6e67206465706f736974000000604482015260640161028d565b603654604051634a3f088d60e01b81526001600160a01b039091169060009081908390634a3f088d906133fd908e908b908b908a90600401614703565b61010060405180830381865afa15801561341b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343f919061472d565b505050505050915091508160000361345e575050505050505050505050565b600061346a868461495c565b90506000846001600160a01b0316630a48d5a98c8c6040518363ffffffff1660e01b815260040161349c92919061441b565b602060405180830381865afa1580156134b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134dd91906144bc565b905060006134eb828561495c565b90506000846134fc61271088614923565b613506919061493a565b9050600082603b5461271061351b919061495c565b6135259087614923565b61352f919061493a565b9050818110156135915760405162461bcd60e51b815260206004820152602760248201527f506f736974696f6e4d616e616765723a206c6f6e67206c6576657261676520646044820152666563726561736560c81b606482015260840161028d565b50505050505050505050505050505050565b60006135f8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613ba69092919063ffffffff16565b80519091501561278f5780806020019051810190613616919061477f565b61278f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161028d565b603654604051634998b10960e11b81526001600160a01b0386811660048301528581166024830152838116604483015260009283929116906393316212906064016020604051808303816000875af11580156136d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136f991906144bc565b90508381101561375f5760405162461bcd60e51b815260206004820152602b60248201527f42617365506f736974696f6e4d616e616765723a20696e73756666696369656e60448201526a1d08185b5bdd5b9d13dd5d60aa1b606482015260840161028d565b90505b949350505050565b600054610100900460ff166137915760405162461bcd60e51b815260040161028d906148d8565b603380546001600160a01b03191633179055565b600054610100900460ff166137cc5760405162461bcd60e51b815260040161028d906148d8565b612e60613bb5565b6000826137e357506000612f39565b816000036137f357506001612f39565b6000866001885161380491906145d7565b81518110613814576138146145f0565b6020908102919091010151603654604051634a3f088d60e01b81529192506001600160a01b03169060009081908390634a3f088d9061385d908e9088908d908d90600401614703565b61010060405180830381865afa15801561387b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061389f919061472d565b50505050505091509150816000036138be576000945050505050612f39565b60006138ca878461495c565b90506000846001600160a01b0316630a48d5a9878d6040518363ffffffff1660e01b81526004016138fc92919061441b565b602060405180830381865afa158015613919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061393d91906144bc565b9050600061394b828561495c565b905060008461395c61271088614923565b613966919061493a565b9050600082603b5461271061397b919061495c565b6139859087614923565b61398f919061493a565b919091109f9e505050505050505050505050505050565b806000036139b357505050565b8115613aaf576001600160a01b0383166000908152603e60205260409020548015801590613a5d575060365460405163783a2b6760e11b8152829184916001600160a01b039091169063f07456ce90613a10908990600401613d53565b602060405180830381865afa158015613a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a5191906144bc565b613a5b919061495c565b115b156124305760405162461bcd60e51b815260206004820152602e60248201526000805160206149e383398151915260448201526d1b1bdb99dcc8195e18d95959195960921b606482015260840161028d565b6001600160a01b0383166000908152603f60205260409020548015801590613b53575060365460405163114f1b5560e31b8152829184916001600160a01b0390911690638a78daa890613b06908990600401613d53565b602060405180830381865afa158015613b23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b4791906144bc565b613b51919061495c565b115b156124305760405162461bcd60e51b815260206004820152602f60248201526000805160206149e383398151915260448201526e1cda1bdc9d1cc8195e18d959591959608a1b606482015260840161028d565b60606137628484600085613bdc565b600054610100900460ff16612d465760405162461bcd60e51b815260040161028d906148d8565b606082471015613c3d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161028d565b600080866001600160a01b03168587604051613c599190614993565b60006040518083038185875af1925050503d8060008114613c96576040519150601f19603f3d011682016040523d82523d6000602084013e613c9b565b606091505b5091509150613cac87838387613cb7565b979650505050505050565b60608315613d24578251600003613d1d57613cd185612d4c565b613d1d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161028d565b5081613762565b6137628383815115613d395781518083602001fd5b8060405162461bcd60e51b815260040161028d91906149af565b6001600160a01b0391909116815260200190565b6001600160a01b0381168114613d7c57600080fd5b50565b600080600060608486031215613d9457600080fd5b8335613d9f81613d67565b9250602084013591506040840135613db681613d67565b809150509250925092565b600060208284031215613dd357600080fd5b8135612cb881613d67565b8015158114613d7c57600080fd5b600060208284031215613dfe57600080fd5b8135612cb881613dde565b60008060408385031215613e1c57600080fd5b8235613e2781613d67565b91506020830135613e3781613dde565b809150509250929050565b600060208284031215613e5457600080fd5b5035919050565b60008060408385031215613e6e57600080fd5b8235613e7981613d67565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613ec557613ec5613e87565b604052919050565b60006001600160401b03821115613ee657613ee6613e87565b5060051b60200190565b600082601f830112613f0157600080fd5b81356020613f16613f1183613ecd565b613e9d565b82815260059290921b84018101918181019086841115613f3557600080fd5b8286015b84811015613f59578035613f4c81613d67565b8352918301918301613f39565b509695505050505050565b600080600080600080600080610100898b031215613f8157600080fd5b88356001600160401b03811115613f9757600080fd5b613fa38b828c01613ef0565b9850506020890135613fb481613d67565b965060408901359550606089013594506080890135613fd281613dde565b935060a0890135613fe281613d67565b979a969950949793969295929450505060c08201359160e0013590565b600080600080600080600060e0888a03121561401a57600080fd5b873561402581613d67565b9650602088013561403581613d67565b95506040880135945060608801359350608088013561405381613dde565b925060a088013561406381613d67565b8092505060c0880135905092959891949750929550565b60008060008060008060c0878903121561409357600080fd5b863561409e81613d67565b955060208701356140ae81613d67565b945060408701356140be81613d67565b935060608701356140ce81613d67565b92506080870135915060a08701356140e581613d67565b809150509295509295509295565b60008060008060008060c0878903121561410c57600080fd5b86356001600160401b0381111561412257600080fd5b61412e89828a01613ef0565b965050602087013561413f81613d67565b94506040870135935060608701359250608087013561415d81613dde565b8092505060a087013590509295509295509295565b600080600080600080600060e0888a03121561418d57600080fd5b87356001600160401b038111156141a357600080fd5b6141af8a828b01613ef0565b97505060208801356141c081613d67565b955060408801359450606088013593506080880135925060a088013561406381613dde565b600080600080600060a086880312156141fd57600080fd5b853561420881613d67565b9450602086013561421881613d67565b9350604086013561422881613d67565b9250606086013561423881613dde565b9150608086013561424881613d67565b809150509295509295909350565b60008060006060848603121561426b57600080fd5b833561427681613d67565b9250602084013561428681613d67565b929592945050506040919091013590565b600082601f8301126142a857600080fd5b813560206142b8613f1183613ecd565b82815260059290921b840181019181810190868411156142d757600080fd5b8286015b84811015613f5957803583529183019183016142db565b60008060006060848603121561430757600080fd5b83356001600160401b038082111561431e57600080fd5b61432a87838801613ef0565b9450602086013591508082111561434057600080fd5b61434c87838801614297565b9350604086013591508082111561436257600080fd5b5061436f86828701614297565b9150509250925092565b6000806040838503121561438c57600080fd5b823561439781613d67565b91506020830135613e3781613d67565b6020808252601a90820152792837b9b4ba34b7b726b0b730b3b2b91d103337b93134b23232b760311b604082015260600190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b60006020828403121561441057600080fd5b8151612cb881613d67565b6001600160a01b03929092168252602082015260400190565b600080600080600080600080610100898b03121561445157600080fd5b885161445c81613d67565b60208a015160408b0151919950975061447481613d67565b60608a015160808b0151919750955061448c81613dde565b60a08a015160c08b015191955093506144a481613dde565b8092505060e089015190509295985092959890939650565b6000602082840312156144ce57600080fd5b5051919050565b6001600160a01b03978816815295871660208701529390951660408501529015156060840152608083015260a082019290925290151560c082015260e00190565b6020808252601e908201527f42617365506f736974696f6e4d616e616765723a20666f7262696464656e0000604082015260600190565b60208082526015908201527423b7bb32b93730b136329d103337b93134b23232b760591b604082015260600190565b60208082526025908201527f506f736974696f6e4d616e616765723a20696e76616c6964205f706174682e6c6040820152640cadccee8d60db1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b818103818111156145ea576145ea6145c1565b92915050565b634e487b7160e01b600052603260045260246000fd5b6020808252601e908201527f506f736974696f6e4d616e616765723a20696e76616c6964205f706174680000604082015260600190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b60008060008060008060008060006101208a8c03121561468657600080fd5b895161469181613d67565b60208b015160408c0151919a5098506146a981613d67565b60608b01519097506146ba81613d67565b60808b015160a08c015191975095506146d281613dde565b60c08b015160e08c015191955093506146ea81613dde565b809250506101008a015190509295985092959850929598565b6001600160a01b039485168152928416602084015292166040820152901515606082015260800190565b600080600080600080600080610100898b03121561474a57600080fd5b885197506020890151965060408901519550606089015194506080890151935060a0890151925060c08901516144a481613dde565b60006020828403121561479157600080fd5b8151612cb881613dde565b6000600182016147ae576147ae6145c1565b5060010190565b600081518084526020808501945080840160005b838110156147e5578151875295820195908201906001016147c9565b509495945050505050565b606080825284519082018190526000906020906080840190828801845b828110156148325781516001600160a01b03168452928401929084019060010161480d565b5050508381038285015261484681876147b5565b9150508281036040840152612f3981856147b5565b6020808252603090820152600080516020614a0383398151915260408201526f1b1bddd95c881d1a185b881b1a5b5a5d60821b606082015260800190565b6020808252603190820152600080516020614a038339815191526040820152701a1a59da195c881d1a185b881b1a5b5a5d607a1b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b80820281158282048414176145ea576145ea6145c1565b60008261495757634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156145ea576145ea6145c1565b60005b8381101561498a578181015183820152602001614972565b50506000910152565b600082516149a581846020870161496f565b9190910192915050565b60208152600082518060208401526149ce81604085016020870161496f565b601f01601f1916919091016040019291505056fe42617365506f736974696f6e4d616e616765723a206d617820676c6f62616c2042617365506f736974696f6e4d616e616765723a206d61726b20707269636520a2646970667358221220f1213cf35497830a65033e71a3b72267da1d2a001323aab13e4ccf45f120c64264736f6c63430008110033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 27 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ 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.