Overview
S Balance
S Value
-More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
LiquidateVault
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 "./interfaces/IPositionVault.sol"; import "./interfaces/ILiquidateVault.sol"; import "./interfaces/IPriceManager.sol"; import "./interfaces/ISettingsManager.sol"; import "./interfaces/IVault.sol"; import "./interfaces/IOperators.sol"; import {Constants} from "../access/Constants.sol"; contract LiquidateVault is Constants, Initializable, ReentrancyGuardUpgradeable, ILiquidateVault { // constants ISettingsManager private settingsManager; IPriceManager private priceManager; IPositionVault private positionVault; IOperators private operators; IVault private vault; bool private isInitialized; // variables mapping(uint256 => address) public liquidateRegistrant; mapping(uint256 => uint256) public liquidateRegisterTime; event RegisterLiquidation(uint256 posId, address caller); event LiquidatePosition( uint256 indexed posId, address indexed account, uint256 indexed tokenId, bool isLong, int256[3] pnlData, uint256[5] posData ); /* ========== INITIALIZE FUNCTIONS ========== */ function initialize() public initializer { __ReentrancyGuard_init(); } function init( IPositionVault _positionVault, ISettingsManager _settingsManager, IVault _vault, IPriceManager _priceManager, IOperators _operators ) external { require(!isInitialized, "initialized"); 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(_priceManager)), "priceManager is invalid"); require(AddressUpgradeable.isContract(address(_operators)), "operators is invalid"); positionVault = _positionVault; settingsManager = _settingsManager; vault = _vault; priceManager = _priceManager; operators = _operators; isInitialized = true; } /* ========== CORE FUNCTIONS ========== */ function registerLiquidatePosition(uint256 _posId) external nonReentrant { (bool isPositionLiquidatable, , , ) = validateLiquidationWithPosid(_posId); require(isPositionLiquidatable, "position is not liquidatable"); require(liquidateRegistrant[_posId] == address(0), "not the firstCaller"); liquidateRegistrant[_posId] = msg.sender; liquidateRegisterTime[_posId] = block.timestamp; emit RegisterLiquidation(_posId, msg.sender); } function liquidatePosition(uint256 _posId) external nonReentrant { (bool isPositionLiquidatable, int256 pnl, int256 fundingFee, int256 borrowFee) = validateLiquidationWithPosid( _posId ); require(isPositionLiquidatable, "position is not liquidatable"); require( operators.getOperatorLevel(msg.sender) >= 1 || (msg.sender == liquidateRegistrant[_posId] && liquidateRegisterTime[_posId] + settingsManager.liquidationPendingTime() <= block.timestamp), "not manager or not allowed before pendingTime" ); Position memory position = positionVault.getPosition(_posId); (uint32 firstCallerPercent, uint32 resolverPercent) = settingsManager.bountyPercent(); uint256 firstCallerBounty = (position.collateral * uint256(firstCallerPercent)) / BASIS_POINTS_DIVISOR; uint256 resolverBounty = (position.collateral * uint256(resolverPercent)) / BASIS_POINTS_DIVISOR; uint256 nslpBounty = position.collateral - firstCallerBounty - resolverBounty; if (liquidateRegistrant[_posId] == address(0)) { vault.takeNSUSDOut(msg.sender, firstCallerBounty); } else { vault.takeNSUSDOut(liquidateRegistrant[_posId], firstCallerBounty); } vault.takeNSUSDOut(msg.sender, resolverBounty); vault.accountDeltaIntoTotalUSD(true, nslpBounty); settingsManager.updateFunding(position.tokenId); settingsManager.decreaseOpenInterest(position.tokenId, position.owner, position.isLong, position.size); emit LiquidatePosition( _posId, position.owner, position.tokenId, position.isLong, [pnl, fundingFee, borrowFee], [position.collateral, position.size, position.averagePrice, priceManager.getLastPrice(position.tokenId), 0] ); positionVault.removeUserAlivePosition(position.owner, _posId); } /* ========== HELPER FUNCTIONS ========== */ function validateLiquidationWithPosid(uint256 _posId) public view returns (bool, int256, int256, int256) { Position memory position = positionVault.getPosition(_posId); return validateLiquidation( position.tokenId, position.isLong, position.size, position.averagePrice, priceManager.getLastPrice(position.tokenId), position.lastIncreasedTime, position.accruedBorrowFee, position.fundingIndex, position.collateral ); } function validateLiquidationWithPosidAndPrice( uint256 _posId, uint256 _price ) external view returns (bool, int256, int256, int256) { Position memory position = positionVault.getPosition(_posId); return validateLiquidation( position.tokenId, position.isLong, position.size, position.averagePrice, _price, position.lastIncreasedTime, position.accruedBorrowFee, position.fundingIndex, position.collateral ); } function validateLiquidation( uint256 _tokenId, bool _isLong, uint256 _size, uint256 _averagePrice, uint256 _lastPrice, uint256 _lastIncreasedTime, uint256 _accruedBorrowFee, int256 _fundingIndex, uint256 _collateral ) public view returns (bool isPositionLiquidatable, int256 pnl, int256 fundingFee, int256 borrowFee) { require(_size > 0, "invalid position"); (pnl, fundingFee, borrowFee) = settingsManager.getPnl( _tokenId, _isLong, _size, _averagePrice, _lastPrice, _lastIncreasedTime, _accruedBorrowFee, _fundingIndex ); // position is liquidatable if pnl is negative and collateral larger than liquidateThreshold are lost if ( pnl < 0 && uint256(-1 * pnl) >= (_collateral * settingsManager.liquidateThreshold(_tokenId)) / LIQUIDATE_THRESHOLD_DIVISOR ) { isPositionLiquidatable = true; } } }
// 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: 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; import {Position, Order, OrderType} from "../structs.sol"; interface ILiquidateVault { function validateLiquidationWithPosid(uint256 _posId) external view returns (bool, int256, int256, int256); function liquidatePosition(uint256 _posId) external; }
// 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 {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
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"int256[3]","name":"pnlData","type":"int256[3]"},{"indexed":false,"internalType":"uint256[5]","name":"posData","type":"uint256[5]"}],"name":"LiquidatePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"posId","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"RegisterLiquidation","type":"event"},{"inputs":[{"internalType":"contract IPositionVault","name":"_positionVault","type":"address"},{"internalType":"contract ISettingsManager","name":"_settingsManager","type":"address"},{"internalType":"contract IVault","name":"_vault","type":"address"},{"internalType":"contract IPriceManager","name":"_priceManager","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":"_posId","type":"uint256"}],"name":"liquidatePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"liquidateRegisterTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"liquidateRegistrant","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"registerLiquidatePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_averagePrice","type":"uint256"},{"internalType":"uint256","name":"_lastPrice","type":"uint256"},{"internalType":"uint256","name":"_lastIncreasedTime","type":"uint256"},{"internalType":"uint256","name":"_accruedBorrowFee","type":"uint256"},{"internalType":"int256","name":"_fundingIndex","type":"int256"},{"internalType":"uint256","name":"_collateral","type":"uint256"}],"name":"validateLiquidation","outputs":[{"internalType":"bool","name":"isPositionLiquidatable","type":"bool"},{"internalType":"int256","name":"pnl","type":"int256"},{"internalType":"int256","name":"fundingFee","type":"int256"},{"internalType":"int256","name":"borrowFee","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"}],"name":"validateLiquidationWithPosid","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"int256","name":"","type":"int256"},{"internalType":"int256","name":"","type":"int256"},{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_posId","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"validateLiquidationWithPosidAndPrice","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"int256","name":"","type":"int256"},{"internalType":"int256","name":"","type":"int256"},{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061177b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80636606943c116100665780636606943c146101285780636e6fa1881461013b5780638129fc1c1461017c578063ca61313c14610184578063cdddd4e51461019757600080fd5b8063090d518d14610098578063359ef75b146100d25780633d1d7a2c146100e75780633da5346914610115575b600080fd5b6100ab6100a63660046112d3565b6101aa565b60408051941515855260208501939093529183015260608201526080015b60405180910390f35b6100e56100e0366004611301565b6102f6565b005b6101076100f53660046112d3565b60396020526000908152604090205481565b6040519081526020016100c9565b6100ab610123366004611380565b610546565b6100e56101363660046112d3565b61072e565b6101646101493660046112d3565b6038602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016100c9565b6100e5610861565b6100ab6101923660046113ec565b610971565b6100e56101a53660046112d3565b610a3d565b60355460405163eb02c30160e01b81526004810183905260009182918291829182916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156101f857600080fd5b505afa15801561020c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102309190611461565b6060810151604080830151610100840151608085015160345493516365fa2f7f60e01b8152600481018690529596506102e6959293919290916001600160a01b0316906365fa2f7f9060240160206040518083038186803b15801561029457600080fd5b505afa1580156102a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102cc91906114fd565b8660e001518761012001518860c001518960a00151610546565b9450945094509450509193509193565b603754600160a01b900460ff16156103435760405162461bcd60e51b815260206004820152600b60248201526a1a5b9a5d1a585b1a5e995960aa1b60448201526064015b60405180910390fd5b6001600160a01b0385163b6103925760405162461bcd60e51b81526020600482015260156024820152741c1bdcda5d1a5bdb95985d5b1d081a5b9d985b1a59605a1b604482015260640161033a565b6001600160a01b0384163b6103e95760405162461bcd60e51b815260206004820152601760248201527f73657474696e67734d616e6167657220696e76616c6964000000000000000000604482015260640161033a565b6001600160a01b0383163b6104305760405162461bcd60e51b815260206004820152600d60248201526c1d985d5b1d081a5b9d985b1a59609a1b604482015260640161033a565b6001600160a01b0382163b6104875760405162461bcd60e51b815260206004820152601760248201527f70726963654d616e6167657220697320696e76616c6964000000000000000000604482015260640161033a565b6001600160a01b0381163b6104d55760405162461bcd60e51b81526020600482015260146024820152731bdc195c985d1bdc9cc81a5cc81a5b9d985b1a5960621b604482015260640161033a565b603580546001600160a01b039687166001600160a01b03199182161790915560338054958716958216959095179094556037805460348054948816948716949094179093556036805492871692909516919091179093556001600160a81b031916921691909117600160a01b179055565b60008060008060008b1161058f5760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b2103837b9b4ba34b7b760811b604482015260640161033a565b60335460405163d136545b60e01b8152600481018f90528d15156024820152604481018d9052606481018c9052608481018b905260a481018a905260c4810189905260e481018890526001600160a01b039091169063d136545b906101040160606040518083038186803b15801561060657600080fd5b505afa15801561061a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063e9190611516565b91945092509050600083128015610714575061065e620186a0600a61155a565b603360009054906101000a90046001600160a01b03166001600160a01b031663fb4f94e78f6040518263ffffffff1660e01b81526004016106a191815260200190565b60206040518083038186803b1580156106b957600080fd5b505afa1580156106cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906114fd565b6106fb908761155a565b6107059190611579565b6107118460001961159b565b10155b1561071e57600193505b9950995099509995505050505050565b61073661121b565b6000610741826101aa565b5050509050806107935760405162461bcd60e51b815260206004820152601c60248201527f706f736974696f6e206973206e6f74206c6971756964617461626c6500000000604482015260640161033a565b6000828152603860205260409020546001600160a01b0316156107ee5760405162461bcd60e51b81526020600482015260136024820152723737ba103a3432903334b939ba21b0b63632b960691b604482015260640161033a565b600082815260386020908152604080832080546001600160a01b0319163390811790915560398352928190204290558051858152918201929092527f8473bca94da62159ccd86df2ef3813d7f549dbf25e493b91aac035d7e58ff2fd910160405180910390a15061085e60018055565b50565b600054610100900460ff16158080156108815750600054600160ff909116105b8061089b5750303b15801561089b575060005460ff166001145b6108fe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161033a565b6000805460ff191660011790558015610921576000805461ff0019166101001790555b61092961127b565b801561085e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b60355460405163eb02c30160e01b81526004810184905260009182918291829182916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156109bf57600080fd5b505afa1580156109d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f79190611461565b9050610a2c8160600151826040015183610100015184608001518a8660e001518761012001518860c001518960a00151610546565b929a91995097509095509350505050565b610a4561121b565b600080600080610a54856101aa565b935093509350935083610aa95760405162461bcd60e51b815260206004820152601c60248201527f706f736974696f6e206973206e6f74206c6971756964617461626c6500000000604482015260640161033a565b60365460405163df07560560e01b81523360048201526001916001600160a01b03169063df0756059060240160206040518083038186803b158015610aed57600080fd5b505afa158015610b01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2591906114fd565b101580610be657506000858152603860205260409020546001600160a01b031633148015610be6575060335460408051639e04877960e01b8152905142926001600160a01b031691639e048779916004808301926020929190829003018186803b158015610b9257600080fd5b505afa158015610ba6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bca91906114fd565b600087815260396020526040902054610be39190611620565b11155b610c485760405162461bcd60e51b815260206004820152602d60248201527f6e6f74206d616e61676572206f72206e6f7420616c6c6f776564206265666f7260448201526c652070656e64696e6754696d6560981b606482015260840161033a565b60355460405163eb02c30160e01b8152600481018790526000916001600160a01b03169063eb02c301906024016101406040518083038186803b158015610c8e57600080fd5b505afa158015610ca2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc69190611461565b6033546040805163bfd2ed0160e01b8152815193945060009384936001600160a01b03169263bfd2ed019260048082019391829003018186803b158015610d0c57600080fd5b505afa158015610d20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d44919061164c565b915091506000620186a08363ffffffff168560a00151610d64919061155a565b610d6e9190611579565b90506000620186a08363ffffffff168660a00151610d8c919061155a565b610d969190611579565b9050600081838760a00151610dab919061167f565b610db5919061167f565b60008c8152603860205260409020549091506001600160a01b0316610e3d5760375460405163cf7c721560e01b8152336004820152602481018590526001600160a01b039091169063cf7c721590604401600060405180830381600087803b158015610e2057600080fd5b505af1158015610e34573d6000803e3d6000fd5b50505050610eb3565b60375460008c8152603860205260409081902054905163cf7c721560e01b81526001600160a01b0391821660048201526024810186905291169063cf7c721590604401600060405180830381600087803b158015610e9a57600080fd5b505af1158015610eae573d6000803e3d6000fd5b505050505b60375460405163cf7c721560e01b8152336004820152602481018490526001600160a01b039091169063cf7c721590604401600060405180830381600087803b158015610eff57600080fd5b505af1158015610f13573d6000803e3d6000fd5b5050603754604051637abadb5960e01b815260016004820152602481018590526001600160a01b039091169250637abadb599150604401600060405180830381600087803b158015610f6457600080fd5b505af1158015610f78573d6000803e3d6000fd5b50506033546060890151604051636ea9f13960e01b81526001600160a01b039092169350636ea9f1399250610fb39160040190815260200190565b600060405180830381600087803b158015610fcd57600080fd5b505af1158015610fe1573d6000803e3d6000fd5b5050603354606089015189516040808c01516101008d01519151633294063360e11b815260048101949094526001600160a01b03928316602485015215156044840152606483015290911692506365280c669150608401600060405180830381600087803b15801561105257600080fd5b505af1158015611066573d6000803e3d6000fd5b50505050856060015186600001516001600160a01b03168c7fc6b6663383783270a5bf3e1e0fe5dddcffcc221e9c1e8cdb7c7edd3b3855c6e3896040015160405180606001604052808f81526020018e81526020018d8152506040518060a001604052808d60a0015181526020018d610100015181526020018d608001518152602001603460009054906101000a90046001600160a01b03166001600160a01b03166365fa2f7f8f606001516040518263ffffffff1660e01b815260040161113091815260200190565b60206040518083038186803b15801561114857600080fd5b505afa15801561115c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118091906114fd565b8152602001600081525060405161119993929190611696565b60405180910390a46035548651604051639bc7a99760e01b81526001600160a01b039182166004820152602481018e9052911690639bc7a99790604401600060405180830381600087803b1580156111f057600080fd5b505af1158015611204573d6000803e3d6000fd5b505050505050505050505050505061085e60018055565b6002600154141561126e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161033a565b6002600155565b60018055565b600054610100900460ff166112a25760405162461bcd60e51b815260040161033a906116fa565b6112aa6112ac565b565b600054610100900460ff166112755760405162461bcd60e51b815260040161033a906116fa565b6000602082840312156112e557600080fd5b5035919050565b6001600160a01b038116811461085e57600080fd5b600080600080600060a0868803121561131957600080fd5b8535611324816112ec565b94506020860135611334816112ec565b93506040860135611344816112ec565b92506060860135611354816112ec565b91506080860135611364816112ec565b809150509295509295909350565b801515811461085e57600080fd5b60008060008060008060008060006101208a8c03121561139f57600080fd5b8935985060208a01356113b181611372565b989b989a505050506040870135966060810135966080820135965060a0820135955060c0820135945060e08201359350610100909101359150565b600080604083850312156113ff57600080fd5b50508035926020909101359150565b604051610140810167ffffffffffffffff8111828210171561144057634e487b7160e01b600052604160045260246000fd5b60405290565b8051611451816112ec565b919050565b805161145181611372565b6000610140828403121561147457600080fd5b61147c61140e565b61148583611446565b815261149360208401611446565b60208201526114a460408401611456565b6040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152508091505092915050565b60006020828403121561150f57600080fd5b5051919050565b60008060006060848603121561152b57600080fd5b8351925060208401519150604084015190509250925092565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561157457611574611544565b500290565b60008261159657634e487b7160e01b600052601260045260246000fd5b500490565b60006001600160ff1b03818413828413808216868404861116156115c1576115c1611544565b600160ff1b60008712828116878305891216156115e0576115e0611544565b600087129250878205871284841616156115fc576115fc611544565b8785058712818416161561161257611612611544565b505050929093029392505050565b6000821982111561163357611633611544565b500190565b805163ffffffff8116811461145157600080fd5b6000806040838503121561165f57600080fd5b61166883611638565b915061167660208401611638565b90509250929050565b60008282101561169157611691611544565b500390565b8315158152610120810160208083018560005b60038110156116c6578151835291830191908301906001016116a9565b505050608083018460005b60058110156116ee578151835291830191908301906001016116d1565b50505050949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea264697066735822122028687915e4fc94bb6d230c37b0712f61c1df6e23bb0f8c8b9a7392573746bc2564736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100935760003560e01c80636606943c116100665780636606943c146101285780636e6fa1881461013b5780638129fc1c1461017c578063ca61313c14610184578063cdddd4e51461019757600080fd5b8063090d518d14610098578063359ef75b146100d25780633d1d7a2c146100e75780633da5346914610115575b600080fd5b6100ab6100a63660046112d3565b6101aa565b60408051941515855260208501939093529183015260608201526080015b60405180910390f35b6100e56100e0366004611301565b6102f6565b005b6101076100f53660046112d3565b60396020526000908152604090205481565b6040519081526020016100c9565b6100ab610123366004611380565b610546565b6100e56101363660046112d3565b61072e565b6101646101493660046112d3565b6038602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016100c9565b6100e5610861565b6100ab6101923660046113ec565b610971565b6100e56101a53660046112d3565b610a3d565b60355460405163eb02c30160e01b81526004810183905260009182918291829182916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156101f857600080fd5b505afa15801561020c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102309190611461565b6060810151604080830151610100840151608085015160345493516365fa2f7f60e01b8152600481018690529596506102e6959293919290916001600160a01b0316906365fa2f7f9060240160206040518083038186803b15801561029457600080fd5b505afa1580156102a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102cc91906114fd565b8660e001518761012001518860c001518960a00151610546565b9450945094509450509193509193565b603754600160a01b900460ff16156103435760405162461bcd60e51b815260206004820152600b60248201526a1a5b9a5d1a585b1a5e995960aa1b60448201526064015b60405180910390fd5b6001600160a01b0385163b6103925760405162461bcd60e51b81526020600482015260156024820152741c1bdcda5d1a5bdb95985d5b1d081a5b9d985b1a59605a1b604482015260640161033a565b6001600160a01b0384163b6103e95760405162461bcd60e51b815260206004820152601760248201527f73657474696e67734d616e6167657220696e76616c6964000000000000000000604482015260640161033a565b6001600160a01b0383163b6104305760405162461bcd60e51b815260206004820152600d60248201526c1d985d5b1d081a5b9d985b1a59609a1b604482015260640161033a565b6001600160a01b0382163b6104875760405162461bcd60e51b815260206004820152601760248201527f70726963654d616e6167657220697320696e76616c6964000000000000000000604482015260640161033a565b6001600160a01b0381163b6104d55760405162461bcd60e51b81526020600482015260146024820152731bdc195c985d1bdc9cc81a5cc81a5b9d985b1a5960621b604482015260640161033a565b603580546001600160a01b039687166001600160a01b03199182161790915560338054958716958216959095179094556037805460348054948816948716949094179093556036805492871692909516919091179093556001600160a81b031916921691909117600160a01b179055565b60008060008060008b1161058f5760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b2103837b9b4ba34b7b760811b604482015260640161033a565b60335460405163d136545b60e01b8152600481018f90528d15156024820152604481018d9052606481018c9052608481018b905260a481018a905260c4810189905260e481018890526001600160a01b039091169063d136545b906101040160606040518083038186803b15801561060657600080fd5b505afa15801561061a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063e9190611516565b91945092509050600083128015610714575061065e620186a0600a61155a565b603360009054906101000a90046001600160a01b03166001600160a01b031663fb4f94e78f6040518263ffffffff1660e01b81526004016106a191815260200190565b60206040518083038186803b1580156106b957600080fd5b505afa1580156106cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906114fd565b6106fb908761155a565b6107059190611579565b6107118460001961159b565b10155b1561071e57600193505b9950995099509995505050505050565b61073661121b565b6000610741826101aa565b5050509050806107935760405162461bcd60e51b815260206004820152601c60248201527f706f736974696f6e206973206e6f74206c6971756964617461626c6500000000604482015260640161033a565b6000828152603860205260409020546001600160a01b0316156107ee5760405162461bcd60e51b81526020600482015260136024820152723737ba103a3432903334b939ba21b0b63632b960691b604482015260640161033a565b600082815260386020908152604080832080546001600160a01b0319163390811790915560398352928190204290558051858152918201929092527f8473bca94da62159ccd86df2ef3813d7f549dbf25e493b91aac035d7e58ff2fd910160405180910390a15061085e60018055565b50565b600054610100900460ff16158080156108815750600054600160ff909116105b8061089b5750303b15801561089b575060005460ff166001145b6108fe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161033a565b6000805460ff191660011790558015610921576000805461ff0019166101001790555b61092961127b565b801561085e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b60355460405163eb02c30160e01b81526004810184905260009182918291829182916001600160a01b03169063eb02c301906024016101406040518083038186803b1580156109bf57600080fd5b505afa1580156109d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f79190611461565b9050610a2c8160600151826040015183610100015184608001518a8660e001518761012001518860c001518960a00151610546565b929a91995097509095509350505050565b610a4561121b565b600080600080610a54856101aa565b935093509350935083610aa95760405162461bcd60e51b815260206004820152601c60248201527f706f736974696f6e206973206e6f74206c6971756964617461626c6500000000604482015260640161033a565b60365460405163df07560560e01b81523360048201526001916001600160a01b03169063df0756059060240160206040518083038186803b158015610aed57600080fd5b505afa158015610b01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2591906114fd565b101580610be657506000858152603860205260409020546001600160a01b031633148015610be6575060335460408051639e04877960e01b8152905142926001600160a01b031691639e048779916004808301926020929190829003018186803b158015610b9257600080fd5b505afa158015610ba6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bca91906114fd565b600087815260396020526040902054610be39190611620565b11155b610c485760405162461bcd60e51b815260206004820152602d60248201527f6e6f74206d616e61676572206f72206e6f7420616c6c6f776564206265666f7260448201526c652070656e64696e6754696d6560981b606482015260840161033a565b60355460405163eb02c30160e01b8152600481018790526000916001600160a01b03169063eb02c301906024016101406040518083038186803b158015610c8e57600080fd5b505afa158015610ca2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc69190611461565b6033546040805163bfd2ed0160e01b8152815193945060009384936001600160a01b03169263bfd2ed019260048082019391829003018186803b158015610d0c57600080fd5b505afa158015610d20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d44919061164c565b915091506000620186a08363ffffffff168560a00151610d64919061155a565b610d6e9190611579565b90506000620186a08363ffffffff168660a00151610d8c919061155a565b610d969190611579565b9050600081838760a00151610dab919061167f565b610db5919061167f565b60008c8152603860205260409020549091506001600160a01b0316610e3d5760375460405163cf7c721560e01b8152336004820152602481018590526001600160a01b039091169063cf7c721590604401600060405180830381600087803b158015610e2057600080fd5b505af1158015610e34573d6000803e3d6000fd5b50505050610eb3565b60375460008c8152603860205260409081902054905163cf7c721560e01b81526001600160a01b0391821660048201526024810186905291169063cf7c721590604401600060405180830381600087803b158015610e9a57600080fd5b505af1158015610eae573d6000803e3d6000fd5b505050505b60375460405163cf7c721560e01b8152336004820152602481018490526001600160a01b039091169063cf7c721590604401600060405180830381600087803b158015610eff57600080fd5b505af1158015610f13573d6000803e3d6000fd5b5050603754604051637abadb5960e01b815260016004820152602481018590526001600160a01b039091169250637abadb599150604401600060405180830381600087803b158015610f6457600080fd5b505af1158015610f78573d6000803e3d6000fd5b50506033546060890151604051636ea9f13960e01b81526001600160a01b039092169350636ea9f1399250610fb39160040190815260200190565b600060405180830381600087803b158015610fcd57600080fd5b505af1158015610fe1573d6000803e3d6000fd5b5050603354606089015189516040808c01516101008d01519151633294063360e11b815260048101949094526001600160a01b03928316602485015215156044840152606483015290911692506365280c669150608401600060405180830381600087803b15801561105257600080fd5b505af1158015611066573d6000803e3d6000fd5b50505050856060015186600001516001600160a01b03168c7fc6b6663383783270a5bf3e1e0fe5dddcffcc221e9c1e8cdb7c7edd3b3855c6e3896040015160405180606001604052808f81526020018e81526020018d8152506040518060a001604052808d60a0015181526020018d610100015181526020018d608001518152602001603460009054906101000a90046001600160a01b03166001600160a01b03166365fa2f7f8f606001516040518263ffffffff1660e01b815260040161113091815260200190565b60206040518083038186803b15801561114857600080fd5b505afa15801561115c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118091906114fd565b8152602001600081525060405161119993929190611696565b60405180910390a46035548651604051639bc7a99760e01b81526001600160a01b039182166004820152602481018e9052911690639bc7a99790604401600060405180830381600087803b1580156111f057600080fd5b505af1158015611204573d6000803e3d6000fd5b505050505050505050505050505061085e60018055565b6002600154141561126e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161033a565b6002600155565b60018055565b600054610100900460ff166112a25760405162461bcd60e51b815260040161033a906116fa565b6112aa6112ac565b565b600054610100900460ff166112755760405162461bcd60e51b815260040161033a906116fa565b6000602082840312156112e557600080fd5b5035919050565b6001600160a01b038116811461085e57600080fd5b600080600080600060a0868803121561131957600080fd5b8535611324816112ec565b94506020860135611334816112ec565b93506040860135611344816112ec565b92506060860135611354816112ec565b91506080860135611364816112ec565b809150509295509295909350565b801515811461085e57600080fd5b60008060008060008060008060006101208a8c03121561139f57600080fd5b8935985060208a01356113b181611372565b989b989a505050506040870135966060810135966080820135965060a0820135955060c0820135945060e08201359350610100909101359150565b600080604083850312156113ff57600080fd5b50508035926020909101359150565b604051610140810167ffffffffffffffff8111828210171561144057634e487b7160e01b600052604160045260246000fd5b60405290565b8051611451816112ec565b919050565b805161145181611372565b6000610140828403121561147457600080fd5b61147c61140e565b61148583611446565b815261149360208401611446565b60208201526114a460408401611456565b6040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152508091505092915050565b60006020828403121561150f57600080fd5b5051919050565b60008060006060848603121561152b57600080fd5b8351925060208401519150604084015190509250925092565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561157457611574611544565b500290565b60008261159657634e487b7160e01b600052601260045260246000fd5b500490565b60006001600160ff1b03818413828413808216868404861116156115c1576115c1611544565b600160ff1b60008712828116878305891216156115e0576115e0611544565b600087129250878205871284841616156115fc576115fc611544565b8785058712818416161561161257611612611544565b505050929093029392505050565b6000821982111561163357611633611544565b500190565b805163ffffffff8116811461145157600080fd5b6000806040838503121561165f57600080fd5b61166883611638565b915061167660208401611638565b90509250929050565b60008282101561169157611691611544565b500390565b8315158152610120810160208083018560005b60038110156116c6578151835291830191908301906001016116a9565b505050608083018460005b60058110156116ee578151835291830191908301906001016116d1565b50505050949350505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea264697066735822122028687915e4fc94bb6d230c37b0712f61c1df6e23bb0f8c8b9a7392573746bc2564736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.