Overview
xDAI Balance
0 xDAI
xDAI Value
$0.00Token Holdings
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 441 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Claim Fee | 33705130 | 219 days ago | IN | 0 xDAI | 0.00012364 | ||||
Withdraw Liquidi... | 33705126 | 219 days ago | IN | 0 xDAI | 0.00013891 | ||||
Redeem | 33705104 | 219 days ago | IN | 0 xDAI | 0.00034602 | ||||
Redeem | 33705060 | 219 days ago | IN | 0 xDAI | 0.00042836 | ||||
Withdraw Liquidi... | 33703516 | 219 days ago | IN | 0 xDAI | 0.00015972 | ||||
Claim Fee | 33703511 | 219 days ago | IN | 0 xDAI | 0.00014219 | ||||
Mint | 33336226 | 241 days ago | IN | 0 xDAI | 0.00031947 | ||||
Redeem | 33057683 | 258 days ago | IN | 0 xDAI | 0.00048091 | ||||
Mint | 32791330 | 274 days ago | IN | 0 xDAI | 0.00077431 | ||||
Redeem | 30180557 | 435 days ago | IN | 0 xDAI | 0.0001589 | ||||
Redeem | 30180547 | 435 days ago | IN | 0 xDAI | 0.00028858 | ||||
Mint | 30130878 | 438 days ago | IN | 0 xDAI | 0.00024061 | ||||
Mint | 29992298 | 446 days ago | IN | 0 xDAI | 0.00042466 | ||||
Redeem | 28813003 | 518 days ago | IN | 0 xDAI | 0.00023151 | ||||
Redeem | 28794091 | 519 days ago | IN | 0 xDAI | 0.00023042 | ||||
Redeem | 28664669 | 527 days ago | IN | 0 xDAI | 0.00021366 | ||||
Redeem | 28368856 | 545 days ago | IN | 0 xDAI | 0.00031417 | ||||
Mint | 28364769 | 545 days ago | IN | 0 xDAI | 0.00038959 | ||||
Redeem | 28335461 | 547 days ago | IN | 0 xDAI | 0.00023042 | ||||
Mint | 28301724 | 549 days ago | IN | 0 xDAI | 0.00038086 | ||||
Mint | 28286745 | 550 days ago | IN | 0 xDAI | 0.00060659 | ||||
Redeem | 28236451 | 553 days ago | IN | 0 xDAI | 0.00079716 | ||||
Mint | 28232431 | 553 days ago | IN | 0 xDAI | 0.00033528 | ||||
Redeem | 27910915 | 572 days ago | IN | 0 xDAI | 0.00091326 | ||||
Redeem | 27910218 | 572 days ago | IN | 0 xDAI | 0.00047342 |
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
19929861 | 1066 days ago | Contract Creation | 0 xDAI |
Loading...
Loading
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.
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x0aA7e2A6...B8F53bD0E The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
SynthereumLiquidityPool
Compiler Version
v0.8.4+commit.c7e474f2
Contract Source Code (Solidity)
/** *Submitted for verification at gnosisscan.io on 2023-06-22 */ // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/structs/EnumerableSet.sol pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * 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; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values 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)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/access/IAccessControl.sol pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/access/IAccessControlEnumerable.sol pragma solidity ^0.8.0; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/Context.sol pragma solidity ^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 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) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/access/AccessControl.sol pragma solidity ^0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/access/AccessControlEnumerable.sol pragma solidity ^0.8.0; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {grantRole} to track enumerable memberships */ function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {revokeRole} to track enumerable memberships */ function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.revokeRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {renounceRole} to track enumerable memberships */ function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { super.renounceRole(role, account); _roleMembers[role].remove(account); } /** * @dev Overload {_setupRole} to track enumerable memberships */ function _setupRole(bytes32 role, address account) internal virtual override { super._setupRole(role, account); _roleMembers[role].add(account); } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/common/ERC2771Context.sol // OpenZeppelin Contracts v4.3.2 (metatx/ERC2771Context.sol) pragma solidity ^0.8.0; /** * @dev Context variant with ERC2771 support. */ abstract contract ERC2771Context is Context { function isTrustedForwarder(address forwarder) public view virtual returns (bool); function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[0:msg.data.length - 20]; } else { return super._msgData(); } } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/security/ReentrancyGuard.sol pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/Address.sol pragma solidity ^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; 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"); (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"); (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"); (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"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // 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 assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/oracle/common/interfaces/IPriceFeed.sol pragma solidity ^0.8.4; interface ISynthereumPriceFeed { /** * @notice Get last chainlink oracle price for a given price identifier * @param priceIdentifier Price feed identifier * @return price Oracle price */ function getLatestPrice(bytes32 priceIdentifier) external view returns (uint256 price); /** * @notice Return if price identifier is supported * @param priceIdentifier Price feed identifier * @return isSupported True if price is supported otherwise false */ function isPriceSupported(bytes32 priceIdentifier) external view returns (bool isSupported); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/core/Constants.sol pragma solidity ^0.8.4; /** * @title Stores common interface names used throughout Synthereum. */ library SynthereumInterfaces { bytes32 public constant Deployer = 'Deployer'; bytes32 public constant FactoryVersioning = 'FactoryVersioning'; bytes32 public constant TokenFactory = 'TokenFactory'; bytes32 public constant PoolRegistry = 'PoolRegistry'; bytes32 public constant SelfMintingRegistry = 'SelfMintingRegistry'; bytes32 public constant PriceFeed = 'PriceFeed'; bytes32 public constant Manager = 'Manager'; bytes32 public constant CreditLineController = 'CreditLineController'; bytes32 public constant CollateralWhitelist = 'CollateralWhitelist'; bytes32 public constant IdentifierWhitelist = 'IdentifierWhitelist'; bytes32 public constant TrustedForwarder = 'TrustedForwarder'; bytes32 public constant FixedRateRegistry = 'FixedRateRegistry'; bytes32 public constant MoneyMarketManager = 'MoneyMarketManager'; bytes32 public constant JarvisBrrrrr = 'JarvisBrrrrr'; } library FactoryInterfaces { bytes32 public constant PoolFactory = 'PoolFactory'; bytes32 public constant SelfMintingFactory = 'SelfMintingFactory'; bytes32 public constant FixedRateFactory = 'FixedRateFactory'; } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/common/interfaces/ITypology.sol pragma solidity ^0.8.4; interface ITypology { /** * @notice Return typology of the contract */ function typology() external view returns (string memory); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/math/SignedSafeMath.sol pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SignedSafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SignedSafeMath { /** * @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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(int256 a, int256 b) internal pure returns (int256) { return a / b; } /** * @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) { return a - b; } /** * @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) { return a + b; } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/utils/math/SafeMath.sol pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ 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) { unchecked { 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) { unchecked { 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) { unchecked { // 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) { unchecked { 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) { unchecked { 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@uma/core/contracts/common/implementation/FixedPoint.sol pragma solidity ^0.8.0; /** * @title Library for fixed point arithmetic on uints */ library FixedPoint { using SafeMath for uint256; using SignedSafeMath for int256; // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5". // For unsigned values: // This can represent a value up to (2^256 - 1)/10^18 = ~10^59. 10^59 will be stored internally as uint256 10^77. uint256 private constant FP_SCALING_FACTOR = 10**18; // --------------------------------------- UNSIGNED ----------------------------------------------------------------------------- struct Unsigned { uint256 rawValue; } /** * @notice Constructs an `Unsigned` from an unscaled uint, e.g., `b=5` gets stored internally as `5*(10**18)`. * @param a uint to convert into a FixedPoint. * @return the converted FixedPoint. */ function fromUnscaledUint(uint256 a) internal pure returns (Unsigned memory) { return Unsigned(a.mul(FP_SCALING_FACTOR)); } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if equal, or False. */ function isEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue == fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if equal, or False. */ function isEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue == b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a > b`, or False. */ function isGreaterThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue > b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a > b`, or False. */ function isGreaterThan(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue > fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a > b`, or False. */ function isGreaterThan(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue > b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue >= b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue >= fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue >= b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a < b`, or False. */ function isLessThan(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue < b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a < b`, or False. */ function isLessThan(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue < fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a < b`, or False. */ function isLessThan(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue < b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Unsigned memory a, Unsigned memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint. * @param b a uint256. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Unsigned memory a, uint256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledUint(b).rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a uint256. * @param b a FixedPoint. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(uint256 a, Unsigned memory b) internal pure returns (bool) { return fromUnscaledUint(a).rawValue <= b.rawValue; } /** * @notice The minimum of `a` and `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return the minimum of `a` and `b`. */ function min(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return a.rawValue < b.rawValue ? a : b; } /** * @notice The maximum of `a` and `b`. * @param a a FixedPoint. * @param b a FixedPoint. * @return the maximum of `a` and `b`. */ function max(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return a.rawValue > b.rawValue ? a : b; } /** * @notice Adds two `Unsigned`s, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the sum of `a` and `b`. */ function add(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.add(b.rawValue)); } /** * @notice Adds an `Unsigned` to an unscaled uint, reverting on overflow. * @param a a FixedPoint. * @param b a uint256. * @return the sum of `a` and `b`. */ function add(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return add(a, fromUnscaledUint(b)); } /** * @notice Subtracts two `Unsigned`s, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the difference of `a` and `b`. */ function sub(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.sub(b.rawValue)); } /** * @notice Subtracts an unscaled uint256 from an `Unsigned`, reverting on overflow. * @param a a FixedPoint. * @param b a uint256. * @return the difference of `a` and `b`. */ function sub(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return sub(a, fromUnscaledUint(b)); } /** * @notice Subtracts an `Unsigned` from an unscaled uint256, reverting on overflow. * @param a a uint256. * @param b a FixedPoint. * @return the difference of `a` and `b`. */ function sub(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) { return sub(fromUnscaledUint(a), b); } /** * @notice Multiplies two `Unsigned`s, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mul(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { // There are two caveats with this computation: // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is // stored internally as a uint256 ~10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which // would round to 3, but this computation produces the result 2. // No need to use SafeMath because FP_SCALING_FACTOR != 0. return Unsigned(a.rawValue.mul(b.rawValue) / FP_SCALING_FACTOR); } /** * @notice Multiplies an `Unsigned` and an unscaled uint256, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint. * @param b a uint256. * @return the product of `a` and `b`. */ function mul(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.mul(b)); } /** * @notice Multiplies two `Unsigned`s and "ceil's" the product, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mulCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { uint256 mulRaw = a.rawValue.mul(b.rawValue); uint256 mulFloor = mulRaw / FP_SCALING_FACTOR; uint256 mod = mulRaw.mod(FP_SCALING_FACTOR); if (mod != 0) { return Unsigned(mulFloor.add(1)); } else { return Unsigned(mulFloor); } } /** * @notice Multiplies an `Unsigned` and an unscaled uint256 and "ceil's" the product, reverting on overflow. * @param a a FixedPoint. * @param b a FixedPoint. * @return the product of `a` and `b`. */ function mulCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { // Since b is an int, there is no risk of truncation and we can just mul it normally return Unsigned(a.rawValue.mul(b)); } /** * @notice Divides one `Unsigned` by an `Unsigned`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { // There are two caveats with this computation: // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows. // 10^41 is stored internally as a uint256 10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666. return Unsigned(a.rawValue.mul(FP_SCALING_FACTOR).div(b.rawValue)); } /** * @notice Divides one `Unsigned` by an unscaled uint256, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return the quotient of `a` divided by `b`. */ function div(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { return Unsigned(a.rawValue.div(b)); } /** * @notice Divides one unscaled uint256 by an `Unsigned`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a uint256 numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(uint256 a, Unsigned memory b) internal pure returns (Unsigned memory) { return div(fromUnscaledUint(a), b); } /** * @notice Divides one `Unsigned` by an `Unsigned` and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function divCeil(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) { uint256 aScaled = a.rawValue.mul(FP_SCALING_FACTOR); uint256 divFloor = aScaled.div(b.rawValue); uint256 mod = aScaled.mod(b.rawValue); if (mod != 0) { return Unsigned(divFloor.add(1)); } else { return Unsigned(divFloor); } } /** * @notice Divides one `Unsigned` by an unscaled uint256 and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return the quotient of `a` divided by `b`. */ function divCeil(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) { // Because it is possible that a quotient gets truncated, we can't just call "Unsigned(a.rawValue.div(b))" // similarly to mulCeil with a uint256 as the second parameter. Therefore we need to convert b into an Unsigned. // This creates the possibility of overflow if b is very large. return divCeil(a, fromUnscaledUint(b)); } /** * @notice Raises an `Unsigned` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`. * @dev This will "floor" the result. * @param a a FixedPoint numerator. * @param b a uint256 denominator. * @return output is `a` to the power of `b`. */ function pow(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory output) { output = fromUnscaledUint(1); for (uint256 i = 0; i < b; i = i.add(1)) { output = mul(output, a); } } // ------------------------------------------------- SIGNED ------------------------------------------------------------- // Supports 18 decimals. E.g., 1e18 represents "1", 5e17 represents "0.5". // For signed values: // This can represent a value up (or down) to +-(2^255 - 1)/10^18 = ~10^58. 10^58 will be stored internally as int256 10^76. int256 private constant SFP_SCALING_FACTOR = 10**18; struct Signed { int256 rawValue; } function fromSigned(Signed memory a) internal pure returns (Unsigned memory) { require(a.rawValue >= 0, "Negative value provided"); return Unsigned(uint256(a.rawValue)); } function fromUnsigned(Unsigned memory a) internal pure returns (Signed memory) { require(a.rawValue <= uint256(type(int256).max), "Unsigned too large"); return Signed(int256(a.rawValue)); } /** * @notice Constructs a `Signed` from an unscaled int, e.g., `b=5` gets stored internally as `5*(10**18)`. * @param a int to convert into a FixedPoint.Signed. * @return the converted FixedPoint.Signed. */ function fromUnscaledInt(int256 a) internal pure returns (Signed memory) { return Signed(a.mul(SFP_SCALING_FACTOR)); } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint.Signed. * @param b a int256. * @return True if equal, or False. */ function isEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue == fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if equal, or False. */ function isEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue == b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a > b`, or False. */ function isGreaterThan(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue > b.rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a > b`, or False. */ function isGreaterThan(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue > fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is greater than `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a > b`, or False. */ function isGreaterThan(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue > b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue >= b.rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue >= fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is greater than or equal to `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a >= b`, or False. */ function isGreaterThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue >= b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a < b`, or False. */ function isLessThan(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue < b.rawValue; } /** * @notice Whether `a` is less than `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a < b`, or False. */ function isLessThan(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue < fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is less than `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a < b`, or False. */ function isLessThan(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue < b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a a FixedPoint.Signed. * @param b an int256. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(Signed memory a, int256 b) internal pure returns (bool) { return a.rawValue <= fromUnscaledInt(b).rawValue; } /** * @notice Whether `a` is less than or equal to `b`. * @param a an int256. * @param b a FixedPoint.Signed. * @return True if `a <= b`, or False. */ function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) { return fromUnscaledInt(a).rawValue <= b.rawValue; } /** * @notice The minimum of `a` and `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the minimum of `a` and `b`. */ function min(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return a.rawValue < b.rawValue ? a : b; } /** * @notice The maximum of `a` and `b`. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the maximum of `a` and `b`. */ function max(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return a.rawValue > b.rawValue ? a : b; } /** * @notice Adds two `Signed`s, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the sum of `a` and `b`. */ function add(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.add(b.rawValue)); } /** * @notice Adds an `Signed` to an unscaled int, reverting on overflow. * @param a a FixedPoint.Signed. * @param b an int256. * @return the sum of `a` and `b`. */ function add(Signed memory a, int256 b) internal pure returns (Signed memory) { return add(a, fromUnscaledInt(b)); } /** * @notice Subtracts two `Signed`s, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the difference of `a` and `b`. */ function sub(Signed memory a, Signed memory b) internal pure returns (Signed memory) { return Signed(a.rawValue.sub(b.rawValue)); } /** * @notice Subtracts an unscaled int256 from an `Signed`, reverting on overflow. * @param a a FixedPoint.Signed. * @param b an int256. * @return the difference of `a` and `b`. */ function sub(Signed memory a, int256 b) internal pure returns (Signed memory) { return sub(a, fromUnscaledInt(b)); } /** * @notice Subtracts an `Signed` from an unscaled int256, reverting on overflow. * @param a an int256. * @param b a FixedPoint.Signed. * @return the difference of `a` and `b`. */ function sub(int256 a, Signed memory b) internal pure returns (Signed memory) { return sub(fromUnscaledInt(a), b); } /** * @notice Multiplies two `Signed`s, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mul(Signed memory a, Signed memory b) internal pure returns (Signed memory) { // There are two caveats with this computation: // 1. Max output for the represented number is ~10^41, otherwise an intermediate value overflows. 10^41 is // stored internally as an int256 ~10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 1.4 * 2e-18 = 2.8e-18, which // would round to 3, but this computation produces the result 2. // No need to use SafeMath because SFP_SCALING_FACTOR != 0. return Signed(a.rawValue.mul(b.rawValue) / SFP_SCALING_FACTOR); } /** * @notice Multiplies an `Signed` and an unscaled int256, reverting on overflow. * @dev This will "floor" the product. * @param a a FixedPoint.Signed. * @param b an int256. * @return the product of `a` and `b`. */ function mul(Signed memory a, int256 b) internal pure returns (Signed memory) { return Signed(a.rawValue.mul(b)); } /** * @notice Multiplies two `Signed`s and "ceil's" the product, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mulAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) { int256 mulRaw = a.rawValue.mul(b.rawValue); int256 mulTowardsZero = mulRaw / SFP_SCALING_FACTOR; // Manual mod because SignedSafeMath doesn't support it. int256 mod = mulRaw % SFP_SCALING_FACTOR; if (mod != 0) { bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0); int256 valueToAdd = isResultPositive ? int256(1) : int256(-1); return Signed(mulTowardsZero.add(valueToAdd)); } else { return Signed(mulTowardsZero); } } /** * @notice Multiplies an `Signed` and an unscaled int256 and "ceil's" the product, reverting on overflow. * @param a a FixedPoint.Signed. * @param b a FixedPoint.Signed. * @return the product of `a` and `b`. */ function mulAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) { // Since b is an int, there is no risk of truncation and we can just mul it normally return Signed(a.rawValue.mul(b)); } /** * @notice Divides one `Signed` by an `Signed`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(Signed memory a, Signed memory b) internal pure returns (Signed memory) { // There are two caveats with this computation: // 1. Max value for the number dividend `a` represents is ~10^41, otherwise an intermediate value overflows. // 10^41 is stored internally as an int256 10^59. // 2. Results that can't be represented exactly are truncated not rounded. E.g., 2 / 3 = 0.6 repeating, which // would round to 0.666666666666666667, but this computation produces the result 0.666666666666666666. return Signed(a.rawValue.mul(SFP_SCALING_FACTOR).div(b.rawValue)); } /** * @notice Divides one `Signed` by an unscaled int256, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a a FixedPoint numerator. * @param b an int256 denominator. * @return the quotient of `a` divided by `b`. */ function div(Signed memory a, int256 b) internal pure returns (Signed memory) { return Signed(a.rawValue.div(b)); } /** * @notice Divides one unscaled int256 by an `Signed`, reverting on overflow or division by 0. * @dev This will "floor" the quotient. * @param a an int256 numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function div(int256 a, Signed memory b) internal pure returns (Signed memory) { return div(fromUnscaledInt(a), b); } /** * @notice Divides one `Signed` by an `Signed` and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b a FixedPoint denominator. * @return the quotient of `a` divided by `b`. */ function divAwayFromZero(Signed memory a, Signed memory b) internal pure returns (Signed memory) { int256 aScaled = a.rawValue.mul(SFP_SCALING_FACTOR); int256 divTowardsZero = aScaled.div(b.rawValue); // Manual mod because SignedSafeMath doesn't support it. int256 mod = aScaled % b.rawValue; if (mod != 0) { bool isResultPositive = isLessThan(a, 0) == isLessThan(b, 0); int256 valueToAdd = isResultPositive ? int256(1) : int256(-1); return Signed(divTowardsZero.add(valueToAdd)); } else { return Signed(divTowardsZero); } } /** * @notice Divides one `Signed` by an unscaled int256 and "ceil's" the quotient, reverting on overflow or division by 0. * @param a a FixedPoint numerator. * @param b an int256 denominator. * @return the quotient of `a` divided by `b`. */ function divAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) { // Because it is possible that a quotient gets truncated, we can't just call "Signed(a.rawValue.div(b))" // similarly to mulCeil with an int256 as the second parameter. Therefore we need to convert b into an Signed. // This creates the possibility of overflow if b is very large. return divAwayFromZero(a, fromUnscaledInt(b)); } /** * @notice Raises an `Signed` to the power of an unscaled uint256, reverting on overflow. E.g., `b=2` squares `a`. * @dev This will "floor" the result. * @param a a FixedPoint.Signed. * @param b a uint256 (negative exponents are not allowed). * @return output is `a` to the power of `b`. */ function pow(Signed memory a, uint256 b) internal pure returns (Signed memory output) { output = fromUnscaledInt(1); for (uint256 i = 0; i < b; i = i.add(1)) { output = mul(output, a); } } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/core/interfaces/IFinder.sol pragma solidity ^0.8.4; /** * @title Provides addresses of the contracts implementing certain interfaces. */ interface ISynthereumFinder { /** * @notice Updates the address of the contract that implements `interfaceName`. * @param interfaceName bytes32 encoding of the interface name that is either changed or registered. * @param implementationAddress address of the deployed contract that implements the interface. */ function changeImplementationAddress( bytes32 interfaceName, address implementationAddress ) external; /** * @notice Gets the address of the contract that implements the given `interfaceName`. * @param interfaceName queried interface. * @return implementationAddress Address of the deployed contract that implements the interface. */ function getImplementationAddress(bytes32 interfaceName) external view returns (address); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/synthereum-pool/v5/interfaces/ILiquidityPoolInteraction.sol pragma solidity ^0.8.4; interface ISynthereumLiquidityPoolInteraction { /** * @notice Called by a source Pool's `exchange` function to mint destination tokens * @notice This functon can be called only by a pool registered in the PoolRegister contract * @param collateralAmount The amount of collateral to use from the source Pool * @param numTokens The number of new tokens to mint * @param recipient Recipient to which send synthetic token minted */ function exchangeMint( uint256 collateralAmount, uint256 numTokens, address recipient ) external; /** * @notice Returns price identifier of the pool * @return identifier Price identifier */ function getPriceFeedIdentifier() external view returns (bytes32 identifier); /** * @notice Return overcollateralization percentage from the storage * @return Overcollateralization percentage */ function overCollateralization() external view returns (uint256); /** * @notice Returns the total amount of liquidity deposited in the pool, but nut used as collateral * @return Total available liquidity */ function totalAvailableLiquidity() external view returns (uint256); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/common/interfaces/IEmergencyShutdown.sol pragma solidity ^0.8.4; interface IEmergencyShutdown { /** * @notice Shutdown the pool or self-minting-derivative in case of emergency * @notice Only Synthereum manager contract can call this function * @return timestamp Timestamp of emergency shutdown transaction * @return price Price of the pair at the moment of shutdown execution */ function emergencyShutdown() external returns (uint256 timestamp, uint256 price); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/token/ERC20/IERC20.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol pragma solidity ^0.8.0; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/core/registries/interfaces/IRegistry.sol pragma solidity ^0.8.4; /** * @title Provides interface with functions of SynthereumRegistry */ interface ISynthereumRegistry { /** * @notice Allow the deployer to register an element * @param syntheticTokenSymbol Symbol of the syntheticToken * @param collateralToken Collateral ERC20 token of the element deployed * @param version Version of the element deployed * @param element Address of the element deployed */ function register( string calldata syntheticTokenSymbol, IERC20 collateralToken, uint8 version, address element ) external; /** * @notice Returns if a particular element exists or not * @param syntheticTokenSymbol Synthetic token symbol of the element * @param collateralToken ERC20 contract of collateral currency * @param version Version of the element * @param element Contract of the element to check * @return isElementDeployed Returns true if a particular element exists, otherwise false */ function isDeployed( string calldata syntheticTokenSymbol, IERC20 collateralToken, uint8 version, address element ) external view returns (bool isElementDeployed); /** * @notice Returns all the elements with partcular symbol, collateral and version * @param syntheticTokenSymbol Synthetic token symbol of the element * @param collateralToken ERC20 contract of collateral currency * @param version Version of the element * @return List of all elements */ function getElements( string calldata syntheticTokenSymbol, IERC20 collateralToken, uint8 version ) external view returns (address[] memory); /** * @notice Returns all the synthetic token symbol used * @return List of all synthetic token symbol */ function getSyntheticTokens() external view returns (string[] memory); /** * @notice Returns all the versions used * @return List of all versions */ function getVersions() external view returns (uint8[] memory); /** * @notice Returns all the collaterals used * @return List of all collaterals */ function getCollaterals() external view returns (address[] memory); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/common/interfaces/IDeployment.sol pragma solidity ^0.8.4; /** * @title Interface that a pool MUST have in order to be included in the deployer */ interface ISynthereumDeployment { /** * @notice Get Synthereum finder of the pool/self-minting derivative * @return finder Returns finder contract */ function synthereumFinder() external view returns (ISynthereumFinder finder); /** * @notice Get Synthereum version * @return contractVersion Returns the version of this pool/self-minting derivative */ function version() external view returns (uint8 contractVersion); /** * @notice Get the collateral token of this pool/self-minting derivative * @return collateralCurrency The ERC20 collateral token */ function collateralToken() external view returns (IERC20 collateralCurrency); /** * @notice Get the synthetic token associated to this pool/self-minting derivative * @return syntheticCurrency The ERC20 synthetic token */ function syntheticToken() external view returns (IERC20 syntheticCurrency); /** * @notice Get the synthetic token symbol associated to this pool/self-minting derivative * @return symbol The ERC20 synthetic token symbol */ function syntheticTokenSymbol() external view returns (string memory symbol); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/synthereum-pool/v5/interfaces/ILiquidityPoolGeneral.sol pragma solidity ^0.8.4; interface ISynthereumLiquidityPoolGeneral is ISynthereumDeployment, ISynthereumLiquidityPoolInteraction {} // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/tokens/interfaces/IMintableBurnableERC20.sol pragma solidity ^0.8.4; /** * @title ERC20 interface that includes burn mint and roles methods. */ interface IMintableBurnableERC20 is IERC20 { /** * @notice Burns a specific amount of the caller's tokens. * @dev This method should be permissioned to only allow designated parties to burn tokens. */ function burn(uint256 value) external; /** * @notice Mints tokens and adds them to the balance of the `to` address. * @dev This method should be permissioned to only allow designated parties to mint tokens. */ function mint(address to, uint256 value) external returns (bool); /** * @notice Returns the number of decimals used to get its user representation. */ function decimals() external view returns (uint8); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/base/interfaces/IStandardERC20.sol pragma solidity ^0.8.4; interface IStandardERC20 is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() external view returns (string memory); /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() external view returns (uint8); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/synthereum-pool/v5/interfaces/ILiquidityPoolStorage.sol pragma solidity ^0.8.4; interface ISynthereumLiquidityPoolStorage { // Describe role structure struct Roles { address admin; address maintainer; address liquidityProvider; } // Describe fee data structure struct FeeData { // Fees charged when a user mints, redeem and exchanges tokens FixedPoint.Unsigned feePercentage; // Recipient receiving fees address[] feeRecipients; // Proportion for each recipient uint32[] feeProportions; } // Describe fee structure struct Fee { // Fee data structure FeeData feeData; // Used with individual proportions to scale values uint256 totalFeeProportions; } struct Storage { // Synthereum finder ISynthereumFinder finder; // Synthereum version uint8 version; // Collateral token IStandardERC20 collateralToken; // Synthetic token IMintableBurnableERC20 syntheticToken; // Overcollateralization percentage FixedPoint.Unsigned overCollateralization; // Fees Fee fee; // Price identifier bytes32 priceIdentifier; } struct LPPosition { // Collateral used for collateralize tokens FixedPoint.Unsigned totalCollateralAmount; // Number of tokens collateralized FixedPoint.Unsigned tokensCollateralized; } struct Liquidation { // Percentage of overcollateralization to which a liquidation can triggered FixedPoint.Unsigned collateralRequirement; // Percentage of reward for correct liquidation by a liquidator FixedPoint.Unsigned liquidationReward; } struct FeeStatus { // Track the fee gained to be withdrawn by an address mapping(address => FixedPoint.Unsigned) feeGained; // Total amount of fees to be withdrawn FixedPoint.Unsigned totalFeeAmount; } struct Shutdown { // Timestamp of execution of shutdown uint256 timestamp; // Price of the pair at the moment of the shutdown FixedPoint.Unsigned price; } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/synthereum-pool/v5/interfaces/ILiquidityPool.sol pragma solidity ^0.8.4; /** * @title Token Issuer Contract Interface */ interface ISynthereumLiquidityPool is ITypology, IEmergencyShutdown, ISynthereumLiquidityPoolGeneral { struct MintParams { // Minimum amount of synthetic tokens that a user wants to mint using collateral (anti-slippage) uint256 minNumTokens; // Amount of collateral that a user wants to spend for minting uint256 collateralAmount; // Expiration time of the transaction uint256 expiration; // Address to which send synthetic tokens minted address recipient; } struct RedeemParams { // Amount of synthetic tokens that user wants to use for redeeming uint256 numTokens; // Minimium amount of collateral that user wants to redeem (anti-slippage) uint256 minCollateral; // Expiration time of the transaction uint256 expiration; // Address to which send collateral tokens redeemed address recipient; } struct ExchangeParams { // Destination pool ISynthereumLiquidityPoolGeneral destPool; // Amount of source synthetic tokens that user wants to use for exchanging uint256 numTokens; // Minimum Amount of destination synthetic tokens that user wants to receive (anti-slippage) uint256 minDestNumTokens; // Expiration time of the transaction uint256 expiration; // Address to which send synthetic tokens exchanged address recipient; } /** * @notice Mint synthetic tokens using fixed amount of collateral * @notice This calculate the price using on chain price feed * @notice User must approve collateral transfer for the mint request to succeed * @param mintParams Input parameters for minting (see MintParams struct) * @return syntheticTokensMinted Amount of synthetic tokens minted by a user * @return feePaid Amount of collateral paid by the user as fee */ function mint(MintParams calldata mintParams) external returns (uint256 syntheticTokensMinted, uint256 feePaid); /** * @notice Redeem amount of collateral using fixed number of synthetic token * @notice This calculate the price using on chain price feed * @notice User must approve synthetic token transfer for the redeem request to succeed * @param redeemParams Input parameters for redeeming (see RedeemParams struct) * @return collateralRedeemed Amount of collateral redeem by user * @return feePaid Amount of collateral paid by user as fee */ function redeem(RedeemParams calldata redeemParams) external returns (uint256 collateralRedeemed, uint256 feePaid); /** * @notice Exchange a fixed amount of synthetic token of this pool, with an amount of synthetic tokens of an another pool * @notice This calculate the price using on chain price feed * @notice User must approve synthetic token transfer for the redeem request to succeed * @param exchangeParams Input parameters for exchanging (see ExchangeParams struct) * @return destNumTokensMinted Amount of collateral redeem by user * @return feePaid Amount of collateral paid by user as fee */ function exchange(ExchangeParams calldata exchangeParams) external returns (uint256 destNumTokensMinted, uint256 feePaid); /** * @notice Withdraw unused deposited collateral by the LP * @notice Only a sender with LP role can call this function * @param collateralAmount Collateral to be withdrawn * @return remainingLiquidity Remaining unused collateral in the pool */ function withdrawLiquidity(uint256 collateralAmount) external returns (uint256 remainingLiquidity); /** * @notice Increase collaterallization of Lp position * @notice Only a sender with LP role can call this function * @param collateralToTransfer Collateral to be transferred before increase collateral in the position * @param collateralToIncrease Collateral to be added to the position * @return newTotalCollateral New total collateral amount */ function increaseCollateral( uint256 collateralToTransfer, uint256 collateralToIncrease ) external returns (uint256 newTotalCollateral); /** * @notice Decrease collaterallization of Lp position * @notice Check that final poosition is not undercollateralized * @notice Only a sender with LP role can call this function * @param collateralToDecrease Collateral to decreased from the position * @param collateralToWithdraw Collateral to be transferred to the LP * @return newTotalCollateral New total collateral amount */ function decreaseCollateral( uint256 collateralToDecrease, uint256 collateralToWithdraw ) external returns (uint256 newTotalCollateral); /** * @notice Withdraw fees gained by the sender * @return feeClaimed Amount of fee claimed */ function claimFee() external returns (uint256 feeClaimed); /** * @notice Liquidate Lp position for an amount of synthetic tokens undercollateralized * @notice Revert if position is not undercollateralized * @param numSynthTokens Number of synthetic tokens that user wants to liquidate * @return synthTokensLiquidated Amount of synthetic tokens liquidated * @return collateralReceived Amount of received collateral equal to the value of tokens liquidated * @return rewardAmount Amount of received collateral as reward for the liquidation */ function liquidate(uint256 numSynthTokens) external returns ( uint256 synthTokensLiquidated, uint256 collateralReceived, uint256 rewardAmount ); /** * @notice Redeem tokens after emergency shutdown * @return synthTokensSettled Amount of synthetic tokens liquidated * @return collateralSettled Amount of collateral withdrawn after emergency shutdown */ function settleEmergencyShutdown() external returns (uint256 synthTokensSettled, uint256 collateralSettled); /** * @notice Update the fee percentage, recipients and recipient proportions * @notice Only the maintainer can call this function * @param _feeData Fee info (percentage + recipients + weigths) */ function setFee(ISynthereumLiquidityPoolStorage.FeeData calldata _feeData) external; /** * @notice Update the fee percentage * @notice Only the maintainer can call this function * @param _feePercentage The new fee percentage */ function setFeePercentage(uint256 _feePercentage) external; /** * @notice Update the addresses of recipients for generated fees and proportions of fees each address will receive * @notice Only the maintainer can call this function * @param feeRecipients An array of the addresses of recipients that will receive generated fees * @param feeProportions An array of the proportions of fees generated each recipient will receive */ function setFeeRecipients( address[] calldata feeRecipients, uint32[] calldata feeProportions ) external; /** * @notice Update the overcollateralization percentage * @notice Only the maintainer can call this function * @param _overCollateralization Overcollateralization percentage */ function setOverCollateralization(uint256 _overCollateralization) external; /** * @notice Update the liquidation reward percentage * @notice Only the maintainer can call this function * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator */ function setLiquidationReward(uint256 _liquidationReward) external; /** * @notice Returns fee percentage set by the maintainer * @return Fee percentage */ function feePercentage() external view returns (uint256); /** * @notice Returns fee recipients info * @return Addresses, weigths and total of weigths */ function feeRecipientsInfo() external view returns ( address[] memory, uint32[] memory, uint256 ); /** * @notice Returns total number of synthetic tokens generated by this pool * @return Number of synthetic tokens */ function totalSyntheticTokens() external view returns (uint256); /** * @notice Returns the total amount of collateral used for collateralizing tokens (users + LP) * @return Total collateral amount */ function totalCollateralAmount() external view returns (uint256); /** * @notice Returns the total amount of fees to be withdrawn * @return Total fee amount */ function totalFeeAmount() external view returns (uint256); /** * @notice Returns the user's fee to be withdrawn * @param user User's address * @return User's fee */ function userFee(address user) external view returns (uint256); /** * @notice Returns the percentage of overcollateralization to which a liquidation can triggered * @return Percentage of overcollateralization */ function collateralRequirement() external view returns (uint256); /** * @notice Returns the percentage of reward for correct liquidation by a liquidator * @return Percentage of reward */ function liquidationReward() external view returns (uint256); /** * @notice Returns the price of the pair at the moment of the shutdown * @return Price of the pair */ function emergencyShutdownPrice() external view returns (uint256); /** * @notice Returns the timestamp (unix time) at the moment of the shutdown * @return Timestamp */ function emergencyShutdownTimestamp() external view returns (uint256); /** * @notice Returns if position is overcollateralized and thepercentage of coverage of the collateral according to the last price * @return True if position is overcollaterlized, otherwise false + percentage of coverage (totalCollateralAmount / (price * tokensCollateralized)) */ function collateralCoverage() external returns (bool, uint256); /** * @notice Returns the synthetic tokens will be received and fees will be paid in exchange for an input collateral amount * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param inputCollateral Input collateral amount to be exchanged * @return synthTokensReceived Synthetic tokens will be minted * @return feePaid Collateral fee will be paid */ function getMintTradeInfo(uint256 inputCollateral) external view returns (uint256 synthTokensReceived, uint256 feePaid); /** * @notice Returns the collateral amount will be received and fees will be paid in exchange for an input amount of synthetic tokens * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param syntheticTokens Amount of synthetic tokens to be exchanged * @return collateralAmountReceived Collateral amount will be received by the user * @return feePaid Collateral fee will be paid */ function getRedeemTradeInfo(uint256 syntheticTokens) external view returns (uint256 collateralAmountReceived, uint256 feePaid); /** * @notice Returns the destination synthetic tokens amount will be received and fees will be paid in exchange for an input amount of synthetic tokens * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param syntheticTokens Amount of synthetic tokens to be exchanged * @param destinationPool Pool in which mint the destination synthetic token * @return destSyntheticTokensReceived Synthetic tokens will be received from destination pool * @return feePaid Collateral fee will be paid */ function getExchangeTradeInfo( uint256 syntheticTokens, ISynthereumLiquidityPoolGeneral destinationPool ) external view returns (uint256 destSyntheticTokensReceived, uint256 feePaid); } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/synthereum-pool/v5/LiquidityPoolLib.sol pragma solidity ^0.8.4; /** * @notice Pool implementation is stored here to reduce deployment costs */ library SynthereumLiquidityPoolLib { using FixedPoint for FixedPoint.Unsigned; using FixedPoint for uint256; using SafeERC20 for IStandardERC20; using SafeERC20 for IMintableBurnableERC20; using SynthereumLiquidityPoolLib for ISynthereumLiquidityPoolStorage.Storage; using SynthereumLiquidityPoolLib for ISynthereumLiquidityPoolStorage.LPPosition; using SynthereumLiquidityPoolLib for ISynthereumLiquidityPoolStorage.FeeStatus; struct ExecuteMintParams { // Amount of synth tokens to mint FixedPoint.Unsigned numTokens; // Amount of collateral (excluding fees) needed for mint FixedPoint.Unsigned collateralAmount; // Amount of fees of collateral user must pay FixedPoint.Unsigned feeAmount; // Amount of collateral equal to collateral minted + fees FixedPoint.Unsigned totCollateralAmount; // Recipient address that will receive synthetic tokens address recipient; // Sender of the mint transaction address sender; } struct ExecuteRedeemParams { //Amount of synth tokens needed for redeem FixedPoint.Unsigned numTokens; // Amount of collateral that user will receive FixedPoint.Unsigned collateralAmount; // Amount of fees of collateral user must pay FixedPoint.Unsigned feeAmount; // Amount of collateral equal to collateral redeemed + fees FixedPoint.Unsigned totCollateralAmount; // Recipient address that will receive synthetic tokens address recipient; // Sender of the redeem transaction address sender; } struct ExecuteExchangeParams { // Destination pool in which mint new tokens ISynthereumLiquidityPoolGeneral destPool; // Amount of tokens to send FixedPoint.Unsigned numTokens; // Amount of collateral (excluding fees) equivalent to synthetic token (exluding fees) to send FixedPoint.Unsigned collateralAmount; // Amount of fees of collateral user must pay FixedPoint.Unsigned feeAmount; // Amount of collateral equal to collateral redemeed + fees FixedPoint.Unsigned totCollateralAmount; // Amount of synthetic token to receive FixedPoint.Unsigned destNumTokens; // Recipient address that will receive synthetic tokens address recipient; // Sender of the exchange transaction address sender; } struct ExecuteSettlement { // Price of emergency shutdown FixedPoint.Unsigned emergencyPrice; // Amount of synthtic tokens to be liquidated FixedPoint.Unsigned userNumTokens; // Total amount of collateral (excluding unused and fees) deposited FixedPoint.Unsigned totalCollateralAmount; // Total amount of synthetic tokens FixedPoint.Unsigned tokensCollaterlized; // Total actual amount of fees to be withdrawn FixedPoint.Unsigned totalFeeAmount; // Overcollateral to be withdrawn by Lp (0 if standard user) FixedPoint.Unsigned overCollateral; // Amount of collateral which value is equal to the synthetic tokens value according to the emergency price FixedPoint.Unsigned totalRedeemableCollateral; // Exepected amount of collateral FixedPoint.Unsigned redeemableCollateral; // Collateral deposited but not used to collateralize FixedPoint.Unsigned unusedCollateral; // Amount of collateral settled to the sender FixedPoint.Unsigned transferableCollateral; } struct ExecuteLiquidation { // Total amount of collateral in the Lp position FixedPoint.Unsigned totalCollateralAmount; // Total number of tokens collateralized in the Lp position FixedPoint.Unsigned tokensCollateralized; // Total number of tokens in liquidation FixedPoint.Unsigned tokensInLiquidation; // Amount of collateral used to collateralize user's tokens FixedPoint.Unsigned userCollateralization; // Available liquidity in the pool FixedPoint.Unsigned unusedCollateral; // Expected collateral received by the user according to the actual price FixedPoint.Unsigned expectedCollateral; // Collateral amount receieved by the user FixedPoint.Unsigned settledCollateral; // Reward amount received by the user FixedPoint.Unsigned rewardAmount; // Price rate at the moment of the liquidation FixedPoint.Unsigned priceRate; } //---------------------------------------- // Events //---------------------------------------- event Mint( address indexed account, uint256 collateralSent, uint256 numTokensReceived, uint256 feePaid, address recipient ); event Redeem( address indexed account, uint256 numTokensSent, uint256 collateralReceived, uint256 feePaid, address recipient ); event Exchange( address indexed account, address indexed destPool, uint256 numTokensSent, uint256 destNumTokensReceived, uint256 feePaid, address recipient ); event WithdrawLiquidity( address indexed lp, uint256 liquidityWithdrawn, uint256 remainingLiquidity ); event IncreaseCollateral( address indexed lp, uint256 collateralAdded, uint256 newTotalCollateral ); event DecreaseCollateral( address indexed lp, uint256 collateralRemoved, uint256 newTotalCollateral ); event ClaimFee( address indexed claimer, uint256 feeAmount, uint256 totalRemainingFees ); event Liquidate( address indexed liquidator, uint256 tokensLiquidated, uint256 price, uint256 collateralExpected, uint256 collateralReceived, uint256 rewardReceived ); event EmergencyShutdown( uint256 timestamp, uint256 price, uint256 finalCollateral ); event Settle( address indexed account, uint256 numTokensSettled, uint256 collateralExpected, uint256 collateralSettled ); event SetFeePercentage(uint256 feePercentage); event SetFeeRecipients(address[] feeRecipients, uint32[] feeProportions); event SetOverCollateralization(uint256 overCollateralization); event SetLiquidationReward(uint256 liquidationReward); //---------------------------------------- // External functions //---------------------------------------- /** * @notice Initializes a liquidity pool * @param self Data type the library is attached to * @param liquidationData Liquidation info (see LiquidationData struct) * @param _finder The Synthereum finder * @param _version Synthereum version * @param _collateralToken ERC20 collateral token * @param _syntheticToken ERC20 synthetic token * @param _overCollateralization Over-collateralization ratio * @param _priceIdentifier Identifier of price to be used in the price feed * @param _collateralRequirement Percentage of overcollateralization to which a liquidation can triggered * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator */ function initialize( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.Liquidation storage liquidationData, ISynthereumFinder _finder, uint8 _version, IStandardERC20 _collateralToken, IMintableBurnableERC20 _syntheticToken, FixedPoint.Unsigned calldata _overCollateralization, bytes32 _priceIdentifier, FixedPoint.Unsigned calldata _collateralRequirement, FixedPoint.Unsigned calldata _liquidationReward ) external { require( _collateralRequirement.isGreaterThan(1), 'Collateral requirement must be bigger than 100%' ); require( _overCollateralization.isGreaterThan(_collateralRequirement.sub(1)), 'Overcollateralization must be bigger than the Lp part of the collateral requirement' ); require( _liquidationReward.rawValue > 0 && _liquidationReward.isLessThanOrEqual(1), 'Liquidation reward must be between 0 and 100%' ); require( _collateralToken.decimals() <= 18, 'Collateral has more than 18 decimals' ); require( _syntheticToken.decimals() == 18, 'Synthetic token has more or less than 18 decimals' ); ISynthereumPriceFeed priceFeed = ISynthereumPriceFeed( _finder.getImplementationAddress(SynthereumInterfaces.PriceFeed) ); require( priceFeed.isPriceSupported(_priceIdentifier), 'Price identifier not supported' ); self.finder = _finder; self.version = _version; self.collateralToken = _collateralToken; self.syntheticToken = _syntheticToken; self.overCollateralization = _overCollateralization; self.priceIdentifier = _priceIdentifier; liquidationData.collateralRequirement = _collateralRequirement; liquidationData.liquidationReward = _liquidationReward; } /** * @notice Mint synthetic tokens using fixed amount of collateral * @notice This calculate the price using on chain price feed * @notice User must approve collateral transfer for the mint request to succeed * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param mintParams Input parameters for minting (see MintParams struct) * @param sender Sender of the mint transaction * @return syntheticTokensMinted Amount of synthetic tokens minted by a user * @return feePaid Amount of collateral paid by the user as fee */ function mint( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ISynthereumLiquidityPool.MintParams calldata mintParams, address sender ) external returns (uint256 syntheticTokensMinted, uint256 feePaid) { FixedPoint.Unsigned memory totCollateralAmount = FixedPoint.Unsigned(mintParams.collateralAmount); ( FixedPoint.Unsigned memory collateralAmount, FixedPoint.Unsigned memory feeAmount, FixedPoint.Unsigned memory numTokens ) = self.mintCalculation(totCollateralAmount); require( numTokens.rawValue >= mintParams.minNumTokens, 'Number of tokens less than minimum limit' ); checkExpiration(mintParams.expiration); self.executeMint( lpPosition, feeStatus, ExecuteMintParams( numTokens, collateralAmount, feeAmount, totCollateralAmount, mintParams.recipient, sender ) ); syntheticTokensMinted = numTokens.rawValue; feePaid = feeAmount.rawValue; } /** * @notice Redeem amount of collateral using fixed number of synthetic token * @notice This calculate the price using on chain price feed * @notice User must approve synthetic token transfer for the redeem request to succeed * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param redeemParams Input parameters for redeeming (see RedeemParams struct) * @param sender Sender of the redeem transaction * @return collateralRedeemed Amount of collateral redeem by user * @return feePaid Amount of collateral paid by user as fee */ function redeem( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ISynthereumLiquidityPool.RedeemParams calldata redeemParams, address sender ) external returns (uint256 collateralRedeemed, uint256 feePaid) { FixedPoint.Unsigned memory numTokens = FixedPoint.Unsigned(redeemParams.numTokens); ( FixedPoint.Unsigned memory totCollateralAmount, FixedPoint.Unsigned memory feeAmount, FixedPoint.Unsigned memory collateralAmount ) = self.redeemCalculation(numTokens); require( collateralAmount.rawValue >= redeemParams.minCollateral, 'Collateral amount less than minimum limit' ); checkExpiration(redeemParams.expiration); self.executeRedeem( lpPosition, feeStatus, ExecuteRedeemParams( numTokens, collateralAmount, feeAmount, totCollateralAmount, redeemParams.recipient, sender ) ); feePaid = feeAmount.rawValue; collateralRedeemed = collateralAmount.rawValue; } /** * @notice Exchange a fixed amount of synthetic token of this pool, with an amount of synthetic tokens of an another pool * @notice This calculate the price using on chain price feed * @notice User must approve synthetic token transfer for the redeem request to succeed * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param exchangeParams Input parameters for exchanging (see ExchangeParams struct) * @param sender Sender of the exchange transaction * @return destNumTokensMinted Amount of synthetic token minted in the destination pool * @return feePaid Amount of collateral paid by user as fee */ function exchange( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ISynthereumLiquidityPool.ExchangeParams calldata exchangeParams, address sender ) external returns (uint256 destNumTokensMinted, uint256 feePaid) { FixedPoint.Unsigned memory numTokens = FixedPoint.Unsigned(exchangeParams.numTokens); ( FixedPoint.Unsigned memory totCollateralAmount, FixedPoint.Unsigned memory feeAmount, FixedPoint.Unsigned memory collateralAmount, FixedPoint.Unsigned memory destNumTokens ) = self.exchangeCalculation(numTokens, exchangeParams.destPool); require( destNumTokens.rawValue >= exchangeParams.minDestNumTokens, 'Number of destination tokens less than minimum limit' ); checkExpiration(exchangeParams.expiration); self.executeExchange( lpPosition, feeStatus, ExecuteExchangeParams( exchangeParams.destPool, numTokens, collateralAmount, feeAmount, totCollateralAmount, destNumTokens, exchangeParams.recipient, sender ) ); destNumTokensMinted = destNumTokens.rawValue; feePaid = feeAmount.rawValue; } /** * @notice Called by a source Pool's `exchange` function to mint destination tokens * @notice This functon can be called only by a pool registered in the deployer * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param collateralAmount The amount of collateral to use from the source Pool * @param numTokens The number of new tokens to mint * @param recipient Recipient to which send synthetic token minted */ function exchangeMint( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, FixedPoint.Unsigned calldata collateralAmount, FixedPoint.Unsigned calldata numTokens, address recipient ) external { self.checkPool(ISynthereumLiquidityPoolGeneral(msg.sender)); // Sending amount must be different from 0 require( collateralAmount.rawValue > 0, 'Sending collateral amount is equal to 0' ); // Collateral available FixedPoint.Unsigned memory unusedCollateral = self.calculateUnusedCollateral( lpPosition.totalCollateralAmount, feeStatus.totalFeeAmount, collateralAmount ); // Update LP's collateralization status FixedPoint.Unsigned memory overCollateral = lpPosition.updateLpPositionInMint( self.overCollateralization, collateralAmount, numTokens ); //Check there is enough liquidity in the pool for overcollateralization require( unusedCollateral.isGreaterThanOrEqual(overCollateral), 'No enough liquidity for cover mint operation' ); // Mint synthetic asset and transfer to the recipient self.syntheticToken.mint(recipient, numTokens.rawValue); } /** * @notice Withdraw unused deposited collateral by the LP * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param collateralAmount Collateral to be withdrawn * @param sender Sender of the withdrawLiquidity transaction * @return remainingLiquidity Remaining unused collateral in the pool */ function withdrawLiquidity( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, FixedPoint.Unsigned calldata collateralAmount, address sender ) external returns (uint256 remainingLiquidity) { remainingLiquidity = self._withdrawLiquidity( lpPosition, feeStatus, collateralAmount, sender ); } /** * @notice Increase collaterallization of Lp position * @notice Only a sender with LP role can call this function * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param collateralToTransfer Collateral to be transferred before increase collateral in the position * @param collateralToIncrease Collateral to be added to the position * @param sender Sender of the increaseCollateral transaction * @return newTotalCollateral New total collateral amount */ function increaseCollateral( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, FixedPoint.Unsigned calldata collateralToTransfer, FixedPoint.Unsigned calldata collateralToIncrease, address sender ) external returns (uint256 newTotalCollateral) { // Check the collateral to be increased is not 0 require(collateralToIncrease.rawValue > 0, 'No collateral to be increased'); // Deposit collateral in the pool if (collateralToTransfer.rawValue > 0) { self.pullCollateral(sender, collateralToTransfer); } // Collateral available FixedPoint.Unsigned memory unusedCollateral = self.calculateUnusedCollateral( lpPosition.totalCollateralAmount, feeStatus.totalFeeAmount, FixedPoint.Unsigned(0) ); // Check that there is enoush availabe collateral deposited in the pool require( unusedCollateral.isGreaterThanOrEqual(collateralToIncrease), 'No enough liquidity for increasing collateral' ); // Update new total collateral amount FixedPoint.Unsigned memory _newTotalCollateral = lpPosition.totalCollateralAmount.add(collateralToIncrease); lpPosition.totalCollateralAmount = _newTotalCollateral; newTotalCollateral = _newTotalCollateral.rawValue; emit IncreaseCollateral( sender, collateralToIncrease.rawValue, newTotalCollateral ); } /** * @notice Decrease collaterallization of Lp position * @notice Check that final position is not undercollateralized * @notice Only a sender with LP role can call this function * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param liquidationData Liquidation info (see LiquidationData struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param collateralToDecrease Collateral to decreased from the position * @param collateralToWithdraw Collateral to be transferred to the LP * @param sender Sender of the decreaseCollateral transaction * @return newTotalCollateral New total collateral amount */ function decreaseCollateral( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.Liquidation storage liquidationData, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, FixedPoint.Unsigned calldata collateralToDecrease, FixedPoint.Unsigned calldata collateralToWithdraw, address sender ) external returns (uint256 newTotalCollateral) { // Check that collateral to be decreased is not 0 require(collateralToDecrease.rawValue > 0, 'No collateral to be decreased'); // Resulting total collateral amount FixedPoint.Unsigned memory _newTotalCollateral = lpPosition.totalCollateralAmount.sub(collateralToDecrease); // Check that position doesn't become undercollateralized (bool _isOverCollateralized, , ) = lpPosition.isOverCollateralized( liquidationData, getPriceFeedRate(self.finder, self.priceIdentifier), getCollateralDecimals(self.collateralToken), _newTotalCollateral ); require(_isOverCollateralized, 'Position undercollateralized'); // Update new total collateral amount lpPosition.totalCollateralAmount = _newTotalCollateral; newTotalCollateral = _newTotalCollateral.rawValue; emit DecreaseCollateral( sender, collateralToDecrease.rawValue, newTotalCollateral ); if (collateralToWithdraw.rawValue > 0) { self._withdrawLiquidity( lpPosition, feeStatus, collateralToWithdraw, sender ); } } /** * @notice Withdraw fees gained by the sender * @param self Data type the library is attached to * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param sender Sender of the claimFee transaction * @return feeClaimed Amount of fee claimed */ function claimFee( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, address sender ) external returns (uint256 feeClaimed) { // Fee to claim FixedPoint.Unsigned memory _feeClaimed = feeStatus.feeGained[sender]; feeClaimed = _feeClaimed.rawValue; // Check that fee is available require(feeClaimed > 0, 'No fee to claim'); // Update fee status delete feeStatus.feeGained[sender]; FixedPoint.Unsigned memory _totalRemainingFees = feeStatus.totalFeeAmount.sub(_feeClaimed); feeStatus.totalFeeAmount = _totalRemainingFees; // Transfer amount to the sender self.collateralToken.safeTransfer(sender, feeClaimed); emit ClaimFee(sender, feeClaimed, _totalRemainingFees.rawValue); } /** * @notice Liquidate Lp position for an amount of synthetic tokens undercollateralized * @notice Revert if position is not undercollateralized * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param liquidationData Liquidation info (see LiquidationData struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param numSynthTokens Number of synthetic tokens that user wants to liquidate * @param sender Sender of the liquidation transaction * @return synthTokensLiquidated Amount of synthetic tokens liquidated * @return collateralReceived Amount of received collateral equal to the value of tokens liquidated * @return rewardAmount Amount of received collateral as reward for the liquidation */ function liquidate( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.Liquidation storage liquidationData, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, FixedPoint.Unsigned calldata numSynthTokens, address sender ) external returns ( uint256 synthTokensLiquidated, uint256 collateralReceived, uint256 rewardAmount ) { // Memory struct for saving local varibales ExecuteLiquidation memory executeLiquidation; executeLiquidation.totalCollateralAmount = lpPosition.totalCollateralAmount; executeLiquidation.priceRate = getPriceFeedRate( self.finder, self.priceIdentifier ); uint8 collateralDecimals = getCollateralDecimals(self.collateralToken); // Collateral value of the synthetic token passed { (bool _isOverCollaterlized, , ) = lpPosition.isOverCollateralized( liquidationData, executeLiquidation.priceRate, collateralDecimals, executeLiquidation.totalCollateralAmount ); // Revert if position is not undercollataralized require(!_isOverCollaterlized, 'Position is overcollateralized'); } IStandardERC20 _collateralToken = self.collateralToken; executeLiquidation.tokensCollateralized = lpPosition.tokensCollateralized; executeLiquidation.tokensInLiquidation = FixedPoint.min( numSynthTokens, executeLiquidation.tokensCollateralized ); executeLiquidation.expectedCollateral = calculateCollateralAmount( executeLiquidation.priceRate, collateralDecimals, executeLiquidation.tokensInLiquidation ); executeLiquidation.userCollateralization = executeLiquidation .tokensInLiquidation .div(executeLiquidation.tokensCollateralized) .mul(executeLiquidation.totalCollateralAmount); if ( executeLiquidation.userCollateralization.isGreaterThanOrEqual( executeLiquidation.expectedCollateral ) ) { executeLiquidation.settledCollateral = executeLiquidation .expectedCollateral; executeLiquidation.rewardAmount = executeLiquidation .userCollateralization .sub(executeLiquidation.expectedCollateral) .mul(liquidationData.liquidationReward); // Update Lp position lpPosition.totalCollateralAmount = executeLiquidation .totalCollateralAmount .sub(executeLiquidation.settledCollateral) .sub(executeLiquidation.rewardAmount); } else { executeLiquidation.unusedCollateral = self.calculateUnusedCollateral( executeLiquidation.totalCollateralAmount, feeStatus.totalFeeAmount, FixedPoint.Unsigned(0) ); executeLiquidation.settledCollateral = FixedPoint.min( executeLiquidation.expectedCollateral, executeLiquidation.userCollateralization.add( executeLiquidation.unusedCollateral ) ); // Update Lp position untill max 105% coverage using available liquidity lpPosition.totalCollateralAmount = FixedPoint.min( executeLiquidation .totalCollateralAmount .add(executeLiquidation.unusedCollateral) .sub(executeLiquidation.settledCollateral), calculateCollateralAmount( executeLiquidation .priceRate, collateralDecimals, executeLiquidation.tokensCollateralized.sub( executeLiquidation.tokensInLiquidation ) ) .mul(liquidationData.collateralRequirement) ); } lpPosition.tokensCollateralized = executeLiquidation .tokensCollateralized .sub(executeLiquidation.tokensInLiquidation); collateralReceived = executeLiquidation.settledCollateral.rawValue; rewardAmount = executeLiquidation.rewardAmount.rawValue; synthTokensLiquidated = executeLiquidation.tokensInLiquidation.rawValue; // Burn synthetic tokens to be liquidated self.burnSyntheticTokens(synthTokensLiquidated, sender); // Transfer liquidated collateral and reward to the user _collateralToken.safeTransfer(sender, collateralReceived + rewardAmount); emit Liquidate( sender, synthTokensLiquidated, executeLiquidation.priceRate.rawValue, executeLiquidation.expectedCollateral.rawValue, collateralReceived, rewardAmount ); } /** * @notice Shutdown the pool in case of emergency * @notice Only Synthereum manager contract can call this function * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param emergencyShutdownData Emergency shutdown info (see Shutdown struct) * @return timestamp Timestamp of emergency shutdown transaction * @return price Price of the pair at the moment of shutdown execution */ function emergencyShutdown( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ISynthereumLiquidityPoolStorage.Shutdown storage emergencyShutdownData ) external returns (uint256 timestamp, uint256 price) { ISynthereumFinder _finder = self.finder; require( msg.sender == _finder.getImplementationAddress(SynthereumInterfaces.Manager), 'Caller must be the Synthereum manager' ); timestamp = block.timestamp; emergencyShutdownData.timestamp = timestamp; FixedPoint.Unsigned memory _price = getPriceFeedRate(_finder, self.priceIdentifier); emergencyShutdownData.price = _price; price = _price.rawValue; // Move available liquidity in the position FixedPoint.Unsigned memory totalCollateral = lpPosition.totalCollateralAmount; FixedPoint.Unsigned memory unusedCollateral = self.calculateUnusedCollateral( totalCollateral, feeStatus.totalFeeAmount, FixedPoint.Unsigned(0) ); FixedPoint.Unsigned memory finalCollateral = totalCollateral.add(unusedCollateral); lpPosition.totalCollateralAmount = finalCollateral; emit EmergencyShutdown(timestamp, price, finalCollateral.rawValue); } /** * @notice Redeem tokens after emergency shutdown * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param emergencyShutdownData Emergency shutdown info (see Shutdown struct) * @param isLiquidityProvider True if the sender is an LP, otherwise false * @param sender Sender of the settleEmergencyShutdown transaction * @return synthTokensSettled Amount of synthetic tokens liquidated * @return collateralSettled Amount of collateral withdrawn after emergency shutdown */ function settleEmergencyShutdown( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ISynthereumLiquidityPoolStorage.Shutdown storage emergencyShutdownData, bool isLiquidityProvider, address sender ) external returns (uint256 synthTokensSettled, uint256 collateralSettled) { // Memory struct for saving local varibales ExecuteSettlement memory executeSettlement; IMintableBurnableERC20 syntheticToken = self.syntheticToken; executeSettlement.emergencyPrice = emergencyShutdownData.price; executeSettlement.userNumTokens = FixedPoint.Unsigned( syntheticToken.balanceOf(sender) ); require( executeSettlement.userNumTokens.rawValue > 0 || isLiquidityProvider, 'Sender has nothing to settle' ); if (executeSettlement.userNumTokens.rawValue > 0) { // Move synthetic tokens from the user to the pool // - This is because derivative expects the tokens to come from the sponsor address syntheticToken.safeTransferFrom( sender, address(this), executeSettlement.userNumTokens.rawValue ); } executeSettlement.totalCollateralAmount = lpPosition.totalCollateralAmount; executeSettlement.tokensCollaterlized = lpPosition.tokensCollateralized; executeSettlement.totalFeeAmount = feeStatus.totalFeeAmount; executeSettlement.overCollateral; IStandardERC20 _collateralToken = self.collateralToken; uint8 collateralDecimals = getCollateralDecimals(_collateralToken); // Add overcollateral and deposited synthetic tokens if the sender is the LP if (isLiquidityProvider) { FixedPoint.Unsigned memory totalRedeemableCollateral = calculateCollateralAmount( executeSettlement.emergencyPrice, collateralDecimals, executeSettlement.tokensCollaterlized ); executeSettlement.overCollateral = executeSettlement .totalCollateralAmount .isGreaterThan(totalRedeemableCollateral) ? executeSettlement.totalCollateralAmount.sub(totalRedeemableCollateral) : FixedPoint.Unsigned(0); executeSettlement.userNumTokens = FixedPoint.Unsigned( syntheticToken.balanceOf(address(this)) ); } // Calculate expected and settled collateral executeSettlement.redeemableCollateral = calculateCollateralAmount( executeSettlement .emergencyPrice, collateralDecimals, executeSettlement .userNumTokens ) .add(executeSettlement.overCollateral); executeSettlement.unusedCollateral = self.calculateUnusedCollateral( executeSettlement.totalCollateralAmount, executeSettlement.totalFeeAmount, FixedPoint.Unsigned(0) ); executeSettlement.transferableCollateral = FixedPoint.min( executeSettlement.redeemableCollateral, executeSettlement.totalCollateralAmount ); // Update Lp position lpPosition.totalCollateralAmount = executeSettlement .totalCollateralAmount .isGreaterThan(executeSettlement.redeemableCollateral) ? executeSettlement.totalCollateralAmount.sub( executeSettlement.redeemableCollateral ) : FixedPoint.Unsigned(0); lpPosition.tokensCollateralized = executeSettlement.tokensCollaterlized.sub( executeSettlement.userNumTokens ); synthTokensSettled = executeSettlement.userNumTokens.rawValue; collateralSettled = executeSettlement.transferableCollateral.rawValue; // Burn synthetic tokens syntheticToken.burn(synthTokensSettled); // Transfer settled collateral to the user _collateralToken.safeTransfer(sender, collateralSettled); emit Settle( sender, synthTokensSettled, executeSettlement.redeemableCollateral.rawValue, collateralSettled ); } /** * @notice Update the fee percentage * @param self Data type the library is attached to * @param _feePercentage The new fee percentage */ function setFeePercentage( ISynthereumLiquidityPoolStorage.Storage storage self, FixedPoint.Unsigned calldata _feePercentage ) external { require( _feePercentage.rawValue < 10**(18), 'Fee Percentage must be less than 100%' ); self.fee.feeData.feePercentage = _feePercentage; emit SetFeePercentage(_feePercentage.rawValue); } /** * @notice Update the addresses of recipients for generated fees and proportions of fees each address will receive * @param self Data type the library is attached to * @param _feeRecipients An array of the addresses of recipients that will receive generated fees * @param _feeProportions An array of the proportions of fees generated each recipient will receive */ function setFeeRecipients( ISynthereumLiquidityPoolStorage.Storage storage self, address[] calldata _feeRecipients, uint32[] calldata _feeProportions ) external { require( _feeRecipients.length == _feeProportions.length, 'Fee recipients and fee proportions do not match' ); uint256 totalActualFeeProportions; // Store the sum of all proportions for (uint256 i = 0; i < _feeProportions.length; i++) { totalActualFeeProportions += _feeProportions[i]; } ISynthereumLiquidityPoolStorage.FeeData storage _feeData = self.fee.feeData; _feeData.feeRecipients = _feeRecipients; _feeData.feeProportions = _feeProportions; self.fee.totalFeeProportions = totalActualFeeProportions; emit SetFeeRecipients(_feeRecipients, _feeProportions); } /** * @notice Update the overcollateralization percentage * @param self Data type the library is attached to * @param liquidationData Liquidation info (see LiquidationData struct) * @param _overCollateralization Overcollateralization percentage */ function setOverCollateralization( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.Liquidation storage liquidationData, FixedPoint.Unsigned calldata _overCollateralization ) external { require( _overCollateralization.isGreaterThan( liquidationData.collateralRequirement.sub(1) ), 'Overcollateralization must be bigger than the Lp part of the collateral requirement' ); self.overCollateralization = _overCollateralization; emit SetOverCollateralization(_overCollateralization.rawValue); } /** * @notice Update the liquidation reward percentage * @param liquidationData Liquidation info (see LiquidationData struct) * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator */ function setLiquidationReward( ISynthereumLiquidityPoolStorage.Liquidation storage liquidationData, FixedPoint.Unsigned calldata _liquidationReward ) external { require( _liquidationReward.rawValue > 0 && _liquidationReward.isLessThanOrEqual(1), 'Liquidation reward must be between 0 and 100%' ); liquidationData.liquidationReward = _liquidationReward; emit SetLiquidationReward(_liquidationReward.rawValue); } //---------------------------------------- // External view functions //---------------------------------------- /** * @notice Returns the total amount of liquidity deposited in the pool, but nut used as collateral * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @return Total available liquidity */ function totalAvailableLiquidity( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus ) external view returns (uint256) { return self .calculateUnusedCollateral( lpPosition .totalCollateralAmount, feeStatus .totalFeeAmount, FixedPoint.Unsigned(0) ) .rawValue; } /** * @notice Returns if position is overcollateralized and thepercentage of coverage of the collateral according to the last price * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param liquidationData Liquidation info (see LiquidationData struct) * @return True if position is overcollaterlized, otherwise false + percentage of coverage (totalCollateralAmount / (price * tokensCollateralized)) */ function collateralCoverage( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.Liquidation storage liquidationData ) external view returns (bool, uint256) { FixedPoint.Unsigned memory priceRate = getPriceFeedRate(self.finder, self.priceIdentifier); uint8 collateralDecimals = getCollateralDecimals(self.collateralToken); ( bool _isOverCollateralized, , FixedPoint.Unsigned memory overCollateralValue ) = lpPosition.isOverCollateralized( liquidationData, priceRate, collateralDecimals, lpPosition.totalCollateralAmount ); FixedPoint.Unsigned memory coverageRatio = lpPosition.totalCollateralAmount.div(overCollateralValue); FixedPoint.Unsigned memory _collateralCoverage = liquidationData.collateralRequirement.mul(coverageRatio); return (_isOverCollateralized, _collateralCoverage.rawValue); } /** * @notice Returns the synthetic tokens will be received and fees will be paid in exchange for an input collateral amount * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param inputCollateral Input collateral amount to be exchanged * @return synthTokensReceived Synthetic tokens will be minted * @return feePaid Collateral fee will be paid */ function getMintTradeInfo( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, FixedPoint.Unsigned calldata inputCollateral ) external view returns (uint256 synthTokensReceived, uint256 feePaid) { ( FixedPoint.Unsigned memory collateralAmount, FixedPoint.Unsigned memory _feePaid, FixedPoint.Unsigned memory _synthTokensReceived ) = self.mintCalculation(inputCollateral); require( collateralAmount.rawValue > 0, 'Sending collateral amount is equal to 0' ); FixedPoint.Unsigned memory overCollateral = collateralAmount.mul(self.overCollateralization); FixedPoint.Unsigned memory unusedCollateral = self.calculateUnusedCollateral( lpPosition.totalCollateralAmount, feeStatus.totalFeeAmount, FixedPoint.Unsigned(0) ); require( unusedCollateral.isGreaterThanOrEqual(overCollateral), 'No enough liquidity for covering mint operation' ); synthTokensReceived = _synthTokensReceived.rawValue; feePaid = _feePaid.rawValue; } /** * @notice Returns the collateral amount will be received and fees will be paid in exchange for an input amount of synthetic tokens * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param syntheticTokens Amount of synthetic tokens to be exchanged * @return collateralAmountReceived Collateral amount will be received by the user * @return feePaid Collateral fee will be paid */ function getRedeemTradeInfo( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, FixedPoint.Unsigned calldata syntheticTokens ) external view returns (uint256 collateralAmountReceived, uint256 feePaid) { FixedPoint.Unsigned memory totalActualTokens = lpPosition.tokensCollateralized; require( syntheticTokens.rawValue > 0, 'Sending tokens amount is equal to 0' ); require( syntheticTokens.isLessThanOrEqual(totalActualTokens), 'Sending tokens amount bigger than amount in the position' ); ( FixedPoint.Unsigned memory totCollateralAmount, FixedPoint.Unsigned memory _feePaid, FixedPoint.Unsigned memory _collateralAmountReceived ) = self.redeemCalculation(syntheticTokens); FixedPoint.Unsigned memory collateralRedeemed = syntheticTokens.div(totalActualTokens).mul( lpPosition.totalCollateralAmount ); require( collateralRedeemed.isGreaterThanOrEqual(totCollateralAmount), 'Position undercapitalized' ); collateralAmountReceived = _collateralAmountReceived.rawValue; feePaid = _feePaid.rawValue; } /** * @notice Returns the destination synthetic tokens amount will be received and fees will be paid in exchange for an input amount of synthetic tokens * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param syntheticTokens Amount of synthetic tokens to be exchanged * @param destinationPool Pool in which mint the destination synthetic token * @return destSyntheticTokensReceived Synthetic tokens will be received from destination pool * @return feePaid Collateral fee will be paid */ function getExchangeTradeInfo( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, FixedPoint.Unsigned calldata syntheticTokens, ISynthereumLiquidityPoolGeneral destinationPool ) external view returns (uint256 destSyntheticTokensReceived, uint256 feePaid) { self.checkPool(destinationPool); require( address(this) != address(destinationPool), 'Same source and destination pool' ); FixedPoint.Unsigned memory totalActualTokens = lpPosition.tokensCollateralized; require( syntheticTokens.rawValue > 0, 'Sending tokens amount is equal to 0' ); require( syntheticTokens.isLessThanOrEqual(totalActualTokens), 'Sending tokens amount bigger than amount in the position' ); ( FixedPoint.Unsigned memory totCollateralAmount, FixedPoint.Unsigned memory _feePaid, FixedPoint.Unsigned memory collateralAmount, FixedPoint.Unsigned memory _destSyntheticTokensReceived ) = self.exchangeCalculation(syntheticTokens, destinationPool); FixedPoint.Unsigned memory collateralRedeemed = syntheticTokens.div(totalActualTokens).mul( lpPosition.totalCollateralAmount ); require( collateralRedeemed.isGreaterThanOrEqual(totCollateralAmount), 'Position undercapitalized' ); require( collateralAmount.rawValue > 0, 'Sending collateral amount is equal to 0' ); FixedPoint.Unsigned memory destOverCollateral = collateralAmount.mul( FixedPoint.Unsigned(destinationPool.overCollateralization()) ); FixedPoint.Unsigned memory destUnusedCollateral = FixedPoint.Unsigned(destinationPool.totalAvailableLiquidity()); require( destUnusedCollateral.isGreaterThanOrEqual(destOverCollateral), 'No enough liquidity for covering mint operation' ); destSyntheticTokensReceived = _destSyntheticTokensReceived.rawValue; feePaid = _feePaid.rawValue; } //---------------------------------------- // Internal functions //---------------------------------------- /** * @notice Execute mint of synthetic tokens * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param executeMintParams Params for execution of mint (see ExecuteMintParams struct) */ function executeMint( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ExecuteMintParams memory executeMintParams ) internal { // Sending amount must be different from 0 require( executeMintParams.collateralAmount.rawValue > 0, 'Sending collateral amount is equal to 0' ); // Collateral available FixedPoint.Unsigned memory unusedCollateral = self.calculateUnusedCollateral( lpPosition.totalCollateralAmount, feeStatus.totalFeeAmount, FixedPoint.Unsigned(0) ); // Update LP's collateralization status FixedPoint.Unsigned memory overCollateral = lpPosition.updateLpPositionInMint( self.overCollateralization, executeMintParams.collateralAmount, executeMintParams.numTokens ); //Check there is enough liquidity in the pool for overcollateralization require( unusedCollateral.isGreaterThanOrEqual(overCollateral), 'No enough liquidity for covering mint operation' ); // Update fees status feeStatus.updateFees(self.fee, executeMintParams.feeAmount); // Pull user's collateral self.pullCollateral( executeMintParams.sender, executeMintParams.totCollateralAmount ); // Mint synthetic asset and transfer to the recipient self.syntheticToken.mint( executeMintParams.recipient, executeMintParams.numTokens.rawValue ); emit Mint( executeMintParams.sender, executeMintParams.totCollateralAmount.rawValue, executeMintParams.numTokens.rawValue, executeMintParams.feeAmount.rawValue, executeMintParams.recipient ); } /** * @notice Execute redeem of collateral * @param self Data type the library is attached tfo * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param executeRedeemParams Params for execution of redeem (see ExecuteRedeemParams struct) */ function executeRedeem( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ExecuteRedeemParams memory executeRedeemParams ) internal { // Sending amount must be different from 0 require( executeRedeemParams.numTokens.rawValue > 0, 'Sending tokens amount is equal to 0' ); FixedPoint.Unsigned memory collateralRedeemed = lpPosition.updateLpPositionInRedeem(executeRedeemParams.numTokens); // Check that collateral redemeed is enough for cover the value of synthetic tokens require( collateralRedeemed.isGreaterThanOrEqual( executeRedeemParams.totCollateralAmount ), 'Position undercapitalized' ); // Update fees status feeStatus.updateFees(self.fee, executeRedeemParams.feeAmount); // Burn synthetic tokens self.burnSyntheticTokens( executeRedeemParams.numTokens.rawValue, executeRedeemParams.sender ); //Send net amount of collateral to the user that submitted the redeem request self.collateralToken.safeTransfer( executeRedeemParams.recipient, executeRedeemParams.collateralAmount.rawValue ); emit Redeem( executeRedeemParams.sender, executeRedeemParams.numTokens.rawValue, executeRedeemParams.collateralAmount.rawValue, executeRedeemParams.feeAmount.rawValue, executeRedeemParams.recipient ); } /** * @notice Execute exchange between synthetic tokens * @param self Data type the library is attached tfo * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param executeExchangeParams Params for execution of exchange (see ExecuteExchangeParams struct) */ function executeExchange( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ExecuteExchangeParams memory executeExchangeParams ) internal { // Sending amount must be different from 0 require( executeExchangeParams.numTokens.rawValue > 0, 'Sending tokens amount is equal to 0' ); FixedPoint.Unsigned memory collateralRedeemed = lpPosition.updateLpPositionInRedeem(executeExchangeParams.numTokens); // Check that collateral redemeed is enough for cover the value of synthetic tokens require( collateralRedeemed.isGreaterThanOrEqual( executeExchangeParams.totCollateralAmount ), 'Position undercapitalized' ); // Update fees status feeStatus.updateFees(self.fee, executeExchangeParams.feeAmount); // Burn synthetic tokens self.burnSyntheticTokens( executeExchangeParams.numTokens.rawValue, executeExchangeParams.sender ); ISynthereumLiquidityPoolGeneral destinationPool = executeExchangeParams.destPool; // Check that destination pool is different from this pool require( address(this) != address(destinationPool), 'Same source and destination pool' ); self.checkPool(destinationPool); // Transfer collateral amount (without overcollateralization) to the destination pool self.collateralToken.safeTransfer( address(destinationPool), executeExchangeParams.collateralAmount.rawValue ); // Mint the destination tokens with the withdrawn collateral destinationPool.exchangeMint( executeExchangeParams.collateralAmount.rawValue, executeExchangeParams.destNumTokens.rawValue, executeExchangeParams.recipient ); emit Exchange( executeExchangeParams.sender, address(destinationPool), executeExchangeParams.numTokens.rawValue, executeExchangeParams.destNumTokens.rawValue, executeExchangeParams.feeAmount.rawValue, executeExchangeParams.recipient ); } /** * @notice Withdraw unused deposited collateral by the LP * @param self Data type the library is attached to * @param lpPosition Position of the LP (see LPPosition struct) * @param feeStatus Actual status of fee gained (see FeeStatus struct) * @param collateralAmount Collateral to be withdrawn * @param sender Sender that withdraws liquidity * @return remainingLiquidity Remaining unused collateral in the pool */ function _withdrawLiquidity( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, FixedPoint.Unsigned memory collateralAmount, address sender ) internal returns (uint256 remainingLiquidity) { // Collateral available FixedPoint.Unsigned memory unusedCollateral = self.calculateUnusedCollateral( lpPosition.totalCollateralAmount, feeStatus.totalFeeAmount, FixedPoint.Unsigned(0) ); // Check that available collateral is bigger than collateral to be withdrawn and returns the difference remainingLiquidity = (unusedCollateral.sub(collateralAmount)).rawValue; // Transfer amount to the Lp uint256 _collateralAmount = collateralAmount.rawValue; self.collateralToken.safeTransfer(sender, _collateralAmount); emit WithdrawLiquidity(sender, _collateralAmount, remainingLiquidity); } /** * @notice Update LP's collateralization status after a mint * @param lpPosition Position of the LP (see LPPosition struct) * @param overCollateralization Overcollateralization rate * @param collateralAmount Collateral amount to be added (only user collateral) * @param numTokens Tokens to be added * @return overCollateral Amount of collateral to be provided by LP for overcollateralization */ function updateLpPositionInMint( ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, FixedPoint.Unsigned storage overCollateralization, FixedPoint.Unsigned memory collateralAmount, FixedPoint.Unsigned memory numTokens ) internal returns (FixedPoint.Unsigned memory overCollateral) { overCollateral = collateralAmount.mul(overCollateralization); lpPosition.totalCollateralAmount = lpPosition .totalCollateralAmount .add(collateralAmount) .add(overCollateral); lpPosition.tokensCollateralized = lpPosition.tokensCollateralized.add( numTokens ); } /** * @notice Update LP's collateralization status after a redeem * @param lpPosition Position of the LP (see LPPosition struct) * @param numTokens Tokens to be removed * @return collateralRedeemed Collateral redeemed */ function updateLpPositionInRedeem( ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, FixedPoint.Unsigned memory numTokens ) internal returns (FixedPoint.Unsigned memory collateralRedeemed) { FixedPoint.Unsigned memory totalActualTokens = lpPosition.tokensCollateralized; FixedPoint.Unsigned memory totalActualCollateral = lpPosition.totalCollateralAmount; FixedPoint.Unsigned memory fractionRedeemed = numTokens.div(totalActualTokens); collateralRedeemed = fractionRedeemed.mul(totalActualCollateral); lpPosition.tokensCollateralized = totalActualTokens.sub(numTokens); lpPosition.totalCollateralAmount = totalActualCollateral.sub( collateralRedeemed ); } /** * @notice Update fee gained by the fee recipients * @param feeStatus Actual status of fee gained to be withdrawn * @param feeInfo Actual status of fee recipients and their proportions * @param feeAmount Collateral fee charged */ function updateFees( ISynthereumLiquidityPoolStorage.FeeStatus storage feeStatus, ISynthereumLiquidityPoolStorage.Fee storage feeInfo, FixedPoint.Unsigned memory feeAmount ) internal { FixedPoint.Unsigned memory feeCharged; address[] storage feeRecipients = feeInfo.feeData.feeRecipients; uint32[] storage feeProportions = feeInfo.feeData.feeProportions; uint256 totalFeeProportions = feeInfo.totalFeeProportions; uint256 numberOfRecipients = feeRecipients.length; mapping(address => FixedPoint.Unsigned) storage feeGained = feeStatus.feeGained; for (uint256 i = 0; i < numberOfRecipients - 1; i++) { address feeRecipient = feeRecipients[i]; FixedPoint.Unsigned memory feeReceived = FixedPoint.Unsigned( (feeAmount.rawValue * feeProportions[i]) / totalFeeProportions ); feeGained[feeRecipient] = feeGained[feeRecipient].add(feeReceived); feeCharged = feeCharged.add(feeReceived); } address lastRecipient = feeRecipients[numberOfRecipients - 1]; feeGained[lastRecipient] = feeGained[lastRecipient].add(feeAmount).sub( feeCharged ); feeStatus.totalFeeAmount = feeStatus.totalFeeAmount.add(feeAmount); } /** * @notice Pulls collateral tokens from the sender to store in the Pool * @param self Data type the library is attached to * @param numTokens The number of tokens to pull */ function pullCollateral( ISynthereumLiquidityPoolStorage.Storage storage self, address from, FixedPoint.Unsigned memory numTokens ) internal { self.collateralToken.safeTransferFrom( from, address(this), numTokens.rawValue ); } /** * @notice Pulls synthetic tokens from the sender and burn them * @param self Data type the library is attached to * @param numTokens The number of tokens to be burned * @param sender Sender of synthetic tokens */ function burnSyntheticTokens( ISynthereumLiquidityPoolStorage.Storage storage self, uint256 numTokens, address sender ) internal { IMintableBurnableERC20 synthToken = self.syntheticToken; // Transfer synthetic token from the user to the pool synthToken.safeTransferFrom(sender, address(this), numTokens); // Burn synthetic asset synthToken.burn(numTokens); } //---------------------------------------- // Internal views functions //---------------------------------------- /** * @notice Given a collateral value to be exchanged, returns the fee amount, net collateral and synthetic tokens * @param self Data type the library is attached tfo * @param totCollateralAmount Collateral amount to be exchanged * @return collateralAmount Net collateral amount (totCollateralAmount - feePercentage) * @return feeAmount Fee to be paid according to the fee percentage * @return numTokens Number of synthetic tokens will be received according to the actual price in exchange for collateralAmount */ function mintCalculation( ISynthereumLiquidityPoolStorage.Storage storage self, FixedPoint.Unsigned memory totCollateralAmount ) internal view returns ( FixedPoint.Unsigned memory collateralAmount, FixedPoint.Unsigned memory feeAmount, FixedPoint.Unsigned memory numTokens ) { feeAmount = totCollateralAmount.mul(self.fee.feeData.feePercentage); collateralAmount = totCollateralAmount.sub(feeAmount); numTokens = calculateNumberOfTokens( getPriceFeedRate(self.finder, self.priceIdentifier), getCollateralDecimals(self.collateralToken), collateralAmount ); } /** * @notice Given a an amount of synthetic tokens to be exchanged, returns the fee amount, net collateral and gross collateral * @param self Data type the library is attached tfo * @param numTokens Synthetic tokens amount to be exchanged * @return totCollateralAmount Gross collateral amount (collateralAmount + feeAmount) * @return feeAmount Fee to be paid according to the fee percentage * @return collateralAmount Net collateral amount will be received according to the actual price in exchange for numTokens */ function redeemCalculation( ISynthereumLiquidityPoolStorage.Storage storage self, FixedPoint.Unsigned memory numTokens ) internal view returns ( FixedPoint.Unsigned memory totCollateralAmount, FixedPoint.Unsigned memory feeAmount, FixedPoint.Unsigned memory collateralAmount ) { totCollateralAmount = calculateCollateralAmount( getPriceFeedRate(self.finder, self.priceIdentifier), getCollateralDecimals(self.collateralToken), numTokens ); feeAmount = totCollateralAmount.mul(self.fee.feeData.feePercentage); collateralAmount = totCollateralAmount.sub(feeAmount); } /** * @notice Given a an amount of synthetic tokens to be exchanged, returns the fee amount, net collateral and gross collateral and number of destination tokens * @param self Data type the library is attached tfo * @param numTokens Synthetic tokens amount to be exchanged * @param destinationPool Pool from which destination tokens will be received * @return totCollateralAmount Gross collateral amount according to the price * @return feeAmount Fee to be paid according to the fee percentage * @return collateralAmount Net collateral amount (totCollateralAmount - feeAmount) * @return destNumTokens Number of destination synthetic tokens will be received according to the actual price in exchange for synthetic tokens */ function exchangeCalculation( ISynthereumLiquidityPoolStorage.Storage storage self, FixedPoint.Unsigned memory numTokens, ISynthereumLiquidityPoolGeneral destinationPool ) internal view returns ( FixedPoint.Unsigned memory totCollateralAmount, FixedPoint.Unsigned memory feeAmount, FixedPoint.Unsigned memory collateralAmount, FixedPoint.Unsigned memory destNumTokens ) { ISynthereumFinder _finder = self.finder; IStandardERC20 _collateralToken = self.collateralToken; uint8 collateralDecimals = getCollateralDecimals(_collateralToken); totCollateralAmount = calculateCollateralAmount( getPriceFeedRate(_finder, self.priceIdentifier), collateralDecimals, numTokens ); feeAmount = totCollateralAmount.mul(self.fee.feeData.feePercentage); collateralAmount = totCollateralAmount.sub(feeAmount); destNumTokens = calculateNumberOfTokens( getPriceFeedRate(_finder, destinationPool.getPriceFeedIdentifier()), collateralDecimals, collateralAmount ); } /** * @notice Check expiration of mint, redeem and exchange transaction * @param expiration Expiration time of the transaction */ function checkExpiration(uint256 expiration) internal view { require(block.timestamp <= expiration, 'Transaction expired'); } /** * @notice Check if sender or receiver pool is a correct registered pool * @param self Data type the library is attached to * @param poolToCheck Pool that should be compared with this pool */ function checkPool( ISynthereumLiquidityPoolStorage.Storage storage self, ISynthereumLiquidityPoolGeneral poolToCheck ) internal view { IStandardERC20 collateralToken = self.collateralToken; require( collateralToken == poolToCheck.collateralToken(), 'Collateral tokens do not match' ); ISynthereumFinder finder = self.finder; require(finder == poolToCheck.synthereumFinder(), 'Finders do not match'); ISynthereumRegistry poolRegister = ISynthereumRegistry( finder.getImplementationAddress(SynthereumInterfaces.PoolRegistry) ); require( poolRegister.isDeployed( poolToCheck.syntheticTokenSymbol(), collateralToken, poolToCheck.version(), address(poolToCheck) ), 'Destination pool not registered' ); } /** * @notice Check if an amount of collateral is enough to collateralize the position * @param lpPosition Position of the LP (see LPPosition struct) * @param priceRate Price rate of the pair * @param collateralDecimals Number of decimals of the collateral * @param liquidationData Liquidation info (see LiquidationData struct) * @param collateralToCompare collateral used for checking the overcollaterlization * @return _isOverCollateralized True if position is overcollaterlized, otherwise false * @return collateralValue Collateral amount equal to the value of tokens * @return overCollateralValue Collateral amount equal to the value of tokens * collateralRequirement */ function isOverCollateralized( ISynthereumLiquidityPoolStorage.LPPosition storage lpPosition, ISynthereumLiquidityPoolStorage.Liquidation storage liquidationData, FixedPoint.Unsigned memory priceRate, uint8 collateralDecimals, FixedPoint.Unsigned memory collateralToCompare ) internal view returns ( bool _isOverCollateralized, FixedPoint.Unsigned memory collateralValue, FixedPoint.Unsigned memory overCollateralValue ) { collateralValue = calculateCollateralAmount( priceRate, collateralDecimals, lpPosition.tokensCollateralized ); overCollateralValue = collateralValue.mul( liquidationData.collateralRequirement ); _isOverCollateralized = collateralToCompare.isGreaterThanOrEqual( overCollateralValue ); } /** * @notice Calculate the unused collateral of this pool * @param self Data type the library is attached to * @param totalCollateral Total collateral used * @param totalFees Total fees gained to be whitdrawn * @param collateralReceived Collateral sent to the pool by a user or contract to be used for collateralization * @param unusedCollateral Unused collateral of the pool */ function calculateUnusedCollateral( ISynthereumLiquidityPoolStorage.Storage storage self, FixedPoint.Unsigned memory totalCollateral, FixedPoint.Unsigned memory totalFees, FixedPoint.Unsigned memory collateralReceived ) internal view returns (FixedPoint.Unsigned memory unusedCollateral) { // Collateral available FixedPoint.Unsigned memory actualBalance = FixedPoint.Unsigned(self.collateralToken.balanceOf(address(this))); unusedCollateral = actualBalance.sub( totalCollateral.add(totalFees).add(collateralReceived) ); } /** * @notice Retrun the on-chain oracle price for a pair * @param finder Synthereum finder * @param priceIdentifier Identifier of price pair * @return priceRate Latest rate of the pair */ function getPriceFeedRate(ISynthereumFinder finder, bytes32 priceIdentifier) internal view returns (FixedPoint.Unsigned memory priceRate) { ISynthereumPriceFeed priceFeed = ISynthereumPriceFeed( finder.getImplementationAddress(SynthereumInterfaces.PriceFeed) ); priceRate = FixedPoint.Unsigned(priceFeed.getLatestPrice(priceIdentifier)); } /** * @notice Retrun the number of decimals of collateral token * @param collateralToken Collateral token contract * @return decimals number of decimals */ function getCollateralDecimals(IStandardERC20 collateralToken) internal view returns (uint8 decimals) { decimals = collateralToken.decimals(); } /** * @notice Calculate synthetic token amount starting from an amount of collateral * @param priceRate Price rate of the pair * @param collateralDecimals Number of decimals of the collateral * @param numTokens Amount of collateral from which you want to calculate synthetic token amount * @return numTokens Amount of tokens after on-chain oracle conversion */ function calculateNumberOfTokens( FixedPoint.Unsigned memory priceRate, uint8 collateralDecimals, FixedPoint.Unsigned memory collateralAmount ) internal pure returns (FixedPoint.Unsigned memory numTokens) { numTokens = collateralAmount.mul(10**(18 - collateralDecimals)).div( priceRate ); } /** * @notice Calculate collateral amount starting from an amount of synthtic token * @param priceRate Price rate of the pair * @param collateralDecimals Number of decimals of the collateral * @param numTokens Amount of synthetic tokens from which you want to calculate collateral amount * @return collateralAmount Amount of collateral after on-chain oracle conversion */ function calculateCollateralAmount( FixedPoint.Unsigned memory priceRate, uint8 collateralDecimals, FixedPoint.Unsigned memory numTokens ) internal pure returns (FixedPoint.Unsigned memory collateralAmount) { collateralAmount = numTokens.mul(priceRate).div( 10**(18 - collateralDecimals) ); } } // File: verified-sources/0x0aA7e2A631198ba957f8335a6FAC6F3B8F53bD0E/sources/deploy/contracts/synthereum-pool/v5/LiquidityPool.sol pragma solidity ^0.8.4; /** * @title Token Issuer Contract * @notice Collects collateral and issues synthetic assets */ contract SynthereumLiquidityPool is ISynthereumLiquidityPoolStorage, ISynthereumLiquidityPool, AccessControlEnumerable, ERC2771Context, ReentrancyGuard { using SynthereumLiquidityPoolLib for Storage; using SynthereumLiquidityPoolLib for Liquidation; struct ConstructorParams { // Synthereum finder ISynthereumFinder finder; // Synthereum pool version uint8 version; // ERC20 collateral token IStandardERC20 collateralToken; // ERC20 synthetic token IMintableBurnableERC20 syntheticToken; // The addresses of admin, maintainer, liquidity provider Roles roles; // Overcollateralization percentage uint256 overCollateralization; // The feeData structure FeeData feeData; // Identifier of price to be used in the price feed bytes32 priceIdentifier; // Percentage of overcollateralization to which a liquidation can triggered uint256 collateralRequirement; // Percentage of reward for correct liquidation by a liquidator uint256 liquidationReward; } //---------------------------------------- // Constants //---------------------------------------- string public constant override typology = 'POOL'; bytes32 public constant MAINTAINER_ROLE = keccak256('Maintainer'); bytes32 public constant LIQUIDITY_PROVIDER_ROLE = keccak256('Liquidity Provider'); //---------------------------------------- // Storage //---------------------------------------- Storage private poolStorage; LPPosition private lpPosition; Liquidation private liquidationData; FeeStatus private feeStatus; Shutdown private emergencyShutdownData; //---------------------------------------- // Events //---------------------------------------- event Mint( address indexed account, uint256 collateralSent, uint256 numTokensReceived, uint256 feePaid, address recipient ); event Redeem( address indexed account, uint256 numTokensSent, uint256 collateralReceived, uint256 feePaid, address recipient ); event Exchange( address indexed account, address indexed destPool, uint256 numTokensSent, uint256 destNumTokensReceived, uint256 feePaid, address recipient ); event WithdrawLiquidity( address indexed lp, uint256 liquidityWithdrawn, uint256 remainingLiquidity ); event IncreaseCollateral( address indexed lp, uint256 collateralAdded, uint256 newTotalCollateral ); event DecreaseCollateral( address indexed lp, uint256 collateralRemoved, uint256 newTotalCollateral ); event ClaimFee( address indexed claimer, uint256 feeAmount, uint256 totalRemainingFees ); event Liquidate( address indexed liquidator, uint256 tokensLiquidated, uint256 price, uint256 collateralExpected, uint256 collateralReceived, uint256 rewardReceived ); event EmergencyShutdown( uint256 timestamp, uint256 price, uint256 finalCollateral ); event Settle( address indexed account, uint256 numTokensSettled, uint256 collateralExpected, uint256 collateralSettled ); event SetFeePercentage(uint256 feePercentage); event SetFeeRecipients(address[] feeRecipients, uint32[] feeProportions); event SetOverCollateralization(uint256 overCollateralization); event SetLiquidationReward(uint256 liquidationReward); //---------------------------------------- // Modifiers //---------------------------------------- modifier onlyMaintainer() { require( hasRole(MAINTAINER_ROLE, _msgSender()), 'Sender must be the maintainer' ); _; } modifier onlyLiquidityProvider() { require( hasRole(LIQUIDITY_PROVIDER_ROLE, _msgSender()), 'Sender must be the liquidity provider' ); _; } modifier notEmergencyShutdown() { require(emergencyShutdownData.timestamp == 0, 'Pool emergency shutdown'); _; } modifier isEmergencyShutdown() { require( emergencyShutdownData.timestamp != 0, 'Pool not emergency shutdown' ); _; } //---------------------------------------- // Constructor //---------------------------------------- /** * @notice Constructor of liquidity pool */ constructor(ConstructorParams memory params) nonReentrant { poolStorage.initialize( liquidationData, params.finder, params.version, params.collateralToken, params.syntheticToken, FixedPoint.Unsigned(params.overCollateralization), params.priceIdentifier, FixedPoint.Unsigned(params.collateralRequirement), FixedPoint.Unsigned(params.liquidationReward) ); poolStorage.setFeePercentage(params.feeData.feePercentage); poolStorage.setFeeRecipients( params.feeData.feeRecipients, params.feeData.feeProportions ); _setRoleAdmin(DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_ROLE); _setRoleAdmin(MAINTAINER_ROLE, DEFAULT_ADMIN_ROLE); _setRoleAdmin(LIQUIDITY_PROVIDER_ROLE, DEFAULT_ADMIN_ROLE); _setupRole(DEFAULT_ADMIN_ROLE, params.roles.admin); _setupRole(MAINTAINER_ROLE, params.roles.maintainer); _setupRole(LIQUIDITY_PROVIDER_ROLE, params.roles.liquidityProvider); } //---------------------------------------- // External functions //---------------------------------------- /** * @notice Mint synthetic tokens using fixed amount of collateral * @notice This calculate the price using on chain price feed * @notice User must approve collateral transfer for the mint request to succeed * @param mintParams Input parameters for minting (see MintParams struct) * @return syntheticTokensMinted Amount of synthetic tokens minted by a user * @return feePaid Amount of collateral paid by the user as fee */ function mint(MintParams calldata mintParams) external override notEmergencyShutdown nonReentrant returns (uint256 syntheticTokensMinted, uint256 feePaid) { (syntheticTokensMinted, feePaid) = poolStorage.mint( lpPosition, feeStatus, mintParams, _msgSender() ); } /** * @notice Redeem amount of collateral using fixed number of synthetic token * @notice This calculate the price using on chain price feed * @notice User must approve synthetic token transfer for the redeem request to succeed * @param redeemParams Input parameters for redeeming (see RedeemParams struct) * @return collateralRedeemed Amount of collateral redeem by user * @return feePaid Amount of collateral paid by user as fee */ function redeem(RedeemParams calldata redeemParams) external override notEmergencyShutdown nonReentrant returns (uint256 collateralRedeemed, uint256 feePaid) { (collateralRedeemed, feePaid) = poolStorage.redeem( lpPosition, feeStatus, redeemParams, _msgSender() ); } /** * @notice Exchange a fixed amount of synthetic token of this pool, with an amount of synthetic tokens of an another pool * @notice This calculate the price using on chain price feed * @notice User must approve synthetic token transfer for the redeem request to succeed * @param exchangeParams Input parameters for exchanging (see ExchangeParams struct) * @return destNumTokensMinted Amount of collateral redeem by user * @return feePaid Amount of collateral paid by user as fee */ function exchange(ExchangeParams calldata exchangeParams) external override notEmergencyShutdown nonReentrant returns (uint256 destNumTokensMinted, uint256 feePaid) { (destNumTokensMinted, feePaid) = poolStorage.exchange( lpPosition, feeStatus, exchangeParams, _msgSender() ); } /** * @notice Called by a source Pool's `exchange` function to mint destination tokens * @notice This functon can be called only by a pool registered in the PoolRegister contract * @param collateralAmount The amount of collateral to use from the source Pool * @param numTokens The number of new tokens to mint * @param recipient Recipient to which send synthetic token minted */ function exchangeMint( uint256 collateralAmount, uint256 numTokens, address recipient ) external override notEmergencyShutdown nonReentrant { poolStorage.exchangeMint( lpPosition, feeStatus, FixedPoint.Unsigned(collateralAmount), FixedPoint.Unsigned(numTokens), recipient ); } /** * @notice Withdraw unused deposited collateral by the LP * @notice Only a sender with LP role can call this function * @param collateralAmount Collateral to be withdrawn * @return remainingLiquidity Remaining unused collateral in the pool */ function withdrawLiquidity(uint256 collateralAmount) external override onlyLiquidityProvider notEmergencyShutdown nonReentrant returns (uint256 remainingLiquidity) { remainingLiquidity = poolStorage.withdrawLiquidity( lpPosition, feeStatus, FixedPoint.Unsigned(collateralAmount), _msgSender() ); } /** * @notice Increase collaterallization of Lp position * @notice Only a sender with LP role can call this function * @param collateralToTransfer Collateral to be transferred before increase collateral in the position * @param collateralToIncrease Collateral to be added to the position * @return newTotalCollateral New total collateral amount */ function increaseCollateral( uint256 collateralToTransfer, uint256 collateralToIncrease ) external override onlyLiquidityProvider nonReentrant returns (uint256 newTotalCollateral) { newTotalCollateral = poolStorage.increaseCollateral( lpPosition, feeStatus, FixedPoint.Unsigned(collateralToTransfer), FixedPoint.Unsigned(collateralToIncrease), _msgSender() ); } /** * @notice Decrease collaterallization of Lp position * @notice Check that final poosition is not undercollateralized * @notice Only a sender with LP role can call this function * @param collateralToDecrease Collateral to decreased from the position * @param collateralToWithdraw Collateral to be transferred to the LP * @return newTotalCollateral New total collateral amount */ function decreaseCollateral( uint256 collateralToDecrease, uint256 collateralToWithdraw ) external override onlyLiquidityProvider notEmergencyShutdown nonReentrant returns (uint256 newTotalCollateral) { newTotalCollateral = poolStorage.decreaseCollateral( lpPosition, liquidationData, feeStatus, FixedPoint.Unsigned(collateralToDecrease), FixedPoint.Unsigned(collateralToWithdraw), _msgSender() ); } /** * @notice Withdraw fees gained by the sender * @return feeClaimed Amount of fee claimed */ function claimFee() external override nonReentrant returns (uint256 feeClaimed) { feeClaimed = poolStorage.claimFee(feeStatus, _msgSender()); } /** * @notice Liquidate Lp position for an amount of synthetic tokens undercollateralized * @notice Revert if position is not undercollateralized * @param numSynthTokens Number of synthetic tokens that user wants to liquidate * @return synthTokensLiquidated Amount of synthetic tokens liquidated * @return collateralReceived Amount of received collateral equal to the value of tokens liquidated * @return rewardAmount Amount of received collateral as reward for the liquidation */ function liquidate(uint256 numSynthTokens) external override notEmergencyShutdown nonReentrant returns ( uint256 synthTokensLiquidated, uint256 collateralReceived, uint256 rewardAmount ) { (synthTokensLiquidated, collateralReceived, rewardAmount) = poolStorage .liquidate( lpPosition, liquidationData, feeStatus, FixedPoint.Unsigned(numSynthTokens), _msgSender() ); } /** * @notice Shutdown the pool in case of emergency * @notice Only Synthereum manager contract can call this function * @return timestamp Timestamp of emergency shutdown transaction * @return price Price of the pair at the moment of shutdown execution */ function emergencyShutdown() external override notEmergencyShutdown nonReentrant returns (uint256 timestamp, uint256 price) { (timestamp, price) = poolStorage.emergencyShutdown( lpPosition, feeStatus, emergencyShutdownData ); } /** * @notice Redeem tokens after emergency shutdown * @return synthTokensSettled Amount of synthetic tokens liquidated * @return collateralSettled Amount of collateral withdrawn after emergency shutdown */ function settleEmergencyShutdown() external override isEmergencyShutdown nonReentrant returns (uint256 synthTokensSettled, uint256 collateralSettled) { address msgSender = _msgSender(); bool isLiquidityProvider = hasRole(LIQUIDITY_PROVIDER_ROLE, msgSender); (synthTokensSettled, collateralSettled) = poolStorage .settleEmergencyShutdown( lpPosition, feeStatus, emergencyShutdownData, isLiquidityProvider, msgSender ); } /** * @notice Update the fee percentage, recipients and recipient proportions * @notice Only the maintainer can call this function * @param _feeData Fee info (percentage + recipients + weigths) */ function setFee(ISynthereumLiquidityPoolStorage.FeeData calldata _feeData) external override onlyMaintainer nonReentrant { poolStorage.setFeePercentage(_feeData.feePercentage); poolStorage.setFeeRecipients( _feeData.feeRecipients, _feeData.feeProportions ); } /** * @notice Update the fee percentage * @notice Only the maintainer can call this function * @param _feePercentage The new fee percentage */ function setFeePercentage(uint256 _feePercentage) external override onlyMaintainer nonReentrant { poolStorage.setFeePercentage(FixedPoint.Unsigned(_feePercentage)); } /** * @notice Update the addresses of recipients for generated fees and proportions of fees each address will receive * @notice Only the maintainer can call this function * @param feeRecipients An array of the addresses of recipients that will receive generated fees * @param feeProportions An array of the proportions of fees generated each recipient will receive */ function setFeeRecipients( address[] calldata feeRecipients, uint32[] calldata feeProportions ) external override onlyMaintainer nonReentrant { poolStorage.setFeeRecipients(feeRecipients, feeProportions); } /** * @notice Update the overcollateralization percentage * @notice Only the maintainer can call this function * @param _overCollateralization Overcollateralization percentage */ function setOverCollateralization(uint256 _overCollateralization) external override onlyMaintainer nonReentrant { poolStorage.setOverCollateralization( liquidationData, FixedPoint.Unsigned(_overCollateralization) ); } /** * @notice Update the liquidation reward percentage * @notice Only the maintainer can call this function * @param _liquidationReward Percentage of reward for correct liquidation by a liquidator */ function setLiquidationReward(uint256 _liquidationReward) external override onlyMaintainer nonReentrant { liquidationData.setLiquidationReward( FixedPoint.Unsigned(_liquidationReward) ); } //---------------------------------------- // External view functions //---------------------------------------- /** * @notice Get Synthereum finder of the pool * @return finder Returns finder contract */ function synthereumFinder() external view override returns (ISynthereumFinder finder) { finder = poolStorage.finder; } /** * @notice Get Synthereum version * @return poolVersion Returns the version of the Synthereum pool */ function version() external view override returns (uint8 poolVersion) { poolVersion = poolStorage.version; } /** * @notice Get the collateral token * @return collateralCurrency The ERC20 collateral token */ function collateralToken() external view override returns (IERC20 collateralCurrency) { collateralCurrency = poolStorage.collateralToken; } /** * @notice Get the synthetic token associated to this pool * @return syntheticCurrency The ERC20 synthetic token */ function syntheticToken() external view override returns (IERC20 syntheticCurrency) { syntheticCurrency = poolStorage.syntheticToken; } /** * @notice Get the synthetic token symbol associated to this pool * @return symbol The ERC20 synthetic token symbol */ function syntheticTokenSymbol() external view override returns (string memory symbol) { symbol = IStandardERC20(address(poolStorage.syntheticToken)).symbol(); } /** * @notice Returns price identifier of the pool * @return identifier Price identifier */ function getPriceFeedIdentifier() external view override returns (bytes32 identifier) { identifier = poolStorage.priceIdentifier; } /** * @notice Return overcollateralization percentage from the storage * @return Overcollateralization percentage */ function overCollateralization() external view override returns (uint256) { return poolStorage.overCollateralization.rawValue; } /** * @notice Returns fee percentage set by the maintainer * @return Fee percentage */ function feePercentage() external view override returns (uint256) { return poolStorage.fee.feeData.feePercentage.rawValue; } /** * @notice Returns fee recipients info * @return Addresses, weigths and total of weigths */ function feeRecipientsInfo() external view override returns ( address[] memory, uint32[] memory, uint256 ) { FeeData storage _feeData = poolStorage.fee.feeData; return ( _feeData.feeRecipients, _feeData.feeProportions, poolStorage.fee.totalFeeProportions ); } /** * @notice Returns total number of synthetic tokens generated by this pool * @return Number of synthetic tokens */ function totalSyntheticTokens() external view override returns (uint256) { return lpPosition.tokensCollateralized.rawValue; } /** * @notice Returns the total amount of collateral used for collateralizing tokens (users + LP) * @return Total collateral amount */ function totalCollateralAmount() external view override returns (uint256) { return lpPosition.totalCollateralAmount.rawValue; } /** * @notice Returns the total amount of liquidity deposited in the pool, but nut used as collateral * @return Total available liquidity */ function totalAvailableLiquidity() external view override returns (uint256) { return poolStorage.totalAvailableLiquidity(lpPosition, feeStatus); } /** * @notice Returns the total amount of fees to be withdrawn * @return Total fee amount */ function totalFeeAmount() external view override returns (uint256) { return feeStatus.totalFeeAmount.rawValue; } /** * @notice Returns the user's fee to be withdrawn * @param user User's address * @return User's fee */ function userFee(address user) external view override returns (uint256) { return feeStatus.feeGained[user].rawValue; } /** * @notice Returns the percentage of overcollateralization to which a liquidation can triggered * @return Percentage of overcollateralization */ function collateralRequirement() external view override returns (uint256) { return liquidationData.collateralRequirement.rawValue; } /** * @notice Returns the percentage of reward for correct liquidation by a liquidator * @return Percentage of reward */ function liquidationReward() external view override returns (uint256) { return liquidationData.liquidationReward.rawValue; } /** * @notice Returns the price of the pair at the moment of the shutdown * @return Price of the pair */ function emergencyShutdownPrice() external view override returns (uint256) { return emergencyShutdownData.price.rawValue; } /** * @notice Returns the timestamp (unix time) at the moment of the shutdown * @return Timestamp */ function emergencyShutdownTimestamp() external view override returns (uint256) { return emergencyShutdownData.timestamp; } /** * @notice Returns if position is overcollateralized and thepercentage of coverage of the collateral according to the last price * @return True if position is overcollaterlized, otherwise false + percentage of coverage (totalCollateralAmount / (price * tokensCollateralized)) */ function collateralCoverage() external view override returns (bool, uint256) { return poolStorage.collateralCoverage(lpPosition, liquidationData); } /** * @notice Returns the synthetic tokens will be received and fees will be paid in exchange for an input collateral amount * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param inputCollateral Input collateral amount to be exchanged * @return synthTokensReceived Synthetic tokens will be minted * @return feePaid Collateral fee will be paid */ function getMintTradeInfo(uint256 inputCollateral) external view override returns (uint256 synthTokensReceived, uint256 feePaid) { (synthTokensReceived, feePaid) = poolStorage.getMintTradeInfo( lpPosition, feeStatus, FixedPoint.Unsigned(inputCollateral) ); } /** * @notice Returns the collateral amount will be received and fees will be paid in exchange for an input amount of synthetic tokens * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param syntheticTokens Amount of synthetic tokens to be exchanged * @return collateralAmountReceived Collateral amount will be received by the user * @return feePaid Collateral fee will be paid */ function getRedeemTradeInfo(uint256 syntheticTokens) external view override returns (uint256 collateralAmountReceived, uint256 feePaid) { (collateralAmountReceived, feePaid) = poolStorage.getRedeemTradeInfo( lpPosition, FixedPoint.Unsigned(syntheticTokens) ); } /** * @notice Returns the destination synthetic tokens amount will be received and fees will be paid in exchange for an input amount of synthetic tokens * @notice This function is only trading-informative, it doesn't check liquidity and collateralization conditions * @param syntheticTokens Amount of synthetic tokens to be exchanged * @param destinationPool Pool in which mint the destination synthetic token * @return destSyntheticTokensReceived Synthetic tokens will be received from destination pool * @return feePaid Collateral fee will be paid */ function getExchangeTradeInfo( uint256 syntheticTokens, ISynthereumLiquidityPoolGeneral destinationPool ) external view override returns (uint256 destSyntheticTokensReceived, uint256 feePaid) { (destSyntheticTokensReceived, feePaid) = poolStorage.getExchangeTradeInfo( lpPosition, FixedPoint.Unsigned(syntheticTokens), destinationPool ); } /** * @notice Check if an address is the trusted forwarder * @param forwarder Address to check * @return True is the input address is the trusted forwarder, otherwise false */ function isTrustedForwarder(address forwarder) public view override returns (bool) { try poolStorage.finder.getImplementationAddress( SynthereumInterfaces.TrustedForwarder ) returns (address trustedForwarder) { if (forwarder == trustedForwarder) { return true; } else { return false; } } catch { return false; } } function _msgSender() internal view override(ERC2771Context, Context) returns (address sender) { return ERC2771Context._msgSender(); } function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata) { return ERC2771Context._msgData(); } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"components":[{"internalType":"contract ISynthereumFinder","name":"finder","type":"address"},{"internalType":"uint8","name":"version","type":"uint8"},{"internalType":"contract IStandardERC20","name":"collateralToken","type":"address"},{"internalType":"contract IMintableBurnableERC20","name":"syntheticToken","type":"address"},{"components":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"maintainer","type":"address"},{"internalType":"address","name":"liquidityProvider","type":"address"}],"internalType":"struct ISynthereumLiquidityPoolStorage.Roles","name":"roles","type":"tuple"},{"internalType":"uint256","name":"overCollateralization","type":"uint256"},{"components":[{"components":[{"internalType":"uint256","name":"rawValue","type":"uint256"}],"internalType":"struct FixedPoint.Unsigned","name":"feePercentage","type":"tuple"},{"internalType":"address[]","name":"feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"feeProportions","type":"uint32[]"}],"internalType":"struct ISynthereumLiquidityPoolStorage.FeeData","name":"feeData","type":"tuple"},{"internalType":"bytes32","name":"priceIdentifier","type":"bytes32"},{"internalType":"uint256","name":"collateralRequirement","type":"uint256"},{"internalType":"uint256","name":"liquidationReward","type":"uint256"}],"internalType":"struct SynthereumLiquidityPool.ConstructorParams","name":"params","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalRemainingFees","type":"uint256"}],"name":"ClaimFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lp","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralRemoved","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalCollateral","type":"uint256"}],"name":"DecreaseCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"finalCollateral","type":"uint256"}],"name":"EmergencyShutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"destPool","type":"address"},{"indexed":false,"internalType":"uint256","name":"numTokensSent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destNumTokensReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feePaid","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"Exchange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lp","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralAdded","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalCollateral","type":"uint256"}],"name":"IncreaseCollateral","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokensLiquidated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralExpected","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardReceived","type":"uint256"}],"name":"Liquidate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralSent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numTokensReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feePaid","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"numTokensSent","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feePaid","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feePercentage","type":"uint256"}],"name":"SetFeePercentage","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"feeRecipients","type":"address[]"},{"indexed":false,"internalType":"uint32[]","name":"feeProportions","type":"uint32[]"}],"name":"SetFeeRecipients","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidationReward","type":"uint256"}],"name":"SetLiquidationReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"overCollateralization","type":"uint256"}],"name":"SetOverCollateralization","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"numTokensSettled","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralExpected","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateralSettled","type":"uint256"}],"name":"Settle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lp","type":"address"},{"indexed":false,"internalType":"uint256","name":"liquidityWithdrawn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"remainingLiquidity","type":"uint256"}],"name":"WithdrawLiquidity","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIQUIDITY_PROVIDER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAINTAINER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimFee","outputs":[{"internalType":"uint256","name":"feeClaimed","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collateralCoverage","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralRequirement","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralToken","outputs":[{"internalType":"contract IERC20","name":"collateralCurrency","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateralToDecrease","type":"uint256"},{"internalType":"uint256","name":"collateralToWithdraw","type":"uint256"}],"name":"decreaseCollateral","outputs":[{"internalType":"uint256","name":"newTotalCollateral","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyShutdown","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyShutdownPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyShutdownTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract ISynthereumLiquidityPoolGeneral","name":"destPool","type":"address"},{"internalType":"uint256","name":"numTokens","type":"uint256"},{"internalType":"uint256","name":"minDestNumTokens","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"internalType":"struct ISynthereumLiquidityPool.ExchangeParams","name":"exchangeParams","type":"tuple"}],"name":"exchange","outputs":[{"internalType":"uint256","name":"destNumTokensMinted","type":"uint256"},{"internalType":"uint256","name":"feePaid","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"uint256","name":"numTokens","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"exchangeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipientsInfo","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint32[]","name":"","type":"uint32[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"syntheticTokens","type":"uint256"},{"internalType":"contract ISynthereumLiquidityPoolGeneral","name":"destinationPool","type":"address"}],"name":"getExchangeTradeInfo","outputs":[{"internalType":"uint256","name":"destSyntheticTokensReceived","type":"uint256"},{"internalType":"uint256","name":"feePaid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"inputCollateral","type":"uint256"}],"name":"getMintTradeInfo","outputs":[{"internalType":"uint256","name":"synthTokensReceived","type":"uint256"},{"internalType":"uint256","name":"feePaid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriceFeedIdentifier","outputs":[{"internalType":"bytes32","name":"identifier","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"syntheticTokens","type":"uint256"}],"name":"getRedeemTradeInfo","outputs":[{"internalType":"uint256","name":"collateralAmountReceived","type":"uint256"},{"internalType":"uint256","name":"feePaid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateralToTransfer","type":"uint256"},{"internalType":"uint256","name":"collateralToIncrease","type":"uint256"}],"name":"increaseCollateral","outputs":[{"internalType":"uint256","name":"newTotalCollateral","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"numSynthTokens","type":"uint256"}],"name":"liquidate","outputs":[{"internalType":"uint256","name":"synthTokensLiquidated","type":"uint256"},{"internalType":"uint256","name":"collateralReceived","type":"uint256"},{"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"liquidationReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"minNumTokens","type":"uint256"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"internalType":"struct ISynthereumLiquidityPool.MintParams","name":"mintParams","type":"tuple"}],"name":"mint","outputs":[{"internalType":"uint256","name":"syntheticTokensMinted","type":"uint256"},{"internalType":"uint256","name":"feePaid","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"overCollateralization","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"numTokens","type":"uint256"},{"internalType":"uint256","name":"minCollateral","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"internalType":"struct ISynthereumLiquidityPool.RedeemParams","name":"redeemParams","type":"tuple"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"collateralRedeemed","type":"uint256"},{"internalType":"uint256","name":"feePaid","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"rawValue","type":"uint256"}],"internalType":"struct FixedPoint.Unsigned","name":"feePercentage","type":"tuple"},{"internalType":"address[]","name":"feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"feeProportions","type":"uint32[]"}],"internalType":"struct ISynthereumLiquidityPoolStorage.FeeData","name":"_feeData","type":"tuple"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feePercentage","type":"uint256"}],"name":"setFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"feeRecipients","type":"address[]"},{"internalType":"uint32[]","name":"feeProportions","type":"uint32[]"}],"name":"setFeeRecipients","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_liquidationReward","type":"uint256"}],"name":"setLiquidationReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_overCollateralization","type":"uint256"}],"name":"setOverCollateralization","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settleEmergencyShutdown","outputs":[{"internalType":"uint256","name":"synthTokensSettled","type":"uint256"},{"internalType":"uint256","name":"collateralSettled","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"synthereumFinder","outputs":[{"internalType":"contract ISynthereumFinder","name":"finder","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"syntheticToken","outputs":[{"internalType":"contract IERC20","name":"syntheticCurrency","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"syntheticTokenSymbol","outputs":[{"internalType":"string","name":"symbol","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAvailableLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalCollateralAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFeeAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSyntheticTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"typology","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint8","name":"poolVersion","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateralAmount","type":"uint256"}],"name":"withdrawLiquidity","outputs":[{"internalType":"uint256","name":"remainingLiquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102f05760003560e01c806367f7d0291161019d578063ae06c1b7116100e9578063d547741f116100a2578063e7ce23611161007c578063e7ce236114610678578063f6bf3ef61461069b578063f8742254146106ac578063ffdd69f8146106c157600080fd5b8063d547741f1461063f578063d668909f14610652578063e2ca8d001461066557600080fd5b8063ae06c1b7146105d6578063b2016bd4146105e9578063b339b368146105fa578063b3a8482014610602578063b5e4039014610619578063ca15c8731461062c57600080fd5b806391d148541161015657806399d32fc41161013057806399d32fc4146105ab5780639a3e4eb8146105b3578063a001ecdd146105c6578063a217fddf146105ce57600080fd5b806391d148541461057d5780639652171614610590578063980f23c51461059857600080fd5b806367f7d029146105255780636cf1be291461052d578063735d80e3146105355780637b34ee7f1461053d5780638230ecd6146105455780639010d07c1461056a57600080fd5b806336815bb71161025c578063525e6b1111610215578063558241dc116101ef578063558241dc146104ce57806356c5f349146104e1578063572b6c051461050a57806363f31d2c1461051d57600080fd5b8063525e6b111461048957806354f0cb0d1461049c57806354fd4d50146104af57600080fd5b806336815bb7146103f957806336d24bb71461040e578063415f12401461042d5780634845a8201461045b57806348e30c3f1461046e578063523635871461047657600080fd5b806325a0d176116102ae57806325a0d176146103a85780632b27324a146103b05780632f2ff15d146103b857806331e78ca7146103cb5780633403c2fc146103de57806336568abe146103e657600080fd5b8062b9add7146102f557806301ffc9a7146103175780630a861f2a1461033a57806311adda7b1461035b57806320037cdd14610370578063248a9ca314610385575b600080fd5b6102fd6106d4565b604080519283526020830191909152015b60405180910390f35b61032a61032536600461244b565b61083a565b604051901515815260200161030e565b61034d6103483660046123e3565b610865565b60405190815260200161030e565b61036e61036936600461252d565b6109bd565b005b61034d600080516020612b1a83398151915281565b61034d6103933660046123e3565b60009081526020819052604090206001015490565b60065461034d565b600b5461034d565b61036e6103c63660046123fb565b610b14565b61036e6103d93660046123e3565b610b3b565b6102fd610be9565b61036e6103f43660046123fb565b610cd9565b610401610cfb565b60405161030e9190612765565b610416610d81565b60408051921515835260208301919091520161030e565b61044061043b3660046123e3565b610e1e565b6040805193845260208401929092529082015260600161030e565b61036e6104693660046123e3565b610f56565b600e5461034d565b61034d61048436600461242a565b610ffd565b6102fd610497366004612565565b611176565b61034d6104aa36600461242a565b611268565b600354600160a01b900460ff1660405160ff909116815260200161030e565b6102fd6104dc36600461251c565b61135a565b61034d6104ef366004612311565b6001600160a01b031660009081526010602052604090205490565b61032a610518366004612311565b6113ee565b600c5461034d565b600d5461034d565b60125461034d565b61034d6114ad565b60135461034d565b6005546001600160a01b03165b6040516001600160a01b03909116815260200161030e565b61055261057836600461242a565b611541565b61032a61058b3660046123fb565b611560565b60115461034d565b6102fd6105a63660046123e3565b611589565b61034d611635565b6102fd6105c1366004612565565b611712565b60075461034d565b61034d600081565b61036e6105e43660046123e3565b611786565b6004546001600160a01b0316610552565b600f5461034d565b61060a61182d565b60405161030e939291906126d1565b61036e610627366004612349565b611926565b61034d61063a3660046123e3565b6119fd565b61036e61064d3660046123fb565b611a14565b6102fd6106603660046123e3565b611a1e565b6102fd6106733660046123fb565b611a7c565b610401604051806040016040528060048152602001631413d3d360e21b81525081565b6003546001600160a01b0316610552565b61034d600080516020612afa83398151915281565b61036e6106cf3660046125bb565b611b37565b601254600090819061072d5760405162461bcd60e51b815260206004820152601b60248201527f506f6f6c206e6f7420656d657267656e63792073687574646f776e000000000060448201526064015b60405180910390fd5b60028054141561074f5760405162461bcd60e51b81526004016107249061284b565b60028055600061075d611c75565b90506000610779600080516020612b1a83398151915283611560565b60405163097bfa9160e31b815260036004820152600c6024820152601060448201526012606482015281151560848201526001600160a01b03841660a482015290915073d0b5376b91e06fb1296f803ae8879b49740ce89f90634bdfd4889060c401604080518083038186803b1580156107f257600080fd5b505af4158015610806573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082a9190612598565b6001600255909590945092505050565b60006001600160e01b03198216635a05180f60e01b148061085f575061085f82611c7f565b92915050565b6000610881600080516020612b1a83398151915261058b611c75565b61089d5760405162461bcd60e51b815260040161072490612798565b601254156108bd5760405162461bcd60e51b815260040161072490612814565b6002805414156108df5760405162461bcd60e51b81526004016107249061284b565b60028081905550600373d0b5376b91e06fb1296f803ae8879b49740ce89f63513b95df9091600c601060405180602001604052808881525061091f611c75565b6040516001600160e01b031960e088901b1681526004810195909552602485019390935260448401919091525160648301526001600160a01b0316608482015260a40160206040518083038186803b15801561097a57600080fd5b505af415801561098e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109b29190612580565b600160025592915050565b6109d7600080516020612afa83398151915261058b611c75565b6109f35760405162461bcd60e51b8152600401610724906127dd565b600280541415610a155760405162461bcd60e51b81526004016107249061284b565b6002805560405163e37616f760e01b8152600360048201528135602482015273d0b5376b91e06fb1296f803ae8879b49740ce89f9063e37616f79060440160006040518083038186803b158015610a6b57600080fd5b505af4158015610a7f573d6000803e3d6000fd5b5073d0b5376b91e06fb1296f803ae8879b49740ce89f925063b5612163915060039050610aaf60208501856129d8565b610abc60408701876129d8565b6040518663ffffffff1660e01b8152600401610adc959493929190612882565b60006040518083038186803b158015610af457600080fd5b505af4158015610b08573d6000803e3d6000fd5b50506001600255505050565b610b1e8282611cb4565b6000828152600160205260409020610b369082611c3a565b505050565b610b55600080516020612afa83398151915261058b611c75565b610b715760405162461bcd60e51b8152600401610724906127dd565b600280541415610b935760405162461bcd60e51b81526004016107249061284b565b600280556040805160208101825282815290516352bc78b160e11b815260036004820152600e60248201529051604482015273d0b5376b91e06fb1296f803ae8879b49740ce89f9063a578f16290606401610adc565b601254600090819015610c0e5760405162461bcd60e51b815260040161072490612814565b600280541415610c305760405162461bcd60e51b81526004016107249061284b565b60028055604051632e6e81fb60e01b815260036004820152600c6024820152601060448201526012606482015273d0b5376b91e06fb1296f803ae8879b49740ce89f90632e6e81fb90608401604080518083038186803b158015610c9357600080fd5b505af4158015610ca7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccb9190612598565b600160025590939092509050565b610ce38282611ce1565b6000828152600160205260409020610b369082611d6b565b600554604080516395d89b4160e01b815290516060926001600160a01b0316916395d89b41916004808301926000929190829003018186803b158015610d4057600080fd5b505afa158015610d54573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d7c9190810190612473565b905090565b604051630ea1541960e11b815260036004820152600c6024820152600e6044820152600090819073d0b5376b91e06fb1296f803ae8879b49740ce89f90631d42a83290606401604080518083038186803b158015610dde57600080fd5b505af4158015610df2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1691906123b2565b915091509091565b6000806000601260000154600014610e485760405162461bcd60e51b815260040161072490612814565b600280541415610e6a5760405162461bcd60e51b81526004016107249061284b565b60028081905550600373d0b5376b91e06fb1296f803ae8879b49740ce89f634faad5909091600c600e601060405180602001604052808b815250610eac611c75565b6040516001600160e01b031960e089901b16815260048101969096526024860194909452604485019290925260648401525160848301526001600160a01b031660a482015260c40160606040518083038186803b158015610f0c57600080fd5b505af4158015610f20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4491906125f3565b60016002559196909550909350915050565b610f70600080516020612afa83398151915261058b611c75565b610f8c5760405162461bcd60e51b8152600401610724906127dd565b600280541415610fae5760405162461bcd60e51b81526004016107249061284b565b60028055604080516020810182528281529051630d388b9760e41b8152600e60048201529051602482015273d0b5376b91e06fb1296f803ae8879b49740ce89f9063d388b97090604401610adc565b6000611019600080516020612b1a83398151915261058b611c75565b6110355760405162461bcd60e51b815260040161072490612798565b601254156110555760405162461bcd60e51b815260040161072490612814565b6002805414156110775760405162461bcd60e51b81526004016107249061284b565b60028081905550600373d0b5376b91e06fb1296f803ae8879b49740ce89f632828cc879091600c600e601060405180602001604052808a81525060405180602001604052808a8152506110c8611c75565b6040516001600160e01b031960e08a901b16815260048101979097526024870195909552604486019390935260648501919091525160848401525160a48301526001600160a01b031660c482015260e4015b60206040518083038186803b15801561113257600080fd5b505af4158015611146573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116a9190612580565b60016002559392505050565b60125460009081901561119b5760405162461bcd60e51b815260040161072490612814565b6002805414156111bd5760405162461bcd60e51b81526004016107249061284b565b6002805573d0b5376b91e06fb1296f803ae8879b49740ce89f63f8bcd2496003600c6010876111ea611c75565b6040518663ffffffff1660e01b815260040161120a95949392919061299a565b604080518083038186803b15801561122157600080fd5b505af4158015611235573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112599190612598565b60016002559094909350915050565b6000611284600080516020612b1a83398151915261058b611c75565b6112a05760405162461bcd60e51b815260040161072490612798565b6002805414156112c25760405162461bcd60e51b81526004016107249061284b565b600280556040805160208082018352858252825190810190925283825273d0b5376b91e06fb1296f803ae8879b49740ce89f9163fc5aa3f391600391600c9160109161130c611c75565b6040516001600160e01b031960e089901b1681526004810196909652602486019490945260448501929092525160648401525160848301526001600160a01b031660a482015260c40161111a565b60125460009081901561137f5760405162461bcd60e51b815260040161072490612814565b6002805414156113a15760405162461bcd60e51b81526004016107249061284b565b6002805573d0b5376b91e06fb1296f803ae8879b49740ce89f6380d374286003600c6010876113ce611c75565b6040518663ffffffff1660e01b815260040161120a959493929190612921565b6003546040516302abf57960e61b81526f2a393ab9ba32b22337b93bb0b93232b960811b60048201526000916001600160a01b03169063aafd5e409060240160206040518083038186803b15801561144557600080fd5b505afa925050508015611475575060408051601f3d908101601f191682019092526114729181019061232d565b60015b61148157506000919050565b806001600160a01b0316836001600160a01b031614156114a45750600192915050565b50600092915050565b6040516306ebb2ab60e11b815260036004820152600c60248201526010604482015260009073d0b5376b91e06fb1296f803ae8879b49740ce89f90630dd765569060640160206040518083038186803b15801561150957600080fd5b505af415801561151d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7c9190612580565b60008281526001602052604081206115599083611d80565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6040805160208101825282815290516308837e8960e31b815260036004820152600c602482015290516044820152600090819073d0b5376b91e06fb1296f803ae8879b49740ce89f9063441bf448906064015b604080518083038186803b1580156115f357600080fd5b505af4158015611607573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162b9190612598565b9094909350915050565b60006002805414156116595760405162461bcd60e51b81526004016107249061284b565b6002805573d0b5376b91e06fb1296f803ae8879b49740ce89f631822268260036010611683611c75565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526001600160a01b0316604482015260640160206040518083038186803b1580156116d057600080fd5b505af41580156116e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117089190612580565b6001600255919050565b6012546000908190156117375760405162461bcd60e51b815260040161072490612814565b6002805414156117595760405162461bcd60e51b81526004016107249061284b565b6002805573d0b5376b91e06fb1296f803ae8879b49740ce89f63b5525b826003600c6010876111ea611c75565b6117a0600080516020612afa83398151915261058b611c75565b6117bc5760405162461bcd60e51b8152600401610724906127dd565b6002805414156117de5760405162461bcd60e51b81526004016107249061284b565b6002805560408051602081018252828152905163e37616f760e01b8152600360048201529051602482015273d0b5376b91e06fb1296f803ae8879b49740ce89f9063e37616f790604401610adc565b600a54600880546040805160208084028201810190925282815260609485946000946007949193600993929091859183018282801561189557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611877575b505050505092508180548060200260200160405190810160405280929190818152602001828054801561191357602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116118d65790505b5050505050915093509350935050909192565b611940600080516020612afa83398151915261058b611c75565b61195c5760405162461bcd60e51b8152600401610724906127dd565b60028054141561197e5760405162461bcd60e51b81526004016107249061284b565b6002805560405163b561216360e01b815273d0b5376b91e06fb1296f803ae8879b49740ce89f9063b5612163906119c2906003908890889088908890600401612882565b60006040518083038186803b1580156119da57600080fd5b505af41580156119ee573d6000803e3d6000fd5b50506001600255505050505050565b600081815260016020526040812061085f90611d8c565b610ce38282611d96565b6040805160208101825282815290516326b48eed60e21b815260036004820152600c60248201526010604482015290516064820152600090819073d0b5376b91e06fb1296f803ae8879b49740ce89f90639ad23bb4906084016115dc565b604080516020810182528381529051632aca1a0b60e11b815260036004820152600c6024820152905160448201526001600160a01b0382166064820152600090819073d0b5376b91e06fb1296f803ae8879b49740ce89f90635594341690608401604080518083038186803b158015611af457600080fd5b505af4158015611b08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2c9190612598565b909590945092505050565b60125415611b575760405162461bcd60e51b815260040161072490612814565b600280541415611b795760405162461bcd60e51b81526004016107249061284b565b60028055604080516020808201835285825282519081018352848152915163078a874960e31b815260036004820152600c60248201526010604482015290516064820152905160848201526001600160a01b03821660a482015273d0b5376b91e06fb1296f803ae8879b49740ce89f90633c543a489060c40160006040518083038186803b158015611c0a57600080fd5b505af4158015611c1e573d6000803e3d6000fd5b505060016002555050505050565b611c368282611dbe565b5050565b6000611559836001600160a01b038416611e43565b6000611c5a336113ee565b15611c6c575060131936013560601c90565b503390565b3390565b6000610d7c611c4f565b60006001600160e01b03198216637965db0b60e01b148061085f57506301ffc9a760e01b6001600160e01b031983161461085f565b600082815260208190526040902060010154611cd781611cd2611c75565b611e92565b610b368383611dbe565b611ce9611c75565b6001600160a01b0316816001600160a01b031614611d615760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610724565b611c368282611ef6565b6000611559836001600160a01b038416611f79565b60006115598383612096565b600061085f825490565b600082815260208190526040902060010154611db481611cd2611c75565b610b368383611ef6565b611dc88282611560565b611c36576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055611dff611c75565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000818152600183016020526040812054611e8a5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561085f565b50600061085f565b611e9c8282611560565b611c3657611eb4816001600160a01b031660146120ce565b611ebf8360206120ce565b604051602001611ed092919061265c565b60408051601f198184030181529082905262461bcd60e51b825261072491600401612765565b611f008282611560565b15611c36576000828152602081815260408083206001600160a01b03851684529091529020805460ff19169055611f35611c75565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000818152600183016020526040812054801561208c576000611f9d600183612a57565b8554909150600090611fb190600190612a57565b9050818114612032576000866000018281548110611fdf57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508087600001848154811061201057634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061205157634e487b7160e01b600052603160045260246000fd5b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061085f565b600091505061085f565b60008260000182815481106120bb57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b606060006120dd836002612a38565b6120e8906002612a20565b67ffffffffffffffff81111561210e57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612138576020820181803683370190505b509050600360fc1b8160008151811061216157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061219e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006121c2846002612a38565b6121cd906001612a20565b90505b6001811115612261576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061220f57634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061223357634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361225a81612a9e565b90506121d0565b5083156115595760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610724565b60008083601f8401126122c1578081fd5b50813567ffffffffffffffff8111156122d8578182fd5b6020830191508360208260051b85010111156122f357600080fd5b9250929050565b60006080828403121561230b578081fd5b50919050565b600060208284031215612322578081fd5b813561155981612ae1565b60006020828403121561233e578081fd5b815161155981612ae1565b6000806000806040858703121561235e578283fd5b843567ffffffffffffffff80821115612375578485fd5b612381888389016122b0565b90965094506020870135915080821115612399578384fd5b506123a6878288016122b0565b95989497509550505050565b600080604083850312156123c4578182fd5b825180151581146123d3578283fd5b6020939093015192949293505050565b6000602082840312156123f4578081fd5b5035919050565b6000806040838503121561240d578182fd5b82359150602083013561241f81612ae1565b809150509250929050565b6000806040838503121561243c578182fd5b50508035926020909101359150565b60006020828403121561245c578081fd5b81356001600160e01b031981168114611559578182fd5b600060208284031215612484578081fd5b815167ffffffffffffffff8082111561249b578283fd5b818401915084601f8301126124ae578283fd5b8151818111156124c0576124c0612acb565b604051601f8201601f19908116603f011681019083821181831017156124e8576124e8612acb565b81604052828152876020848701011115612500578586fd5b612511836020830160208801612a6e565b979650505050505050565b600060a0828403121561230b578081fd5b60006020828403121561253e578081fd5b813567ffffffffffffffff811115612554578182fd5b820160608185031215611559578182fd5b600060808284031215612576578081fd5b61155983836122fa565b600060208284031215612591578081fd5b5051919050565b600080604083850312156125aa578182fd5b505080516020909101519092909150565b6000806000606084860312156125cf578081fd5b833592506020840135915060408401356125e881612ae1565b809150509250925092565b600080600060608486031215612607578081fd5b8351925060208401519150604084015190509250925092565b803582526020810135602083015260408101356040830152606081013561264681612ae1565b6001600160a01b03166060929092019190915250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612694816017850160208801612a6e565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516126c5816028840160208801612a6e565b01602801949350505050565b606080825284519082018190526000906020906080840190828801845b828110156127155781516001600160a01b03168452602084019350908401906001016126ee565b50505083810382850152855180825286830191830190845b8181101561274f57835163ffffffff168352928401929184019160010161272d565b5050809350505050826040830152949350505050565b6020815260008251806020840152612784816040850160208701612a6e565b601f01601f19169190910160400192915050565b60208082526025908201527f53656e646572206d75737420626520746865206c69717569646974792070726f6040820152643b34b232b960d91b606082015260800190565b6020808252601d908201527f53656e646572206d75737420626520746865206d61696e7461696e6572000000604082015260600190565b60208082526017908201527f506f6f6c20656d657267656e63792073687574646f776e000000000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b85815260606020808301829052908201859052600090869060808401835b888110156128d05783356128b381612ae1565b6001600160a01b03168252928201926020909101906001016128a0565b5084810360408601528581528101915085835b8681101561291257813563ffffffff81168082146128ff578687fd5b85525092820192908201906001016128e3565b50919998505050505050505050565b85815260208101859052604081018490526101208101833561294281612ae1565b60018060a01b03808216606085015260208601356080850152604086013560a0850152606086013560c08501526080860135915061297f82612ae1565b90811660e08401529290921661010090910152949350505050565b858152602081018590526040810184905261010081016129bd6060830185612620565b6001600160a01b039290921660e09190910152949350505050565b6000808335601e198436030181126129ee578283fd5b83018035915067ffffffffffffffff821115612a08578283fd5b6020019150600581901b36038213156122f357600080fd5b60008219821115612a3357612a33612ab5565b500190565b6000816000190483118215151615612a5257612a52612ab5565b500290565b600082821015612a6957612a69612ab5565b500390565b60005b83811015612a89578181015183820152602001612a71565b83811115612a98576000848401525b50505050565b600081612aad57612aad612ab5565b506000190190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114612af657600080fd5b5056fe126303c860ea810f85e857ad8768056e2eebc24b7796655ff3107e4af18e3f1ece7acaec76157f4ab170d5942fe00a5c7b7d3c7b0f5c45f2bda3a5f7012cb7c7a2646970667358221220e86b7cad89413ee881461efdeb1192736252517c380b8be839c879f713f2f15464736f6c63430008040033
Deployed Bytecode Sourcemap
188023:25501:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;201281:512;;;:::i;:::-;;;;27061:25:1;;;27117:2;27102:18;;27095:34;;;;27034:18;201281:512:0;;;;;;;;29711:214;;;;;;:::i;:::-;;:::i;:::-;;;10460:14:1;;10453:22;10435:41;;10423:2;10408:18;29711:214:0;10390:92:1;197070:371:0;;;;;;:::i;:::-;;:::i;:::-;;;10896:25:1;;;10884:2;10869:18;197070:371:0;10851:76:1;202015:314:0;;;;;;:::i;:::-;;:::i;:::-;;189341:86;;-1:-1:-1;;;;;;;;;;;189341:86:0;;25932:123;;;;;;:::i;:::-;25998:7;26025:12;;;;;;;;;;:22;;;;25932:123;206215:136;206303:33;:42;206215:136;;205915:162;206044:27;;205915:162;;31069:196;;;;;;:::i;:::-;;:::i;203522:267::-;;;;;;:::i;:::-;;:::i;200760:289::-;;;:::i;31654:205::-;;;;;;:::i;:::-;;:::i;205611:191::-;;;:::i;:::-;;;;;;;:::i;209842:156::-;;;:::i;:::-;;;;10680:14:1;;10673:22;10655:41;;10727:2;10712:18;;10705:34;;;;10628:18;209842:156:0;10610:135:1;199999:476:0;;;;;;:::i;:::-;;:::i;:::-;;;;16843:25:1;;;16899:2;16884:18;;16877:34;;;;16927:18;;;16920:34;16831:2;16816:18;199999:476:0;16798:162:1;204014:231:0;;;;;;:::i;:::-;;:::i;208593:140::-;208681:15;:46;208593:140;;198691:500;;;;;;:::i;:::-;;:::i;194837:335::-;;;;;;:::i;:::-;;:::i;197822:450::-;;;;;;:::i;:::-;;:::i;204757:116::-;204848:11;:19;-1:-1:-1;;;204848:19:0;;;;204757:116;;27636:4:1;27624:17;;;27606:36;;27594:2;27579:18;204757:116:0;27561:87:1;195694:347:0;;;;;;:::i;:::-;;:::i;208298:126::-;;;;;;:::i;:::-;-1:-1:-1;;;;;208384:25:0;208361:7;208384:25;;;:9;:25;;;;;:34;;208298:126;212755:428;;;;;;:::i;:::-;;:::i;207482:135::-;207570:10;:41;207482:135;;207193:133;207280:31;:40;207193:133;;209386:153;209502:21;:31;209386:153;;207779:154;;;:::i;209133:131::-;209222:27;:36;209133:131;;205302:166;205436:26;;-1:-1:-1;;;;;205436:26:0;205302:166;;;-1:-1:-1;;;;;9004:32:1;;;8986:51;;8974:2;8959:18;205302:166:0;8941:102:1;30524:145:0;;;;;;:::i;:::-;;:::i;24817:139::-;;;;;;:::i;:::-;;:::i;208047:120::-;208128:24;:33;208047:120;;211241:311;;;;;;:::i;:::-;;:::i;199307:174::-;;;:::i;194035:331::-;;;;;;:::i;:::-;;:::i;206459:132::-;206539:15;:46;206459:132;;23908:49;;23953:4;23908:49;;202497:197;;;;;;:::i;:::-;;:::i;204992:170::-;205129:27;;-1:-1:-1;;;;;205129:27:0;204992:170;;208875:132;208959:33;:42;208875:132;;206707:347;;;:::i;:::-;;;;;;;;;:::i;203091:227::-;;;;;;:::i;:::-;;:::i;30843:134::-;;;;;;:::i;:::-;;:::i;31358:201::-;;;;;;:::i;:::-;;:::i;210445:315::-;;;;;;:::i;:::-;;:::i;212144:409::-;;;;;;:::i;:::-;;:::i;189213:49::-;;;;;;;;;;;;;;;-1:-1:-1;;;189213:49:0;;;;;204482:149;204607:11;:18;-1:-1:-1;;;;;204607:18:0;204482:149;;189269:65;;-1:-1:-1;;;;;;;;;;;189269:65:0;;196453:342;;;;;;:::i;:::-;;:::i;201281:512::-;192196:21;:31;201401:26;;;;192180:97;;;;-1:-1:-1;;;192180:97:0;;12746:2:1;192180:97:0;;;12728:21:1;12785:2;12765:18;;;12758:30;12824:29;12804:18;;;12797:57;12871:18;;192180:97:0;;;;;;;;;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;201466:17:::2;201486:12;:10;:12::i;:::-;201466:32;;201505:24;201532:43;-1:-1:-1::0;;;;;;;;;;;201565:9:0::2;201532:7;:43::i;:::-;201624:163;::::0;-1:-1:-1;;;201624:163:0;;:11:::2;:163;::::0;::::2;20295:25:1::0;201676:10:0::2;20336:18:1::0;;;20329:34;201695:9:0::2;20379:18:1::0;;;20372:34;201713:21:0::2;20422:18:1::0;;;20415:34;20493:14;;20486:22;20465:19;;;20458:51;-1:-1:-1;;;;;20546:32:1;;20525:19;;;20518:61;201505:70:0;;-1:-1:-1;201624:43:0::2;::::0;::::2;::::0;20267:19:1;;201624:163:0::2;::::0;::::2;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;34969:1:::1;35921:7;:22:::0;201582:205;;;;-1:-1:-1;201281:512:0;-1:-1:-1;;;201281:512:0:o;29711:214::-;29796:4;-1:-1:-1;;;;;;29820:57:0;;-1:-1:-1;;;29820:57:0;;:97;;;29881:36;29905:11;29881:23;:36::i;:::-;29813:104;29711:214;-1:-1:-1;;29711:214:0:o;197070:371::-;197236:26;191890:46;-1:-1:-1;;;;;;;;;;;191923:12:0;:10;:12::i;191890:46::-;191874:117;;;;-1:-1:-1;;;191874:117:0;;;;;;;:::i;:::-;192058:21:::1;:31:::0;:36;192050:72:::1;;;;-1:-1:-1::0;;;192050:72:0::1;;;;;;;:::i;:::-;35013:1:::2;35609:7:::0;::::2;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::2;;;;;;;:::i;:::-;35013:1;35742:7:::0;:18:::2;;;;197295:11:::3;:29;;;;197333:10;197352:9;197370:37;;;;;;;;197390:16;197370:37;;::::0;197416:12:::3;:10;:12::i;:::-;197295:140;::::0;-1:-1:-1;;;;;;197295:140:0::3;::::0;;;;;;::::3;::::0;::::3;21522:25:1::0;;;;21563:18;;;21556:34;;;;21606:18;;;21599:34;;;;21669:13;21649:18;;;21642:41;-1:-1:-1;;;;;21720:32:1;21699:19;;;21692:61;21494:19;;197295:140:0::3;;;;;;;;;;;;;;;;::::0;::::3;;;;;;;;;;;;::::0;::::3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;34969:1:::2;35921:7;:22:::0;197274:161;197070:371;-1:-1:-1;;197070:371:0:o;202015:314::-;191729:38;-1:-1:-1;;;;;;;;;;;191754:12:0;:10;:12::i;191729:38::-;191713:101;;;;-1:-1:-1;;;191713:101:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;202166:52:::2;::::0;-1:-1:-1;;;202166:52:0;;:11:::2;:52;::::0;::::2;26266:25:1::0;26327:20;;26307:18;;;26300:48;202166:28:0::2;::::0;::::2;::::0;26239:18:1;;202166:52:0::2;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;202225:28:0::2;::::0;-1:-1:-1;202225:28:0::2;::::0;-1:-1:-1;202225:11:0::2;::::0;-1:-1:-1;202262:22:0::2;;::::0;::::2;:8:::0;:22:::2;:::i;:::-;202293:23;;::::0;::::2;:8:::0;:23:::2;:::i;:::-;202225:98;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;34969:1:0::1;35921:7;:22:::0;-1:-1:-1;;;202015:314:0:o;31069:196::-;31185:30;31201:4;31207:7;31185:15;:30::i;:::-;31226:18;;;;:12;:18;;;;;:31;;31249:7;31226:22;:31::i;:::-;;31069:196;;:::o;203522:267::-;191729:38;-1:-1:-1;;;;;;;;;;;191754:12:0;:10;:12::i;191729:38::-;191713:101;;;;-1:-1:-1;;;191713:101:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;203733:43:::2;::::0;;::::2;::::0;::::2;::::0;;;;;203664:119;;-1:-1:-1;;;203664:119:0;;:11:::2;:119;::::0;::::2;24852:25:1::0;203709:15:0::2;24893:18:1::0;;;24886:34;24956:13;;24936:18;;;24929:41;203664:36:0::2;::::0;::::2;::::0;24825:18:1;;203664:119:0::2;24807:169:1::0;200760:289:0;192058:21;:31;200875:17;;;;192058:36;192050:72;;;;-1:-1:-1;;;192050:72:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;200940:103:::2;::::0;-1:-1:-1;;;200940:103:0;;:11:::2;:103;::::0;::::2;19743:25:1::0;200978:10:0::2;19784:18:1::0;;;19777:34;200997:9:0::2;19827:18:1::0;;;19820:34;201015:21:0::2;19870:18:1::0;;;19863:34;200940:29:0::2;::::0;::::2;::::0;19715:19:1;;200940:103:0::2;::::0;::::2;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;34969:1:::1;35921:7;:22:::0;200919:124;;;;-1:-1:-1;200760:289:0;-1:-1:-1;200760:289:0:o;31654:205::-;31773:33;31792:4;31798:7;31773:18;:33::i;:::-;31817:18;;;;:12;:18;;;;;:34;;31843:7;31817:25;:34::i;205611:191::-;205759:26;;205736:60;;;-1:-1:-1;;;205736:60:0;;;;205695:20;;-1:-1:-1;;;;;205759:26:0;;205736:58;;:60;;;;;205759:26;;205736:60;;;;;;;205759:26;205736:60;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;205736:60:0;;;;;;;;;;;;:::i;:::-;205727:69;;205611:191;:::o;209842:156::-;209933:59;;-1:-1:-1;;;209933:59:0;;:11;:59;;;16843:25:1;209964:10:0;16884:18:1;;;16877:34;209976:15:0;16927:18:1;;;16920:34;209904:4:0;;;;209933:30;;;;16816:18:1;;209933:59:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;209926:66;;;;209842:156;;:::o;199999:476::-;200136:29;200174:26;200209:20;192058:21;:31;;;192093:1;192058:36;192050:72;;;;-1:-1:-1;;;192050:72:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:7:::0;:18:::1;;;;200307:11:::2;:29;;;;200345:10;200364:15;200388:9;200406:35;;;;;;;;200426:14;200406:35;;::::0;200450:12:::2;:10;:12::i;:::-;200307:162;::::0;-1:-1:-1;;;;;;200307:162:0::2;::::0;;;;;;::::2;::::0;::::2;23388:25:1::0;;;;23429:18;;;23422:34;;;;23472:18;;;23465:34;;;;23515:18;;;23508:34;23579:13;23558:19;;;23551:42;-1:-1:-1;;;;;23630:32:1;23609:19;;;23602:61;23360:19;;200307:162:0::2;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;34969:1:::1;35921:7;:22:::0;200247:222;;;;-1:-1:-1;200247:222:0;;-1:-1:-1;199999:476:0;-1:-1:-1;;199999:476:0:o;204014:231::-;191729:38;-1:-1:-1;;;;;;;;;;;191754:12:0;:10;:12::i;191729:38::-;191713:101;;;;-1:-1:-1;;;191713:101:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;204193:39:::2;::::0;;::::2;::::0;::::2;::::0;;;;;204148:91;;-1:-1:-1;;;204148:91:0;;:15:::2;:91;::::0;::::2;14650:25:1::0;14711:13;;14691:18;;;14684:41;204148:36:0::2;::::0;::::2;::::0;14623:18:1;;204148:91:0::2;14605:126:1::0;198691:500:0;198907:26;191890:46;-1:-1:-1;;;;;;;;;;;191923:12:0;:10;:12::i;191890:46::-;191874:117;;;;-1:-1:-1;;;191874:117:0;;;;;;;:::i;:::-;192058:21:::1;:31:::0;:36;192050:72:::1;;;;-1:-1:-1::0;;;192050:72:0::1;;;;;;;:::i;:::-;35013:1:::2;35609:7:::0;::::2;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::2;;;;;;;:::i;:::-;35013:1;35742:7:::0;:18:::2;;;;198966:11:::3;:30;;;;199005:10;199024:15;199048:9;199066:41;;;;;;;;199086:20;199066:41;;::::0;199116::::3;;;;;;;;199136:20;199116:41;;::::0;199166:12:::3;:10;:12::i;:::-;198966:219;::::0;-1:-1:-1;;;;;;198966:219:0::3;::::0;;;;;;::::3;::::0;::::3;24202:25:1::0;;;;24243:18;;;24236:34;;;;24286:18;;;24279:34;;;;24329:18;;;24322:34;;;;24393:13;24372:19;;;24365:42;24444:13;24423:19;;;24416:42;-1:-1:-1;;;;;24495:32:1;24474:19;;;24467:61;24174:19;;198966:219:0::3;;;;;;;;;;;;;;;;;::::0;::::3;;;;;;;;;;;;::::0;::::3;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;34969:1:::2;35921:7;:22:::0;198945:240;198691:500;-1:-1:-1;;;198691:500:0:o;194837:335::-;192058:21;:31;194975:26;;;;192058:36;192050:72;;;;-1:-1:-1;;;192050:72:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;195062::::2;;:11;195089:10;195108:9;195126:12:::0;195147::::2;:10;:12::i;:::-;195062:104;;;;;;;;;;;;;;;;;;;:::i;:::-;;::::0;::::2;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;34969:1:::1;35921:7;:22:::0;195030:136;;;;-1:-1:-1;194837:335:0;-1:-1:-1;;194837:335:0:o;197822:450::-;198012:26;191890:46;-1:-1:-1;;;;;;;;;;;191923:12:0;:10;:12::i;191890:46::-;191874:117;;;;-1:-1:-1;;;191874:117:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;198147:41:::2;::::0;;::::2;::::0;;::::2;::::0;;;;;198197;;;;::::2;::::0;;;;;;198071:30:::2;::::0;::::2;::::0;:11:::2;::::0;198110:10:::2;::::0;198129:9:::2;::::0;198247:12:::2;:10;:12::i;:::-;198071:195;::::0;-1:-1:-1;;;;;;198071:195:0::2;::::0;;;;;;::::2;::::0;::::2;22238:25:1::0;;;;22279:18;;;22272:34;;;;22322:18;;;22315:34;;;;22385:13;22365:18;;;22358:41;22436:13;22415:19;;;22408:42;-1:-1:-1;;;;;22487:32:1;22466:19;;;22459:61;22210:19;;198071:195:0::2;22192:334:1::0;195694:347:0;192058:21;:31;195838:27;;;;192058:36;192050:72;;;;-1:-1:-1;;;192050:72:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;195927:20:::2;;:11;195956:10;195975:9;195993:14:::0;196016:12:::2;:10;:12::i;:::-;195927:108;;;;;;;;;;;;;;;;;;;:::i;212755:428::-:0;212879:11;:18;:100;;-1:-1:-1;;;212879:100:0;;-1:-1:-1;;;212879:100:0;;;10896:25:1;212852:4:0;;-1:-1:-1;;;;;212879:18:0;;:43;;10869:18:1;;212879:100:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;212879:100:0;;;;;;;;-1:-1:-1;;212879:100:0;;;;;;;;;;;;:::i;:::-;;;212868:310;;-1:-1:-1;213165:5:0;;212755:428;-1:-1:-1;212755:428:0:o;212868:310::-;213046:16;-1:-1:-1;;;;;213033:29:0;:9;-1:-1:-1;;;;;213033:29:0;;213029:106;;;-1:-1:-1;213082:4:0;;212755:428;-1:-1:-1;;212755:428:0:o;213029:106::-;-1:-1:-1;213120:5:0;;212755:428;-1:-1:-1;;212755:428:0:o;207779:154::-;207869:58;;-1:-1:-1;;;207869:58:0;;:11;:58;;;16843:25:1;207905:10:0;16884:18:1;;;16877:34;207917:9:0;16927:18:1;;;16920:34;207846:7:0;;207869:35;;;;16816:18:1;;207869:58:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;30524:145::-;30606:7;30633:18;;;:12;:18;;;;;:28;;30655:5;30633:21;:28::i;:::-;30626:35;30524:145;-1:-1:-1;;;30524:145:0:o;24817:139::-;24895:4;24919:12;;;;;;;;;;;-1:-1:-1;;;;;24919:29:0;;;;;;;;;;;;;;;24817:139::o;211241:311::-;211503:36;;;;;;;;;;;211445:101;;-1:-1:-1;;;211445:101:0;;:11;:101;;;24852:25:1;211484:10:0;24893:18:1;;;24886:34;24956:13;;24936:18;;;24929:41;-1:-1:-1;;;;211445:30:0;;;;24825:18:1;;211445:101:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;211407:139;;;;-1:-1:-1;211241:311:0;-1:-1:-1;;211241:311:0:o;199307:174::-;199387:18;35013:1;35609:7;;:19;;35601:63;;;;-1:-1:-1;;;35601:63:0;;;;;;;:::i;:::-;35013:1;35742:18;;199430:20:::1;;:11;199451:9;199462:12;:10;:12::i;:::-;199430:45;::::0;-1:-1:-1;;;;;;199430:45:0::1;::::0;;;;;;::::1;::::0;::::1;16410:25:1::0;;;;16451:18;;;16444:34;;;;-1:-1:-1;;;;;16514:32:1;16494:18;;;16487:60;16383:18;;199430:45:0::1;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;34969:1:::0;35921:7;:22;199417:58;199307:174;-1:-1:-1;199307:174:0:o;194035:331::-;192058:21;:31;194167:29;;;;192058:36;192050:72;;;;-1:-1:-1;;;192050:72:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;194260:16:::2;;:11;194285:10;194304:9;194322:10:::0;194341:12:::2;:10;:12::i;202497:197::-:0;191729:38;-1:-1:-1;;;;;;;;;;;191754:12:0;:10;:12::i;191729:38::-;191713:101;;;;-1:-1:-1;;;191713:101:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;202652:35:::2;::::0;;::::2;::::0;::::2;::::0;;;;;202623:65;;-1:-1:-1;;;202623:65:0;;:11:::2;:65;::::0;::::2;14650:25:1::0;14711:13;;14691:18;;;14684:41;202623:28:0::2;::::0;::::2;::::0;14623:18:1;;202623:65:0::2;14605:126:1::0;206707:347:0;207006:35;;206943:22;206927:121;;;;;;;;;;;;;;;;;;;206796:16;;;;206845:7;;206897:15;;206943:22;;206974:23;;207006:35;206927:121;;206943:22;;206927:121;;206943:22;206927:121;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;206927:121:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;206707:347;;;:::o;203091:227::-;191729:38;-1:-1:-1;;;;;;;;;;;191754:12:0;:10;:12::i;191729:38::-;191713:101;;;;-1:-1:-1;;;191713:101:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;203253:59:::2;::::0;-1:-1:-1;;;203253:59:0;;:28:::2;::::0;::::2;::::0;:59:::2;::::0;:11:::2;::::0;203282:13;;;;203297:14;;;;203253:59:::2;;;:::i;:::-;;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;34969:1:0::1;35921:7;:22:::0;-1:-1:-1;;;;;;203091:227:0:o;30843:134::-;30915:7;30942:18;;;:12;:18;;;;;:27;;:25;:27::i;31358:201::-;31475:31;31492:4;31498:7;31475:16;:31::i;210445:315::-;210711:36;;;;;;;;;;;210637:117;;-1:-1:-1;;;210637:117:0;;:11;:117;;;20956:25:1;210674:10:0;20997:18:1;;;20990:34;210693:9:0;21040:18:1;;;21033:34;21103:13;;21083:18;;;21076:41;-1:-1:-1;;;;210637:28:0;;;;20928:19:1;;210637:117:0;20910:213:1;212144:409:0;212480:36;;;;;;;;;;;212420:127;;-1:-1:-1;;;212420:127:0;;:11;:127;;;25363:25:1;212461:10:0;25404:18:1;;;25397:34;25467:13;;25447:18;;;25440:41;-1:-1:-1;;;;;25517:32:1;;25497:18;;;25490:60;-1:-1:-1;;;;212420:32:0;;;;25335:19:1;;212420:127:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;212379:168;;;;-1:-1:-1;212144:409:0;-1:-1:-1;;;212144:409:0:o;196453:342::-;192058:21;:31;:36;192050:72;;;;-1:-1:-1;;;192050:72:0;;;;;;;:::i;:::-;35013:1:::1;35609:7:::0;::::1;:19;;35601:63;;;;-1:-1:-1::0;;;35601:63:0::1;;;;;;;:::i;:::-;35013:1;35742:18:::0;;196688:37:::2;::::0;;::::2;::::0;;::::2;::::0;;;;;196734:30;;;;::::2;::::0;;;;;196618:171;;-1:-1:-1;;;196618:171:0;;:11:::2;:171;::::0;::::2;22238:25:1::0;196651:10:0::2;22279:18:1::0;;;22272:34;196670:9:0::2;22322:18:1::0;;;22315:34;22385:13;;22365:18;;;22358:41;22436:13;;22415:19;;;22408:42;-1:-1:-1;;;;;22487:32:1;;22466:19;;;22459:61;196618:24:0::2;::::0;::::2;::::0;22210:19:1;;196618:171:0::2;;;;;;;;;;;;;;;;::::0;::::2;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;;34969:1:0::1;35921:7;:22:::0;-1:-1:-1;;;;;196453:342:0:o;28166:112::-;28245:25;28256:4;28262:7;28245:10;:25::i;:::-;28166:112;;:::o;7879:152::-;7949:4;7973:50;7978:3;-1:-1:-1;;;;;7998:23:0;;7973:4;:50::i;32560:392::-;32647:14;32677:30;32696:10;32677:18;:30::i;:::-;32673:274;;;-1:-1:-1;;;32862:14:0;32858:23;32845:37;32841:2;32837:46;32560:392;:::o;32816:76::-;-1:-1:-1;21797:10:0;;205611:191::o;21717:98::-;21797:10;;21717:98::o;213189:165::-;213288:14;213321:27;:25;:27::i;24521:204::-;24606:4;-1:-1:-1;;;;;;24630:47:0;;-1:-1:-1;;;24630:47:0;;:87;;-1:-1:-1;;;;;;;;;;14490:40:0;;;24681:36;14381:157;26317:147;25998:7;26025:12;;;;;;;;;;:22;;;24399:30;24410:4;24416:12;:10;:12::i;:::-;24399:10;:30::i;:::-;26431:25:::1;26442:4;26448:7;26431:10;:25::i;27365:218::-:0;27472:12;:10;:12::i;:::-;-1:-1:-1;;;;;27461:23:0;:7;-1:-1:-1;;;;;27461:23:0;;27453:83;;;;-1:-1:-1;;;27453:83:0;;14172:2:1;27453:83:0;;;14154:21:1;14211:2;14191:18;;;14184:30;14250:34;14230:18;;;14223:62;-1:-1:-1;;;14301:18:1;;;14294:45;14356:19;;27453:83:0;14144:237:1;27453:83:0;27549:26;27561:4;27567:7;27549:11;:26::i;8207:158::-;8280:4;8304:53;8312:3;-1:-1:-1;;;;;8332:23:0;;8304:7;:53::i;9175:158::-;9249:7;9300:22;9304:3;9316:5;9300:3;:22::i;8704:117::-;8767:7;8794:19;8802:3;4188:18;;4105:109;26709:149;25998:7;26025:12;;;;;;;;;;:22;;;24399:30;24410:4;24416:12;:10;:12::i;24399:30::-;26824:26:::1;26836:4;26842:7;26824:11;:26::i;28669:229::-:0;28744:22;28752:4;28758:7;28744;:22::i;:::-;28739:152;;28783:6;:12;;;;;;;;;;;-1:-1:-1;;;;;28783:29:0;;;;;;;;;:36;;-1:-1:-1;;28783:36:0;28815:4;28783:36;;;28866:12;:10;:12::i;:::-;-1:-1:-1;;;;;28839:40:0;28857:7;-1:-1:-1;;;;;28839:40:0;28851:4;28839:40;;;;;;;;;;28669:229;;:::o;1794:414::-;1857:4;3987:19;;;:12;;;:19;;;;;;1874:327;;-1:-1:-1;1917:23:0;;;;;;;;:11;:23;;;;;;;;;;;;;2100:18;;2078:19;;;:12;;;:19;;;;;;:40;;;;2133:11;;1874:327;-1:-1:-1;2184:5:0;2177:12;;25246:497;25327:22;25335:4;25341:7;25327;:22::i;:::-;25322:414;;25515:41;25543:7;-1:-1:-1;;;;;25515:41:0;25553:2;25515:19;:41::i;:::-;25629:38;25657:4;25664:2;25629:19;:38::i;:::-;25420:270;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;25420:270:0;;;;;;;;;;-1:-1:-1;;;25366:358:0;;;;;;;:::i;28906:230::-;28981:22;28989:4;28995:7;28981;:22::i;:::-;28977:152;;;29052:5;29020:12;;;;;;;;;;;-1:-1:-1;;;;;29020:29:0;;;;;;;;;:37;;-1:-1:-1;;29020:37:0;;;29104:12;:10;:12::i;:::-;-1:-1:-1;;;;;29077:40:0;29095:7;-1:-1:-1;;;;;29077:40:0;29089:4;29077:40;;;;;;;;;;28906:230;;:::o;2384:1420::-;2450:4;2589:19;;;:12;;;:19;;;;;;2625:15;;2621:1176;;3000:21;3024:14;3037:1;3024:10;:14;:::i;:::-;3073:18;;3000:38;;-1:-1:-1;3053:17:0;;3073:22;;3094:1;;3073:22;:::i;:::-;3053:42;;3129:13;3116:9;:26;3112:405;;3163:17;3183:3;:11;;3195:9;3183:22;;;;;;-1:-1:-1;;;3183:22:0;;;;;;;;;;;;;;;;;3163:42;;3337:9;3308:3;:11;;3320:13;3308:26;;;;;;-1:-1:-1;;;3308:26:0;;;;;;;;;;;;;;;;;;;;:38;;;;3422:23;;;:12;;;:23;;;;;:36;;;3112:405;3598:17;;:3;;:17;;;-1:-1:-1;;;3598:17:0;;;;;;;;;;;;;;;;;;;;;;;;;;3693:3;:12;;:19;3706:5;3693:19;;;;;;;;;;;3686:26;;;3736:4;3729:11;;;;;;;2621:1176;3780:5;3773:12;;;;;4568:120;4635:7;4662:3;:11;;4674:5;4662:18;;;;;;-1:-1:-1;;;4662:18:0;;;;;;;;;;;;;;;;;4655:25;;4568:120;;;;:::o;16232:451::-;16307:13;16333:19;16365:10;16369:6;16365:1;:10;:::i;:::-;:14;;16378:1;16365:14;:::i;:::-;16355:25;;;;;;-1:-1:-1;;;16355:25:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;16355:25:0;;16333:47;;-1:-1:-1;;;16391:6:0;16398:1;16391:9;;;;;;-1:-1:-1;;;16391:9:0;;;;;;;;;;;;:15;-1:-1:-1;;;;;16391:15:0;;;;;;;;;-1:-1:-1;;;16417:6:0;16424:1;16417:9;;;;;;-1:-1:-1;;;16417:9:0;;;;;;;;;;;;:15;-1:-1:-1;;;;;16417:15:0;;;;;;;;-1:-1:-1;16448:9:0;16460:10;16464:6;16460:1;:10;:::i;:::-;:14;;16473:1;16460:14;:::i;:::-;16448:26;;16443:135;16480:1;16476;:5;16443:135;;;-1:-1:-1;;;16528:5:0;16536:3;16528:11;16515:25;;;;;-1:-1:-1;;;16515:25:0;;;;;;;;;;;;16503:6;16510:1;16503:9;;;;;;-1:-1:-1;;;16503:9:0;;;;;;;;;;;;:37;-1:-1:-1;;;;;16503:37:0;;;;;;;;-1:-1:-1;16565:1:0;16555:11;;;;;16483:3;;;:::i;:::-;;;16443:135;;;-1:-1:-1;16596:10:0;;16588:55;;;;-1:-1:-1;;;16588:55:0;;11979:2:1;16588:55:0;;;11961:21:1;;;11998:18;;;11991:30;12057:34;12037:18;;;12030:62;12109:18;;16588:55:0;11951:182:1;14:391;77:8;87:6;141:3;134:4;126:6;122:17;118:27;108:2;;164:6;156;149:22;108:2;-1:-1:-1;192:20:1;;235:18;224:30;;221:2;;;274:8;264;257:26;221:2;318:4;310:6;306:17;294:29;;378:3;371:4;361:6;358:1;354:14;346:6;342:27;338:38;335:47;332:2;;;395:1;392;385:12;332:2;98:307;;;;;:::o;410:167::-;473:5;518:3;509:6;504:3;500:16;496:26;493:2;;;539:5;532;525:20;493:2;-1:-1:-1;565:6:1;483:94;-1:-1:-1;483:94:1:o;582:257::-;641:6;694:2;682:9;673:7;669:23;665:32;662:2;;;715:6;707;700:22;662:2;759:9;746:23;778:31;803:5;778:31;:::i;844:261::-;914:6;967:2;955:9;946:7;942:23;938:32;935:2;;;988:6;980;973:22;935:2;1025:9;1019:16;1044:31;1069:5;1044:31;:::i;1110:802::-;1231:6;1239;1247;1255;1308:2;1296:9;1287:7;1283:23;1279:32;1276:2;;;1329:6;1321;1314:22;1276:2;1374:9;1361:23;1403:18;1444:2;1436:6;1433:14;1430:2;;;1465:6;1457;1450:22;1430:2;1509:70;1571:7;1562:6;1551:9;1547:22;1509:70;:::i;:::-;1598:8;;-1:-1:-1;1483:96:1;-1:-1:-1;1686:2:1;1671:18;;1658:32;;-1:-1:-1;1702:16:1;;;1699:2;;;1736:6;1728;1721:22;1699:2;;1780:72;1844:7;1833:8;1822:9;1818:24;1780:72;:::i;:::-;1266:646;;;;-1:-1:-1;1871:8:1;-1:-1:-1;;;;1266:646:1:o;1917:358::-;1993:6;2001;2054:2;2042:9;2033:7;2029:23;2025:32;2022:2;;;2075:6;2067;2060:22;2022:2;2112:9;2106:16;2165:5;2158:13;2151:21;2144:5;2141:32;2131:2;;2192:6;2184;2177:22;2131:2;2265;2250:18;;;;2244:25;2220:5;;2244:25;;-1:-1:-1;;;2012:263:1:o;2280:190::-;2339:6;2392:2;2380:9;2371:7;2367:23;2363:32;2360:2;;;2413:6;2405;2398:22;2360:2;-1:-1:-1;2441:23:1;;2350:120;-1:-1:-1;2350:120:1:o;2475:325::-;2543:6;2551;2604:2;2592:9;2583:7;2579:23;2575:32;2572:2;;;2625:6;2617;2610:22;2572:2;2666:9;2653:23;2643:33;;2726:2;2715:9;2711:18;2698:32;2739:31;2764:5;2739:31;:::i;:::-;2789:5;2779:15;;;2562:238;;;;;:::o;2805:258::-;2873:6;2881;2934:2;2922:9;2913:7;2909:23;2905:32;2902:2;;;2955:6;2947;2940:22;2902:2;-1:-1:-1;;2983:23:1;;;3053:2;3038:18;;;3025:32;;-1:-1:-1;2892:171:1:o;3068:306::-;3126:6;3179:2;3167:9;3158:7;3154:23;3150:32;3147:2;;;3200:6;3192;3185:22;3147:2;3231:23;;-1:-1:-1;;;;;;3283:32:1;;3273:43;;3263:2;;3335:6;3327;3320:22;3379:924;3459:6;3512:2;3500:9;3491:7;3487:23;3483:32;3480:2;;;3533:6;3525;3518:22;3480:2;3571:9;3565:16;3600:18;3641:2;3633:6;3630:14;3627:2;;;3662:6;3654;3647:22;3627:2;3705:6;3694:9;3690:22;3680:32;;3750:7;3743:4;3739:2;3735:13;3731:27;3721:2;;3777:6;3769;3762:22;3721:2;3811;3805:9;3833:2;3829;3826:10;3823:2;;;3839:18;;:::i;:::-;3914:2;3908:9;3882:2;3968:13;;-1:-1:-1;;3964:22:1;;;3988:2;3960:31;3956:40;3944:53;;;4012:18;;;4032:22;;;4009:46;4006:2;;;4058:18;;:::i;:::-;4098:10;4094:2;4087:22;4133:2;4125:6;4118:18;4173:7;4168:2;4163;4159;4155:11;4151:20;4148:33;4145:2;;;4199:6;4191;4184:22;4145:2;4217:55;4269:2;4264;4256:6;4252:15;4247:2;4243;4239:11;4217:55;:::i;:::-;4291:6;3470:833;-1:-1:-1;;;;;;;3470:833:1:o;4308:211::-;4401:6;4454:3;4442:9;4433:7;4429:23;4425:33;4422:2;;;4476:6;4468;4461:22;4524:416;4610:6;4663:2;4651:9;4642:7;4638:23;4634:32;4631:2;;;4684:6;4676;4669:22;4631:2;4729:9;4716:23;4762:18;4754:6;4751:30;4748:2;;;4799:6;4791;4784:22;4748:2;4827:22;;4883:2;4865:16;;;4861:25;4858:2;;;4904:6;4896;4889:22;4945:255;5034:6;5087:3;5075:9;5066:7;5062:23;5058:33;5055:2;;;5109:6;5101;5094:22;5055:2;5137:57;5186:7;5175:9;5137:57;:::i;5662:194::-;5732:6;5785:2;5773:9;5764:7;5760:23;5756:32;5753:2;;;5806:6;5798;5791:22;5753:2;-1:-1:-1;5834:16:1;;5743:113;-1:-1:-1;5743:113:1:o;6494:255::-;6573:6;6581;6634:2;6622:9;6613:7;6609:23;6605:32;6602:2;;;6655:6;6647;6640:22;6602:2;-1:-1:-1;;6683:16:1;;6739:2;6724:18;;;6718:25;6683:16;;6718:25;;-1:-1:-1;6592:157:1:o;6754:393::-;6831:6;6839;6847;6900:2;6888:9;6879:7;6875:23;6871:32;6868:2;;;6921:6;6913;6906:22;6868:2;6962:9;6949:23;6939:33;;7019:2;7008:9;7004:18;6991:32;6981:42;;7073:2;7062:9;7058:18;7045:32;7086:31;7111:5;7086:31;:::i;:::-;7136:5;7126:15;;;6858:289;;;;;:::o;7152:316::-;7240:6;7248;7256;7309:2;7297:9;7288:7;7284:23;7280:32;7277:2;;;7330:6;7322;7315:22;7277:2;7364:9;7358:16;7348:26;;7414:2;7403:9;7399:18;7393:25;7383:35;;7458:2;7447:9;7443:18;7437:25;7427:35;;7267:201;;;;;:::o;7645:399::-;7743:5;7730:19;7725:3;7718:32;7806:4;7799:5;7795:16;7782:30;7775:4;7770:3;7766:14;7759:54;7869:4;7862:5;7858:16;7845:30;7838:4;7833:3;7829:14;7822:54;7924:4;7917:5;7913:16;7900:30;7939:33;7964:7;7939:33;:::i;:::-;-1:-1:-1;;;;;8004:33:1;7997:4;7988:14;;;;7981:57;;;;-1:-1:-1;7708:336:1:o;8049:786::-;8460:25;8455:3;8448:38;8430:3;8515:6;8509:13;8531:62;8586:6;8581:2;8576:3;8572:12;8565:4;8557:6;8553:17;8531:62;:::i;:::-;-1:-1:-1;;;8652:2:1;8612:16;;;8644:11;;;8637:40;8702:13;;8724:63;8702:13;8773:2;8765:11;;8758:4;8746:17;;8724:63;:::i;:::-;8807:17;8826:2;8803:26;;8438:397;-1:-1:-1;;;;8438:397:1:o;9048:1242::-;9342:2;9354:21;;;9424:13;;9327:18;;;9446:22;;;9294:4;;9522;;9499:3;9484:19;;;9549:15;;;9294:4;9595:166;9609:6;9606:1;9603:13;9595:166;;;9694:13;;-1:-1:-1;;;;;7564:32:1;7552:45;;7629:4;7620:14;;9658:55;-1:-1:-1;9736:15:1;;;;9631:1;9624:9;9595:166;;;-1:-1:-1;;;9797:19:1;;;9777:18;;;9770:47;9867:13;;9889:21;;;9965:15;;;;9928:12;;;10000:4;10013:206;10029:8;10024:3;10021:17;10013:206;;;10102:15;;10119:10;10098:32;10084:47;;10192:17;;;;10153:14;;;;10057:1;10048:11;10013:206;;;10017:3;;10236:5;10228:13;;;;;10277:6;10272:2;10261:9;10257:18;10250:34;9303:987;;;;;;:::o;11389:383::-;11538:2;11527:9;11520:21;11501:4;11570:6;11564:13;11613:6;11608:2;11597:9;11593:18;11586:34;11629:66;11688:6;11683:2;11672:9;11668:18;11663:2;11655:6;11651:15;11629:66;:::i;:::-;11756:2;11735:15;-1:-1:-1;;11731:29:1;11716:45;;;;11763:2;11712:54;;11510:262;-1:-1:-1;;11510:262:1:o;12138:401::-;12340:2;12322:21;;;12379:2;12359:18;;;12352:30;12418:34;12413:2;12398:18;;12391:62;-1:-1:-1;;;12484:2:1;12469:18;;12462:35;12529:3;12514:19;;12312:227::o;12900:353::-;13102:2;13084:21;;;13141:2;13121:18;;;13114:30;13180:31;13175:2;13160:18;;13153:59;13244:2;13229:18;;13074:179::o;13258:347::-;13460:2;13442:21;;;13499:2;13479:18;;;13472:30;13538:25;13533:2;13518:18;;13511:53;13596:2;13581:18;;13432:173::o;13610:355::-;13812:2;13794:21;;;13851:2;13831:18;;;13824:30;13890:33;13885:2;13870:18;;13863:61;13956:2;13941:18;;13784:181::o;14736:1409::-;15096:25;;;15084:2;15140;15158:18;;;15151:30;;;15069:18;;;15216:22;;;15036:4;;15296:6;;15269:3;15254:19;;15036:4;15333:248;15347:6;15344:1;15341:13;15333:248;;;15422:6;15409:20;15442:31;15467:5;15442:31;:::i;:::-;-1:-1:-1;;;;;7564:32:1;7552:45;;15556:15;;;;7629:4;7620:14;;;;15369:1;15362:9;15333:248;;;-1:-1:-1;15617:19:1;;;15612:2;15597:18;;15590:47;15671:19;;;15708:12;;;-1:-1:-1;15745:6:1;15771:4;15784:333;15800:6;15795:3;15792:15;15784:333;;;15881:8;15868:22;15926:10;15917:7;15913:24;15972:2;15963:7;15960:15;15950:2;;15992:4;15986;15979:18;15950:2;16012:17;;-1:-1:-1;16051:14:1;;;;16090:17;;;;15826:1;15817:11;15784:333;;;-1:-1:-1;16134:5:1;;15045:1100;-1:-1:-1;;;;;;;;;15045:1100:1:o;16965:::-;17373:25;;;17429:2;17414:18;;17407:34;;;17472:2;17457:18;;17450:34;;;17360:3;17345:19;;17506:20;;17535:31;17506:20;17535:31;:::i;:::-;17602:1;17598;17593:3;17589:11;17585:19;17651:2;17644:5;17640:14;17635:2;17624:9;17620:18;17613:42;17717:2;17709:6;17705:15;17692:29;17686:3;17675:9;17671:19;17664:58;17784:2;17776:6;17772:15;17759:29;17753:3;17742:9;17738:19;17731:58;17851:2;17843:6;17839:15;17826:29;17820:3;17809:9;17805:19;17798:58;17905:3;17897:6;17893:16;17880:30;17865:45;;17919:33;17944:7;17919:33;:::i;:::-;17989:16;;;17983:3;17968:19;;17961:45;18043:15;;;;18037:3;18022:19;;;18015:44;17327:738;;-1:-1:-1;;;;17327:738:1:o;18070:661::-;18470:25;;;18526:2;18511:18;;18504:34;;;18569:2;18554:18;;18547:34;;;18457:3;18442:19;;18590:65;18651:2;18636:18;;18628:6;18590:65;:::i;:::-;-1:-1:-1;;;;;18692:32:1;;;;18686:3;18671:19;;;;18664:61;18424:307;;-1:-1:-1;;;;18424:307:1:o;27653:557::-;27746:4;27752:6;27812:11;27799:25;27906:2;27902:7;27891:8;27875:14;27871:29;27867:43;27847:18;27843:68;27833:2;;27928:4;27922;27915:18;27833:2;27958:33;;28010:20;;;-1:-1:-1;28053:18:1;28042:30;;28039:2;;;28088:4;28082;28075:18;28039:2;28124:4;28112:17;;-1:-1:-1;28175:1:1;28171:14;;;28155;28151:35;28141:46;;28138:2;;;28200:1;28197;28190:12;28776:128;28816:3;28847:1;28843:6;28840:1;28837:13;28834:2;;;28853:18;;:::i;:::-;-1:-1:-1;28889:9:1;;28824:80::o;28909:168::-;28949:7;29015:1;29011;29007:6;29003:14;29000:1;28997:21;28992:1;28985:9;28978:17;28974:45;28971:2;;;29022:18;;:::i;:::-;-1:-1:-1;29062:9:1;;28961:116::o;29082:125::-;29122:4;29150:1;29147;29144:8;29141:2;;;29155:18;;:::i;:::-;-1:-1:-1;29192:9:1;;29131:76::o;29212:258::-;29284:1;29294:113;29308:6;29305:1;29302:13;29294:113;;;29384:11;;;29378:18;29365:11;;;29358:39;29330:2;29323:10;29294:113;;;29425:6;29422:1;29419:13;29416:2;;;29460:1;29451:6;29446:3;29442:16;29435:27;29416:2;;29265:205;;;:::o;29475:136::-;29514:3;29542:5;29532:2;;29551:18;;:::i;:::-;-1:-1:-1;;;29587:18:1;;29522:89::o;29616:127::-;29677:10;29672:3;29668:20;29665:1;29658:31;29708:4;29705:1;29698:15;29732:4;29729:1;29722:15;29748:127;29809:10;29804:3;29800:20;29797:1;29790:31;29840:4;29837:1;29830:15;29864:4;29861:1;29854:15;29880:131;-1:-1:-1;;;;;29955:31:1;;29945:42;;29935:2;;30001:1;29998;29991:12;29935:2;29925:86;:::o
Swarm Source
ipfs://e86b7cad89413ee881461efdeb1192736252517c380b8be839c879f713f2f154
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.