Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
OrderVault
Compiler Version
v0.8.9+commit.e5eed63a
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "./interfaces/IOrderVault.sol"; import "./interfaces/IPositionVault.sol"; import "./interfaces/IPriceManager.sol"; import "./interfaces/ISettingsManager.sol"; import "./interfaces/IVault.sol"; import "./interfaces/IOperators.sol"; import {Constants} from "../access/Constants.sol"; import {OrderStatus, TriggerInfo, TriggerStatus, PositionTrigger, AddPositionOrder, DecreasePositionOrder} from "./structs.sol"; contract OrderVault is Constants, Initializable, ReentrancyGuardUpgradeable, IOrderVault { // constants IPriceManager private priceManager; IPositionVault private positionVault; ISettingsManager private settingsManager; IVault private vault; IOperators private operators; bool private isInitialized; // variables mapping(uint256 => Order) public orders; mapping(uint256 => AddPositionOrder) public addPositionOrders; mapping(uint256 => DecreasePositionOrder) public decreasePositionOrders; mapping(uint256 => PositionTrigger) private triggerOrders; mapping(uint256 => EnumerableSetUpgradeable.UintSet) private aliveTriggerIds; event NewOrder( uint256 posId, address account, bool isLong, uint256 tokenId, uint256 positionType, OrderStatus orderStatus, uint256[] triggerData, address refer ); event UpdateOrder(uint256 posId, uint256 positionType, OrderStatus orderStatus); event FinishOrder(uint256 posId, uint256 positionType, OrderStatus orderStatus); event AddTriggerOrders( uint256 posId, uint256 orderId, bool isTP, uint256 price, uint256 amountPercent, TriggerStatus status ); event EditTriggerOrder(uint256 indexed posId, uint256 orderId, bool isTP, uint256 price, uint256 amountPercent); event ExecuteTriggerOrders(uint256 posId, uint256 amount, uint256 orderId, uint256 price); event UpdateTriggerOrderStatus(uint256 posId, uint256 orderId, TriggerStatus status); event AddTrailingStop(uint256 posId, uint256[] data); event UpdateTrailingStop(uint256 posId, uint256 stpPrice); modifier onlyVault() { require(msg.sender == address(vault), "Only vault"); _; } modifier onlyPositionVault() { require(msg.sender == address(positionVault), "Only position vault"); _; } modifier onlyOperator(uint256 level) { require(operators.getOperatorLevel(msg.sender) >= level, "invalid operator"); _; } /* ========== INITIALIZE FUNCTIONS ========== */ function initialize() public initializer { __ReentrancyGuard_init(); } function init( IPriceManager _priceManager, IPositionVault _positionVault, ISettingsManager _settingsManager, IVault _vault, IOperators _operators ) external { require(!isInitialized, "initialized"); require(AddressUpgradeable.isContract(address(_priceManager)), "priceManager invalid"); require(AddressUpgradeable.isContract(address(_positionVault)), "positionVault invalid"); require(AddressUpgradeable.isContract(address(_settingsManager)), "settingsManager invalid"); require(AddressUpgradeable.isContract(address(_vault)), "vault invalid"); require(AddressUpgradeable.isContract(address(_operators)), "operators is invalid"); priceManager = _priceManager; settingsManager = _settingsManager; positionVault = _positionVault; vault = _vault; operators = _operators; isInitialized = true; } /* ========== FOR OPENING POSITIONS ========== */ function createNewOrder( uint256 _posId, address _account, bool _isLong, uint256 _tokenId, uint256 _positionType, uint256[] memory _params, address _refer ) external override onlyPositionVault { Order storage order = orders[_posId]; order.status = OrderStatus.PENDING; order.positionType = _positionType; order.collateral = _params[2]; order.size = _params[3]; order.lmtPrice = _params[0]; order.stpPrice = _params[1]; order.timestamp = block.timestamp; emit NewOrder(_posId, _account, _isLong, _tokenId, order.positionType, order.status, _params, _refer); } function cancelMarketOrder(uint256 _posId) public override onlyPositionVault { // only cancel if the order still exists if (orders[_posId].size > 0) { Order storage order = orders[_posId]; order.status = OrderStatus.CANCELED; Position memory position = positionVault.getPosition(_posId); vault.takeNSUSDOut(position.owner, order.collateral + positionVault.getPaidFees(_posId).paidPositionFee); emit FinishOrder(_posId, order.positionType, order.status); } } function cancelPendingOrder(address _account, uint256 _posId) external override onlyVault { Order storage order = orders[_posId]; Position memory position = positionVault.getPosition(_posId); require(_account == position.owner, "You are not allowed to cancel"); require(order.status == OrderStatus.PENDING, "Not in Pending"); require(order.positionType != POSITION_MARKET, "market order cannot be cancelled"); if (order.positionType == POSITION_TRAILING_STOP) { order.status = OrderStatus.FILLED; order.positionType = POSITION_MARKET; } else { order.status = OrderStatus.CANCELED; vault.takeNSUSDOut(position.owner, order.collateral + positionVault.getPaidFees(_posId).paidPositionFee); } order.collateral = 0; order.size = 0; order.lmtPrice = 0; order.stpPrice = 0; emit FinishOrder(_posId, order.positionType, order.status); } function updateOrder( uint256 _posId, uint256 _positionType, uint256 _collateral, uint256 _size, OrderStatus _status ) public override onlyPositionVault { _updateOrder(_posId, _positionType, _collateral, _size, _status); } function _updateOrder( uint256 _posId, uint256 _positionType, uint256 _collateral, uint256 _size, OrderStatus _status ) private { Order storage order = orders[_posId]; order.positionType = _positionType; order.collateral = _collateral; order.size = _size; order.status = _status; if (_status == OrderStatus.FILLED || _status == OrderStatus.CANCELED) { emit FinishOrder(_posId, _positionType, _status); } else { emit UpdateOrder(_posId, _positionType, _status); } } /* ========== FOR ADDING POSITIONS ========== */ function createAddPositionOrder( address _owner, uint256 _posId, uint256 _collateralDelta, uint256 _sizeDelta, uint256 _allowedPrice, uint256 _fee ) external override onlyPositionVault { require(addPositionOrders[_posId].size == 0, "addPositionOrder already exists"); addPositionOrders[_posId] = AddPositionOrder({ owner: _owner, collateral: _collateralDelta, size: _sizeDelta, allowedPrice: _allowedPrice, timestamp: block.timestamp, fee: _fee }); } function cancelAddPositionOrder(uint256 _posId) external override onlyPositionVault { AddPositionOrder memory addPositionOrder = addPositionOrders[_posId]; if (addPositionOrder.size > 0) { vault.takeNSUSDOut(addPositionOrder.owner, addPositionOrder.collateral + addPositionOrder.fee); delete addPositionOrders[_posId]; } } function deleteAddPositionOrder(uint256 _posId) external override onlyPositionVault { delete addPositionOrders[_posId]; } /* ========== FOR CLOSING POSITIONS (MARKET ORDER) ========== */ function createDecreasePositionOrder( uint256 _posId, uint256 _sizeDelta, uint256 _allowedPrice ) external override onlyPositionVault { require(decreasePositionOrders[_posId].size == 0, "decreasePositionOrder already exists"); decreasePositionOrders[_posId] = DecreasePositionOrder({ size: _sizeDelta, allowedPrice: _allowedPrice, timestamp: block.timestamp }); } function deleteDecreasePositionOrder(uint256 _posId) external override onlyPositionVault { delete decreasePositionOrders[_posId]; } /* ========== FOR CLOSING POSITIONS (TPSL ORDER) ========== */ function addTriggerOrders( uint256 _posId, address _account, bool[] memory _isTPs, uint256[] memory _prices, uint256[] memory _amountPercents ) external override onlyVault { Position memory position = positionVault.getPosition(_posId); require(position.owner == _account, "not allowed"); require(_prices.length == _isTPs.length && _prices.length == _amountPercents.length, "invalid params"); require(_prices.length > 0, "empty order"); require( EnumerableSetUpgradeable.length(aliveTriggerIds[_posId]) + _prices.length <= settingsManager.maxTriggerPerPosition(), "too many triggers" ); PositionTrigger storage triggerOrder = triggerOrders[_posId]; for (uint256 i; i < _prices.length; ++i) { require(_amountPercents[i] > 0 && _amountPercents[i] <= BASIS_POINTS_DIVISOR, "invalid percent"); uint256 triggersLength = triggerOrder.triggers.length; EnumerableSetUpgradeable.add(aliveTriggerIds[_posId], triggersLength); triggerOrder.triggers.push( TriggerInfo({ isTP: _isTPs[i], amountPercent: _amountPercents[i], createdAt: block.timestamp, price: _prices[i], triggeredAmount: 0, triggeredAt: 0, status: TriggerStatus.OPEN }) ); emit AddTriggerOrders( _posId, triggersLength, _isTPs[i], _prices[i], _amountPercents[i], TriggerStatus.OPEN ); } } function cancelTriggerOrder(uint256 _posId, uint256 _orderId) external nonReentrant { _cancelTriggerOrder(_posId, _orderId); } function cancelTriggerOrderPacked(uint256 x) external nonReentrant { uint256 posId = x / 2 ** 128; uint256 orderId = x % 2 ** 128; _cancelTriggerOrder(posId, orderId); } function _cancelTriggerOrder(uint256 _posId, uint256 _orderId) private { PositionTrigger storage order = triggerOrders[_posId]; Position memory position = positionVault.getPosition(_posId); require(position.owner == msg.sender, "not allowed"); require(order.triggers[_orderId].status == TriggerStatus.OPEN, "TriggerOrder was cancelled"); order.triggers[_orderId].status = TriggerStatus.CANCELLED; EnumerableSetUpgradeable.remove(aliveTriggerIds[_posId], _orderId); emit UpdateTriggerOrderStatus(_posId, _orderId, order.triggers[_orderId].status); } function cancelAllTriggerOrders(uint256 _posId) external nonReentrant { PositionTrigger storage order = triggerOrders[_posId]; Position memory position = positionVault.getPosition(_posId); require(position.owner == msg.sender, "not allowed"); uint256 length = EnumerableSetUpgradeable.length(aliveTriggerIds[_posId]); require(length > 0, "already cancelled"); uint256[] memory tmp = new uint256[](length); for (uint256 i = 0; i < length; ++i) { uint256 idx = EnumerableSetUpgradeable.at(aliveTriggerIds[_posId], i); TriggerInfo storage trigger = order.triggers[idx]; trigger.status = TriggerStatus.CANCELLED; emit UpdateTriggerOrderStatus(_posId, idx, trigger.status); tmp[i] = idx; } for (uint256 i = 0; i < length; ++i) { EnumerableSetUpgradeable.remove(aliveTriggerIds[_posId], tmp[i]); } } function editTriggerOrder( uint256 _posId, uint256 _orderId, bool _isTP, uint256 _price, uint256 _amountPercent ) external nonReentrant { PositionTrigger storage order = triggerOrders[_posId]; Position memory position = positionVault.getPosition(_posId); require(position.owner == msg.sender, "not allowed"); require(order.triggers[_orderId].status == TriggerStatus.OPEN, "TriggerOrder not Open"); require(_amountPercent > 0 && _amountPercent <= BASIS_POINTS_DIVISOR, "invalid percent"); order.triggers[_orderId].isTP = _isTP; order.triggers[_orderId].price = _price; order.triggers[_orderId].amountPercent = _amountPercent; order.triggers[_orderId].createdAt = block.timestamp; emit EditTriggerOrder(_posId, _orderId, _isTP, _price, _amountPercent); } function executeTriggerOrders(uint256 _posId) internal returns (uint256, uint256) { PositionTrigger storage order = triggerOrders[_posId]; Position memory position = positionVault.getPosition(_posId); require(position.size > 0, "Trigger Not Open"); uint256 price = priceManager.getLastPrice(position.tokenId); for (uint256 i = 0; i < EnumerableSetUpgradeable.length(aliveTriggerIds[_posId]); ++i) { uint256 idx = EnumerableSetUpgradeable.at(aliveTriggerIds[_posId], i); TriggerInfo storage trigger = order.triggers[idx]; if (validateTrigger(trigger.status, trigger.isTP, position.isLong, trigger.price, price)) { uint256 triggerAmount = (position.size * trigger.amountPercent) / BASIS_POINTS_DIVISOR; trigger.triggeredAmount = triggerAmount; trigger.triggeredAt = block.timestamp; trigger.status = TriggerStatus.TRIGGERED; EnumerableSetUpgradeable.remove(aliveTriggerIds[_posId], idx); emit ExecuteTriggerOrders(_posId, trigger.triggeredAmount, idx, price); return (triggerAmount, price); } } revert("trigger not ready"); } function validateTrigger( TriggerStatus _status, bool _isTP, bool _isLong, uint256 _triggerPrice, uint256 _lastPrice ) private pure returns (bool) { if (_status != TriggerStatus.OPEN) return false; if (_isTP) { if (_isLong) { if (_lastPrice >= _triggerPrice) return true; } else { if (_lastPrice <= _triggerPrice) return true; } } else { if (_isLong) { if (_lastPrice <= _triggerPrice) return true; } else { if (_lastPrice >= _triggerPrice) return true; } } return false; } /* ========== FOR CLOSING POSITIONS (TRAILING STOP ORDER) ========== */ function addTrailingStop(address _account, uint256 _posId, uint256[] memory _params) external override onlyVault { Order storage order = orders[_posId]; Position memory position = positionVault.getPosition(_posId); require(_account == position.owner, "you are not allowed to add trailing stop"); require(position.size > 0, "position not alive"); validateTrailingStopInputData(_params); if (position.size < _params[1]) { order.size = position.size; } else { order.size = _params[1]; } order.collateral = _params[0]; order.status = OrderStatus.PENDING; order.positionType = POSITION_TRAILING_STOP; order.stepType = _params[2]; order.stpPrice = _params[3]; order.stepAmount = _params[4]; emit AddTrailingStop(_posId, _params); } function validateTrailingStopInputData(uint256[] memory _params) public pure returns (bool) { require(_params[1] > 0, "trailing size is zero"); require(_params[4] > 0 && _params[3] > 0, "invalid trailing data"); require(_params[2] <= 1, "invalid type"); if (_params[2] == TRAILING_STOP_TYPE_PERCENT) { require(_params[4] < BASIS_POINTS_DIVISOR, "percent cant exceed 100%"); } return true; } function updateTrailingStop(uint256 _posId) external nonReentrant { Position memory position = positionVault.getPosition(_posId); Order storage order = orders[_posId]; uint256 price = priceManager.getLastPrice(position.tokenId); require(position.owner == msg.sender || operators.getOperatorLevel(msg.sender) >= 1, "updateTStop not allowed"); require(position.size > 0, "position not alive"); validateTrailingStopPrice(position.tokenId, position.isLong, _posId, true); uint256 oldStpPrice = order.stpPrice; if (position.isLong) { order.stpPrice = order.stepType == 0 ? price - order.stepAmount : (price * (BASIS_POINTS_DIVISOR - order.stepAmount)) / BASIS_POINTS_DIVISOR; } else { order.stpPrice = order.stepType == 0 ? price + order.stepAmount : (price * (BASIS_POINTS_DIVISOR + order.stepAmount)) / BASIS_POINTS_DIVISOR; } uint256 diff; if (order.stpPrice > oldStpPrice) { diff = order.stpPrice - oldStpPrice; } else { diff = oldStpPrice - order.stpPrice; } require( (diff * BASIS_POINTS_DIVISOR) / oldStpPrice >= settingsManager.priceMovementPercent(), "!price movement" ); emit UpdateTrailingStop(_posId, order.stpPrice); } function validateTrailingStopPrice( uint256 _tokenId, bool _isLong, uint256 _posId, bool _raise ) public view returns (bool) { Order memory order = orders[_posId]; uint256 price = priceManager.getLastPrice(_tokenId); uint256 stopPrice; if (_isLong) { if (order.stepType == TRAILING_STOP_TYPE_AMOUNT) { stopPrice = order.stpPrice + order.stepAmount; } else { stopPrice = (order.stpPrice * BASIS_POINTS_DIVISOR) / (BASIS_POINTS_DIVISOR - order.stepAmount); } } else { if (order.stepType == TRAILING_STOP_TYPE_AMOUNT) { stopPrice = order.stpPrice - order.stepAmount; } else { stopPrice = (order.stpPrice * BASIS_POINTS_DIVISOR) / (BASIS_POINTS_DIVISOR + order.stepAmount); } } bool flag; if ( _isLong && order.status == OrderStatus.PENDING && order.positionType == POSITION_TRAILING_STOP && stopPrice <= price ) { flag = true; } else if ( !_isLong && order.status == OrderStatus.PENDING && order.positionType == POSITION_TRAILING_STOP && stopPrice >= price ) { flag = true; } if (_raise) { require(flag, "price incorrect"); } return flag; } /* ========== EXECUTE ORDERS ========== */ function triggerForOpenOrders(uint256 _posId) external nonReentrant onlyOperator(1) { Position memory position = positionVault.getPosition(_posId); Order memory order = orders[_posId]; require(order.status == OrderStatus.PENDING, "order not pending"); uint256 price = priceManager.getLastPrice(position.tokenId); if (order.positionType == POSITION_LIMIT) { if (position.isLong) { require(order.lmtPrice >= price, "trigger not met"); } else { require(order.lmtPrice <= price, "trigger not met"); } positionVault.increasePosition( _posId, position.owner, position.tokenId, position.isLong, price, order.collateral, order.size, positionVault.getPaidFees(_posId).paidPositionFee ); _updateOrder(_posId, order.positionType, 0, 0, OrderStatus.FILLED); positionVault.removeUserOpenOrder(position.owner, _posId); } else if (order.positionType == POSITION_STOP_MARKET) { if (position.isLong) { require(order.stpPrice <= price, "trigger not met"); } else { require(order.stpPrice >= price, "trigger not met"); } positionVault.increasePosition( _posId, position.owner, position.tokenId, position.isLong, price, order.collateral, order.size, positionVault.getPaidFees(_posId).paidPositionFee ); _updateOrder(_posId, order.positionType, 0, 0, OrderStatus.FILLED); positionVault.removeUserOpenOrder(position.owner, _posId); } else if (order.positionType == POSITION_STOP_LIMIT) { if (position.isLong) { require(order.stpPrice <= price, "trigger not met"); } else { require(order.stpPrice >= price, "trigger not met"); } _updateOrder(_posId, POSITION_LIMIT, order.collateral, order.size, order.status); } else if (order.positionType == POSITION_TRAILING_STOP) { if (position.isLong) { require(order.stpPrice >= price, "trigger not met"); } else { require(order.stpPrice <= price, "trigger not met"); } positionVault.decreasePositionByOrderVault(_posId, price, order.size); _updateOrder(_posId, POSITION_MARKET, 0, 0, OrderStatus.FILLED); } else { revert("!positionType"); } } function triggerForTPSL(uint256 _posId) external nonReentrant onlyOperator(1) { (uint256 triggeredAmount, uint256 triggerPrice) = executeTriggerOrders(_posId); positionVault.decreasePositionByOrderVault(_posId, triggerPrice, triggeredAmount); } /* ========== VIEW FUNCTIONS ========== */ function getOrder(uint256 _posId) external view override returns (Order memory) { return orders[_posId]; } function getAddPositionOrder(uint256 _posId) external view override returns (AddPositionOrder memory) { return addPositionOrders[_posId]; } function getDecreasePositionOrder(uint256 _posId) external view override returns (DecreasePositionOrder memory) { return decreasePositionOrders[_posId]; } function getTriggerOrderInfo(uint256 _posId) external view override returns (PositionTrigger memory) { return triggerOrders[_posId]; } function getAliveTriggerIds(uint256 _posId) external view returns (uint256[] memory _aliveTriggerIds) { uint256 length = EnumerableSetUpgradeable.length(aliveTriggerIds[_posId]); _aliveTriggerIds = new uint256[](length); for (uint256 i; i < length; ++i) { _aliveTriggerIds[i] = EnumerableSetUpgradeable.at(aliveTriggerIds[_posId], i); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import {Initializable} from "../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 Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _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 (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./PythStructs.sol"; import "./IPythEvents.sol"; /// @title Consume prices from the Pyth Network (https://pyth.network/). /// @dev Please refer to the guidance at https://docs.pyth.network/documentation/pythnet-price-feeds/best-practices for how to consume prices safely. /// @author Pyth Data Association interface IPyth is IPythEvents { /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time function getValidTimePeriod() external view returns (uint validTimePeriod); /// @notice Returns the price and confidence interval. /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds. /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPrice( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price and confidence interval. /// @dev Reverts if the EMA price is not available. /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPrice( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the price of a price feed without any sanity checks. /// @dev This function returns the most recent price update in this contract without any recency checks. /// This function is unsafe as the returned price update may be arbitrarily far in the past. /// /// Users of this function should check the `publishTime` in the price to ensure that the returned price is /// sufficiently recent for their application. If you are considering using this function, it may be /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPriceUnsafe( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the price that is no older than `age` seconds of the current time. /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently /// recently. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPriceNoOlderThan( bytes32 id, uint age ) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks. /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available. /// However, if the price is not recent this function returns the latest available price. /// /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that /// the returned price is recent or useful for any particular application. /// /// Users of this function should check the `publishTime` in the price to ensure that the returned price is /// sufficiently recent for their application. If you are considering using this function, it may be /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPriceUnsafe( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds /// of the current time. /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently /// recently. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPriceNoOlderThan( bytes32 id, uint age ) external view returns (PythStructs.Price memory price); /// @notice Update price feeds with given update messages. /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// Prices will be updated if they are more recent than the current stored prices. /// The call will succeed even if the update is not the most recent. /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid. /// @param updateData Array of price update data. function updatePriceFeeds(bytes[] calldata updateData) external payable; /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the /// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`. /// /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas. /// Otherwise, it calls updatePriceFeeds method to update the prices. /// /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid. /// @param updateData Array of price update data. /// @param priceIds Array of price ids. /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]` function updatePriceFeedsIfNecessary( bytes[] calldata updateData, bytes32[] calldata priceIds, uint64[] calldata publishTimes ) external payable; /// @notice Returns the required fee to update an array of price updates. /// @param updateData Array of price update data. /// @return feeAmount The required fee in Wei. function getUpdateFee( bytes[] calldata updateData ) external view returns (uint feeAmount); /// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published /// within `minPublishTime` and `maxPublishTime`. /// /// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price; /// otherwise, please consider using `updatePriceFeeds`. This method may store the price updates on-chain, if they /// are more recent than the current stored prices. /// /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// /// /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is /// no update for any of the given `priceIds` within the given time range. /// @param updateData Array of price update data. /// @param priceIds Array of price ids. /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`. /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`. /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order). function parsePriceFeedUpdates( bytes[] calldata updateData, bytes32[] calldata priceIds, uint64 minPublishTime, uint64 maxPublishTime ) external payable returns (PythStructs.PriceFeed[] memory priceFeeds); /// @notice Similar to `parsePriceFeedUpdates` but ensures the updates returned are /// the first updates published in minPublishTime. That is, if there are multiple updates for a given timestamp, /// this method will return the first update. This method may store the price updates on-chain, if they /// are more recent than the current stored prices. /// /// /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is /// no update for any of the given `priceIds` within the given time range and uniqueness condition. /// @param updateData Array of price update data. /// @param priceIds Array of price ids. /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`. /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`. /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order). function parsePriceFeedUpdatesUnique( bytes[] calldata updateData, bytes32[] calldata priceIds, uint64 minPublishTime, uint64 maxPublishTime ) external payable returns (PythStructs.PriceFeed[] memory priceFeeds); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @title IPythEvents contains the events that Pyth contract emits. /// @dev This interface can be used for listening to the updates for off-chain and testing purposes. interface IPythEvents { /// @dev Emitted when the price feed with `id` has received a fresh update. /// @param id The Pyth Price Feed ID. /// @param publishTime Publish time of the given price update. /// @param price Price of the given price update. /// @param conf Confidence interval of the given price update. event PriceFeedUpdate( bytes32 indexed id, uint64 publishTime, int64 price, uint64 conf ); /// @dev Emitted when a batch price update is processed successfully. /// @param chainId ID of the source chain that the batch price update comes from. /// @param sequenceNumber Sequence number of the batch price update. event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; contract PythStructs { // A price with a degree of uncertainty, represented as a price +- a confidence interval. // // The confidence interval roughly corresponds to the standard error of a normal distribution. // Both the price and confidence are stored in a fixed-point numeric representation, // `x * (10^expo)`, where `expo` is the exponent. // // Please refer to the documentation at https://docs.pyth.network/documentation/pythnet-price-feeds/best-practices for how // to how this price safely. struct Price { // Price int64 price; // Confidence interval around the price uint64 conf; // Price exponent int32 expo; // Unix timestamp describing when the price was published uint publishTime; } // PriceFeed represents a current aggregate price from pyth publisher feeds. struct PriceFeed { // The price ID. bytes32 id; // Latest available price Price price; // Latest available exponentially-weighted moving average price Price emaPrice; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; contract Constants { uint8 internal constant STAKING_PID_FOR_CHARGE_FEE = 1; uint256 internal constant BASIS_POINTS_DIVISOR = 100000; uint256 internal constant LIQUIDATE_THRESHOLD_DIVISOR = 10 * BASIS_POINTS_DIVISOR; uint256 internal constant DEFAULT_NSLP_PRICE = 100000; uint256 internal constant FUNDING_RATE_PRECISION = BASIS_POINTS_DIVISOR ** 3; // 1e15 uint256 internal constant MAX_DEPOSIT_WITHDRAW_FEE = 10000; // 10% uint256 internal constant MAX_DELTA_TIME = 24 hours; uint256 internal constant MAX_COOLDOWN_DURATION = 30 days; uint256 internal constant MAX_FEE_BASIS_POINTS = 5000; // 5% uint256 internal constant MAX_PRICE_MOVEMENT_PERCENT = 10000; // 10% uint256 internal constant MAX_BORROW_FEE_FACTOR = 500; // 0.5% per hour uint256 internal constant MAX_FUNDING_RATE = FUNDING_RATE_PRECISION / 10; // 10% per hour uint256 internal constant MAX_STAKING_UNSTAKING_FEE = 10000; // 10% uint256 internal constant MAX_EXPIRY_DURATION = 60; // 60 seconds uint256 internal constant MAX_SELF_EXECUTE_COOLDOWN = 300; // 5 minutes uint256 internal constant MAX_TOKENFARM_COOLDOWN_DURATION = 4 weeks; uint256 internal constant MAX_TRIGGER_GAS_FEE = 1e8 gwei; uint256 internal constant MAX_MARKET_ORDER_GAS_FEE = 1e8 gwei; uint256 internal constant MAX_VESTING_DURATION = 700 days; uint256 internal constant MIN_LEVERAGE = 10000; // 1x uint256 internal constant POSITION_MARKET = 0; uint256 internal constant POSITION_LIMIT = 1; uint256 internal constant POSITION_STOP_MARKET = 2; uint256 internal constant POSITION_STOP_LIMIT = 3; uint256 internal constant POSITION_TRAILING_STOP = 4; uint256 internal constant PRICE_PRECISION = 10 ** 30; uint256 internal constant TRAILING_STOP_TYPE_AMOUNT = 0; uint256 internal constant TRAILING_STOP_TYPE_PERCENT = 1; uint256 internal constant NSLP_DECIMALS = 18; function uintToBytes(uint v) internal pure returns (bytes32 ret) { if (v == 0) { ret = "0"; } else { while (v > 0) { ret = bytes32(uint(ret) / (2 ** 8)); ret |= bytes32(((v % 10) + 48) * 2 ** (8 * 31)); v /= 10; } } return ret; } function checkSlippage(bool isLong, uint256 allowedPrice, uint256 actualMarketPrice) internal pure { if (isLong) { require( actualMarketPrice <= allowedPrice, string( abi.encodePacked( "long: slippage exceeded ", uintToBytes(actualMarketPrice), " ", uintToBytes(allowedPrice) ) ) ); } else { require( actualMarketPrice >= allowedPrice, string( abi.encodePacked( "short: slippage exceeded ", uintToBytes(actualMarketPrice), " ", uintToBytes(allowedPrice) ) ) ); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IOperators { function getOperatorLevel(address op) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import {Order, OrderType, OrderStatus, AddPositionOrder, DecreasePositionOrder, PositionTrigger} from "../structs.sol"; interface IOrderVault { function addTrailingStop(address _account, uint256 _posId, uint256[] memory _params) external; function addTriggerOrders( uint256 _posId, address _account, bool[] memory _isTPs, uint256[] memory _prices, uint256[] memory _amountPercents ) external; function cancelPendingOrder(address _account, uint256 _posId) external; function updateOrder( uint256 _posId, uint256 _positionType, uint256 _collateral, uint256 _size, OrderStatus _status ) external; function cancelMarketOrder(uint256 _posId) external; function createNewOrder( uint256 _posId, address _accout, bool _isLong, uint256 _tokenId, uint256 _positionType, uint256[] memory _params, address _refer ) external; function createAddPositionOrder( address _owner, uint256 _posId, uint256 _collateralDelta, uint256 _sizeDelta, uint256 _allowedPrice, uint256 _fee ) external; function createDecreasePositionOrder(uint256 _posId, uint256 _sizeDelta, uint256 _allowedPrice) external; function cancelAddPositionOrder(uint256 _posId) external; function deleteAddPositionOrder(uint256 _posId) external; function deleteDecreasePositionOrder(uint256 _posId) external; function getOrder(uint256 _posId) external view returns (Order memory); function getAddPositionOrder(uint256 _posId) external view returns (AddPositionOrder memory); function getDecreasePositionOrder(uint256 _posId) external view returns (DecreasePositionOrder memory); function getTriggerOrderInfo(uint256 _posId) external view returns (PositionTrigger memory); function triggerForOpenOrders(uint256 _posId) external; function triggerForTPSL(uint256 _posId) external; function updateTrailingStop(uint256 _posId) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import {Position, Order, OrderType, PaidFees} from "../structs.sol"; interface IPositionVault { function newPositionOrder( address _account, uint256 _tokenId, bool _isLong, OrderType _orderType, uint256[] memory _params, address _refer ) external; function addOrRemoveCollateral(address _account, uint256 _posId, bool isPlus, uint256 _amount) external; function createAddPositionOrder( address _account, uint256 _posId, uint256 _collateralDelta, uint256 _sizeDelta, uint256 _allowedPrice ) external; function createDecreasePositionOrder( uint256 _posId, address _account, uint256 _sizeDelta, uint256 _allowedPrice ) external; function increasePosition( uint256 _posId, address _account, uint256 _tokenId, bool _isLong, uint256 _price, uint256 _collateralDelta, uint256 _sizeDelta, uint256 _fee ) external; function decreasePosition(uint256 _posId, uint256 _price, uint256 _sizeDelta) external; function decreasePositionByOrderVault(uint256 _posId, uint256 _price, uint256 _sizeDelta) external; function removeUserAlivePosition(address _user, uint256 _posId) external; function removeUserOpenOrder(address _user, uint256 _posId) external; function lastPosId() external view returns (uint256); function queueIndex() external view returns (uint256); function getNumOfUnexecuted() external view returns (uint256); function queuePosIds(uint256 _id) external view returns (uint256); function getPosition(uint256 _posId) external view returns (Position memory); function getUserPositionIds(address _account) external view returns (uint256[] memory); function getUserOpenOrderIds(address _account) external view returns (uint256[] memory); function getPaidFees(uint256 _posId) external view returns (PaidFees memory); function getVaultUSDBalance() external view returns (uint256); function executeOrders(uint256 numOfOrders) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@pythnetwork/pyth-sdk-solidity/IPyth.sol"; interface IPriceManager { function assets(uint256 _assetId) external view returns ( string memory symbol, bytes32 pythId, uint256 price, uint256 timestamp, uint256 allowedStaleness, uint256 allowedDeviation, uint256 maxLeverage, uint256 tokenDecimals ); function getLastPrice(uint256 _tokenId) external view returns (uint256); function getPythLastPrice(uint256 _assetId, bool _requireFreshness) external view returns (uint256); function pyth() external view returns (IPyth); function maxLeverage(uint256 _tokenId) external view returns (uint256); function tokenToUsd(address _token, uint256 _tokenAmount) external view returns (uint256); function usdToToken(address _token, uint256 _usdAmount) external view returns (uint256); function setPrice(uint256 _assetId, uint256 _price, uint256 _ts) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface ISettingsManager { function decreaseOpenInterest(uint256 _tokenId, address _sender, bool _isLong, uint256 _amount) external; function increaseOpenInterest(uint256 _tokenId, address _sender, bool _isLong, uint256 _amount) external; function openInterestPerAssetPerSide(uint256 _tokenId, bool _isLong) external view returns (uint256); function openInterestPerUser(address _sender) external view returns (uint256); function bountyPercent() external view returns (uint32, uint32); function checkBanList(address _delegate) external view returns (bool); function checkDelegation(address _master, address _delegate) external view returns (bool); function minCollateral() external view returns (uint256); function closeDeltaTime() external view returns (uint256); function expiryDuration() external view returns (uint256); function selfExecuteCooldown() external view returns (uint256); function cooldownDuration() external view returns (uint256); function liquidationPendingTime() external view returns (uint256); function depositFee(address token) external view returns (uint256); function withdrawFee(address token) external view returns (uint256); function feeManager() external view returns (address); function feeRewardBasisPoints() external view returns (uint256); function defaultBorrowFeeFactor() external view returns (uint256); function borrowFeeFactor(uint256 tokenId) external view returns (uint256); function totalOpenInterest() external view returns (uint256); function basisFundingRateFactor() external view returns (uint256); function deductFeePercent(address _account) external view returns (uint256); function referrerTiers(address _referrer) external view returns (uint256); function tierFees(uint256 _tier) external view returns (uint256); function fundingIndex(uint256 _tokenId) external view returns (int256); function fundingRateFactor(uint256 _tokenId) external view returns (uint256); function slippageFactor(uint256 _tokenId) external view returns (uint256); function getFundingFee( uint256 _tokenId, bool _isLong, uint256 _size, int256 _fundingIndex ) external view returns (int256); function getFundingChange(uint256 _tokenId) external view returns (int256); function getBorrowRate(uint256 _tokenId, bool _isLong) external view returns (uint256); function getFundingRate(uint256 _tokenId) external view returns (int256); function getTradingFee( address _account, uint256 _tokenId, bool _isLong, uint256 _sizeDelta ) external view returns (uint256); function getPnl( uint256 _tokenId, bool _isLong, uint256 _size, uint256 _averagePrice, uint256 _lastPrice, uint256 _lastIncreasedTime, uint256 _accruedBorrowFee, int256 _fundingIndex ) external view returns (int256, int256, int256); function updateFunding(uint256 _tokenId) external; function getBorrowFee( uint256 _borrowedSize, uint256 _lastIncreasedTime, uint256 _tokenId, bool _isLong ) external view returns (uint256); function getUndiscountedTradingFee( uint256 _tokenId, bool _isLong, uint256 _sizeDelta ) external view returns (uint256); function getReferFee(address _refer) external view returns (uint256); function getReferFeeAndTraderRebate(address _refer) external view returns (uint256 referFee, uint256 traderRebate); function platformFees(address _platform) external view returns (uint256); function getPriceWithSlippage( uint256 _tokenId, bool _isLong, uint256 _size, uint256 _price ) external view returns (uint256); function getDelegates(address _master) external view returns (address[] memory); function isDeposit(address _token) external view returns (bool); function isStakingEnabled(address _token) external view returns (bool); function isUnstakingEnabled(address _token) external view returns (bool); function isIncreasingPositionDisabled(uint256 _tokenId) external view returns (bool); function isDecreasingPositionDisabled(uint256 _tokenId) external view returns (bool); function isWhitelistedFromCooldown(address _addr) external view returns (bool); function isWhitelistedFromTransferCooldown(address _addr) external view returns (bool); function isWithdraw(address _token) external view returns (bool); function lastFundingTimes(uint256 _tokenId) external view returns (uint256); function liquidateThreshold(uint256) external view returns (uint256); function tradingFee(uint256 _tokenId, bool _isLong) external view returns (uint256); function defaultMaxOpenInterestPerUser() external view returns (uint256); function maxProfitPercent(uint256 _tokenId) external view returns (uint256); function defaultMaxProfitPercent() external view returns (uint256); function maxOpenInterestPerAssetPerSide(uint256 _tokenId, bool _isLong) external view returns (uint256); function priceMovementPercent() external view returns (uint256); function maxOpenInterestPerUser(address _account) external view returns (uint256); function stakingFee(address token) external view returns (uint256); function unstakingFee(address token) external view returns (uint256); function triggerGasFee() external view returns (uint256); function marketOrderGasFee() external view returns (uint256); function maxTriggerPerPosition() external view returns (uint256); function maxFundingRate() external view returns (uint256); function maxTotalNslp() external view returns (uint256); function minProfitDurations(uint256 tokenId) external view returns (uint256); function maxCloseProfits(uint256 tokenId) external view returns (uint256); function maxCloseProfitPercents(uint256 tokenId) external view returns (uint256); function getTierInfo(address _account) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IVault { function accountDeltaIntoTotalUSD(bool _isIncrease, uint256 _delta) external; function distributeFee(uint256 _fee, address _refer, address _trader) external; function takeNSUSDIn(address _account, uint256 _amount) external; function takeNSUSDOut(address _account, uint256 _amount) external; function lastStakedAt(address _account) external view returns (uint256); function getVaultUSDBalance() external view returns (uint256); function getNSLPPrice() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; enum OrderType { MARKET, LIMIT, STOP, STOP_LIMIT } enum OrderStatus { NONE, PENDING, FILLED, CANCELED } enum TriggerStatus { NONE, PENDING, OPEN, TRIGGERED, CANCELLED } struct Order { OrderStatus status; uint256 lmtPrice; uint256 size; uint256 collateral; uint256 positionType; uint256 stepAmount; uint256 stepType; uint256 stpPrice; uint256 timestamp; } struct AddPositionOrder { address owner; uint256 collateral; uint256 size; uint256 allowedPrice; uint256 timestamp; uint256 fee; } struct DecreasePositionOrder { uint256 size; uint256 allowedPrice; uint256 timestamp; } struct Position { address owner; address refer; bool isLong; uint256 tokenId; uint256 averagePrice; uint256 collateral; int256 fundingIndex; uint256 lastIncreasedTime; uint256 size; uint256 accruedBorrowFee; } struct PaidFees { uint256 paidPositionFee; uint256 paidBorrowFee; int256 paidFundingFee; } struct Temp { uint256 a; uint256 b; uint256 c; uint256 d; uint256 e; } struct TriggerInfo { bool isTP; uint256 amountPercent; uint256 createdAt; uint256 price; uint256 triggeredAmount; uint256 triggeredAt; TriggerStatus status; } struct PositionTrigger { TriggerInfo[] triggers; }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"data","type":"uint256[]"}],"name":"AddTrailingStop","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isTP","type":"bool"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountPercent","type":"uint256"},{"indexed":false,"internalType":"enum TriggerStatus","name":"status","type":"uint8"}],"name":"AddTriggerOrders","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isTP","type":"bool"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountPercent","type":"uint256"}],"name":"EditTriggerOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"ExecuteTriggerOrders","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"positionType","type":"uint256"},{"indexed":false,"internalType":"enum OrderStatus","name":"orderStatus","type":"uint8"}],"name":"FinishOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"positionType","type":"uint256"},{"indexed":false,"internalType":"enum OrderStatus","name":"orderStatus","type":"uint8"},{"indexed":false,"internalType":"uint256[]","name":"triggerData","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"refer","type":"address"}],"name":"NewOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"positionType","type":"uint256"},{"indexed":false,"internalType":"enum OrderStatus","name":"orderStatus","type":"uint8"}],"name":"UpdateOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stpPrice","type":"uint256"}],"name":"UpdateTrailingStop","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"enum TriggerStatus","name":"status","type":"uint8"}],"name":"UpdateTriggerOrderStatus","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"addPositionOrders","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"allowedPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"uint256[]","name":"_params","type":"uint256[]"}],"name":"addTrailingStop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool[]","name":"_isTPs","type":"bool[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"},{"internalType":"uint256[]","name":"_amountPercents","type":"uint256[]"}],"name":"addTriggerOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"cancelAddPositionOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"cancelAllTriggerOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"cancelMarketOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"cancelPendingOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"uint256","name":"_orderId","type":"uint256"}],"name":"cancelTriggerOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"}],"name":"cancelTriggerOrderPacked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"uint256","name":"_allowedPrice","type":"uint256"},{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"createAddPositionOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"uint256","name":"_allowedPrice","type":"uint256"}],"name":"createDecreasePositionOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_positionType","type":"uint256"},{"internalType":"uint256[]","name":"_params","type":"uint256[]"},{"internalType":"address","name":"_refer","type":"address"}],"name":"createNewOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"decreasePositionOrders","outputs":[{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"allowedPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"deleteAddPositionOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"deleteDecreasePositionOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"uint256","name":"_orderId","type":"uint256"},{"internalType":"bool","name":"_isTP","type":"bool"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_amountPercent","type":"uint256"}],"name":"editTriggerOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"getAddPositionOrder","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"allowedPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"internalType":"struct AddPositionOrder","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"getAliveTriggerIds","outputs":[{"internalType":"uint256[]","name":"_aliveTriggerIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"getDecreasePositionOrder","outputs":[{"components":[{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"allowedPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct DecreasePositionOrder","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"getOrder","outputs":[{"components":[{"internalType":"enum OrderStatus","name":"status","type":"uint8"},{"internalType":"uint256","name":"lmtPrice","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"positionType","type":"uint256"},{"internalType":"uint256","name":"stepAmount","type":"uint256"},{"internalType":"uint256","name":"stepType","type":"uint256"},{"internalType":"uint256","name":"stpPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct Order","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"getTriggerOrderInfo","outputs":[{"components":[{"components":[{"internalType":"bool","name":"isTP","type":"bool"},{"internalType":"uint256","name":"amountPercent","type":"uint256"},{"internalType":"uint256","name":"createdAt","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"triggeredAmount","type":"uint256"},{"internalType":"uint256","name":"triggeredAt","type":"uint256"},{"internalType":"enum TriggerStatus","name":"status","type":"uint8"}],"internalType":"struct TriggerInfo[]","name":"triggers","type":"tuple[]"}],"internalType":"struct PositionTrigger","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IPriceManager","name":"_priceManager","type":"address"},{"internalType":"contract IPositionVault","name":"_positionVault","type":"address"},{"internalType":"contract ISettingsManager","name":"_settingsManager","type":"address"},{"internalType":"contract IVault","name":"_vault","type":"address"},{"internalType":"contract IOperators","name":"_operators","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"orders","outputs":[{"internalType":"enum OrderStatus","name":"status","type":"uint8"},{"internalType":"uint256","name":"lmtPrice","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"positionType","type":"uint256"},{"internalType":"uint256","name":"stepAmount","type":"uint256"},{"internalType":"uint256","name":"stepType","type":"uint256"},{"internalType":"uint256","name":"stpPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"triggerForOpenOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"triggerForTPSL","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"uint256","name":"_positionType","type":"uint256"},{"internalType":"uint256","name":"_collateral","type":"uint256"},{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"enum OrderStatus","name":"_status","type":"uint8"}],"name":"updateOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"updateTrailingStop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_params","type":"uint256[]"}],"name":"validateTrailingStopInputData","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"bool","name":"_raise","type":"bool"}],"name":"validateTrailingStopPrice","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50614a22806100206000396000f3fe608060405234801561001057600080fd5b50600436106101da5760003560e01c806396759c9411610104578063ba2fcc73116100a2578063e7f3e0a511610071578063e7f3e0a51461056c578063ef2ae9501461057f578063f32af30114610592578063f6374340146105b257600080fd5b8063ba2fcc7314610513578063c980106814610526578063d09ef24114610539578063d950049e1461055957600080fd5b8063a0cb3bb3116100de578063a0cb3bb314610468578063a1ccbf641461047b578063a3e895b41461048e578063a85c38ef146104a157600080fd5b806396759c941461040d5780639f83930714610420578063a07729601461045557600080fd5b806358eda3ab1161017c5780638129fc1c1161014b5780638129fc1c146103cc578063860a19f1146103d457806386a2c686146103e75780638e4fdc6a146103fa57600080fd5b806358eda3ab146102ec578063678f4c7f146102ff578063688aa7f31461034957806372b3f27a1461036957600080fd5b8063359ef75b116101b8578063359ef75b14610290578063381f89b8146102a35780633f9c2f93146102b6578063518f6563146102d957600080fd5b8063102b9864146101df5780631119bacf146101f45780633407c8ea1461027d575b600080fd5b6101f26101ed366004613eb1565b6105c5565b005b610241610202366004613eb1565b6039602052600090815260409020805460018201546002830154600384015460048501546005909501546001600160a01b039094169492939192909186565b604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015260a082015260c0015b60405180910390f35b6101f261028b366004613eb1565b610616565b6101f261029e366004613edf565b610a85565b6101f26102b1366004613eb1565b610cc2565b6102c96102c4366004613f5e565b610d03565b6040519015158152602001610274565b6101f26102e73660046140a8565b610fb2565b6101f26102fa36600461413c565b6110e9565b61032e61030d366004613eb1565b603a6020526000908152604090208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610274565b61035c610357366004613eb1565b6111f6565b60405161027491906141c3565b61037c610377366004613eb1565b6112af565b604051610274919081516001600160a01b031681526020808301519082015260408083015190820152606080830151908201526080808301519082015260a0918201519181019190915260c00190565b6101f2611353565b6101f26103e23660046141d6565b611463565b6101f26103f5366004613eb1565b61171f565b6101f261040836600461422f565b61193d565b6101f261041b366004613eb1565b61197b565b61043361042e366004613eb1565b61205a565b6040805182518152602080840151908201529181015190820152606001610274565b6101f2610463366004613eb1565b6120b7565b6101f2610476366004613eb1565b61234a565b6101f2610489366004614272565b61249f565b6101f261049c366004614377565b612978565b6104fe6104af366004613eb1565b60386020526000908152604090208054600182015460028301546003840154600485015460058601546006870154600788015460089098015460ff909716979596949593949293919290919089565b604051610274999897969594939291906143c3565b6101f2610521366004614410565b612993565b6101f2610534366004613eb1565b612c3d565b61054c610547366004613eb1565b612d8e565b6040516102749190614459565b6101f26105673660046144c5565b612e7c565b6101f261057a366004613eb1565b612f4a565b6102c961058d3660046144f1565b612fb2565b6105a56105a0366004613eb1565b61318e565b6040516102749190614536565b6101f26105c03660046145d2565b613280565b6034546001600160a01b031633146105f85760405162461bcd60e51b81526004016105ef906145fe565b60405180910390fd5b6000908152603a602052604081208181556001810182905560020155565b61061e6135d3565b60345460405163eb02c30160e01b8152600481018390526000916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561066457600080fd5b505afa158015610678573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069c9190614646565b600083815260386020526040808220603354606085015192516365fa2f7f60e01b81526004810193909352939450926001600160a01b0316906365fa2f7f9060240160206040518083038186803b1580156106f657600080fd5b505afa15801561070a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072e91906146e2565b83519091506001600160a01b03163314806107c3575060375460405163df07560560e01b81523360048201526001916001600160a01b03169063df0756059060240160206040518083038186803b15801561078857600080fd5b505afa15801561079c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c091906146e2565b10155b61080f5760405162461bcd60e51b815260206004820152601760248201527f7570646174655453746f70206e6f7420616c6c6f77656400000000000000000060448201526064016105ef565b6000836101000151116108595760405162461bcd60e51b8152602060048201526012602482015271706f736974696f6e206e6f7420616c69766560701b60448201526064016105ef565b61086e83606001518460400151866001610d03565b5060078201546040840151156108d1576006830154156108b857620186a08360050154620186a061089f9190614711565b6108a99084614728565b6108b3919061475d565b6108c7565b60058301546108c79083614711565b6007840155610920565b60068301541561090b57620186a08360050154620186a06108f29190614771565b6108fc9084614728565b610906919061475d565b61091a565b600583015461091a9083614771565b60078401555b600081846007015411156109455781846007015461093e9190614711565b9050610957565b60078401546109549083614711565b90505b603560009054906101000a90046001600160a01b03166001600160a01b03166361695ebe6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109a557600080fd5b505afa1580156109b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109dd91906146e2565b826109eb620186a084614728565b6109f5919061475d565b1015610a355760405162461bcd60e51b815260206004820152600f60248201526e085c1c9a58d9481b5bdd995b595b9d608a1b60448201526064016105ef565b60078401546040805188815260208101929092527fd2cd743a94fbf08b6043f0fc643411e183fbbdfc7c629117e13bcd64edf1ad93910160405180910390a15050505050610a8260018055565b50565b603754600160a01b900460ff1615610acd5760405162461bcd60e51b815260206004820152600b60248201526a1a5b9a5d1a585b1a5e995960aa1b60448201526064016105ef565b6001600160a01b0385163b610b1b5760405162461bcd60e51b81526020600482015260146024820152731c1c9a58d953585b9859d95c881a5b9d985b1a5960621b60448201526064016105ef565b6001600160a01b0384163b610b6a5760405162461bcd60e51b81526020600482015260156024820152741c1bdcda5d1a5bdb95985d5b1d081a5b9d985b1a59605a1b60448201526064016105ef565b6001600160a01b0383163b610bc15760405162461bcd60e51b815260206004820152601760248201527f73657474696e67734d616e6167657220696e76616c696400000000000000000060448201526064016105ef565b6001600160a01b0382163b610c085760405162461bcd60e51b815260206004820152600d60248201526c1d985d5b1d081a5b9d985b1a59609a1b60448201526064016105ef565b6001600160a01b0381163b610c565760405162461bcd60e51b81526020600482015260146024820152731bdc195c985d1bdc9cc81a5cc81a5b9d985b1a5960621b60448201526064016105ef565b603380546001600160a01b039687166001600160a01b031991821617909155603580549487169482169490941790935560348054948616948416949094179093556036805491851691909216179055603780546001600160a81b0319169190921617600160a01b179055565b610cca6135d3565b6000610cda600160801b8361475d565b90506000610cec600160801b84614789565b9050610cf88282613633565b5050610a8260018055565b60008281526038602052604080822081516101208101909252805483929190829060ff166003811115610d3857610d38614399565b6003811115610d4957610d49614399565b8152600182015460208201526002820154604080830191909152600383015460608301526004808401546080840152600584015460a0840152600684015460c0840152600784015460e08401526008909301546101009092019190915260335490516365fa2f7f60e01b81529182018990529192506000916001600160a01b0316906365fa2f7f9060240160206040518083038186803b158015610dec57600080fd5b505afa158015610e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2491906146e2565b905060008615610e815760c0830151610e52578260a001518360e00151610e4b9190614771565b9050610ed0565b60a0830151610e6490620186a0614711565b620186a08460e00151610e779190614728565b610e4b919061475d565b60c0830151610e9e578260a001518360e00151610e4b9190614711565b60a0830151610eb090620186a0614771565b620186a08460e00151610ec39190614728565b610ecd919061475d565b90505b6000878015610ef15750600184516003811115610eef57610eef614399565b145b8015610f01575060048460800151145b8015610f0d5750828211155b15610f1a57506001610f5f565b87158015610f3a5750600184516003811115610f3857610f38614399565b145b8015610f4a575060048460800151145b8015610f565750828210155b15610f5f575060015b8515610fa45780610fa45760405162461bcd60e51b815260206004820152600f60248201526e1c1c9a58d9481a5b98dbdc9c9958dd608a1b60448201526064016105ef565b93505050505b949350505050565b6034546001600160a01b03163314610fdc5760405162461bcd60e51b81526004016105ef906145fe565b6000878152603860205260409020805460ff19166001178155600481018490558251839060029081106110115761101161479d565b60200260200101518160030181905550826003815181106110345761103461479d565b60200260200101518160020181905550826000815181106110575761105761479d565b602002602001015181600101819055508260018151811061107a5761107a61479d565b60209081029190910101516007820155426008820155600481015481546040517fb09a2e4a32528ccab1e46bd7e612b276fba44b21959fe5baf15da0eab2deda6c926110d7928c928c928c928c9260ff909116908b908b906147b3565b60405180910390a15050505050505050565b6034546001600160a01b031633146111135760405162461bcd60e51b81526004016105ef906145fe565b600085815260396020526040902060020154156111725760405162461bcd60e51b815260206004820152601f60248201527f616464506f736974696f6e4f7264657220616c7265616479206578697374730060448201526064016105ef565b6040805160c0810182526001600160a01b039788168152602080820196875281830195865260608201948552426080830190815260a083019485526000988952603990915291909620955186546001600160a01b03191697169690961785559251600185015590516002840155516003830155915160048201559051600590910155565b6000818152603c602052604081206060919061121190613837565b90508067ffffffffffffffff81111561122c5761122c613fa8565b604051908082528060200260200182016040528015611255578160200160208202803683370190505b50915060005b818110156112a8576000848152603c6020526040902061127b9082613847565b83828151811061128d5761128d61479d565b60209081029190910101526112a181614816565b905061125b565b5050919050565b6112f16040518060c0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081525090565b50600090815260396020908152604091829020825160c08101845281546001600160a01b03168152600182015492810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a082015290565b600054610100900460ff16158080156113735750600054600160ff909116105b8061138d5750303b15801561138d575060005460ff166001145b6113f05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105ef565b6000805460ff191660011790558015611413576000805461ff0019166101001790555b61141b61385a565b8015610a82576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b6036546001600160a01b0316331461148d5760405162461bcd60e51b81526004016105ef90614831565b600082815260386020526040808220603454915163eb02c30160e01b8152600481018690529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156114e157600080fd5b505afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115199190614646565b905080600001516001600160a01b0316856001600160a01b0316146115915760405162461bcd60e51b815260206004820152602860248201527f796f7520617265206e6f7420616c6c6f77656420746f2061646420747261696c6044820152670696e672073746f760c41b60648201526084016105ef565b6000816101000151116115db5760405162461bcd60e51b8152602060048201526012602482015271706f736974696f6e206e6f7420616c69766560701b60448201526064016105ef565b6115e483612fb2565b50826001815181106115f8576115f861479d565b6020026020010151816101000151101561161c576101008101516002830155611640565b8260018151811061162f5761162f61479d565b602002602001015182600201819055505b826000815181106116535761165361479d565b60209081029190910101516003830155815460ff191660011782556004808301558251839060029081106116895761168961479d565b60200260200101518260060181905550826003815181106116ac576116ac61479d565b60200260200101518260070181905550826004815181106116cf576116cf61479d565b602002602001015182600501819055507fa60c001cf7dd3d1abac8fc1f3ff25b3fb3e93143c213398697f898adb861f76b8484604051611710929190614855565b60405180910390a15050505050565b6034546001600160a01b031633146117495760405162461bcd60e51b81526004016105ef906145fe565b60008181526038602052604090206002015415610a8257600081815260386020526040808220805460ff19166003178155603454915163eb02c30160e01b8152600481018590529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156117bf57600080fd5b505afa1580156117d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f79190614646565b60365481516034546040516306393ef960e41b8152600481018890529394506001600160a01b039283169363cf7c72159390911690636393ef909060240160606040518083038186803b15801561184d57600080fd5b505afa158015611861573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611885919061486e565b5160038601546118959190614771565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156118db57600080fd5b505af11580156118ef573d6000803e3d6000fd5b50505050600482015482546040517f11284c7a8f4d9021e9e1f15c19e4d8fadc91365c1ce8a71ce57245c673cc927a9261193092879260ff909116906148ca565b60405180910390a1505050565b6034546001600160a01b031633146119675760405162461bcd60e51b81526004016105ef906145fe565b611974858585858561388b565b5050505050565b6119836135d3565b60375460405163df07560560e01b815233600482015260019182916001600160a01b039091169063df0756059060240160206040518083038186803b1580156119cb57600080fd5b505afa1580156119df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0391906146e2565b1015611a445760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b21037b832b930ba37b960811b60448201526064016105ef565b60345460405163eb02c30160e01b8152600481018490526000916001600160a01b03169063eb02c301906024016101406040518083038186803b158015611a8a57600080fd5b505afa158015611a9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac29190614646565b6000848152603860205260408082208151610120810190925280549394509192909190829060ff166003811115611afb57611afb614399565b6003811115611b0c57611b0c614399565b81526001828101546020830152600283015460408301526003830154606083015260048301546080830152600583015460a0830152600683015460c0830152600783015460e08301526008909201546101009091015290915081516003811115611b7857611b78614399565b14611bb95760405162461bcd60e51b81526020600482015260116024820152706f72646572206e6f742070656e64696e6760781b60448201526064016105ef565b60335460608301516040516365fa2f7f60e01b815260048101919091526000916001600160a01b0316906365fa2f7f9060240160206040518083038186803b158015611c0457600080fd5b505afa158015611c18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c3c91906146e2565b9050600182608001511415611e4d57826040015115611c7e578082602001511015611c795760405162461bcd60e51b81526004016105ef906148e5565b611ca2565b8082602001511115611ca25760405162461bcd60e51b81526004016105ef906148e5565b6034548351606080860151604080880151928701518782015191516306393ef960e41b8152600481018c90526001600160a01b0390961695638f3d5864958c95909493909289929091908990636393ef909060240160606040518083038186803b158015611d0f57600080fd5b505afa158015611d23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d47919061486e565b5160405160e08a901b6001600160e01b031916815260048101989098526001600160a01b03909616602488015260448701949094529115156064860152608485015260a484015260c483015260e482015261010401600060405180830381600087803b158015611db657600080fd5b505af1158015611dca573d6000803e3d6000fd5b50505050611de1858360800151600080600261388b565b60345483516040516308f474d160e11b81526001600160a01b039182166004820152602481018890529116906311e8e9a290604401600060405180830381600087803b158015611e3057600080fd5b505af1158015611e44573d6000803e3d6000fd5b5050505061204d565b600282608001511415611eac57826040015115611e8857808260e001511115611c795760405162461bcd60e51b81526004016105ef906148e5565b808260e001511015611ca25760405162461bcd60e51b81526004016105ef906148e5565b600382608001511415611f2f57826040015115611eec57808260e001511115611ee75760405162461bcd60e51b81526004016105ef906148e5565b611f10565b808260e001511015611f105760405162461bcd60e51b81526004016105ef906148e5565b611f2a85600184606001518560400151866000015161388b565b61204d565b60048260800151141561201557826040015115611f6f57808260e001511015611f6a5760405162461bcd60e51b81526004016105ef906148e5565b611f93565b808260e001511115611f935760405162461bcd60e51b81526004016105ef906148e5565b60345460408381015190516336a6d6ff60e11b8152600481018890526024810184905260448101919091526001600160a01b0390911690636d4dadfe90606401600060405180830381600087803b158015611fed57600080fd5b505af1158015612001573d6000803e3d6000fd5b50505050611f2a856000806000600261388b565b60405162461bcd60e51b815260206004820152600d60248201526c21706f736974696f6e5479706560981b60448201526064016105ef565b50505050610a8260018055565b61207e60405180606001604052806000815260200160008152602001600081525090565b506000908152603a6020908152604091829020825160608101845281548152600182015492810192909252600201549181019190915290565b6120bf6135d3565b6000818152603b6020526040808220603454915163eb02c30160e01b8152600481018590529092916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561211357600080fd5b505afa158015612127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214b9190614646565b80519091506001600160a01b031633146121775760405162461bcd60e51b81526004016105ef9061490e565b6000838152603c6020526040812061218e90613837565b9050600081116121d45760405162461bcd60e51b8152602060048201526011602482015270185b1c9958591e4818d85b98d95b1b1959607a1b60448201526064016105ef565b60008167ffffffffffffffff8111156121ef576121ef613fa8565b604051908082528060200260200182016040528015612218578160200160208202803683370190505b50905060005b828110156122ea576000868152603c6020526040812061223e9083613847565b905060008660000182815481106122575761225761479d565b600091825260209091206006600790920201908101805460ff191660049081179091556040519192507f30c1d870abfaca592f3207107a071dddbb1e81de2169bc209f6eb6fb3633f458916122b0918b91869190614933565b60405180910390a1818484815181106122cb576122cb61479d565b6020026020010181815250505050806122e390614816565b905061221e565b5060005b8281101561233c5761232b603c600088815260200190815260200160002083838151811061231e5761231e61479d565b602002602001015161398d565b5061233581614816565b90506122ee565b5050505050610a8260018055565b6034546001600160a01b031633146123745760405162461bcd60e51b81526004016105ef906145fe565b600081815260396020908152604091829020825160c08101845281546001600160a01b03168152600182015492810192909252600281015492820183905260038101546060830152600481015460808301526005015460a0820152901561249b57603654815160a083015160208401516001600160a01b039093169263cf7c7215929161240091614771565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561244657600080fd5b505af115801561245a573d6000803e3d6000fd5b505050600083815260396020526040812080546001600160a01b03191681556001810182905560028101829055600381018290556004810182905560050155505b5050565b6036546001600160a01b031633146124c95760405162461bcd60e51b81526004016105ef90614831565b60345460405163eb02c30160e01b8152600481018790526000916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561250f57600080fd5b505afa158015612523573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125479190614646565b9050846001600160a01b031681600001516001600160a01b03161461257e5760405162461bcd60e51b81526004016105ef9061490e565b83518351148015612590575081518351145b6125cd5760405162461bcd60e51b815260206004820152600e60248201526d696e76616c696420706172616d7360901b60448201526064016105ef565b600083511161260c5760405162461bcd60e51b815260206004820152600b60248201526a32b6b83a3c9037b93232b960a91b60448201526064016105ef565b603560009054906101000a90046001600160a01b03166001600160a01b031663455321636040518163ffffffff1660e01b815260040160206040518083038186803b15801561265a57600080fd5b505afa15801561266e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061269291906146e2565b83516000888152603c602052604090206126ab90613837565b6126b59190614771565b11156126f75760405162461bcd60e51b8152602060048201526011602482015270746f6f206d616e7920747269676765727360781b60448201526064016105ef565b6000868152603b60205260408120905b845181101561296e5760008482815181106127245761272461479d565b60200260200101511180156127555750620186a084828151811061274a5761274a61479d565b602002602001015111155b6127935760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b60448201526064016105ef565b81546000898152603c602052604090206127ad9082613999565b50826000016040518060e001604052808985815181106127cf576127cf61479d565b6020026020010151151581526020018785815181106127f0576127f061479d565b602002602001015181526020014281526020018885815181106128155761281561479d565b6020026020010151815260200160008152602001600081526020016002600481111561284357612843614399565b905281546001818101845560009384526020938490208351600790930201805492151560ff1993841617815593830151848201556040830151600285015560608301516003850155608083015160048086019190915560a0840151600586015560c08401516006860180549596959194909391169184908111156128c9576128c9614399565b021790555050507ff1a13d80b3de86cec4302338b365ff08f70980dd6e2b86859a883b228c1df64689828985815181106129055761290561479d565b602002602001015189868151811061291f5761291f61479d565b60200260200101518987815181106129395761293961479d565b602002602001015160026040516129559695949392919061494e565b60405180910390a15061296781614816565b9050612707565b5050505050505050565b6129806135d3565b61298a8282613633565b61249b60018055565b61299b6135d3565b6000858152603b6020526040808220603454915163eb02c30160e01b8152600481018990529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156129ef57600080fd5b505afa158015612a03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a279190614646565b80519091506001600160a01b03163314612a535760405162461bcd60e51b81526004016105ef9061490e565b6002826000018781548110612a6a57612a6a61479d565b600091825260209091206006600790920201015460ff166004811115612a9257612a92614399565b14612ad75760405162461bcd60e51b81526020600482015260156024820152742a3934b3b3b2b927b93232b9103737ba1027b832b760591b60448201526064016105ef565b600083118015612aea5750620186a08311155b612b285760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b60448201526064016105ef565b84826000018781548110612b3e57612b3e61479d565b60009182526020909120600790910201805460ff191691151591909117905581548490839088908110612b7357612b7361479d565b90600052602060002090600702016003018190555082826000018781548110612b9e57612b9e61479d565b90600052602060002090600702016001018190555042826000018781548110612bc957612bc961479d565b906000526020600020906007020160020181905550867f338e9691e0a5bfbef1c9203b11bed24c4e218f79ce9afe2372ba6a2678424ac787878787604051612c2a949392919093845291151560208401526040830152606082015260800190565b60405180910390a2505061197460018055565b612c456135d3565b60375460405163df07560560e01b815233600482015260019182916001600160a01b039091169063df0756059060240160206040518083038186803b158015612c8d57600080fd5b505afa158015612ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc591906146e2565b1015612d065760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b21037b832b930ba37b960811b60448201526064016105ef565b600080612d12846139a5565b6034546040516336a6d6ff60e11b81526004810188905260248101839052604481018490529294509092506001600160a01b031690636d4dadfe90606401600060405180830381600087803b158015612d6a57600080fd5b505af1158015612d7e573d6000803e3d6000fd5b50505050505050610a8260018055565b612dde604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60008281526038602052604090819020815161012081019092528054829060ff166003811115612e1057612e10614399565b6003811115612e2157612e21614399565b815260018201546020820152600282015460408201526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e08201526008909101546101009091015292915050565b6034546001600160a01b03163314612ea65760405162461bcd60e51b81526004016105ef906145fe565b6000838152603a602052604090205415612f0e5760405162461bcd60e51b8152602060048201526024808201527f6465637265617365506f736974696f6e4f7264657220616c72656164792065786044820152636973747360e01b60648201526084016105ef565b604080516060810182529283526020808401928352428483019081526000958652603a9091529320915182555160018201559051600290910155565b6034546001600160a01b03163314612f745760405162461bcd60e51b81526004016105ef906145fe565b600090815260396020526040812080546001600160a01b03191681556001810182905560028101829055600381018290556004810182905560050155565b60008082600181518110612fc857612fc861479d565b6020026020010151116130155760405162461bcd60e51b8152602060048201526015602482015274747261696c696e672073697a65206973207a65726f60581b60448201526064016105ef565b60008260048151811061302a5761302a61479d565b6020026020010151118015613059575060008260038151811061304f5761304f61479d565b6020026020010151115b61309d5760405162461bcd60e51b8152602060048201526015602482015274696e76616c696420747261696c696e67206461746160581b60448201526064016105ef565b6001826002815181106130b2576130b261479d565b602002602001015111156130f75760405162461bcd60e51b815260206004820152600c60248201526b696e76616c6964207479706560a01b60448201526064016105ef565b60018260028151811061310c5761310c61479d565b6020026020010151141561318657620186a0826004815181106131315761313161479d565b6020026020010151106131865760405162461bcd60e51b815260206004820152601860248201527f70657263656e742063616e74206578636565642031303025000000000000000060448201526064016105ef565b506001919050565b6040805160208082018352606082526000848152603b8252838120845181548085028201870187529381018481529495909491938593859285015b828210156132725760008481526020908190206040805160e08101825260078602909201805460ff90811615158452600182015494840194909452600281015491830191909152600381015460608301526004808201546080840152600582015460a084015260068201549293919260c0850192169081111561324e5761324e614399565b600481111561325f5761325f614399565b81525050815260200190600101906131c9565b505050915250909392505050565b6036546001600160a01b031633146132aa5760405162461bcd60e51b81526004016105ef90614831565b600081815260386020526040808220603454915163eb02c30160e01b8152600481018590529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156132fe57600080fd5b505afa158015613312573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133369190614646565b905080600001516001600160a01b0316846001600160a01b03161461339d5760405162461bcd60e51b815260206004820152601d60248201527f596f7520617265206e6f7420616c6c6f77656420746f2063616e63656c00000060448201526064016105ef565b6001825460ff1660038111156133b5576133b5614399565b146133f35760405162461bcd60e51b815260206004820152600e60248201526d4e6f7420696e2050656e64696e6760901b60448201526064016105ef565b60048201546134445760405162461bcd60e51b815260206004820181905260248201527f6d61726b6574206f726465722063616e6e6f742062652063616e63656c6c656460448201526064016105ef565b60048260040154141561346857815460ff191660021782556000600483015561356c565b815460ff1916600317825560365481516034546040516306393ef960e41b8152600481018790526001600160a01b039384169363cf7c721593921690636393ef909060240160606040518083038186803b1580156134c557600080fd5b505afa1580156134d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134fd919061486e565b51600386015461350d9190614771565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561355357600080fd5b505af1158015613567573d6000803e3d6000fd5b505050505b60006003830181905560028301819055600183018190556007830155600482015482546040517f11284c7a8f4d9021e9e1f15c19e4d8fadc91365c1ce8a71ce57245c673cc927a926135c592879260ff909116906148ca565b60405180910390a150505050565b600260015414156136265760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105ef565b6002600155565b60018055565b6000828152603b6020526040808220603454915163eb02c30160e01b8152600481018690529092916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561368757600080fd5b505afa15801561369b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136bf9190614646565b80519091506001600160a01b031633146136eb5760405162461bcd60e51b81526004016105ef9061490e565b60028260000184815481106137025761370261479d565b600091825260209091206006600790920201015460ff16600481111561372a5761372a614399565b146137775760405162461bcd60e51b815260206004820152601a60248201527f547269676765724f72646572207761732063616e63656c6c656400000000000060448201526064016105ef565b600482600001848154811061378e5761378e61479d565b60009182526020909120600660079092020101805460ff191660018360048111156137bb576137bb614399565b02179055506000848152603c602052604090206137d8908461398d565b507f30c1d870abfaca592f3207107a071dddbb1e81de2169bc209f6eb6fb3633f45884848460000186815481106138115761381161479d565b60009182526020909120600660079092020101546040516135c593929160ff1690614933565b6000613841825490565b92915050565b60006138538383613c9b565b9392505050565b600054610100900460ff166138815760405162461bcd60e51b81526004016105ef9061498b565b613889613cc5565b565b60008581526038602052604090206004810185905560038082018590556002820184905581548391839160ff19169060019084908111156138ce576138ce614399565b021790555060028260038111156138e7576138e7614399565b14806139045750600382600381111561390257613902614399565b145b15613949577f11284c7a8f4d9021e9e1f15c19e4d8fadc91365c1ce8a71ce57245c673cc927a86868460405161393c939291906148ca565b60405180910390a1613985565b7f8fb91a48f2c30e066e4feb84035a64058e6438c9542ffffade55e1a1fdead73c86868460405161397c939291906148ca565b60405180910390a15b505050505050565b60006138538383613cec565b60006138538383613ddf565b6000818152603b6020526040808220603454915163eb02c30160e01b815260048101859052839283916001600160a01b039091169063eb02c301906024016101406040518083038186803b1580156139fc57600080fd5b505afa158015613a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a349190614646565b9050600081610100015111613a7e5760405162461bcd60e51b815260206004820152601060248201526f2a3934b3b3b2b9102737ba1027b832b760811b60448201526064016105ef565b60335460608201516040516365fa2f7f60e01b815260048101919091526000916001600160a01b0316906365fa2f7f9060240160206040518083038186803b158015613ac957600080fd5b505afa158015613add573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0191906146e2565b905060005b6000878152603c60205260409020613b1d90613837565b811015613c5e576000878152603c60205260408120613b3c9083613847565b90506000856000018281548110613b5557613b5561479d565b600091825260209091206007909102016006810154815460408801516003840154939450613b8d9360ff938416939092169188613e2e565b15613c4b576000620186a08260010154876101000151613bad9190614728565b613bb7919061475d565b6004830181905542600584015560068301805460ff1916600317905560008b8152603c60205260409020909150613bee908461398d565b506004820154604080518c815260208101929092528101849052606081018690527f70d540360d56572a2bde588895f25818d664218b09fcca5e9d0df0f8260665749060800160405180910390a199939850929650505050505050565b505080613c5790614816565b9050613b06565b5060405162461bcd60e51b815260206004820152601160248201527074726967676572206e6f7420726561647960781b60448201526064016105ef565b6000826000018281548110613cb257613cb261479d565b9060005260206000200154905092915050565b600054610100900460ff1661362d5760405162461bcd60e51b81526004016105ef9061498b565b60008181526001830160205260408120548015613dd5576000613d10600183614711565b8554909150600090613d2490600190614711565b9050818114613d89576000866000018281548110613d4457613d4461479d565b9060005260206000200154905080876000018481548110613d6757613d6761479d565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613d9a57613d9a6149d6565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050613841565b6000915050613841565b6000818152600183016020526040812054613e2657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155613841565b506000613841565b60006002866004811115613e4457613e44614399565b14613e5157506000613ea8565b8415613e80578315613e7157828210613e6c57506001613ea8565b613ea4565b828211613e6c57506001613ea8565b8315613e9557828211613e6c57506001613ea8565b828210613ea457506001613ea8565b5060005b95945050505050565b600060208284031215613ec357600080fd5b5035919050565b6001600160a01b0381168114610a8257600080fd5b600080600080600060a08688031215613ef757600080fd5b8535613f0281613eca565b94506020860135613f1281613eca565b93506040860135613f2281613eca565b92506060860135613f3281613eca565b91506080860135613f4281613eca565b809150509295509295909350565b8015158114610a8257600080fd5b60008060008060808587031215613f7457600080fd5b843593506020850135613f8681613f50565b9250604085013591506060850135613f9d81613f50565b939692955090935050565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff81118282101715613fe257613fe2613fa8565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561401157614011613fa8565b604052919050565b600067ffffffffffffffff82111561403357614033613fa8565b5060051b60200190565b600082601f83011261404e57600080fd5b8135602061406361405e83614019565b613fe8565b82815260059290921b8401810191818101908684111561408257600080fd5b8286015b8481101561409d5780358352918301918301614086565b509695505050505050565b600080600080600080600060e0888a0312156140c357600080fd5b8735965060208801356140d581613eca565b955060408801356140e581613f50565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561410f57600080fd5b61411b8a828b0161403d565b92505060c088013561412c81613eca565b8091505092959891949750929550565b60008060008060008060c0878903121561415557600080fd5b863561416081613eca565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b600081518084526020808501945080840160005b838110156141b85781518752958201959082019060010161419c565b509495945050505050565b6020815260006138536020830184614188565b6000806000606084860312156141eb57600080fd5b83356141f681613eca565b925060208401359150604084013567ffffffffffffffff81111561421957600080fd5b6142258682870161403d565b9150509250925092565b600080600080600060a0868803121561424757600080fd5b85359450602086013593506040860135925060608601359150608086013560048110613f4257600080fd5b600080600080600060a0868803121561428a57600080fd5b8535945060208087013561429d81613eca565b9450604087013567ffffffffffffffff808211156142ba57600080fd5b818901915089601f8301126142ce57600080fd5b81356142dc61405e82614019565b81815260059190911b8301840190848101908c8311156142fb57600080fd5b938501935b8285101561432257843561431381613f50565b82529385019390850190614300565b97505050606089013592508083111561433a57600080fd5b6143468a848b0161403d565b9450608089013592508083111561435c57600080fd5b505061436a8882890161403d565b9150509295509295909350565b6000806040838503121561438a57600080fd5b50508035926020909101359150565b634e487b7160e01b600052602160045260246000fd5b600481106143bf576143bf614399565b9052565b61012081016143d2828c6143af565b602082019990995260408101979097526060870195909552608086019390935260a085019190915260c084015260e083015261010090910152919050565b600080600080600060a0868803121561442857600080fd5b8535945060208601359350604086013561444181613f50565b94979396509394606081013594506080013592915050565b60006101208201905061446d8284516143af565b6020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525092915050565b6000806000606084860312156144da57600080fd5b505081359360208301359350604090920135919050565b60006020828403121561450357600080fd5b813567ffffffffffffffff81111561451a57600080fd5b610faa8482850161403d565b600581106143bf576143bf614399565b60006020808352604080840185518384870152818151808452606093508388019150858301925060005b818110156145c45783518051151584528781015188850152868101518785015285810151868501526080808201519085015260a0808201519085015260c090810151906145af81860183614526565b50509286019260e09290920191600101614560565b509098975050505050505050565b600080604083850312156145e557600080fd5b82356145f081613eca565b946020939093013593505050565b60208082526013908201527213db9b1e481c1bdcda5d1a5bdb881d985d5b1d606a1b604082015260600190565b805161463681613eca565b919050565b805161463681613f50565b6000610140828403121561465957600080fd5b614661613fbe565b61466a8361462b565b81526146786020840161462b565b60208201526146896040840161463b565b6040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152508091505092915050565b6000602082840312156146f457600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015614723576147236146fb565b500390565b6000816000190483118215151615614742576147426146fb565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261476c5761476c614747565b500490565b60008219821115614784576147846146fb565b500190565b60008261479857614798614747565b500690565b634e487b7160e01b600052603260045260246000fd5b60006101008a835260018060a01b03808b16602085015289151560408501528860608501528760808501526147eb60a08501886143af565b8160c08501526147fd82850187614188565b925080851660e085015250509998505050505050505050565b600060001982141561482a5761482a6146fb565b5060010190565b6020808252600a908201526913db9b1e481d985d5b1d60b21b604082015260600190565b828152604060208201526000610faa6040830184614188565b60006060828403121561488057600080fd5b6040516060810181811067ffffffffffffffff821117156148a3576148a3613fa8565b80604052508251815260208301516020820152604083015160408201528091505092915050565b8381526020810183905260608101610faa60408301846143af565b6020808252600f908201526e1d1c9a59d9d95c881b9bdd081b595d608a1b604082015260600190565b6020808252600b908201526a1b9bdd08185b1b1bddd95960aa1b604082015260600190565b8381526020810183905260608101610faa6040830184614526565b600060c082019050878252866020830152851515604083015284606083015283608083015261498060a0830184614526565b979650505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fdfea264697066735822122098b74fe18c1e40b65b5f34a7c93b2eae71b138d3090bf6f963337fec5d45dc1f64736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c806396759c9411610104578063ba2fcc73116100a2578063e7f3e0a511610071578063e7f3e0a51461056c578063ef2ae9501461057f578063f32af30114610592578063f6374340146105b257600080fd5b8063ba2fcc7314610513578063c980106814610526578063d09ef24114610539578063d950049e1461055957600080fd5b8063a0cb3bb3116100de578063a0cb3bb314610468578063a1ccbf641461047b578063a3e895b41461048e578063a85c38ef146104a157600080fd5b806396759c941461040d5780639f83930714610420578063a07729601461045557600080fd5b806358eda3ab1161017c5780638129fc1c1161014b5780638129fc1c146103cc578063860a19f1146103d457806386a2c686146103e75780638e4fdc6a146103fa57600080fd5b806358eda3ab146102ec578063678f4c7f146102ff578063688aa7f31461034957806372b3f27a1461036957600080fd5b8063359ef75b116101b8578063359ef75b14610290578063381f89b8146102a35780633f9c2f93146102b6578063518f6563146102d957600080fd5b8063102b9864146101df5780631119bacf146101f45780633407c8ea1461027d575b600080fd5b6101f26101ed366004613eb1565b6105c5565b005b610241610202366004613eb1565b6039602052600090815260409020805460018201546002830154600384015460048501546005909501546001600160a01b039094169492939192909186565b604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015260a082015260c0015b60405180910390f35b6101f261028b366004613eb1565b610616565b6101f261029e366004613edf565b610a85565b6101f26102b1366004613eb1565b610cc2565b6102c96102c4366004613f5e565b610d03565b6040519015158152602001610274565b6101f26102e73660046140a8565b610fb2565b6101f26102fa36600461413c565b6110e9565b61032e61030d366004613eb1565b603a6020526000908152604090208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610274565b61035c610357366004613eb1565b6111f6565b60405161027491906141c3565b61037c610377366004613eb1565b6112af565b604051610274919081516001600160a01b031681526020808301519082015260408083015190820152606080830151908201526080808301519082015260a0918201519181019190915260c00190565b6101f2611353565b6101f26103e23660046141d6565b611463565b6101f26103f5366004613eb1565b61171f565b6101f261040836600461422f565b61193d565b6101f261041b366004613eb1565b61197b565b61043361042e366004613eb1565b61205a565b6040805182518152602080840151908201529181015190820152606001610274565b6101f2610463366004613eb1565b6120b7565b6101f2610476366004613eb1565b61234a565b6101f2610489366004614272565b61249f565b6101f261049c366004614377565b612978565b6104fe6104af366004613eb1565b60386020526000908152604090208054600182015460028301546003840154600485015460058601546006870154600788015460089098015460ff909716979596949593949293919290919089565b604051610274999897969594939291906143c3565b6101f2610521366004614410565b612993565b6101f2610534366004613eb1565b612c3d565b61054c610547366004613eb1565b612d8e565b6040516102749190614459565b6101f26105673660046144c5565b612e7c565b6101f261057a366004613eb1565b612f4a565b6102c961058d3660046144f1565b612fb2565b6105a56105a0366004613eb1565b61318e565b6040516102749190614536565b6101f26105c03660046145d2565b613280565b6034546001600160a01b031633146105f85760405162461bcd60e51b81526004016105ef906145fe565b60405180910390fd5b6000908152603a602052604081208181556001810182905560020155565b61061e6135d3565b60345460405163eb02c30160e01b8152600481018390526000916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561066457600080fd5b505afa158015610678573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061069c9190614646565b600083815260386020526040808220603354606085015192516365fa2f7f60e01b81526004810193909352939450926001600160a01b0316906365fa2f7f9060240160206040518083038186803b1580156106f657600080fd5b505afa15801561070a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072e91906146e2565b83519091506001600160a01b03163314806107c3575060375460405163df07560560e01b81523360048201526001916001600160a01b03169063df0756059060240160206040518083038186803b15801561078857600080fd5b505afa15801561079c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c091906146e2565b10155b61080f5760405162461bcd60e51b815260206004820152601760248201527f7570646174655453746f70206e6f7420616c6c6f77656400000000000000000060448201526064016105ef565b6000836101000151116108595760405162461bcd60e51b8152602060048201526012602482015271706f736974696f6e206e6f7420616c69766560701b60448201526064016105ef565b61086e83606001518460400151866001610d03565b5060078201546040840151156108d1576006830154156108b857620186a08360050154620186a061089f9190614711565b6108a99084614728565b6108b3919061475d565b6108c7565b60058301546108c79083614711565b6007840155610920565b60068301541561090b57620186a08360050154620186a06108f29190614771565b6108fc9084614728565b610906919061475d565b61091a565b600583015461091a9083614771565b60078401555b600081846007015411156109455781846007015461093e9190614711565b9050610957565b60078401546109549083614711565b90505b603560009054906101000a90046001600160a01b03166001600160a01b03166361695ebe6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109a557600080fd5b505afa1580156109b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109dd91906146e2565b826109eb620186a084614728565b6109f5919061475d565b1015610a355760405162461bcd60e51b815260206004820152600f60248201526e085c1c9a58d9481b5bdd995b595b9d608a1b60448201526064016105ef565b60078401546040805188815260208101929092527fd2cd743a94fbf08b6043f0fc643411e183fbbdfc7c629117e13bcd64edf1ad93910160405180910390a15050505050610a8260018055565b50565b603754600160a01b900460ff1615610acd5760405162461bcd60e51b815260206004820152600b60248201526a1a5b9a5d1a585b1a5e995960aa1b60448201526064016105ef565b6001600160a01b0385163b610b1b5760405162461bcd60e51b81526020600482015260146024820152731c1c9a58d953585b9859d95c881a5b9d985b1a5960621b60448201526064016105ef565b6001600160a01b0384163b610b6a5760405162461bcd60e51b81526020600482015260156024820152741c1bdcda5d1a5bdb95985d5b1d081a5b9d985b1a59605a1b60448201526064016105ef565b6001600160a01b0383163b610bc15760405162461bcd60e51b815260206004820152601760248201527f73657474696e67734d616e6167657220696e76616c696400000000000000000060448201526064016105ef565b6001600160a01b0382163b610c085760405162461bcd60e51b815260206004820152600d60248201526c1d985d5b1d081a5b9d985b1a59609a1b60448201526064016105ef565b6001600160a01b0381163b610c565760405162461bcd60e51b81526020600482015260146024820152731bdc195c985d1bdc9cc81a5cc81a5b9d985b1a5960621b60448201526064016105ef565b603380546001600160a01b039687166001600160a01b031991821617909155603580549487169482169490941790935560348054948616948416949094179093556036805491851691909216179055603780546001600160a81b0319169190921617600160a01b179055565b610cca6135d3565b6000610cda600160801b8361475d565b90506000610cec600160801b84614789565b9050610cf88282613633565b5050610a8260018055565b60008281526038602052604080822081516101208101909252805483929190829060ff166003811115610d3857610d38614399565b6003811115610d4957610d49614399565b8152600182015460208201526002820154604080830191909152600383015460608301526004808401546080840152600584015460a0840152600684015460c0840152600784015460e08401526008909301546101009092019190915260335490516365fa2f7f60e01b81529182018990529192506000916001600160a01b0316906365fa2f7f9060240160206040518083038186803b158015610dec57600080fd5b505afa158015610e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2491906146e2565b905060008615610e815760c0830151610e52578260a001518360e00151610e4b9190614771565b9050610ed0565b60a0830151610e6490620186a0614711565b620186a08460e00151610e779190614728565b610e4b919061475d565b60c0830151610e9e578260a001518360e00151610e4b9190614711565b60a0830151610eb090620186a0614771565b620186a08460e00151610ec39190614728565b610ecd919061475d565b90505b6000878015610ef15750600184516003811115610eef57610eef614399565b145b8015610f01575060048460800151145b8015610f0d5750828211155b15610f1a57506001610f5f565b87158015610f3a5750600184516003811115610f3857610f38614399565b145b8015610f4a575060048460800151145b8015610f565750828210155b15610f5f575060015b8515610fa45780610fa45760405162461bcd60e51b815260206004820152600f60248201526e1c1c9a58d9481a5b98dbdc9c9958dd608a1b60448201526064016105ef565b93505050505b949350505050565b6034546001600160a01b03163314610fdc5760405162461bcd60e51b81526004016105ef906145fe565b6000878152603860205260409020805460ff19166001178155600481018490558251839060029081106110115761101161479d565b60200260200101518160030181905550826003815181106110345761103461479d565b60200260200101518160020181905550826000815181106110575761105761479d565b602002602001015181600101819055508260018151811061107a5761107a61479d565b60209081029190910101516007820155426008820155600481015481546040517fb09a2e4a32528ccab1e46bd7e612b276fba44b21959fe5baf15da0eab2deda6c926110d7928c928c928c928c9260ff909116908b908b906147b3565b60405180910390a15050505050505050565b6034546001600160a01b031633146111135760405162461bcd60e51b81526004016105ef906145fe565b600085815260396020526040902060020154156111725760405162461bcd60e51b815260206004820152601f60248201527f616464506f736974696f6e4f7264657220616c7265616479206578697374730060448201526064016105ef565b6040805160c0810182526001600160a01b039788168152602080820196875281830195865260608201948552426080830190815260a083019485526000988952603990915291909620955186546001600160a01b03191697169690961785559251600185015590516002840155516003830155915160048201559051600590910155565b6000818152603c602052604081206060919061121190613837565b90508067ffffffffffffffff81111561122c5761122c613fa8565b604051908082528060200260200182016040528015611255578160200160208202803683370190505b50915060005b818110156112a8576000848152603c6020526040902061127b9082613847565b83828151811061128d5761128d61479d565b60209081029190910101526112a181614816565b905061125b565b5050919050565b6112f16040518060c0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081525090565b50600090815260396020908152604091829020825160c08101845281546001600160a01b03168152600182015492810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a082015290565b600054610100900460ff16158080156113735750600054600160ff909116105b8061138d5750303b15801561138d575060005460ff166001145b6113f05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105ef565b6000805460ff191660011790558015611413576000805461ff0019166101001790555b61141b61385a565b8015610a82576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b6036546001600160a01b0316331461148d5760405162461bcd60e51b81526004016105ef90614831565b600082815260386020526040808220603454915163eb02c30160e01b8152600481018690529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156114e157600080fd5b505afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115199190614646565b905080600001516001600160a01b0316856001600160a01b0316146115915760405162461bcd60e51b815260206004820152602860248201527f796f7520617265206e6f7420616c6c6f77656420746f2061646420747261696c6044820152670696e672073746f760c41b60648201526084016105ef565b6000816101000151116115db5760405162461bcd60e51b8152602060048201526012602482015271706f736974696f6e206e6f7420616c69766560701b60448201526064016105ef565b6115e483612fb2565b50826001815181106115f8576115f861479d565b6020026020010151816101000151101561161c576101008101516002830155611640565b8260018151811061162f5761162f61479d565b602002602001015182600201819055505b826000815181106116535761165361479d565b60209081029190910101516003830155815460ff191660011782556004808301558251839060029081106116895761168961479d565b60200260200101518260060181905550826003815181106116ac576116ac61479d565b60200260200101518260070181905550826004815181106116cf576116cf61479d565b602002602001015182600501819055507fa60c001cf7dd3d1abac8fc1f3ff25b3fb3e93143c213398697f898adb861f76b8484604051611710929190614855565b60405180910390a15050505050565b6034546001600160a01b031633146117495760405162461bcd60e51b81526004016105ef906145fe565b60008181526038602052604090206002015415610a8257600081815260386020526040808220805460ff19166003178155603454915163eb02c30160e01b8152600481018590529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156117bf57600080fd5b505afa1580156117d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f79190614646565b60365481516034546040516306393ef960e41b8152600481018890529394506001600160a01b039283169363cf7c72159390911690636393ef909060240160606040518083038186803b15801561184d57600080fd5b505afa158015611861573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611885919061486e565b5160038601546118959190614771565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156118db57600080fd5b505af11580156118ef573d6000803e3d6000fd5b50505050600482015482546040517f11284c7a8f4d9021e9e1f15c19e4d8fadc91365c1ce8a71ce57245c673cc927a9261193092879260ff909116906148ca565b60405180910390a1505050565b6034546001600160a01b031633146119675760405162461bcd60e51b81526004016105ef906145fe565b611974858585858561388b565b5050505050565b6119836135d3565b60375460405163df07560560e01b815233600482015260019182916001600160a01b039091169063df0756059060240160206040518083038186803b1580156119cb57600080fd5b505afa1580156119df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0391906146e2565b1015611a445760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b21037b832b930ba37b960811b60448201526064016105ef565b60345460405163eb02c30160e01b8152600481018490526000916001600160a01b03169063eb02c301906024016101406040518083038186803b158015611a8a57600080fd5b505afa158015611a9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac29190614646565b6000848152603860205260408082208151610120810190925280549394509192909190829060ff166003811115611afb57611afb614399565b6003811115611b0c57611b0c614399565b81526001828101546020830152600283015460408301526003830154606083015260048301546080830152600583015460a0830152600683015460c0830152600783015460e08301526008909201546101009091015290915081516003811115611b7857611b78614399565b14611bb95760405162461bcd60e51b81526020600482015260116024820152706f72646572206e6f742070656e64696e6760781b60448201526064016105ef565b60335460608301516040516365fa2f7f60e01b815260048101919091526000916001600160a01b0316906365fa2f7f9060240160206040518083038186803b158015611c0457600080fd5b505afa158015611c18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c3c91906146e2565b9050600182608001511415611e4d57826040015115611c7e578082602001511015611c795760405162461bcd60e51b81526004016105ef906148e5565b611ca2565b8082602001511115611ca25760405162461bcd60e51b81526004016105ef906148e5565b6034548351606080860151604080880151928701518782015191516306393ef960e41b8152600481018c90526001600160a01b0390961695638f3d5864958c95909493909289929091908990636393ef909060240160606040518083038186803b158015611d0f57600080fd5b505afa158015611d23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d47919061486e565b5160405160e08a901b6001600160e01b031916815260048101989098526001600160a01b03909616602488015260448701949094529115156064860152608485015260a484015260c483015260e482015261010401600060405180830381600087803b158015611db657600080fd5b505af1158015611dca573d6000803e3d6000fd5b50505050611de1858360800151600080600261388b565b60345483516040516308f474d160e11b81526001600160a01b039182166004820152602481018890529116906311e8e9a290604401600060405180830381600087803b158015611e3057600080fd5b505af1158015611e44573d6000803e3d6000fd5b5050505061204d565b600282608001511415611eac57826040015115611e8857808260e001511115611c795760405162461bcd60e51b81526004016105ef906148e5565b808260e001511015611ca25760405162461bcd60e51b81526004016105ef906148e5565b600382608001511415611f2f57826040015115611eec57808260e001511115611ee75760405162461bcd60e51b81526004016105ef906148e5565b611f10565b808260e001511015611f105760405162461bcd60e51b81526004016105ef906148e5565b611f2a85600184606001518560400151866000015161388b565b61204d565b60048260800151141561201557826040015115611f6f57808260e001511015611f6a5760405162461bcd60e51b81526004016105ef906148e5565b611f93565b808260e001511115611f935760405162461bcd60e51b81526004016105ef906148e5565b60345460408381015190516336a6d6ff60e11b8152600481018890526024810184905260448101919091526001600160a01b0390911690636d4dadfe90606401600060405180830381600087803b158015611fed57600080fd5b505af1158015612001573d6000803e3d6000fd5b50505050611f2a856000806000600261388b565b60405162461bcd60e51b815260206004820152600d60248201526c21706f736974696f6e5479706560981b60448201526064016105ef565b50505050610a8260018055565b61207e60405180606001604052806000815260200160008152602001600081525090565b506000908152603a6020908152604091829020825160608101845281548152600182015492810192909252600201549181019190915290565b6120bf6135d3565b6000818152603b6020526040808220603454915163eb02c30160e01b8152600481018590529092916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561211357600080fd5b505afa158015612127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214b9190614646565b80519091506001600160a01b031633146121775760405162461bcd60e51b81526004016105ef9061490e565b6000838152603c6020526040812061218e90613837565b9050600081116121d45760405162461bcd60e51b8152602060048201526011602482015270185b1c9958591e4818d85b98d95b1b1959607a1b60448201526064016105ef565b60008167ffffffffffffffff8111156121ef576121ef613fa8565b604051908082528060200260200182016040528015612218578160200160208202803683370190505b50905060005b828110156122ea576000868152603c6020526040812061223e9083613847565b905060008660000182815481106122575761225761479d565b600091825260209091206006600790920201908101805460ff191660049081179091556040519192507f30c1d870abfaca592f3207107a071dddbb1e81de2169bc209f6eb6fb3633f458916122b0918b91869190614933565b60405180910390a1818484815181106122cb576122cb61479d565b6020026020010181815250505050806122e390614816565b905061221e565b5060005b8281101561233c5761232b603c600088815260200190815260200160002083838151811061231e5761231e61479d565b602002602001015161398d565b5061233581614816565b90506122ee565b5050505050610a8260018055565b6034546001600160a01b031633146123745760405162461bcd60e51b81526004016105ef906145fe565b600081815260396020908152604091829020825160c08101845281546001600160a01b03168152600182015492810192909252600281015492820183905260038101546060830152600481015460808301526005015460a0820152901561249b57603654815160a083015160208401516001600160a01b039093169263cf7c7215929161240091614771565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561244657600080fd5b505af115801561245a573d6000803e3d6000fd5b505050600083815260396020526040812080546001600160a01b03191681556001810182905560028101829055600381018290556004810182905560050155505b5050565b6036546001600160a01b031633146124c95760405162461bcd60e51b81526004016105ef90614831565b60345460405163eb02c30160e01b8152600481018790526000916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561250f57600080fd5b505afa158015612523573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125479190614646565b9050846001600160a01b031681600001516001600160a01b03161461257e5760405162461bcd60e51b81526004016105ef9061490e565b83518351148015612590575081518351145b6125cd5760405162461bcd60e51b815260206004820152600e60248201526d696e76616c696420706172616d7360901b60448201526064016105ef565b600083511161260c5760405162461bcd60e51b815260206004820152600b60248201526a32b6b83a3c9037b93232b960a91b60448201526064016105ef565b603560009054906101000a90046001600160a01b03166001600160a01b031663455321636040518163ffffffff1660e01b815260040160206040518083038186803b15801561265a57600080fd5b505afa15801561266e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061269291906146e2565b83516000888152603c602052604090206126ab90613837565b6126b59190614771565b11156126f75760405162461bcd60e51b8152602060048201526011602482015270746f6f206d616e7920747269676765727360781b60448201526064016105ef565b6000868152603b60205260408120905b845181101561296e5760008482815181106127245761272461479d565b60200260200101511180156127555750620186a084828151811061274a5761274a61479d565b602002602001015111155b6127935760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b60448201526064016105ef565b81546000898152603c602052604090206127ad9082613999565b50826000016040518060e001604052808985815181106127cf576127cf61479d565b6020026020010151151581526020018785815181106127f0576127f061479d565b602002602001015181526020014281526020018885815181106128155761281561479d565b6020026020010151815260200160008152602001600081526020016002600481111561284357612843614399565b905281546001818101845560009384526020938490208351600790930201805492151560ff1993841617815593830151848201556040830151600285015560608301516003850155608083015160048086019190915560a0840151600586015560c08401516006860180549596959194909391169184908111156128c9576128c9614399565b021790555050507ff1a13d80b3de86cec4302338b365ff08f70980dd6e2b86859a883b228c1df64689828985815181106129055761290561479d565b602002602001015189868151811061291f5761291f61479d565b60200260200101518987815181106129395761293961479d565b602002602001015160026040516129559695949392919061494e565b60405180910390a15061296781614816565b9050612707565b5050505050505050565b6129806135d3565b61298a8282613633565b61249b60018055565b61299b6135d3565b6000858152603b6020526040808220603454915163eb02c30160e01b8152600481018990529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156129ef57600080fd5b505afa158015612a03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a279190614646565b80519091506001600160a01b03163314612a535760405162461bcd60e51b81526004016105ef9061490e565b6002826000018781548110612a6a57612a6a61479d565b600091825260209091206006600790920201015460ff166004811115612a9257612a92614399565b14612ad75760405162461bcd60e51b81526020600482015260156024820152742a3934b3b3b2b927b93232b9103737ba1027b832b760591b60448201526064016105ef565b600083118015612aea5750620186a08311155b612b285760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b60448201526064016105ef565b84826000018781548110612b3e57612b3e61479d565b60009182526020909120600790910201805460ff191691151591909117905581548490839088908110612b7357612b7361479d565b90600052602060002090600702016003018190555082826000018781548110612b9e57612b9e61479d565b90600052602060002090600702016001018190555042826000018781548110612bc957612bc961479d565b906000526020600020906007020160020181905550867f338e9691e0a5bfbef1c9203b11bed24c4e218f79ce9afe2372ba6a2678424ac787878787604051612c2a949392919093845291151560208401526040830152606082015260800190565b60405180910390a2505061197460018055565b612c456135d3565b60375460405163df07560560e01b815233600482015260019182916001600160a01b039091169063df0756059060240160206040518083038186803b158015612c8d57600080fd5b505afa158015612ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cc591906146e2565b1015612d065760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b21037b832b930ba37b960811b60448201526064016105ef565b600080612d12846139a5565b6034546040516336a6d6ff60e11b81526004810188905260248101839052604481018490529294509092506001600160a01b031690636d4dadfe90606401600060405180830381600087803b158015612d6a57600080fd5b505af1158015612d7e573d6000803e3d6000fd5b50505050505050610a8260018055565b612dde604080516101208101909152806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60008281526038602052604090819020815161012081019092528054829060ff166003811115612e1057612e10614399565b6003811115612e2157612e21614399565b815260018201546020820152600282015460408201526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e08201526008909101546101009091015292915050565b6034546001600160a01b03163314612ea65760405162461bcd60e51b81526004016105ef906145fe565b6000838152603a602052604090205415612f0e5760405162461bcd60e51b8152602060048201526024808201527f6465637265617365506f736974696f6e4f7264657220616c72656164792065786044820152636973747360e01b60648201526084016105ef565b604080516060810182529283526020808401928352428483019081526000958652603a9091529320915182555160018201559051600290910155565b6034546001600160a01b03163314612f745760405162461bcd60e51b81526004016105ef906145fe565b600090815260396020526040812080546001600160a01b03191681556001810182905560028101829055600381018290556004810182905560050155565b60008082600181518110612fc857612fc861479d565b6020026020010151116130155760405162461bcd60e51b8152602060048201526015602482015274747261696c696e672073697a65206973207a65726f60581b60448201526064016105ef565b60008260048151811061302a5761302a61479d565b6020026020010151118015613059575060008260038151811061304f5761304f61479d565b6020026020010151115b61309d5760405162461bcd60e51b8152602060048201526015602482015274696e76616c696420747261696c696e67206461746160581b60448201526064016105ef565b6001826002815181106130b2576130b261479d565b602002602001015111156130f75760405162461bcd60e51b815260206004820152600c60248201526b696e76616c6964207479706560a01b60448201526064016105ef565b60018260028151811061310c5761310c61479d565b6020026020010151141561318657620186a0826004815181106131315761313161479d565b6020026020010151106131865760405162461bcd60e51b815260206004820152601860248201527f70657263656e742063616e74206578636565642031303025000000000000000060448201526064016105ef565b506001919050565b6040805160208082018352606082526000848152603b8252838120845181548085028201870187529381018481529495909491938593859285015b828210156132725760008481526020908190206040805160e08101825260078602909201805460ff90811615158452600182015494840194909452600281015491830191909152600381015460608301526004808201546080840152600582015460a084015260068201549293919260c0850192169081111561324e5761324e614399565b600481111561325f5761325f614399565b81525050815260200190600101906131c9565b505050915250909392505050565b6036546001600160a01b031633146132aa5760405162461bcd60e51b81526004016105ef90614831565b600081815260386020526040808220603454915163eb02c30160e01b8152600481018590529092916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156132fe57600080fd5b505afa158015613312573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133369190614646565b905080600001516001600160a01b0316846001600160a01b03161461339d5760405162461bcd60e51b815260206004820152601d60248201527f596f7520617265206e6f7420616c6c6f77656420746f2063616e63656c00000060448201526064016105ef565b6001825460ff1660038111156133b5576133b5614399565b146133f35760405162461bcd60e51b815260206004820152600e60248201526d4e6f7420696e2050656e64696e6760901b60448201526064016105ef565b60048201546134445760405162461bcd60e51b815260206004820181905260248201527f6d61726b6574206f726465722063616e6e6f742062652063616e63656c6c656460448201526064016105ef565b60048260040154141561346857815460ff191660021782556000600483015561356c565b815460ff1916600317825560365481516034546040516306393ef960e41b8152600481018790526001600160a01b039384169363cf7c721593921690636393ef909060240160606040518083038186803b1580156134c557600080fd5b505afa1580156134d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134fd919061486e565b51600386015461350d9190614771565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561355357600080fd5b505af1158015613567573d6000803e3d6000fd5b505050505b60006003830181905560028301819055600183018190556007830155600482015482546040517f11284c7a8f4d9021e9e1f15c19e4d8fadc91365c1ce8a71ce57245c673cc927a926135c592879260ff909116906148ca565b60405180910390a150505050565b600260015414156136265760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105ef565b6002600155565b60018055565b6000828152603b6020526040808220603454915163eb02c30160e01b8152600481018690529092916001600160a01b03169063eb02c301906024016101406040518083038186803b15801561368757600080fd5b505afa15801561369b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136bf9190614646565b80519091506001600160a01b031633146136eb5760405162461bcd60e51b81526004016105ef9061490e565b60028260000184815481106137025761370261479d565b600091825260209091206006600790920201015460ff16600481111561372a5761372a614399565b146137775760405162461bcd60e51b815260206004820152601a60248201527f547269676765724f72646572207761732063616e63656c6c656400000000000060448201526064016105ef565b600482600001848154811061378e5761378e61479d565b60009182526020909120600660079092020101805460ff191660018360048111156137bb576137bb614399565b02179055506000848152603c602052604090206137d8908461398d565b507f30c1d870abfaca592f3207107a071dddbb1e81de2169bc209f6eb6fb3633f45884848460000186815481106138115761381161479d565b60009182526020909120600660079092020101546040516135c593929160ff1690614933565b6000613841825490565b92915050565b60006138538383613c9b565b9392505050565b600054610100900460ff166138815760405162461bcd60e51b81526004016105ef9061498b565b613889613cc5565b565b60008581526038602052604090206004810185905560038082018590556002820184905581548391839160ff19169060019084908111156138ce576138ce614399565b021790555060028260038111156138e7576138e7614399565b14806139045750600382600381111561390257613902614399565b145b15613949577f11284c7a8f4d9021e9e1f15c19e4d8fadc91365c1ce8a71ce57245c673cc927a86868460405161393c939291906148ca565b60405180910390a1613985565b7f8fb91a48f2c30e066e4feb84035a64058e6438c9542ffffade55e1a1fdead73c86868460405161397c939291906148ca565b60405180910390a15b505050505050565b60006138538383613cec565b60006138538383613ddf565b6000818152603b6020526040808220603454915163eb02c30160e01b815260048101859052839283916001600160a01b039091169063eb02c301906024016101406040518083038186803b1580156139fc57600080fd5b505afa158015613a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a349190614646565b9050600081610100015111613a7e5760405162461bcd60e51b815260206004820152601060248201526f2a3934b3b3b2b9102737ba1027b832b760811b60448201526064016105ef565b60335460608201516040516365fa2f7f60e01b815260048101919091526000916001600160a01b0316906365fa2f7f9060240160206040518083038186803b158015613ac957600080fd5b505afa158015613add573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b0191906146e2565b905060005b6000878152603c60205260409020613b1d90613837565b811015613c5e576000878152603c60205260408120613b3c9083613847565b90506000856000018281548110613b5557613b5561479d565b600091825260209091206007909102016006810154815460408801516003840154939450613b8d9360ff938416939092169188613e2e565b15613c4b576000620186a08260010154876101000151613bad9190614728565b613bb7919061475d565b6004830181905542600584015560068301805460ff1916600317905560008b8152603c60205260409020909150613bee908461398d565b506004820154604080518c815260208101929092528101849052606081018690527f70d540360d56572a2bde588895f25818d664218b09fcca5e9d0df0f8260665749060800160405180910390a199939850929650505050505050565b505080613c5790614816565b9050613b06565b5060405162461bcd60e51b815260206004820152601160248201527074726967676572206e6f7420726561647960781b60448201526064016105ef565b6000826000018281548110613cb257613cb261479d565b9060005260206000200154905092915050565b600054610100900460ff1661362d5760405162461bcd60e51b81526004016105ef9061498b565b60008181526001830160205260408120548015613dd5576000613d10600183614711565b8554909150600090613d2490600190614711565b9050818114613d89576000866000018281548110613d4457613d4461479d565b9060005260206000200154905080876000018481548110613d6757613d6761479d565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613d9a57613d9a6149d6565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050613841565b6000915050613841565b6000818152600183016020526040812054613e2657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155613841565b506000613841565b60006002866004811115613e4457613e44614399565b14613e5157506000613ea8565b8415613e80578315613e7157828210613e6c57506001613ea8565b613ea4565b828211613e6c57506001613ea8565b8315613e9557828211613e6c57506001613ea8565b828210613ea457506001613ea8565b5060005b95945050505050565b600060208284031215613ec357600080fd5b5035919050565b6001600160a01b0381168114610a8257600080fd5b600080600080600060a08688031215613ef757600080fd5b8535613f0281613eca565b94506020860135613f1281613eca565b93506040860135613f2281613eca565b92506060860135613f3281613eca565b91506080860135613f4281613eca565b809150509295509295909350565b8015158114610a8257600080fd5b60008060008060808587031215613f7457600080fd5b843593506020850135613f8681613f50565b9250604085013591506060850135613f9d81613f50565b939692955090935050565b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff81118282101715613fe257613fe2613fa8565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561401157614011613fa8565b604052919050565b600067ffffffffffffffff82111561403357614033613fa8565b5060051b60200190565b600082601f83011261404e57600080fd5b8135602061406361405e83614019565b613fe8565b82815260059290921b8401810191818101908684111561408257600080fd5b8286015b8481101561409d5780358352918301918301614086565b509695505050505050565b600080600080600080600060e0888a0312156140c357600080fd5b8735965060208801356140d581613eca565b955060408801356140e581613f50565b9450606088013593506080880135925060a088013567ffffffffffffffff81111561410f57600080fd5b61411b8a828b0161403d565b92505060c088013561412c81613eca565b8091505092959891949750929550565b60008060008060008060c0878903121561415557600080fd5b863561416081613eca565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b600081518084526020808501945080840160005b838110156141b85781518752958201959082019060010161419c565b509495945050505050565b6020815260006138536020830184614188565b6000806000606084860312156141eb57600080fd5b83356141f681613eca565b925060208401359150604084013567ffffffffffffffff81111561421957600080fd5b6142258682870161403d565b9150509250925092565b600080600080600060a0868803121561424757600080fd5b85359450602086013593506040860135925060608601359150608086013560048110613f4257600080fd5b600080600080600060a0868803121561428a57600080fd5b8535945060208087013561429d81613eca565b9450604087013567ffffffffffffffff808211156142ba57600080fd5b818901915089601f8301126142ce57600080fd5b81356142dc61405e82614019565b81815260059190911b8301840190848101908c8311156142fb57600080fd5b938501935b8285101561432257843561431381613f50565b82529385019390850190614300565b97505050606089013592508083111561433a57600080fd5b6143468a848b0161403d565b9450608089013592508083111561435c57600080fd5b505061436a8882890161403d565b9150509295509295909350565b6000806040838503121561438a57600080fd5b50508035926020909101359150565b634e487b7160e01b600052602160045260246000fd5b600481106143bf576143bf614399565b9052565b61012081016143d2828c6143af565b602082019990995260408101979097526060870195909552608086019390935260a085019190915260c084015260e083015261010090910152919050565b600080600080600060a0868803121561442857600080fd5b8535945060208601359350604086013561444181613f50565b94979396509394606081013594506080013592915050565b60006101208201905061446d8284516143af565b6020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525092915050565b6000806000606084860312156144da57600080fd5b505081359360208301359350604090920135919050565b60006020828403121561450357600080fd5b813567ffffffffffffffff81111561451a57600080fd5b610faa8482850161403d565b600581106143bf576143bf614399565b60006020808352604080840185518384870152818151808452606093508388019150858301925060005b818110156145c45783518051151584528781015188850152868101518785015285810151868501526080808201519085015260a0808201519085015260c090810151906145af81860183614526565b50509286019260e09290920191600101614560565b509098975050505050505050565b600080604083850312156145e557600080fd5b82356145f081613eca565b946020939093013593505050565b60208082526013908201527213db9b1e481c1bdcda5d1a5bdb881d985d5b1d606a1b604082015260600190565b805161463681613eca565b919050565b805161463681613f50565b6000610140828403121561465957600080fd5b614661613fbe565b61466a8361462b565b81526146786020840161462b565b60208201526146896040840161463b565b6040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152508091505092915050565b6000602082840312156146f457600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015614723576147236146fb565b500390565b6000816000190483118215151615614742576147426146fb565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261476c5761476c614747565b500490565b60008219821115614784576147846146fb565b500190565b60008261479857614798614747565b500690565b634e487b7160e01b600052603260045260246000fd5b60006101008a835260018060a01b03808b16602085015289151560408501528860608501528760808501526147eb60a08501886143af565b8160c08501526147fd82850187614188565b925080851660e085015250509998505050505050505050565b600060001982141561482a5761482a6146fb565b5060010190565b6020808252600a908201526913db9b1e481d985d5b1d60b21b604082015260600190565b828152604060208201526000610faa6040830184614188565b60006060828403121561488057600080fd5b6040516060810181811067ffffffffffffffff821117156148a3576148a3613fa8565b80604052508251815260208301516020820152604083015160408201528091505092915050565b8381526020810183905260608101610faa60408301846143af565b6020808252600f908201526e1d1c9a59d9d95c881b9bdd081b595d608a1b604082015260600190565b6020808252600b908201526a1b9bdd08185b1b1bddd95960aa1b604082015260600190565b8381526020810183905260608101610faa6040830184614526565b600060c082019050878252866020830152851515604083015284606083015283608083015261498060a0830184614526565b979650505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fdfea264697066735822122098b74fe18c1e40b65b5f34a7c93b2eae71b138d3090bf6f963337fec5d45dc1f64736f6c63430008090033
Loading...
Loading
Loading...
Loading
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.