Contract
0x592c6A6419fB86BAD15926c840A9f9306f69f590
1
Contract Overview
Balance:
0 ETH
ETH Value:
$0.00
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x578f4b2a4c60dae2f498a61eaff0196f685c57425be4ad25059dd456e7c09130 | 0x60806040 | 219936 | 314 days 3 hrs ago | 0x904b5993fc92979eeedc19ccc58bed6b7216667c | IN | Create: PoolCreator | 0 ETH | 0.018019652125 ETH |
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
PoolCreator
Compiler Version
v0.7.4+commit.3f05b770
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "./KeeperWhitelist.sol"; import "./PoolCreatorV2.sol"; contract PoolCreator is PoolCreatorV2 { bool public override isUniverseSettled; uint256 public poolVersion; uint256 public guardianCount; mapping(address => bool) public guardians; event AddGuardian(address indexed account); event TransferGuardian(address indexed fromAccount, address indexed toAccount); event RenounceGuardian(address indexed account); event SetUniverseSettled(); modifier onlyGuardian() { require(isGuardian(_msgSender()), "sender is not guardian"); _; } function isGuardian(address account) public view returns (bool) { return guardians[account]; } /** * @notice Set the guardian who is able to set `isUniverseSettled` flag. */ function addGuardian(address account) public onlyOwner { _addGuardian(account); } /** * @notice Transfer guardian from sender to some account. */ function transferGuardian(address toAccount) public onlyGuardian { require(toAccount != address(0), "guardian is zero address"); require(!isGuardian(toAccount), "guardian is already set"); address fromAccount = _msgSender(); guardians[fromAccount] = false; guardians[toAccount] = true; emit TransferGuardian(fromAccount, toAccount); } /** * @notice Renounce guardian. */ function renounceGuardian() external onlyGuardian { address account = _msgSender(); guardians[account] = false; guardianCount--; emit RenounceGuardian(account); } /** * @notice Indicates the universe settle state. When called: * - all the perpetual created by this poolCreator can be settled immediately; * - all the trading method will be unavailable. */ function setUniverseSettled() external onlyGuardian { require(!isUniverseSettled, "state is not changed"); isUniverseSettled = true; emit SetUniverseSettled(); } function _addGuardian(address account) internal { require(account != address(0), "guardian is zero address"); require(!isGuardian(account), "guardian is already set"); guardians[account] = true; guardianCount++; emit AddGuardian(account); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "../interface/IKeeperWhitelist.sol"; import "../libraries/Utils.sol"; contract KeeperWhitelist is Initializable, OwnableUpgradeable, IKeeperWhitelist { using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using Utils for EnumerableSetUpgradeable.AddressSet; EnumerableSetUpgradeable.AddressSet internal _keepers; event AddKeeperToWhitelist(address indexed keeper); event RemoveKeeperFromWhitelist(address indexed keeper); /** * @notice Add an address to keeper whitelist. */ function addKeeper(address keeper) external virtual override onlyOwner { require(keeper != address(0), "account is zero-address"); require(!isKeeper(keeper), "keeper is already in the whitelist"); bool success = _keepers.add(keeper); require(success, "fail to add keeper"); emit AddKeeperToWhitelist(keeper); } /** * @notice Remove an address from keeper whitelist. */ function removeKeeper(address keeper) external virtual override onlyOwner { require(keeper != address(0), "account is zero-address"); require(isKeeper(keeper), "keeper is not in the whitelist"); bool success = _keepers.remove(keeper); require(success, "fail to remove keeper"); emit RemoveKeeperFromWhitelist(keeper); } /** * @notice Check if an address is in keeper whitelist. */ function isKeeper(address keeper) public view virtual override returns (bool) { return _keepers.contains(keeper); } /** * @notice Get count of current keepers. * @return Number of keepers. */ function getKeeperCount() public view returns (uint256) { return _keepers.length(); } /** * @notice List all local keepers. * @param begin The begin index of keeper to retrieve. * @param end The end index of keeper, exclusive. * @return result An array of keeper addresses. */ function listKeepers(uint256 begin, uint256 end) public view virtual returns (address[] memory) { return _keepers.toArray(begin, end); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "./KeeperWhitelist.sol"; import "./PoolCreatorV1.sol"; abstract contract PoolCreatorV2 is PoolCreatorV1, KeeperWhitelist { /** * @notice Owner of version control. */ function owner() public view override(OwnableUpgradeable, PoolCreatorV1) returns (address) { return OwnableUpgradeable.owner(); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal initializer { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ 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; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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)))); } // 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 on 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)); } }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; 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 a proxied contract can't have 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. * * 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 {UpgradeableProxy-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. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; interface IKeeperWhitelist { /** * @notice Add an address to keeper whitelist. */ function addKeeper(address keeper) external; /** * @notice Remove an address from keeper whitelist. */ function removeKeeper(address keeper) external; /** * @notice Check if an address is in keeper whitelist. */ function isKeeper(address keeper) external view returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "@openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/math/SignedSafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "./SafeMathExt.sol"; library Utils { using SafeMathExt for int256; using SafeMathExt for uint256; using SafeMathUpgradeable for uint256; using SignedSafeMathUpgradeable for int256; using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.Bytes32Set; /* * @dev Check if two numbers have the same sign. Zero has the same sign with any number */ function hasTheSameSign(int256 x, int256 y) internal pure returns (bool) { if (x == 0 || y == 0) { return true; } return (x ^ y) >> 255 == 0; } /** * @dev Check if the trader has opened position in the trade. * Example: 2, 1 => true; 2, -1 => false; -2, -3 => true * @param amount The position of the trader after the trade * @param delta The update position amount of the trader after the trade * @return True if the trader has opened position in the trade */ function hasOpenedPosition(int256 amount, int256 delta) internal pure returns (bool) { if (amount == 0) { return false; } return Utils.hasTheSameSign(amount, delta); } /* * @dev Split the delta to two numbers. * Use for splitting the trading amount to the amount to close position and the amount to open position. * Examples: 2, 1 => 0, 1; 2, -1 => -1, 0; 2, -3 => -2, -1 */ function splitAmount(int256 amount, int256 delta) internal pure returns (int256, int256) { if (Utils.hasTheSameSign(amount, delta)) { return (0, delta); } else if (amount.abs() >= delta.abs()) { return (delta, 0); } else { return (amount.neg(), amount.add(delta)); } } /* * @dev Check if amount will be away from zero or cross zero if added the delta. * Use for checking if trading amount will make trader open position. * Example: 2, 1 => true; 2, -1 => false; 2, -3 => true */ function isOpen(int256 amount, int256 delta) internal pure returns (bool) { return Utils.hasTheSameSign(amount, delta) || amount.abs() < delta.abs(); } /* * @dev Get the id of the current chain */ function chainID() internal pure returns (uint256 id) { assembly { id := chainid() } } // function toArray( // EnumerableSet.AddressSet storage set, // uint256 begin, // uint256 end // ) internal view returns (address[] memory result) { // require(end > begin, "begin should be lower than end"); // uint256 length = set.length(); // if (begin >= length) { // return result; // } // uint256 safeEnd = end.min(length); // result = new address[](safeEnd.sub(begin)); // for (uint256 i = begin; i < safeEnd; i++) { // result[i.sub(begin)] = set.at(i); // } // return result; // } function toArray( EnumerableSetUpgradeable.AddressSet storage set, uint256 begin, uint256 end ) internal view returns (address[] memory result) { require(end > begin, "begin should be lower than end"); uint256 length = set.length(); if (begin >= length) { return result; } uint256 safeEnd = end.min(length); result = new address[](safeEnd.sub(begin)); for (uint256 i = begin; i < safeEnd; i++) { result[i.sub(begin)] = set.at(i); } return result; } function toArray( EnumerableSetUpgradeable.Bytes32Set storage set, uint256 begin, uint256 end ) internal view returns (bytes32[] memory result) { require(end > begin, "begin should be lower than end"); uint256 length = set.length(); if (begin >= length) { return result; } uint256 safeEnd = end.min(length); result = new bytes32[](safeEnd.sub(begin)); for (uint256 i = begin; i < safeEnd; i++) { result[i.sub(begin)] = set.at(i); } return result; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // 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; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. 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] = toDeleteIndex + 1; // All indexes are 1-based // 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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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)))); } // 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 on 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)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title SignedSafeMath * @dev Signed math operations with safety checks that revert on error. */ library SignedSafeMathUpgradeable { int256 constant private _INT256_MIN = -2**255; /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two signed integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "SignedSafeMath: division by zero"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; return c; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/math/SignedSafeMathUpgradeable.sol"; import "./Constant.sol"; import "./Utils.sol"; enum Round { CEIL, FLOOR } library SafeMathExt { using SafeMathUpgradeable for uint256; using SignedSafeMathUpgradeable for int256; /* * @dev Always half up for uint256 */ function wmul(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x.mul(y).add(Constant.UNSIGNED_ONE / 2) / Constant.UNSIGNED_ONE; } /* * @dev Always half up for uint256 */ function wdiv(uint256 x, uint256 y) internal pure returns (uint256 z) { z = x.mul(Constant.UNSIGNED_ONE).add(y / 2).div(y); } /* * @dev Always half up for uint256 */ function wfrac( uint256 x, uint256 y, uint256 z ) internal pure returns (uint256 r) { r = x.mul(y).add(z / 2).div(z); } /* * @dev Always half up if no rounding parameter */ function wmul(int256 x, int256 y) internal pure returns (int256 z) { z = roundHalfUp(x.mul(y), Constant.SIGNED_ONE) / Constant.SIGNED_ONE; } /* * @dev Always half up if no rounding parameter */ function wdiv(int256 x, int256 y) internal pure returns (int256 z) { if (y < 0) { y = neg(y); x = neg(x); } z = roundHalfUp(x.mul(Constant.SIGNED_ONE), y).div(y); } /* * @dev Always half up if no rounding parameter */ function wfrac( int256 x, int256 y, int256 z ) internal pure returns (int256 r) { int256 t = x.mul(y); if (z < 0) { z = neg(z); t = neg(t); } r = roundHalfUp(t, z).div(z); } function wmul( int256 x, int256 y, Round round ) internal pure returns (int256 z) { z = div(x.mul(y), Constant.SIGNED_ONE, round); } function wdiv( int256 x, int256 y, Round round ) internal pure returns (int256 z) { z = div(x.mul(Constant.SIGNED_ONE), y, round); } function wfrac( int256 x, int256 y, int256 z, Round round ) internal pure returns (int256 r) { int256 t = x.mul(y); r = div(t, z, round); } function abs(int256 x) internal pure returns (int256) { return x >= 0 ? x : neg(x); } function neg(int256 a) internal pure returns (int256) { return SignedSafeMathUpgradeable.sub(int256(0), a); } /* * @dev ROUND_HALF_UP rule helper. * You have to call roundHalfUp(x, y) / y to finish the rounding operation. * 0.5 ≈ 1, 0.4 ≈ 0, -0.5 ≈ -1, -0.4 ≈ 0 */ function roundHalfUp(int256 x, int256 y) internal pure returns (int256) { require(y > 0, "roundHalfUp only supports y > 0"); if (x >= 0) { return x.add(y / 2); } return x.sub(y / 2); } /* * @dev Division, rounding ceil or rounding floor */ function div( int256 x, int256 y, Round round ) internal pure returns (int256 divResult) { require(y != 0, "division by zero"); divResult = x.div(y); if (x % y == 0) { return divResult; } bool isSameSign = Utils.hasTheSameSign(x, y); if (round == Round.CEIL && isSameSign) { divResult = divResult.add(1); } if (round == Round.FLOOR && !isSameSign) { divResult = divResult.sub(1); } } function max(int256 a, int256 b) internal pure returns (int256) { return a >= b ? a : b; } function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; library Constant { address internal constant INVALID_ADDRESS = address(0); int256 internal constant SIGNED_ONE = 10**18; uint256 internal constant UNSIGNED_ONE = 10**18; uint256 internal constant PRIVILEGE_DEPOSIT = 0x1; uint256 internal constant PRIVILEGE_WITHDRAW = 0x2; uint256 internal constant PRIVILEGE_TRADE = 0x4; uint256 internal constant PRIVILEGE_LIQUIDATE = 0x8; uint256 internal constant PRIVILEGE_GUARD = PRIVILEGE_DEPOSIT | PRIVILEGE_WITHDRAW | PRIVILEGE_TRADE | PRIVILEGE_LIQUIDATE; // max number of uint256 uint256 internal constant SET_ALL_PERPETUALS_TO_EMERGENCY_STATE = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/ProxyAdmin.sol"; import "../interface/IGovernor.sol"; import "../interface/ILiquidityPool.sol"; import "../interface/IProxyAdmin.sol"; import "../interface/IPoolCreator.sol"; import "./Tracer.sol"; import "./VersionControl.sol"; import "./Variables.sol"; import "./AccessControl.sol"; abstract contract PoolCreatorV1 is Initializable, Tracer, VersionControl, Variables, AccessControl, IPoolCreator { using AddressUpgradeable for address; IProxyAdmin public override upgradeAdmin; event CreateLiquidityPool( bytes32 versionKey, address indexed liquidityPool, address indexed governor, address indexed operator, address shareToken, // downward compatibility for offline infrastructure address collateral, uint256 collateralDecimals, bytes initData ); event UpgradeLiquidityPool( bytes32 versionKey, address indexed liquidityPool, address indexed governor ); function initialize( address symbolService, address globalVault, int256 globalVaultFeeRate ) external initializer { __Ownable_init(); __Variables_init(symbolService, globalVault, globalVaultFeeRate); upgradeAdmin = IProxyAdmin(address(new ProxyAdmin())); } /** * @notice Owner of version control. */ function owner() public view virtual override(VersionControl, Variables) returns (address) { return OwnableUpgradeable.owner(); } /** * @notice Create a liquidity pool with the latest version. * The sender will be the operator of pool. * * @param collateral he collateral address of the liquidity pool. * @param collateralDecimals The collateral's decimals of the liquidity pool. * @param nonce A random nonce to calculate the address of deployed contracts. * @param initData A bytes array contains data to initialize new created liquidity pool. * @return liquidityPool The address of the created liquidity pool. */ function createLiquidityPool( address collateral, uint256 collateralDecimals, int256 nonce, bytes calldata initData ) external override returns (address liquidityPool, address governor) { (liquidityPool, governor) = _createLiquidityPoolWith( getLatestVersion(), collateral, collateralDecimals, nonce, initData ); } // /** // * @notice Create a liquidity pool with the specific version. The operator will be the sender. // * // * @param versionKey The key of the version to create. // * @param collateral The collateral address of the liquidity pool. // * @param collateralDecimals The collateral's decimals of the liquidity pool. // * @param nonce A random nonce to calculate the address of deployed contracts. // * @param initData A bytes array contains data to initialize new created liquidity pool. // * @return liquidityPool The address of the created liquidity pool. // * @return governor The address of the created governor. // */ // function createLiquidityPoolWith( // bytes32 versionKey, // address collateral, // uint256 collateralDecimals, // int256 nonce, // bytes memory initData // ) external override returns (address liquidityPool, address governor) { // (liquidityPool, governor) = _createLiquidityPoolWith( // versionKey, // collateral, // collateralDecimals, // nonce, // initData // ); // } /** * @notice Upgrade a liquidity pool and governor pair then call a patch function on the upgraded contract (optional). * This method checks the sender and forwards the request to ProxyAdmin to do upgrading. * * @param targetVersionKey The key of version to be upgrade up. The target version must be compatiable with * current version. * @param dataForLiquidityPool The patch calldata for upgraded liquidity pool. * @param dataForGovernor The patch calldata of upgraded governor. */ function upgradeToAndCall( bytes32 targetVersionKey, bytes memory dataForLiquidityPool, bytes memory dataForGovernor ) external override { ( address liquidityPool, address governor, address liquidityPoolTemplate, address governorTemplate ) = _getUpgradeContext(targetVersionKey); if (dataForLiquidityPool.length > 0) { upgradeAdmin.upgradeAndCall(liquidityPool, liquidityPoolTemplate, dataForLiquidityPool); } else { upgradeAdmin.upgrade(liquidityPool, liquidityPoolTemplate); } if (dataForGovernor.length > 0) { upgradeAdmin.upgradeAndCall(governor, governorTemplate, dataForGovernor); } else { upgradeAdmin.upgrade(governor, governorTemplate); } _updateDeployedInstances(targetVersionKey, liquidityPool, governor); emit UpgradeLiquidityPool(targetVersionKey, liquidityPool, governor); } /** * @dev Create a liquidity pool with the specific version. The operator will be the sender. * * @param versionKey The address of version * @param collateral The collateral address of the liquidity pool. * @param collateralDecimals The collateral's decimals of the liquidity pool. * @param nonce A random nonce to calculate the address of deployed contracts. * @param initData A bytes array contains data to initialize new created liquidity pool. * @return liquidityPool The address of the created liquidity pool. * @return governor The address of the created governor. */ function _createLiquidityPoolWith( bytes32 versionKey, address collateral, uint256 collateralDecimals, int256 nonce, bytes memory initData ) internal returns (address liquidityPool, address governor) { require(isVersionKeyValid(versionKey), "invalid version"); // initialize address operator = msg.sender; (address liquidityPoolTemplate, address governorTemplate, ) = getVersion(versionKey); bytes32 salt = keccak256(abi.encode(versionKey, collateral, initData, nonce)); liquidityPool = _createUpgradeableProxy(liquidityPoolTemplate, salt); governor = _createUpgradeableProxy(governorTemplate, salt); ILiquidityPool(liquidityPool).initialize( operator, collateral, collateralDecimals, governor, initData ); IGovernor(governor).initialize( "MCDEX Share Token", "STK", liquidityPool, liquidityPool, getMCBToken(), address(this) ); // register pool to tracer _registerLiquidityPool(liquidityPool, operator); _updateDeployedInstances(versionKey, liquidityPool, governor); // [EVENT UPDATE] emit CreateLiquidityPool( versionKey, liquidityPool, governor, operator, governor, collateral, collateralDecimals, initData ); } /** * @dev Create an upgradeable proxy contract of the implementation of liquidity pool. * * @param implementation The address of the implementation. * @param salt The random number for create2. * @return instance The address of the created upgradeable proxy contract. */ function _createUpgradeableProxy(address implementation, bytes32 salt) internal returns (address instance) { require(implementation.isContract(), "implementation must be contract"); bytes memory deploymentData = abi.encodePacked( type(TransparentUpgradeableProxy).creationCode, abi.encode(implementation, address(upgradeAdmin), "") ); assembly { instance := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt) } require(instance != address(0), "create2 call failed"); } /** * @dev Validate sender: * - the transaction must be sent from a governor. * - the sender governor and its liquidity pool must be already registered. * - the target version must be compatible with the current version. */ function _getUpgradeContext(bytes32 targetVersionKey) internal view returns ( address liquidityPool, address governor, address liquidityPoolTemplate, address governorTemplate ) { governor = _msgSender(); require(governor.isContract(), "sender must be a contract"); liquidityPool = IGovernor(governor).getTarget(); require(isLiquidityPool(liquidityPool), "sender is not the governor of a registered pool"); bytes32 deployedAddressHash = _getVersionHash(liquidityPool, governor); bytes32 baseVersionKey = _deployedVersions[deployedAddressHash]; require( isVersionCompatible(targetVersionKey, baseVersionKey), "the target version is not compatible" ); (liquidityPoolTemplate, governorTemplate, ) = getVersion(targetVersionKey); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./UpgradeableProxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is UpgradeableProxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}. */ constructor(address _logic, address admin_, bytes memory _data) public payable UpgradeableProxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _setAdmin(admin_); } /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _admin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { require(newAdmin != address(0), "TransparentUpgradeableProxy: new admin is the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external virtual ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable virtual ifAdmin { _upgradeTo(newImplementation); Address.functionDelegateCall(newImplementation, data); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address adm) { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { adm := sload(slot) } } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { bytes32 slot = _ADMIN_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newAdmin) } } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _admin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../access/Ownable.sol"; import "./TransparentUpgradeableProxy.sol"; /** * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. */ contract ProxyAdmin is Ownable { /** * @dev Returns the current implementation of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("implementation()")) == 0x5c60da1b (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); require(success); return abi.decode(returndata, (address)); } /** * @dev Returns the current admin of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("admin()")) == 0xf851a440 (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440"); require(success); return abi.decode(returndata, (address)); } /** * @dev Changes the admin of `proxy` to `newAdmin`. * * Requirements: * * - This contract must be the current admin of `proxy`. */ function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner { proxy.changeAdmin(newAdmin); } /** * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner { proxy.upgradeTo(implementation); } /** * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See * {TransparentUpgradeableProxy-upgradeToAndCall}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IGovernor { function initialize( string memory name, string memory symbol, address minter, address target_, address rewardToken, address poolCreator ) external; function totalSupply() external view returns (uint256); function getTarget() external view returns (address); function mint(address account, uint256 amount) external; function burn(address account, uint256 amount) external; function balanceOf(address account) external view returns (uint256); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "../Type.sol"; interface ILiquidityPool { /** * @notice Initialize the liquidity pool and set up its configuration. * * @param operator The operator's address of the liquidity pool. * @param collateral The collateral's address of the liquidity pool. * @param collateralDecimals The collateral's decimals of the liquidity pool. * @param governor The governor's address of the liquidity pool. * @param initData A bytes array contains data to initialize new created liquidity pool. */ function initialize( address operator, address collateral, uint256 collateralDecimals, address governor, bytes calldata initData ) external; /** * @notice Set the liquidity pool to running state. Can be call only once by operater.m n */ function runLiquidityPool() external; /** * @notice If you want to get the real-time data, call this function first */ function forceToSyncState() external; /** * @notice Add liquidity to the liquidity pool. * Liquidity provider deposits collaterals then gets share tokens back. * The ratio of added cash to share token is determined by current liquidity. * Can only called when the pool is running. * * @param cashToAdd The amount of cash to add. always use decimals 18. */ function addLiquidity(int256 cashToAdd) external; /** * @notice Remove liquidity from the liquidity pool. * Liquidity providers redeems share token then gets collateral back. * The amount of collateral retrieved may differ from the amount when adding liquidity, * The index price, trading fee and positions holding by amm will affect the profitability of providers. * Can only called when the pool is running. * * @param shareToRemove The amount of share token to remove. The amount always use decimals 18. * @param cashToReturn The amount of cash(collateral) to return. The amount always use decimals 18. */ function removeLiquidity(int256 shareToRemove, int256 cashToReturn) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; interface IProxyAdmin { function getProxyImplementation(address proxy) external view returns (address); /** * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgrade(address proxy, address implementation) external; /** * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See * {TransparentUpgradeableProxy-upgradeToAndCall}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgradeAndCall( address proxy, address implementation, bytes memory data ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; import "./IProxyAdmin.sol"; interface IPoolCreator { function upgradeAdmin() external view returns (IProxyAdmin proxyAdmin); /** * @notice Create a liquidity pool with the latest version. * The sender will be the operator of pool. * * @param collateral he collateral address of the liquidity pool. * @param collateralDecimals The collateral's decimals of the liquidity pool. * @param nonce A random nonce to calculate the address of deployed contracts. * @param initData A bytes array contains data to initialize new created liquidity pool. * @return liquidityPool The address of the created liquidity pool. */ function createLiquidityPool( address collateral, uint256 collateralDecimals, int256 nonce, bytes calldata initData ) external returns (address liquidityPool, address governor); /** * @notice Upgrade a liquidity pool and governor pair then call a patch function on the upgraded contract (optional). * This method checks the sender and forwards the request to ProxyAdmin to do upgrading. * * @param targetVersionKey The key of version to be upgrade up. The target version must be compatible with * current version. * @param dataForLiquidityPool The patch calldata for upgraded liquidity pool. * @param dataForGovernor The patch calldata of upgraded governor. */ function upgradeToAndCall( bytes32 targetVersionKey, bytes memory dataForLiquidityPool, bytes memory dataForGovernor ) external; /** * @notice Indicates the universe settle state. * If the flag set to true: * - all the pereptual created by this poolCreator can be settled immediately; * - all the trading method will be unavailable. */ function isUniverseSettled() external view returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "../libraries/SafeMathExt.sol"; import "../libraries/Utils.sol"; contract Tracer { using SafeMath for uint256; using SafeMathExt for uint256; using Utils for EnumerableSetUpgradeable.AddressSet; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.Bytes32Set; struct PerpetualUID { address liquidityPool; uint256 perpetualIndex; } // liquidity pool address[] EnumerableSetUpgradeable.AddressSet internal _liquidityPoolSet; // hash(puid) => PerpetualUID {} mapping(bytes32 => PerpetualUID) internal _perpetualUIDs; // trader => hash(puid) [] mapping(address => EnumerableSetUpgradeable.Bytes32Set) internal _traderActiveLiquidityPools; // operator => address mapping(address => EnumerableSetUpgradeable.AddressSet) internal _operatorOwnedLiquidityPools; mapping(address => address) internal _liquidityPoolOwners; modifier onlyLiquidityPool() { require(isLiquidityPool(msg.sender), "caller is not liquidity pool instance"); _; } // =========================== Liquidity Pool =========================== /** * @notice Get the number of all liquidity pools. * * @return uint256 The number of all liquidity pools */ function getLiquidityPoolCount() public view returns (uint256) { return _liquidityPoolSet.length(); } /** * @notice Check if the liquidity pool exists. * * @param liquidityPool The address of the liquidity pool. * @return True if the liquidity pool exists. */ function isLiquidityPool(address liquidityPool) public view returns (bool) { return _liquidityPoolSet.contains(liquidityPool); } /** * @notice Get the liquidity pools whose index between begin and end. * * @param begin The begin index. * @param end The end index. * @return result An array of liquidity pool addresses whose index between begin and end. */ function listLiquidityPools(uint256 begin, uint256 end) public view returns (address[] memory result) { result = _liquidityPoolSet.toArray(begin, end); } /** * @notice Get the number of the liquidity pools owned by the operator. * * @param operator The address of operator. * @return uint256 The number of the liquidity pools owned by the operator. */ function getOwnedLiquidityPoolsCountOf(address operator) public view returns (uint256) { return _operatorOwnedLiquidityPools[operator].length(); } /** * @notice Get the liquidity pools owned by the operator and whose index between begin and end. * * @param operator The address of the operator. * @param begin The begin index. * @param end The end index. * @return result The liquidity pools owned by the operator and whose index between begin and end. */ function listLiquidityPoolOwnedBy( address operator, uint256 begin, uint256 end ) public view returns (address[] memory result) { return _operatorOwnedLiquidityPools[operator].toArray(begin, end); } /** * @notice Liquidity pool must call this method when changing its ownership to the new operator. * Can only be called by a liquidity pool. This method does not affect 'ownership' or privileges * of operator but only make a record for further query. * * @param liquidityPool The address of the liquidity pool. * @param operator The address of the new operator, must be different from the old operator. */ function registerOperatorOfLiquidityPool(address liquidityPool, address operator) public onlyLiquidityPool { address prevOperator = _liquidityPoolOwners[liquidityPool]; _operatorOwnedLiquidityPools[prevOperator].remove(liquidityPool); _operatorOwnedLiquidityPools[operator].add(liquidityPool); _liquidityPoolOwners[liquidityPool] = operator; } /** * @dev Record the liquidity pool, the liquidity pool should not be recorded before * * @param liquidityPool The address of the liquidity pool. * @param operator The address of operator. */ function _registerLiquidityPool(address liquidityPool, address operator) internal { require(liquidityPool != address(0), "invalid liquidity pool address"); bool success = _liquidityPoolSet.add(liquidityPool); require(success, "liquidity pool exists"); _operatorOwnedLiquidityPools[operator].add(liquidityPool); _liquidityPoolOwners[liquidityPool] = operator; } // =========================== Active Liquidity Pool of Trader =========================== /** * @notice Get the number of the trader's active liquidity pools. Active means the trader's account is * not all empty in perpetuals of the liquidity pool. Empty means cash and position are zero. * * @param trader The address of the trader. * @return Number of the trader's active liquidity pools. */ function getActiveLiquidityPoolCountOf(address trader) public view returns (uint256) { return _traderActiveLiquidityPools[trader].length(); } /** * @notice Check if the perpetual is active for the trader. Active means the trader's account is * not empty in the perpetual. Empty means cash and position are zero. * * @param trader The address of the trader. * @param liquidityPool The address of liquidity pool. * @param perpetualIndex The index of the perpetual in the liquidity pool. * @return True if the perpetual is active for the trader. */ function isActiveLiquidityPoolOf( address trader, address liquidityPool, uint256 perpetualIndex ) public view returns (bool) { return _traderActiveLiquidityPools[trader].contains( _getPerpetualKey(liquidityPool, perpetualIndex) ); } /** * @notice Get the liquidity pools whose index between begin and end and active for the trader. * Active means the trader's account is not all empty in perpetuals of the liquidity pool. * Empty means cash and position are zero. * * @param trader The address of the trader. * @param begin The begin index. * @param end The end index. * @return result An array of active (non-empty margin account) liquidity pool address and perpetul index. */ function listActiveLiquidityPoolsOf( address trader, uint256 begin, uint256 end ) public view returns (PerpetualUID[] memory result) { require(end > begin, "begin should be lower than end"); uint256 length = _traderActiveLiquidityPools[trader].length(); if (begin >= length) { return result; } uint256 safeEnd = end.min(length); result = new PerpetualUID[](safeEnd.sub(begin)); for (uint256 i = begin; i < safeEnd; i++) { result[i.sub(begin)] = _perpetualUIDs[_traderActiveLiquidityPools[trader].at(i)]; } return result; } /** * @notice Activate the perpetual for the trader. Active means the trader's account is not empty in * the perpetual. Empty means cash and position are zero. Can only called by a liquidity pool. * * @param trader The address of the trader. * @param perpetualIndex The index of the perpetual in the liquidity pool. * @return True if the activation is successful. */ function activatePerpetualFor(address trader, uint256 perpetualIndex) external onlyLiquidityPool returns (bool) { bytes32 key = _getPerpetualKey(msg.sender, perpetualIndex); if (_perpetualUIDs[key].liquidityPool == address(0)) { _perpetualUIDs[key] = PerpetualUID({ liquidityPool: msg.sender, perpetualIndex: perpetualIndex }); } return _traderActiveLiquidityPools[trader].add(key); } /** * @notice Deactivate the perpetual for the trader. Active means the trader's account is not empty in * the perpetual. Empty means cash and position are zero. Can only called by a liquidity pool. * * @param trader The address of the trader. * @param perpetualIndex The index of the perpetual in the liquidity pool. * @return True if the deactivation is successful. */ function deactivatePerpetualFor(address trader, uint256 perpetualIndex) external onlyLiquidityPool returns (bool) { return _traderActiveLiquidityPools[trader].remove( _getPerpetualKey(msg.sender, perpetualIndex) ); } // =========================== Active Liquidity Pool of Trader =========================== /** * @dev Get the key of the perpetual * @param liquidityPool The address of the liquidity pool which the perpetual belongs to. * @param perpetualIndex The index of the perpetual in the liquidity pool. * @return Key hash of the perpetual. */ function _getPerpetualKey(address liquidityPool, uint256 perpetualIndex) internal pure returns (bytes32) { return keccak256(abi.encodePacked(liquidityPool, perpetualIndex)); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol"; import "../interface/IUpgradeableProxy.sol"; import "../interface/IVersionControl.sol"; import "../libraries/SafeMathExt.sol"; contract VersionControl is OwnableUpgradeable, IVersionControl { using Utils for EnumerableSetUpgradeable.Bytes32Set; using SafeMathExt for uint256; using AddressUpgradeable for address; using SafeMathUpgradeable for uint256; using EnumerableSetUpgradeable for EnumerableSetUpgradeable.Bytes32Set; struct VersionDescription { address liquidityPoolTemplate; address governorTemplate; uint256 compatibility; } EnumerableSetUpgradeable.Bytes32Set internal _versionKeys; mapping(bytes32 => VersionDescription) internal _versionDescriptions; mapping(bytes32 => bytes32) internal _deployedVersions; event AddVersion( bytes32 versionKey, address indexed liquidityPoolTemplate, address indexed governorTemplate, address indexed creator, uint256 compatibility, string note ); /** * @notice Owner of version control. */ function owner() public view virtual override(IVersionControl, OwnableUpgradeable) returns (address) { return OwnableUpgradeable.owner(); } /** * @notice Create a new version with template of liquidity pool and governor. * * @param liquidityPoolTemplate The address of the liquidityPool implementation. * @param governorTemplate The address of the governor implementation. * @param compatibility The compatibility of the implementation * @param note The note of the version, only in log. * @return versionKey The key of the version added. */ function addVersion( address liquidityPoolTemplate, address governorTemplate, uint256 compatibility, string calldata note ) external onlyOwner returns (bytes32 versionKey) { require(liquidityPoolTemplate.isContract(), "implementation must be contract"); require(governorTemplate.isContract(), "implementation must be contract"); versionKey = _getVersionHash(liquidityPoolTemplate, governorTemplate); require(!isVersionKeyValid(versionKey), "implementation already exists"); _versionDescriptions[versionKey] = VersionDescription({ liquidityPoolTemplate: liquidityPoolTemplate, governorTemplate: governorTemplate, compatibility: compatibility }); _versionKeys.add(versionKey); emit AddVersion( versionKey, liquidityPoolTemplate, governorTemplate, msg.sender, compatibility, note ); } /** * @notice Get the latest created key of template. Revert if there is no key yet. * * @return latestVersionKey The key of the latest template of liquidity pool and governor. */ function getLatestVersion() public view override returns (bytes32 latestVersionKey) { require(_versionKeys.length() > 0, "no version"); latestVersionKey = _versionKeys.at(_versionKeys.length() - 1); } /** * @notice Get the details of the version. * * @param versionKey The key of the version to get. * @return liquidityPoolTemplate The address of the liquidity pool template. * @return governorTemplate The address of the governor template. * @return compatibility The compatibility of the specified version. */ function getVersion(bytes32 versionKey) public view override returns ( address liquidityPoolTemplate, address governorTemplate, uint256 compatibility ) { require(isVersionKeyValid(versionKey), "implementation is invalid"); VersionDescription storage version = _versionDescriptions[versionKey]; liquidityPoolTemplate = version.liquidityPoolTemplate; governorTemplate = version.governorTemplate; compatibility = version.compatibility; } /** * @notice Get the description of the implementation of liquidity pool. * Description contains creator, create time, compatibility and note * * @param liquidityPool The address of the liquidity pool. * @param governor The address of the governor. * @return appliedVersionKey The version key of given liquidity pool and governor. */ function getAppliedVersionKey(address liquidityPool, address governor) external view override returns (bytes32 appliedVersionKey) { bytes32 deployedAddressHash = _getVersionHash(liquidityPool, governor); appliedVersionKey = _deployedVersions[deployedAddressHash]; } /** * @notice Check if a key is valid (exists). * * @param versionKey The key of the version to test. * @return isValid Return true if the version of given key is valid. */ function isVersionKeyValid(bytes32 versionKey) public view override returns (bool isValid) { isValid = _versionKeys.contains(versionKey); } /** * @notice Check if the implementation of liquidity pool target is compatible with the implementation base. * Being compatible means having larger compatibility. * * @param targetVersionKey The key of the version to be upgraded to. * @param baseVersionKey The key of the version to be upgraded from. * @return isCompatible True if the target version is compatible with the base version. */ function isVersionCompatible(bytes32 targetVersionKey, bytes32 baseVersionKey) public view override returns (bool isCompatible) { require(isVersionKeyValid(targetVersionKey), "target version is invalid"); require(isVersionKeyValid(baseVersionKey), "base version is invalid"); isCompatible = _versionDescriptions[targetVersionKey].compatibility >= _versionDescriptions[baseVersionKey].compatibility; } /** * @dev Get a certain number of implementations of liquidity pool within range [begin, end). * * @param begin The index of first element to retrieve. * @param end The end index of element, exclusive. * @return versionKeys An array contains current version keys. */ function listAvailableVersions(uint256 begin, uint256 end) external view override returns (bytes32[] memory versionKeys) { versionKeys = _versionKeys.toArray(begin, end); } function _getVersionHash(address liquidityPoolTemplate, address governorTemplate) internal pure returns (bytes32) { return keccak256(abi.encodePacked(liquidityPoolTemplate, governorTemplate)); } function _updateDeployedInstances( bytes32 versionKeys, address liquidityPool, address governor ) internal { bytes32 deployedAddressHash = _getVersionHash(liquidityPool, governor); _deployedVersions[deployedAddressHash] = versionKeys; } function _validateUpgradeVersion( bytes32 targetVersionKey, address liquidityPool, address governor ) internal view { bytes32 deployedAddressHash = _getVersionHash(liquidityPool, governor); bytes32 baseVersionKey = _deployedVersions[deployedAddressHash]; require( isVersionCompatible(targetVersionKey, baseVersionKey), "the target version is not compatible" ); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import "../interface/IVariables.sol"; contract Variables is Initializable, OwnableUpgradeable, IVariables { bytes32 internal _reserved1; address internal _symbolService; address internal _vault; int256 internal _vaultFeeRate; event SetVaultFeeRate(int256 prevFeeRate, int256 newFeeRate); event SetVault(address previousVault, address newVault); event SetKeeper(address previousKeeper, address newKeeper); event SetRewardDistributor(address previousRewardDistributor, address newRewardDistributor); function __Variables_init( address symbolService_, address vault_, int256 vaultFeeRate_ ) internal initializer { require(symbolService_ != address(0), "invalid symbol service address"); require(vault_ != address(0), "invalid vault address"); require(vaultFeeRate_ >= 0, "negative vault fee rate"); _symbolService = symbolService_; _vault = vault_; _vaultFeeRate = vaultFeeRate_; } /** * @notice Owner of version control. */ function owner() public view virtual override(IVariables, OwnableUpgradeable) returns (address) { return OwnableUpgradeable.owner(); } /** * @notice Get the address of the vault * @return address The address of the vault */ function getVault() public view override returns (address) { return _vault; } /** * @notice Get the vault fee rate * @return int256 The vault fee rate */ function getVaultFeeRate() public view override returns (int256) { return _vaultFeeRate; } /** * @notice Set the vault address. Can only called by owner(dao). * * @param newVault The new value of the vault fee rate */ function setVault(address newVault) external override onlyOwner { require(newVault != address(0), "new vault is zero-address"); require(_vault != newVault, "new vault is already current vault"); emit SetVault(_vault, newVault); _vault = newVault; } /** * @notice Set the vault fee rate. Can only called by owner(dao). * * @param newVaultFeeRate The new value of the vault fee rate */ function setVaultFeeRate(int256 newVaultFeeRate) external override onlyOwner { require(newVaultFeeRate >= 0, "negative vault fee rate"); require(newVaultFeeRate != _vaultFeeRate, "unchanged vault fee rate"); emit SetVaultFeeRate(_vaultFeeRate, newVaultFeeRate); _vaultFeeRate = newVaultFeeRate; } /** * @notice Get the address of the access controller. It's always its own address. * * @return address The address of the access controller. */ function getAccessController() external view override returns (address) { return address(this); } /** * @notice Get the address of the symbol service. * * @return Address The address of the symbol service. */ function getSymbolService() external view override returns (address) { return _symbolService; } /** * @notice Get the address of the mcb token. * @dev [ConfirmBeforeDeployment] * * @return Address The address of the mcb token. */ function getMCBToken() public pure override returns (address) { return address(0x4e352cF164E64ADCBad318C3a1e222E9EBa4Ce42); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; import "../libraries/EnumerableMapExt.sol"; import "../libraries/BitwiseMath.sol"; import "../libraries/Constant.sol"; import "../interface/IAccessControl.sol"; contract AccessControl is IAccessControl { using BitwiseMath for uint256; using EnumerableMapExt for EnumerableMapExt.AddressToUintMap; mapping(address => EnumerableMapExt.AddressToUintMap) internal _accessControls; // privilege event GrantPrivilege(address indexed grantor, address indexed grantee, uint256 privilege); event RevokePrivilege(address indexed grantor, address indexed grantee, uint256 privilege); /** * @notice Grant the grantee the privilege by sender. * There are three kinds of privilege: deposit, withdraw and trade. * * @param grantee The address of the grantee. * @param privilege The privilege to grant. */ function grantPrivilege(address grantee, uint256 privilege) external override { require(_isValid(privilege), "privilege is invalid"); require(!isGranted(msg.sender, grantee, privilege), "privilege is already granted"); uint256 grantedPrivileges = _accessControls[msg.sender].contains(grantee) ? _accessControls[msg.sender].get(grantee) : 0; grantedPrivileges = grantedPrivileges.set(privilege); _accessControls[msg.sender].set(grantee, grantedPrivileges); emit GrantPrivilege(msg.sender, grantee, privilege); } /** * @notice Revoke the privilege of the grantee. Can only called by the grantor. * * @param grantee The address of the grantee, the account to accept privilege. * @param privilege The privilege to revoke. */ function revokePrivilege(address grantee, uint256 privilege) external override { require(_isValid(privilege), "privilege is invalid"); require(isGranted(msg.sender, grantee, privilege), "privilege is not granted"); _accessControls[msg.sender].set( grantee, _accessControls[msg.sender].get(grantee).clean(privilege) ); emit RevokePrivilege(msg.sender, grantee, privilege); } /** * @notice Check if the grantee is granted the privilege by the grantor * @param grantor The address of the main account, the account gives privilege. * @param grantee The address of the grantee, the account to accept privilege. * @param privilege The privilege, there are three kinds of valid privilege: deposit, withdraw, trade * @return True if the grantee is granted the privilege by the grantor. */ function isGranted( address grantor, address grantee, uint256 privilege ) public view override returns (bool) { if (!_isValid(privilege)) { return false; } if (!_accessControls[grantor].contains(grantee)) { return false; } uint256 granted = _accessControls[grantor].get(grantee); return granted > 0 && granted.test(privilege); } function _isValid(uint256 privilege) private pure returns (bool) { return privilege > 0 && privilege <= Constant.PRIVILEGE_GUARD; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./Proxy.sol"; import "../utils/Address.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. * * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see * {TransparentUpgradeableProxy}. */ contract UpgradeableProxy is Proxy { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) public payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _setImplementation(_logic); if(_data.length > 0) { Address.functionDelegateCall(_logic, _data); } } /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { impl := sload(slot) } } /** * @dev Upgrades the proxy to a new implementation. * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal virtual { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "UpgradeableProxy: new implementation is not a contract"); bytes32 slot = _IMPLEMENTATION_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newImplementation) } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { // solhint-disable-next-line no-inline-assembly assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback () external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive () external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; import "@openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol"; /** * @notice Perpetual state: * - INVALID: Uninitialized or not non-existent perpetual; * - INITIALIZING: Only when LiquidityPoolStorage.isRunning == false. Traders cannot perform operations; * - NORMAL: Full functional state. Traders is able to perform all operations; * - EMERGENCY: Perpetual is unsafe and only clear is available; * - CLEARED: All margin account is cleared. Trade could withdraw remaining margin balance. */ enum PerpetualState { INVALID, INITIALIZING, NORMAL, EMERGENCY, CLEARED } enum OrderType { LIMIT, MARKET, STOP } /** * @notice Data structure to store risk parameter value. */ struct Option { int256 value; int256 minValue; int256 maxValue; } /** * @notice Data structure to store oracle price data. */ struct OraclePriceData { int256 price; uint256 time; } /** * @notice Data structure to store user margin information. See MarginAccountModule.sol for details. */ struct MarginAccount { int256 cash; int256 position; int256 targetLeverage; } /** * @notice Data structure of an order object. */ struct Order { address trader; address broker; address relayer; address referrer; address liquidityPool; int256 minTradeAmount; int256 amount; int256 limitPrice; int256 triggerPrice; uint256 chainID; uint64 expiredAt; uint32 perpetualIndex; uint32 brokerFeeLimit; uint32 flags; uint32 salt; } /** * @notice Core data structure, a core . */ struct LiquidityPoolStorage { bool isRunning; bool isFastCreationEnabled; // addresses address creator; address operator; address transferringOperator; address governor; address shareToken; address accessController; bool reserved3; // isWrapped uint256 scaler; uint256 collateralDecimals; address collateralToken; // pool attributes int256 poolCash; uint256 fundingTime; uint256 reserved5; uint256 operatorExpiration; mapping(address => int256) reserved1; bytes32[] reserved2; // perpetuals uint256 perpetualCount; mapping(uint256 => PerpetualStorage) perpetuals; // insurance fund int256 insuranceFundCap; int256 insuranceFund; int256 donatedInsuranceFund; address reserved4; // reserved slot for future upgrade bytes32[16] reserved; } /** * @notice Core data structure, storing perpetual information. */ struct PerpetualStorage { uint256 id; PerpetualState state; address oracle; int256 totalCollateral; int256 openInterest; // prices OraclePriceData indexPriceData; OraclePriceData markPriceData; OraclePriceData settlementPriceData; // funding state int256 fundingRate; int256 unitAccumulativeFunding; // base parameters int256 initialMarginRate; int256 maintenanceMarginRate; int256 operatorFeeRate; int256 lpFeeRate; int256 referralRebateRate; int256 liquidationPenaltyRate; int256 keeperGasReward; int256 insuranceFundRate; int256 reserved1; int256 maxOpenInterestRate; // risk parameters Option halfSpread; Option openSlippageFactor; Option closeSlippageFactor; Option fundingRateLimit; Option fundingRateFactor; Option ammMaxLeverage; Option maxClosePriceDiscount; // users uint256 totalAccount; int256 totalMarginWithoutPosition; int256 totalMarginWithPosition; int256 redemptionRateWithoutPosition; int256 redemptionRateWithPosition; EnumerableSetUpgradeable.AddressSet activeAccounts; // insurance fund int256 reserved2; int256 reserved3; // accounts mapping(address => MarginAccount) marginAccounts; Option defaultTargetLeverage; // keeper address reserved4; EnumerableSetUpgradeable.AddressSet ammKeepers; EnumerableSetUpgradeable.AddressSet reserved5; // reserved slot for future upgrade bytes32[12] reserved; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; interface IUpgradeableProxy { function implementation() external view returns (address); function upgradeTo(address newImplementation) external; function upgradeToAndCall(address newImplementation, bytes calldata data) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; import "./IProxyAdmin.sol"; interface IVersionControl { function owner() external view returns (address); function getLatestVersion() external view returns (bytes32 latestVersionKey); /** * @notice Get the details of the version. * * @param versionKey The key of the version to get. * @return liquidityPoolTemplate The address of the liquidity pool template. * @return governorTemplate The address of the governor template. * @return compatibility The compatibility of the specified version. */ function getVersion(bytes32 versionKey) external view returns ( address liquidityPoolTemplate, address governorTemplate, uint256 compatibility ); /** * @notice Get the description of the implementation of liquidity pool. * Description contains creator, create time, compatibility and note * * @param liquidityPool The address of the liquidity pool. * @param governor The address of the governor. * @return appliedVersionKey The version key of given liquidity pool and governor. */ function getAppliedVersionKey(address liquidityPool, address governor) external view returns (bytes32 appliedVersionKey); /** * @notice Check if a key is valid (exists). * * @param versionKey The key of the version to test. * @return isValid Return true if the version of given key is valid. */ function isVersionKeyValid(bytes32 versionKey) external view returns (bool isValid); /** * @notice Check if the implementation of liquidity pool target is compatible with the implementation base. * Being compatible means having larger compatibility. * * @param targetVersionKey The key of the version to be upgraded to. * @param baseVersionKey The key of the version to be upgraded from. * @return isCompatible True if the target version is compatible with the base version. */ function isVersionCompatible(bytes32 targetVersionKey, bytes32 baseVersionKey) external view returns (bool isCompatible); /** * @dev Get a certain number of implementations of liquidity pool within range [begin, end). * * @param begin The index of first element to retrieve. * @param end The end index of element, exclusive. * @return versionKeys An array contains current version keys. */ function listAvailableVersions(uint256 begin, uint256 end) external view returns (bytes32[] memory versionKeys); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; import "./IProxyAdmin.sol"; interface IVariables { function owner() external view returns (address); /** * @notice Get the address of the vault * @return address The address of the vault */ function getVault() external view returns (address); /** * @notice Get the vault fee rate * @return int256 The vault fee rate */ function getVaultFeeRate() external view returns (int256); /** * @notice Get the address of the access controller. It's always its own address. * * @return address The address of the access controller. */ function getAccessController() external view returns (address); /** * @notice Get the address of the symbol service. * * @return Address The address of the symbol service. */ function getSymbolService() external view returns (address); /** * @notice Set the vault address. Can only called by owner. * * @param newVault The new value of the vault fee rate */ function setVault(address newVault) external; /** * @notice Get the address of the mcb token. * @dev [ConfirmBeforeDeployment] * * @return Address The address of the mcb token. */ function getMCBToken() external pure returns (address); /** * @notice Set the vault fee rate. Can only called by owner. * * @param newVaultFeeRate The new value of the vault fee rate */ function setVaultFeeRate(int256 newVaultFeeRate) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; // The MIT License (MIT) // Copyright (c) 2020 zOS Global Limited // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. library EnumerableMapExt { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses internal functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { address _key; uint256 _value; } struct AddressToUintMap { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping(address => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( AddressToUintMap storage map, address key, uint256 value ) internal returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToUintMap storage map, address key) internal returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToUintMap storage map, address key) internal view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function length(AddressToUintMap storage map) internal view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToUintMap storage map, address key) internal view returns (uint256) { return get(map, key, "EnumerableMap: nonexistent key"); } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. */ function get( AddressToUintMap storage map, address key, string memory errorMessage ) internal view returns (uint256) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.4; library BitwiseMath { /** * @dev Check if the value is 1 at the bit position * @param value The value * @param bit The bit, should be 2^n * @return bool True if the value is 1 at the bit position */ function test(uint256 value, uint256 bit) internal pure returns (bool) { return value & bit > 0; } /** * @dev Set the value to 1 at the bit position * @param value The value * @param bit The bit, should be 2^n * @return uint256 The modified value */ function set(uint256 value, uint256 bit) internal pure returns (uint256) { return value | bit; } /** * @dev Set value to 0 at the bit position * @param value The value * @param bit The bit, should be 2^n * @return uint256 The modified value */ function clean(uint256 value, uint256 bit) internal pure returns (uint256) { return value & (~bit); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.4; interface IAccessControl { function grantPrivilege(address trader, uint256 privilege) external; function revokePrivilege(address trader, uint256 privilege) external; function isGranted( address owner, address trader, uint256 privilege ) external view returns (bool); }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"AddGuardian","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"keeper","type":"address"}],"name":"AddKeeperToWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"versionKey","type":"bytes32"},{"indexed":true,"internalType":"address","name":"liquidityPoolTemplate","type":"address"},{"indexed":true,"internalType":"address","name":"governorTemplate","type":"address"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256","name":"compatibility","type":"uint256"},{"indexed":false,"internalType":"string","name":"note","type":"string"}],"name":"AddVersion","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"versionKey","type":"bytes32"},{"indexed":true,"internalType":"address","name":"liquidityPool","type":"address"},{"indexed":true,"internalType":"address","name":"governor","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"shareToken","type":"address"},{"indexed":false,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDecimals","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"initData","type":"bytes"}],"name":"CreateLiquidityPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"grantor","type":"address"},{"indexed":true,"internalType":"address","name":"grantee","type":"address"},{"indexed":false,"internalType":"uint256","name":"privilege","type":"uint256"}],"name":"GrantPrivilege","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"keeper","type":"address"}],"name":"RemoveKeeperFromWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"RenounceGuardian","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"grantor","type":"address"},{"indexed":true,"internalType":"address","name":"grantee","type":"address"},{"indexed":false,"internalType":"uint256","name":"privilege","type":"uint256"}],"name":"RevokePrivilege","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousKeeper","type":"address"},{"indexed":false,"internalType":"address","name":"newKeeper","type":"address"}],"name":"SetKeeper","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousRewardDistributor","type":"address"},{"indexed":false,"internalType":"address","name":"newRewardDistributor","type":"address"}],"name":"SetRewardDistributor","type":"event"},{"anonymous":false,"inputs":[],"name":"SetUniverseSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousVault","type":"address"},{"indexed":false,"internalType":"address","name":"newVault","type":"address"}],"name":"SetVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int256","name":"prevFeeRate","type":"int256"},{"indexed":false,"internalType":"int256","name":"newFeeRate","type":"int256"}],"name":"SetVaultFeeRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fromAccount","type":"address"},{"indexed":true,"internalType":"address","name":"toAccount","type":"address"}],"name":"TransferGuardian","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"versionKey","type":"bytes32"},{"indexed":true,"internalType":"address","name":"liquidityPool","type":"address"},{"indexed":true,"internalType":"address","name":"governor","type":"address"}],"name":"UpgradeLiquidityPool","type":"event"},{"inputs":[{"internalType":"address","name":"trader","type":"address"},{"internalType":"uint256","name":"perpetualIndex","type":"uint256"}],"name":"activatePerpetualFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"keeper","type":"address"}],"name":"addKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"liquidityPoolTemplate","type":"address"},{"internalType":"address","name":"governorTemplate","type":"address"},{"internalType":"uint256","name":"compatibility","type":"uint256"},{"internalType":"string","name":"note","type":"string"}],"name":"addVersion","outputs":[{"internalType":"bytes32","name":"versionKey","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"collateralDecimals","type":"uint256"},{"internalType":"int256","name":"nonce","type":"int256"},{"internalType":"bytes","name":"initData","type":"bytes"}],"name":"createLiquidityPool","outputs":[{"internalType":"address","name":"liquidityPool","type":"address"},{"internalType":"address","name":"governor","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"trader","type":"address"},{"internalType":"uint256","name":"perpetualIndex","type":"uint256"}],"name":"deactivatePerpetualFor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAccessController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"trader","type":"address"}],"name":"getActiveLiquidityPoolCountOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"liquidityPool","type":"address"},{"internalType":"address","name":"governor","type":"address"}],"name":"getAppliedVersionKey","outputs":[{"internalType":"bytes32","name":"appliedVersionKey","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getKeeperCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestVersion","outputs":[{"internalType":"bytes32","name":"latestVersionKey","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidityPoolCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMCBToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"getOwnedLiquidityPoolsCountOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSymbolService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVaultFeeRate","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"versionKey","type":"bytes32"}],"name":"getVersion","outputs":[{"internalType":"address","name":"liquidityPoolTemplate","type":"address"},{"internalType":"address","name":"governorTemplate","type":"address"},{"internalType":"uint256","name":"compatibility","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"grantee","type":"address"},{"internalType":"uint256","name":"privilege","type":"uint256"}],"name":"grantPrivilege","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"guardianCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"guardians","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"symbolService","type":"address"},{"internalType":"address","name":"globalVault","type":"address"},{"internalType":"int256","name":"globalVaultFeeRate","type":"int256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"liquidityPool","type":"address"},{"internalType":"uint256","name":"perpetualIndex","type":"uint256"}],"name":"isActiveLiquidityPoolOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"grantor","type":"address"},{"internalType":"address","name":"grantee","type":"address"},{"internalType":"uint256","name":"privilege","type":"uint256"}],"name":"isGranted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isGuardian","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"keeper","type":"address"}],"name":"isKeeper","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"liquidityPool","type":"address"}],"name":"isLiquidityPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isUniverseSettled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"targetVersionKey","type":"bytes32"},{"internalType":"bytes32","name":"baseVersionKey","type":"bytes32"}],"name":"isVersionCompatible","outputs":[{"internalType":"bool","name":"isCompatible","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"versionKey","type":"bytes32"}],"name":"isVersionKeyValid","outputs":[{"internalType":"bool","name":"isValid","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"trader","type":"address"},{"internalType":"uint256","name":"begin","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"listActiveLiquidityPoolsOf","outputs":[{"components":[{"internalType":"address","name":"liquidityPool","type":"address"},{"internalType":"uint256","name":"perpetualIndex","type":"uint256"}],"internalType":"struct Tracer.PerpetualUID[]","name":"result","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"begin","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"listAvailableVersions","outputs":[{"internalType":"bytes32[]","name":"versionKeys","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"begin","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"listKeepers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"begin","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"listLiquidityPoolOwnedBy","outputs":[{"internalType":"address[]","name":"result","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"begin","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"}],"name":"listLiquidityPools","outputs":[{"internalType":"address[]","name":"result","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"liquidityPool","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"registerOperatorOfLiquidityPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"keeper","type":"address"}],"name":"removeKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"grantee","type":"address"},{"internalType":"uint256","name":"privilege","type":"uint256"}],"name":"revokePrivilege","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setUniverseSettled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newVault","type":"address"}],"name":"setVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"newVaultFeeRate","type":"int256"}],"name":"setVaultFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"toAccount","type":"address"}],"name":"transferGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"upgradeAdmin","outputs":[{"internalType":"contract IProxyAdmin","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"targetVersionKey","type":"bytes32"},{"internalType":"bytes","name":"dataForLiquidityPool","type":"bytes"},{"internalType":"bytes","name":"dataForGovernor","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506156e5806100206000396000f3fe60806040523480156200001157600080fd5b50600436106200037b5760003560e01c8063715018a611620001dd578063affe5bed1162000111578063da81573111620000b1578063e9946f6c1162000087578063e9946f6c146200073e578063f2fde38b1462000748578063f81d65f1146200075f578063fcf2b3fc1462000776576200037b565b8063da8157311462000706578063db7ca94b1462000710578063e85455d71462000727576200037b565b8063c2f3da1d11620000e7578063c2f3da1d14620006db578063c4d5608a14620006f2578063d54bda9714620006fc576200037b565b8063affe5bed14620006a3578063b49f32e714620006ba578063c1d27fe714620006c4576200037b565b806384ffaf28116200017d5780639aaf9f0811620001535780639aaf9f08146200064d578063a526d83b1462000675578063ade79601146200068c576200037b565b806384ffaf2814620006225780638d928af814620006395780638da5cb5b1462000643576200037b565b8063824372c711620001b3578063824372c714620005ce5780638277c65114620005f457806384452fef146200060b576200037b565b8063715018a614620005a357806372d27c9d14620005ad5780637a5f0ffd14620005c4576200037b565b806333c0b0fc11620002b55780634831d32f1162000255578063625fdca3116200022b578063625fdca3146200055e5780636817031b14620005755780636ba42aaa146200058c576200037b565b80634831d32f1462000540578063492c26b6146200054a57806354387ad71462000554576200037b565b806341cbd53d116200028b57806341cbd53d1462000508578063439adb781462000512578063471a4bc61462000529576200037b565b806333c0b0fc14620004c35780633c597ff614620004da5780634032b72b14620004f1576200037b565b80630e6d1de911620003215780631fe5ee8811620002f75780631fe5ee88146200046f57806325b7f04f14620004955780632accccc414620004ac576200037b565b80630e6d1de9146200043557806314ae9f2e146200044e57806316d6b5f61462000465576200037b565b8063091954cd1162000357578063091954cd14620003e15780630a4a9bb414620003f85780630c68ba21146200041e576200037b565b8062dc415a14620003805780630633b14a146200039957806307c4d48614620003c8575b600080fd5b62000397620003913660046200364a565b6200079d565b005b620003b0620003aa3660046200360c565b6200085c565b604051620003bf919062003b10565b60405180910390f35b620003d262000871565b604051620003bf91906200393d565b62000397620003f23660046200360c565b62000880565b6200040f6200040936600462003827565b62000975565b604051620003bf919062003a2d565b620003b06200042f3660046200360c565b6200098e565b6200043f620009ac565b604051620003bf919062003b1b565b620003976200045f3660046200360c565b62000a30565b620003d262000bfe565b6200048662000480366004620037d7565b62000c02565b604051620003bf919062003ab6565b6200040f620004a6366004620037d7565b62000d6b565b62000397620004bd36600462003849565b62000d9b565b62000397620004d43660046200380e565b62000fdc565b620003b0620004eb36600462003827565b62001146565b62000397620005023660046200360c565b62001224565b62000397620013de565b620003b0620005233660046200375a565b62001469565b620003976200053a3660046200375a565b6200152d565b620003b0620016a0565b6200043f620016a9565b6200043f620016af565b6200040f6200056f36600462003827565b620016b5565b62000397620005863660046200360c565b620016c5565b620003b06200059d3660046200360c565b62001853565b6200039762001862565b6200043f620005be3660046200360c565b62001925565b6200043f62001948565b620005e5620005df36600462003827565b62001956565b604051620003bf919062003a7c565b620003b0620006053660046200380e565b62001966565b6200043f6200061c366004620036e1565b62001975565b620003976200063336600462003687565b62001c31565b620003d262001d41565b620003d262001d50565b620006646200065e3660046200380e565b62001d5c565b604051620003bf93929190620039c2565b62000397620006863660046200360c565b62001def565b620003b06200069d366004620036cc565b62001e76565b62000397620006b43660046200375a565b62001ea7565b620003d262001fef565b6200043f620006d53660046200360c565b62002007565b620003b0620006ec366004620036cc565b6200202a565b620003d2620020be565b6200043f620020cd565b6200043f620020db565b6200043f620007213660046200364a565b620020e1565b620003b0620007383660046200360c565b62002107565b6200039762002116565b62000397620007593660046200360c565b620021a7565b620003b0620007703660046200375a565b620022c3565b6200078d6200078736600462003788565b6200231e565b604051620003bf92919062003951565b620007a83362002107565b620007d05760405162461bcd60e51b8152600401620007c79062003dae565b60405180910390fd5b6001600160a01b0380831660009081526006602090815260408083205490931680835260059091529190206200080790846200237d565b506001600160a01b03821660009081526005602052604090206200082c908462002394565b50506001600160a01b03918216600090815260066020526040902080546001600160a01b03191691909216179055565b607a6020526000908152604090205460ff1681565b6070546001600160a01b031690565b6200088e6200042f620023ab565b620008ad5760405162461bcd60e51b8152600401620007c79062003c07565b6001600160a01b038116620008d65760405162461bcd60e51b8152600401620007c79062003d40565b620008e1816200098e565b15620009015760405162461bcd60e51b8152600401620007c79062003e0b565b60006200090d620023ab565b6001600160a01b038082166000818152607a6020526040808220805460ff19908116909155938716808352818320805490951660011790945551939450919290917f19e3cbfd9b25c12fb88132e5887dc3a2a4f52979bd0af17f78e6fea817addf4b91a35050565b60606200098560758484620023af565b90505b92915050565b6001600160a01b03166000908152607a602052604090205460ff1690565b600080620009bb606b620024d5565b1162000a0e576040805162461bcd60e51b815260206004820152600a60248201527f6e6f2076657273696f6e00000000000000000000000000000000000000000000604482015290519081900360640190fd5b62000a2b600162000a20606b620024d5565b606b919003620024e2565b905090565b62000a3a620023ab565b6001600160a01b031662000a4d62001d50565b6001600160a01b03161462000aa9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811662000b05576040805162461bcd60e51b815260206004820152601760248201527f6163636f756e74206973207a65726f2d61646472657373000000000000000000604482015290519081900360640190fd5b62000b108162001853565b62000b62576040805162461bcd60e51b815260206004820152601e60248201527f6b6565706572206973206e6f7420696e207468652077686974656c6973740000604482015290519081900360640190fd5b600062000b716075836200237d565b90508062000bc6576040805162461bcd60e51b815260206004820152601560248201527f6661696c20746f2072656d6f7665206b65657065720000000000000000000000604482015290519081900360640190fd5b6040516001600160a01b038316907fbe3bdeafee52d4ccc66d6c1392815c90e3a1c88659588b2ee138035fd8ab009e90600090a25050565b3090565b606082821162000c265760405162461bcd60e51b8152600401620007c79062003b99565b6001600160a01b038416600090815260046020526040812062000c4990620024d5565b905080841062000c5a575062000d64565b600062000c688483620024f0565b905062000c76818662002508565b67ffffffffffffffff8111801562000c8d57600080fd5b5060405190808252806020026020018201604052801562000ccb57816020015b62000cb762003511565b81526020019060019003908162000cad5790505b509250845b8181101562000d60576001600160a01b03871660009081526004602052604081206003919062000d019084620024e2565b81526020808201929092526040908101600020815180830190925280546001600160a01b0316825260010154918101919091528462000d41838962002508565b8151811062000d4c57fe5b602090810291909101015260010162000cd0565b5050505b9392505050565b6001600160a01b038316600090815260056020526040902060609062000d93908484620023af565b949350505050565b60008060008062000dac8762002566565b935093509350935060008651111562000e2f57607454604051639623609d60e01b81526001600160a01b0390911690639623609d9062000df590879086908b906004016200396b565b600060405180830381600087803b15801562000e1057600080fd5b505af115801562000e25573d6000803e3d6000fd5b5050505062000e98565b60745460405163266a23b160e21b81526001600160a01b03909116906399a88ec49062000e63908790869060040162003951565b600060405180830381600087803b15801562000e7e57600080fd5b505af115801562000e93573d6000803e3d6000fd5b505050505b84511562000f1057607454604051639623609d60e01b81526001600160a01b0390911690639623609d9062000ed690869085908a906004016200396b565b600060405180830381600087803b15801562000ef157600080fd5b505af115801562000f06573d6000803e3d6000fd5b5050505062000f79565b60745460405163266a23b160e21b81526001600160a01b03909116906399a88ec49062000f44908690859060040162003951565b600060405180830381600087803b15801562000f5f57600080fd5b505af115801562000f74573d6000803e3d6000fd5b505050505b62000f86878585620026b1565b826001600160a01b0316846001600160a01b03167f7f690cf92643ebecf3ed65f2c0400eaf65578ae88d1e46c6d00039bbdf0fb91a8960405162000fcb919062003b1b565b60405180910390a350505050505050565b62000fe6620023ab565b6001600160a01b031662000ff962001d50565b6001600160a01b03161462001055576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000811215620010ac576040805162461bcd60e51b815260206004820152601760248201527f6e65676174697665207661756c74206665652072617465000000000000000000604482015290519081900360640190fd5b60725481141562001104576040805162461bcd60e51b815260206004820152601860248201527f756e6368616e676564207661756c742066656520726174650000000000000000604482015290519081900360640190fd5b607254604080519182526020820183905280517f720bdddca2e8c70d6ac27a51abd2eb4fbaca31653c8a9990eb307838fc5162919281900390910190a1607255565b6000620011538362001966565b620011a5576040805162461bcd60e51b815260206004820152601960248201527f7461726765742076657273696f6e20697320696e76616c696400000000000000604482015290519081900360640190fd5b620011b08262001966565b62001202576040805162461bcd60e51b815260206004820152601760248201527f626173652076657273696f6e20697320696e76616c6964000000000000000000604482015290519081900360640190fd5b506000908152606d602052604080822060029081015493835291200154101590565b6200122e620023ab565b6001600160a01b03166200124162001d50565b6001600160a01b0316146200129d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116620012f9576040805162461bcd60e51b815260206004820152601760248201527f6163636f756e74206973207a65726f2d61646472657373000000000000000000604482015290519081900360640190fd5b620013048162001853565b15620013425760405162461bcd60e51b81526004018080602001828103825260228152602001806200568e6022913960400191505060405180910390fd5b60006200135160758362002394565b905080620013a6576040805162461bcd60e51b815260206004820152601260248201527f6661696c20746f20616464206b65657065720000000000000000000000000000604482015290519081900360640190fd5b6040516001600160a01b038316907f26ae89c0d3c267cb14cd6aa7e2de3d1c55a87f6610a3ca5f1d8cf19ca65cd39d90600090a25050565b620013ec6200042f620023ab565b6200140b5760405162461bcd60e51b8152600401620007c79062003c07565b60775460ff1615620014315760405162461bcd60e51b8152600401620007c79062003c3e565b6077805460ff191660011790556040517f5d3b5534803eff415e41e2b11bff1cc3536cf0f85e12143eb543ea33a2aeb3ff90600090a1565b6000620014763362002107565b620014955760405162461bcd60e51b8152600401620007c79062003dae565b6000620014a33384620026d6565b6000818152600360205260409020549091506001600160a01b03166200150957604080518082018252338152602080820186815260008581526003909252929020905181546001600160a01b0319166001600160a01b0390911617815590516001909101555b6001600160a01b038416600090815260046020526040902062000d9390826200270b565b620015388162002719565b6200158a576040805162461bcd60e51b815260206004820152601460248201527f70726976696c65676520697320696e76616c6964000000000000000000000000604482015290519081900360640190fd5b620015973383836200202a565b15620015ea576040805162461bcd60e51b815260206004820152601c60248201527f70726976696c65676520697320616c7265616479206772616e74656400000000604482015290519081900360640190fd5b3360009081526073602052604081206200160590846200272e565b620016125760006200162d565b3360009081526073602052604090206200162d90846200274f565b90506200163b818362002793565b3360009081526073602052604090209091506200165a90848362002797565b506040805183815290516001600160a01b0385169133917fb542e9113bf4db53a191bfb69cafe0c1d0647ca432aa8a6d36b6f9b04ec5473b9181900360200190a3505050565b60775460ff1681565b60725490565b60795481565b60606200098560018484620023af565b620016cf620023ab565b6001600160a01b0316620016e262001d50565b6001600160a01b0316146200173e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166200179a576040805162461bcd60e51b815260206004820152601960248201527f6e6577207661756c74206973207a65726f2d6164647265737300000000000000604482015290519081900360640190fd5b6071546001600160a01b0382811691161415620017e95760405162461bcd60e51b8152600401808060200182810382526022815260200180620056186022913960400191505060405180910390fd5b607154604080516001600160a01b039283168152918316602083015280517f22a9f7c8a21e91a43518238948d4ed67511ad8492ca0e13fdbc93c134701a72a9281900390910190a1607180546001600160a01b0319166001600160a01b0392909216919091179055565b6000620009886075836200285f565b6200186c620023ab565b6001600160a01b03166200187f62001d50565b6001600160a01b031614620018db576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6039546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603980546001600160a01b0319169055565b6001600160a01b03811660009081526004602052604081206200098890620024d5565b600062000a2b6001620024d5565b606062000985606b848462002876565b600062000988606b836200298f565b600062001981620023ab565b6001600160a01b03166200199462001d50565b6001600160a01b031614620019f0576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b62001a04866001600160a01b03166200299d565b62001a56576040805162461bcd60e51b815260206004820152601f60248201527f696d706c656d656e746174696f6e206d75737420626520636f6e747261637400604482015290519081900360640190fd5b62001a6a856001600160a01b03166200299d565b62001abc576040805162461bcd60e51b815260206004820152601f60248201527f696d706c656d656e746174696f6e206d75737420626520636f6e747261637400604482015290519081900360640190fd5b62001ac88686620029a3565b905062001ad58162001966565b1562001b28576040805162461bcd60e51b815260206004820152601d60248201527f696d706c656d656e746174696f6e20616c726561647920657869737473000000604482015290519081900360640190fd5b604080516060810182526001600160a01b03808916825287811660208084019182528385018981526000878152606d909252949020925183549083166001600160a01b03199182161784559051600184018054919093169116179055905160029091015562001b99606b826200270b565b50336001600160a01b0316856001600160a01b0316876001600160a01b03167f1ae7782997ea5d0490cc9c4db962cfb50f949390e7b99082d3df8ac5d58eaef98488888860405180858152602001848152602001806020018281038252848482818152602001925080828437600083820152604051601f909101601f191690920182900397509095505050505050a495945050505050565b600054610100900460ff168062001c4d575062001c4d620029ea565b8062001c5c575060005460ff16155b62001c995760405162461bcd60e51b815260040180806020018281038252602e81526020018062005660602e913960400191505060405180910390fd5b600054610100900460ff1615801562001cc5576000805460ff1961ff0019909116610100171660011790555b62001ccf620029fd565b62001cdc84848462002aba565b60405162001cea9062003528565b604051809103906000f08015801562001d07573d6000803e3d6000fd5b50607480546001600160a01b0319166001600160a01b0392909216919091179055801562001d3b576000805461ff00191690555b50505050565b6071546001600160a01b031690565b600062000a2b62002caa565b600080600062001d6c8462001966565b62001dbe576040805162461bcd60e51b815260206004820152601960248201527f696d706c656d656e746174696f6e20697320696e76616c696400000000000000604482015290519081900360640190fd5b5050506000908152606d60205260409020805460018201546002909201546001600160a01b03918216939290911691565b62001df9620023ab565b6001600160a01b031662001e0c62001d50565b6001600160a01b03161462001e68576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b62001e738162002cb9565b50565b600062000d9362001e888484620026d6565b6001600160a01b0386166000908152600460205260409020906200298f565b62001eb28162002719565b62001f04576040805162461bcd60e51b815260206004820152601460248201527f70726976696c65676520697320696e76616c6964000000000000000000000000604482015290519081900360640190fd5b62001f113383836200202a565b62001f63576040805162461bcd60e51b815260206004820152601860248201527f70726976696c656765206973206e6f74206772616e7465640000000000000000604482015290519081900360640190fd5b33600090815260736020526040902062001faa90839062001f9390849062001f8c90846200274f565b9062002d65565b336000908152607360205260409020919062002797565b506040805182815290516001600160a01b0384169133917f2e910d80b3ddddaff95f2e39c7c226987cd86d56b81c7352b8393efe6f0914709181900360200190a35050565b734e352cf164e64adcbad318c3a1e222e9eba4ce4290565b6001600160a01b03811660009081526005602052604081206200098890620024d5565b6000620020378262002719565b620020455750600062000d64565b6001600160a01b03841660009081526073602052604090206200206990846200272e565b620020775750600062000d64565b6001600160a01b03841660009081526073602052604081206200209b90856200274f565b9050600081118015620020b55750620020b5818462002d6a565b95945050505050565b6074546001600160a01b031681565b600062000a2b6075620024d5565b60785481565b600080620020f08484620029a3565b6000908152606e6020526040902054949350505050565b6000620009886001836200285f565b620021246200042f620023ab565b620021435760405162461bcd60e51b8152600401620007c79062003c07565b60006200214f620023ab565b6001600160a01b0381166000818152607a6020526040808220805460ff19169055607980546000190190555192935090917fb472605167b0007a2ba90117c6f9ca960abddaa4aaed0e6e3b5e7a5e3eec70149190a250565b620021b1620023ab565b6001600160a01b0316620021c462001d50565b6001600160a01b03161462002220576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116620022675760405162461bcd60e51b81526004018080602001828103825260268152602001806200563a6026913960400191505060405180910390fd5b6039546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603980546001600160a01b0319166001600160a01b0392909216919091179055565b6000620022d03362002107565b620022ef5760405162461bcd60e51b8152600401620007c79062003dae565b62000985620022ff3384620026d6565b6001600160a01b03851660009081526004602052604090209062002d70565b6000806200236f6200232f620009ac565b88888888888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525062002d7e92505050565b909890975095505050505050565b600062000985836001600160a01b03841662002f89565b600062000985836001600160a01b0384166200305c565b3390565b606082821162002406576040805162461bcd60e51b815260206004820152601e60248201527f626567696e2073686f756c64206265206c6f776572207468616e20656e640000604482015290519081900360640190fd5b60006200241385620024d5565b905080841062002424575062000d64565b6000620024328483620024f0565b905062002440818662002508565b67ffffffffffffffff811180156200245757600080fd5b5060405190808252806020026020018201604052801562002482578160200160208202803683370190505b509250845b8181101562000d60576200249c8782620024e2565b84620024a9838962002508565b81518110620024b457fe5b6001600160a01b039092166020928302919091019091015260010162002487565b60006200098882620030ab565b6000620009858383620030af565b600081831062002501578162000985565b5090919050565b60008282111562002560576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008060008062002576620023ab565b92506200258c836001600160a01b03166200299d565b620025ab5760405162461bcd60e51b8152600401620007c79062003f6d565b826001600160a01b031663f00e6a2a6040518163ffffffff1660e01b815260040160206040518083038186803b158015620025e557600080fd5b505afa158015620025fa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200262091906200362b565b93506200262d8462002107565b6200264c5760405162461bcd60e51b8152600401620007c79062003cac565b60006200265a8585620029a3565b6000818152606e602052604090205490915062002678878262001146565b620026975760405162461bcd60e51b8152600401620007c79062003f10565b620026a28762001d5c565b50969895975095949350505050565b6000620026bf8383620029a3565b6000908152606e6020526040902093909355505050565b60008282604051602001620026ed929190620038e8565b60405160208183030381529060405280519060200120905092915050565b60006200098583836200305c565b6000808211801562000988575050600f101590565b6001600160a01b031660009081526001919091016020526040902054151590565b60006200098583836040518060400160405280601e81526020017f456e756d657261626c654d61703a206e6f6e6578697374656e74206b6579000081525062003116565b1790565b6001600160a01b0382166000908152600184016020526040812054806200282b5750506040805180820182526001600160a01b038481168083526020808401868152885460018082018b5560008b81528481209751600290930290970180546001600160a01b0319169290961691909117855590519381019390935587549184528288019052929091209190915562000d64565b828560000160018303815481106200283f57fe5b906000526020600020906002020160010181905550600091505062000d64565b600062000985836001600160a01b038416620031ef565b6060828211620028cd576040805162461bcd60e51b815260206004820152601e60248201527f626567696e2073686f756c64206265206c6f776572207468616e20656e640000604482015290519081900360640190fd5b6000620028da85620024d5565b9050808410620028eb575062000d64565b6000620028f98483620024f0565b905062002907818662002508565b67ffffffffffffffff811180156200291e57600080fd5b5060405190808252806020026020018201604052801562002949578160200160208202803683370190505b509250845b8181101562000d6057620029638782620024e2565b8462002970838962002508565b815181106200297b57fe5b60209081029190910101526001016200294e565b6000620009858383620031ef565b3b151590565b604080516bffffffffffffffffffffffff19606094851b81166020808401919091529390941b90931660348401528051602881850301815260489093019052815191012090565b6000620029f7306200299d565b15905090565b600054610100900460ff168062002a19575062002a19620029ea565b8062002a28575060005460ff16155b62002a655760405162461bcd60e51b815260040180806020018281038252602e81526020018062005660602e913960400191505060405180910390fd5b600054610100900460ff1615801562002a91576000805460ff1961ff0019909116610100171660011790555b62002a9b62003207565b62002aa5620032af565b801562001e73576000805461ff001916905550565b600054610100900460ff168062002ad6575062002ad6620029ea565b8062002ae5575060005460ff16155b62002b225760405162461bcd60e51b815260040180806020018281038252602e81526020018062005660602e913960400191505060405180910390fd5b600054610100900460ff1615801562002b4e576000805460ff1961ff0019909116610100171660011790555b6001600160a01b03841662002baa576040805162461bcd60e51b815260206004820152601e60248201527f696e76616c69642073796d626f6c207365727669636520616464726573730000604482015290519081900360640190fd5b6001600160a01b03831662002c06576040805162461bcd60e51b815260206004820152601560248201527f696e76616c6964207661756c7420616464726573730000000000000000000000604482015290519081900360640190fd5b600082121562002c5d576040805162461bcd60e51b815260206004820152601760248201527f6e65676174697665207661756c74206665652072617465000000000000000000604482015290519081900360640190fd5b607080546001600160a01b038087166001600160a01b03199283161790925560718054928616929091169190911790556072829055801562001d3b576000805461ff001916905550505050565b6039546001600160a01b031690565b6001600160a01b03811662002ce25760405162461bcd60e51b8152600401620007c79062003d40565b62002ced816200098e565b1562002d0d5760405162461bcd60e51b8152600401620007c79062003e0b565b6001600160a01b0381166000818152607a6020526040808220805460ff19166001908117909155607980549091019055517f1648d9bcedc1ce9debe5943030bb342edf8bcabe4770643cf181d22c3b473dd29190a250565b191690565b16151590565b600062000985838362002f89565b60008062002d8c8762001966565b62002dab5760405162461bcd60e51b8152600401620007c79062003bd0565b3360008062002dba8a62001d5c565b509150915060008a8a888a60405160200162002dda949392919062003b5e565b60405160208183030381529060405280519060200120905062002dfe8382620033b2565b955062002e0c8282620033b2565b6040517f7074020e0000000000000000000000000000000000000000000000000000000081529095506001600160a01b03871690637074020e9062002e5e9087908e908e908b908e90600401620039e6565b600060405180830381600087803b15801562002e7957600080fd5b505af115801562002e8e573d6000803e3d6000fd5b50505050846001600160a01b031663e56f2fe4878862002ead62001fef565b306040518563ffffffff1660e01b815260040162002ecf949392919062003e79565b600060405180830381600087803b15801562002eea57600080fd5b505af115801562002eff573d6000803e3d6000fd5b5050505062002f0f868562003493565b62002f1c8b8787620026b1565b836001600160a01b0316856001600160a01b0316876001600160a01b03167f7b8def528c4bce8aace2c39ea9d8f4c6d3d5dece020ef9441b205f7a831b4dc78e898f8f8e60405162002f7395949392919062003b24565b60405180910390a4505050509550959350505050565b600081815260018301602052604081205480156200304a578354600019808301919081019060009087908390811062002fbe57fe5b906000526020600020015490508087600001848154811062002fdc57fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806200300d57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505062000988565b600091505062000988565b5092915050565b60006200306a8383620031ef565b620030a25750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000988565b50600062000988565b5490565b81546000908210620030f35760405162461bcd60e51b8152600401808060200182810382526022815260200180620055f66022913960400191505060405180910390fd5b8260000182815481106200310357fe5b9060005260206000200154905092915050565b6001600160a01b03821660009081526001840160205260408120548281620031bf5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156200318357818101518382015260200162003169565b50505050905090810190601f168015620031b15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110620031d357fe5b9060005260206000209060020201600101549150509392505050565b60009081526001919091016020526040902054151590565b600054610100900460ff168062003223575062003223620029ea565b8062003232575060005460ff16155b6200326f5760405162461bcd60e51b815260040180806020018281038252602e81526020018062005660602e913960400191505060405180910390fd5b600054610100900460ff1615801562002aa5576000805460ff1961ff001990911661010017166001179055801562001e73576000805461ff001916905550565b600054610100900460ff1680620032cb5750620032cb620029ea565b80620032da575060005460ff16155b620033175760405162461bcd60e51b815260040180806020018281038252602e81526020018062005660602e913960400191505060405180910390fd5b600054610100900460ff1615801562003343576000805460ff1961ff0019909116610100171660011790555b60006200334f620023ab565b603980546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350801562001e73576000805461ff001916905550565b6000620033c8836001600160a01b03166200299d565b620033e75760405162461bcd60e51b8152600401620007c79062003d77565b606060405180602001620033fb9062003536565b601f1982820381018352601f9091011660408190526074546200342d9187916001600160a01b03169060200162003999565b60408051601f19818403018152908290526200344d92916020016200390a565b6040516020818303038152906040529050828151826020016000f591506001600160a01b038216620030555760405162461bcd60e51b8152600401620007c79062003c75565b6001600160a01b038216620034bc5760405162461bcd60e51b8152600401620007c79062003d09565b6000620034cb60018462002394565b905080620034ed5760405162461bcd60e51b8152600401620007c79062003e42565b6001600160a01b03821660009081526005602052604090206200082c908462002394565b604080518082019091526000808252602082015290565b61097e8062003fea83390190565b610c8e806200496883390190565b60008083601f84011262003556578182fd5b50813567ffffffffffffffff8111156200356e578182fd5b6020830191508360208285010111156200358757600080fd5b9250929050565b600082601f8301126200359f578081fd5b813567ffffffffffffffff80821115620035b557fe5b604051601f8301601f191681016020018281118282101715620035d457fe5b604052828152925082848301602001861015620035f057600080fd5b8260208601602083013760006020848301015250505092915050565b6000602082840312156200361e578081fd5b813562000d648162003fd3565b6000602082840312156200363d578081fd5b815162000d648162003fd3565b600080604083850312156200365d578081fd5b82356200366a8162003fd3565b915060208301356200367c8162003fd3565b809150509250929050565b6000806000606084860312156200369c578081fd5b8335620036a98162003fd3565b92506020840135620036bb8162003fd3565b929592945050506040919091013590565b6000806000606084860312156200369c578283fd5b600080600080600060808688031215620036f9578081fd5b8535620037068162003fd3565b94506020860135620037188162003fd3565b935060408601359250606086013567ffffffffffffffff8111156200373b578182fd5b620037498882890162003544565b969995985093965092949392505050565b600080604083850312156200376d578182fd5b82356200377a8162003fd3565b946020939093013593505050565b600080600080600060808688031215620037a0578081fd5b8535620037ad8162003fd3565b94506020860135935060408601359250606086013567ffffffffffffffff8111156200373b578182fd5b600080600060608486031215620037ec578283fd5b8335620037f98162003fd3565b95602085013595506040909401359392505050565b60006020828403121562003820578081fd5b5035919050565b600080604083850312156200383a578182fd5b50508035926020909101359150565b6000806000606084860312156200385e578283fd5b83359250602084013567ffffffffffffffff808211156200387d578384fd5b6200388b878388016200358e565b93506040860135915080821115620038a1578283fd5b50620038b0868287016200358e565b9150509250925092565b60008151808452620038d481602086016020860162003fa4565b601f01601f19169290920160200192915050565b60609290921b6bffffffffffffffffffffffff19168252601482015260340190565b600083516200391e81846020880162003fa4565b8351908301906200393481836020880162003fa4565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b60006001600160a01b03808616835280851660208401525060606040830152620020b56060830184620038ba565b6001600160a01b0392831681529116602082015260606040820181905260009082015260800190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006001600160a01b038088168352808716602084015285604084015280851660608401525060a0608083015262003a2260a0830184620038ba565b979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101562003a705783516001600160a01b03168352928401929184019160010162003a49565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101562003a705783518352928401929184019160010162003a98565b602080825282518282018190526000919060409081850190868401855b8281101562003b0357815180516001600160a01b0316855286015186850152928401929085019060010162003ad3565b5091979650505050505050565b901515815260200190565b90815260200190565b60008682526001600160a01b03808716602084015280861660408401525083606083015260a0608083015262003a2260a0830184620038ba565b60008582526001600160a01b03851660208301526080604083015262003b886080830185620038ba565b905082606083015295945050505050565b6020808252601e908201527f626567696e2073686f756c64206265206c6f776572207468616e20656e640000604082015260600190565b6020808252600f908201527f696e76616c69642076657273696f6e0000000000000000000000000000000000604082015260600190565b60208082526016908201527f73656e646572206973206e6f7420677561726469616e00000000000000000000604082015260600190565b60208082526014908201527f7374617465206973206e6f74206368616e676564000000000000000000000000604082015260600190565b60208082526013908201527f637265617465322063616c6c206661696c656400000000000000000000000000604082015260600190565b6020808252602f908201527f73656e646572206973206e6f742074686520676f7665726e6f72206f6620612060408201527f7265676973746572656420706f6f6c0000000000000000000000000000000000606082015260800190565b6020808252601e908201527f696e76616c6964206c697175696469747920706f6f6c20616464726573730000604082015260600190565b60208082526018908201527f677561726469616e206973207a65726f20616464726573730000000000000000604082015260600190565b6020808252601f908201527f696d706c656d656e746174696f6e206d75737420626520636f6e747261637400604082015260600190565b60208082526025908201527f63616c6c6572206973206e6f74206c697175696469747920706f6f6c20696e7360408201527f74616e6365000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526017908201527f677561726469616e20697320616c726561647920736574000000000000000000604082015260600190565b60208082526015908201527f6c697175696469747920706f6f6c206578697374730000000000000000000000604082015260600190565b60c08082526011908201527f4d4344455820536861726520546f6b656e00000000000000000000000000000060e0820152610100602082018190526003908201527f53544b00000000000000000000000000000000000000000000000000000000006101208201526001600160a01b0394851660408201529284166060840152908316608083015290911660a08201526101400190565b60208082526024908201527f746865207461726765742076657273696f6e206973206e6f7420636f6d70617460408201527f69626c6500000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f73656e646572206d757374206265206120636f6e747261637400000000000000604082015260600190565b60005b8381101562003fc157818101518382015260200162003fa7565b8381111562001d3b5750506000910152565b6001600160a01b038116811462001e7357600080fdfe608060405234801561001057600080fd5b50600061001b61006a565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35061006e565b3390565b6109018061007d6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461013657806399a88ec4146101f5578063f2fde38b14610230578063f3b7dead146102635761007b565b8063204e1c7a14610080578063715018a6146100cf5780637eff275e146100e65780638da5cb5b14610121575b600080fd5b34801561008c57600080fd5b506100b3600480360360208110156100a357600080fd5b50356001600160a01b0316610296565b604080516001600160a01b039092168252519081900360200190f35b3480156100db57600080fd5b506100e4610341565b005b3480156100f257600080fd5b506100e46004803603604081101561010957600080fd5b506001600160a01b038135811691602001351661040c565b34801561012d57600080fd5b506100b36104eb565b6100e46004803603606081101561014c57600080fd5b6001600160a01b03823581169260208101359091169181019060608101604082013564010000000081111561018057600080fd5b82018360208201111561019257600080fd5b803590602001918460018302840111640100000000831117156101b457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506104fa945050505050565b34801561020157600080fd5b506100e46004803603604081101561021857600080fd5b506001600160a01b0381358116916020013516610645565b34801561023c57600080fd5b506100e46004803603602081101561025357600080fd5b50356001600160a01b0316610708565b34801561026f57600080fd5b506100b36004803603602081101561028657600080fd5b50356001600160a01b0316610829565b6000806060836001600160a01b031660405180807f5c60da1b000000000000000000000000000000000000000000000000000000008152506004019050600060405180830381855afa9150503d806000811461030e576040519150601f19603f3d011682016040523d82523d6000602084013e610313565b606091505b50915091508161032257600080fd5b80806020019051602081101561033757600080fd5b5051949350505050565b6103496108a1565b6001600160a01b031661035a6104eb565b6001600160a01b0316146103b5576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b6104146108a1565b6001600160a01b03166104256104eb565b6001600160a01b031614610480576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b816001600160a01b0316638f283970826040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b1580156104cf57600080fd5b505af11580156104e3573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031690565b6105026108a1565b6001600160a01b03166105136104eb565b6001600160a01b03161461056e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b826001600160a01b0316634f1ef2863484846040518463ffffffff1660e01b815260040180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156105db5781810151838201526020016105c3565b50505050905090810190601f1680156106085780820380516001836020036101000a031916815260200191505b5093505050506000604051808303818588803b15801561062757600080fd5b505af115801561063b573d6000803e3d6000fd5b5050505050505050565b61064d6108a1565b6001600160a01b031661065e6104eb565b6001600160a01b0316146106b9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b816001600160a01b0316633659cfe6826040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b1580156104cf57600080fd5b6107106108a1565b6001600160a01b03166107216104eb565b6001600160a01b03161461077c576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166107c15760405162461bcd60e51b81526004018080602001828103825260268152602001806108a66026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000806060836001600160a01b031660405180807ff851a440000000000000000000000000000000000000000000000000000000008152506004019050600060405180830381855afa9150503d806000811461030e576040519150601f19603f3d011682016040523d82523d6000602084013e610313565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a2646970667358221220291ab7b08f81e1f06bf811a4ba1befef7e8ac100d0fdc029e7a8e75fe65a133564736f6c63430007040033608060405260405162000c8e38038062000c8e833981810160405260608110156200002957600080fd5b815160208301516040808501805191519395929483019291846401000000008211156200005557600080fd5b9083019060208201858111156200006b57600080fd5b82516401000000008111828201881017156200008657600080fd5b82525081516020918201929091019080838360005b83811015620000b55781810151838201526020016200009b565b50505050905090810190601f168015620000e35780820380516001836020036101000a031916815260200191505b5060405250849150829050620000f98262000137565b8051156200011a57620001188282620001ae60201b620003941760201c565b505b50620001239050565b6200012e82620001dd565b505050620003bf565b6200014d816200020160201b620003c01760201c565b6200018a5760405162461bcd60e51b815260040180806020018281038252603681526020018062000c326036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b6060620001d6838360405180606001604052806027815260200162000c0b6027913962000207565b9392505050565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b3b151590565b6060620002148462000201565b620002515760405162461bcd60e51b815260040180806020018281038252602681526020018062000c686026913960400191505060405180910390fd5b60006060856001600160a01b0316856040518082805190602001908083835b60208310620002915780518252601f19909201916020918201910162000270565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114620002f3576040519150601f19603f3d011682016040523d82523d6000602084013e620002f8565b606091505b5090925090506200030b82828662000315565b9695505050505050565b6060831562000326575081620001d6565b825115620003375782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156200038357818101518382015260200162000369565b50505050905090810190601f168015620003b15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b61083c80620003cf6000396000f3fe60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146101285780638f28397014610159578063f851a4401461018c5761006d565b80633659cfe6146100755780634f1ef286146100a85761006d565b3661006d5761006b6101a1565b005b61006b6101a1565b34801561008157600080fd5b5061006b6004803603602081101561009857600080fd5b50356001600160a01b03166101bb565b61006b600480360360408110156100be57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100e957600080fd5b8201836020820111156100fb57600080fd5b8035906020019184600183028401116401000000008311171561011d57600080fd5b5090925090506101f5565b34801561013457600080fd5b5061013d610272565b604080516001600160a01b039092168252519081900360200190f35b34801561016557600080fd5b5061006b6004803603602081101561017c57600080fd5b50356001600160a01b03166102af565b34801561019857600080fd5b5061013d610369565b6101a96103c6565b6101b96101b4610426565b61044b565b565b6101c361046f565b6001600160a01b0316336001600160a01b031614156101ea576101e581610494565b6101f2565b6101f26101a1565b50565b6101fd61046f565b6001600160a01b0316336001600160a01b031614156102655761021f83610494565b61025f8383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061039492505050565b5061026d565b61026d6101a1565b505050565b600061027c61046f565b6001600160a01b0316336001600160a01b031614156102a45761029d610426565b90506102ac565b6102ac6101a1565b90565b6102b761046f565b6001600160a01b0316336001600160a01b031614156101ea576001600160a01b0381166103155760405162461bcd60e51b815260040180806020018281038252603a815260200180610708603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61033e61046f565b604080516001600160a01b03928316815291841660208301528051918290030190a16101e5816104d4565b600061037361046f565b6001600160a01b0316336001600160a01b031614156102a45761029d61046f565b60606103b98383604051806060016040528060278152602001610742602791396104f8565b9392505050565b3b151590565b6103ce61046f565b6001600160a01b0316336001600160a01b0316141561041e5760405162461bcd60e51b81526004018080602001828103825260428152602001806107c56042913960600191505060405180910390fd5b6101b96101b9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561046a573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b61049d816105fb565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6060610503846103c0565b61053e5760405162461bcd60e51b815260040180806020018281038252602681526020018061079f6026913960400191505060405180910390fd5b60006060856001600160a01b0316856040518082805190602001908083835b6020831061057c5780518252601f19909201916020918201910161055d565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146105dc576040519150601f19603f3d011682016040523d82523d6000602084013e6105e1565b606091505b50915091506105f1828286610663565b9695505050505050565b610604816103c0565b61063f5760405162461bcd60e51b81526004018080602001828103825260368152602001806107696036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b606083156106725750816103b9565b8251156106825782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156106cc5781810151838201526020016106b4565b50505050905090810190601f1680156106f95780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f2061646472657373416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65645570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6e74726163745472616e73706172656e745570677261646561626c6550726f78793a2061646d696e2063616e6e6f742066616c6c6261636b20746f2070726f787920746172676574a26469706673582212208abef82df4ccbbe5116d43e18645757954680a0f3e3b17a5ca661b652c75599664736f6c63430007040033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65645570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6e7472616374456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64736e6577207661756c7420697320616c72656164792063757272656e74207661756c744f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65646b656570657220697320616c726561647920696e207468652077686974656c697374a2646970667358221220b9c48dd642cfc4bff9fda492196d46a632b6f06546849edb515d8928442647e164736f6c63430007040033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.