Overview
ETH Balance
0 ETH
Eth Value
$0.00Token Holdings
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 1,971 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Mint Fractional ... | 14557283 | 958 days ago | IN | 0 ETH | 0.00058717 | ||||
Set Owner | 13393040 | 1139 days ago | IN | 0 ETH | 0.00270456 | ||||
Grant Role | 13368309 | 1143 days ago | IN | 0 ETH | 0.01227496 | ||||
Redeem Fractiona... | 11693612 | 1403 days ago | IN | 0 ETH | 0.0017052 | ||||
Recollateralize ... | 11693612 | 1403 days ago | IN | 0 ETH | 0.00162655 | ||||
Mint Fractional ... | 11693612 | 1403 days ago | IN | 0 ETH | 0.00165965 | ||||
Buy Back FXS | 11693612 | 1403 days ago | IN | 0 ETH | 0.00164746 | ||||
Set Pool Paramet... | 11693525 | 1403 days ago | IN | 0 ETH | 0.00339431 | ||||
Toggle Redeeming | 11693497 | 1403 days ago | IN | 0 ETH | 0.00218156 | ||||
Toggle Buy Back | 11693497 | 1403 days ago | IN | 0 ETH | 0.00218164 | ||||
Collect Redempti... | 11693251 | 1403 days ago | IN | 0 ETH | 0.0085709 | ||||
Redeem Fractiona... | 11693244 | 1403 days ago | IN | 0 ETH | 0.01717341 | ||||
Collect Redempti... | 11693237 | 1403 days ago | IN | 0 ETH | 0.00788647 | ||||
Redeem Fractiona... | 11693227 | 1403 days ago | IN | 0 ETH | 0.01629902 | ||||
Collect Redempti... | 11693223 | 1403 days ago | IN | 0 ETH | 0.00794982 | ||||
Redeem Fractiona... | 11693217 | 1403 days ago | IN | 0 ETH | 0.0163015 | ||||
Redeem Fractiona... | 11693213 | 1403 days ago | IN | 0 ETH | 0.00806467 | ||||
Collect Redempti... | 11693206 | 1403 days ago | IN | 0 ETH | 0.00819825 | ||||
Redeem Fractiona... | 11693199 | 1403 days ago | IN | 0 ETH | 0.01568007 | ||||
Collect Redempti... | 11693186 | 1403 days ago | IN | 0 ETH | 0.00819825 | ||||
Redeem Fractiona... | 11693180 | 1403 days ago | IN | 0 ETH | 0.01543192 | ||||
Collect Redempti... | 11693172 | 1403 days ago | IN | 0 ETH | 0.00794982 | ||||
Redeem Fractiona... | 11693165 | 1403 days ago | IN | 0 ETH | 0.01667723 | ||||
Collect Redempti... | 11693143 | 1403 days ago | IN | 0 ETH | 0.01180216 | ||||
Redeem Fractiona... | 11693136 | 1403 days ago | IN | 0 ETH | 0.02414465 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
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.
Contract Name:
Pool_USDC
Compiler Version
v0.6.11+commit.5ef660b1
Contract Source Code (Solidity Multiple files format)
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./FraxPool.sol"; contract Pool_USDC is FraxPool { address public USDC_address; constructor( address _frax_contract_address, address _fxs_contract_address, address _collateral_address, address _creator_address, address _timelock_address, uint256 _pool_ceiling ) FraxPool(_frax_contract_address, _fxs_contract_address, _collateral_address, _creator_address, _timelock_address, _pool_ceiling) public { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); USDC_address = _collateral_address; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./EnumerableSet.sol"; import "./Address.sol"; import "./Context.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * 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 { using EnumerableSet for EnumerableSet.AddressSet; using Address for address; struct RoleData { EnumerableSet.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; //bytes32(uint256(0x4B437D01b575618140442A4975db38850e3f8f5f) << 96); /** * @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 {_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) public view returns (bool) { return _roles[role].members.contains(account); } /** * @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 returns (uint256) { return _roles[role].members.length(); } /** * @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 returns (address) { return _roles[role].members.at(index); } /** * @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 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 { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _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 { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _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 { 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 { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; /** * @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 in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; // computes square roots using the babylonian method // https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method library Babylonian { function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } // else z = 0 } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; // file: BlockMinder.sol // used to "waste" blocks for truffle tests contract BlockMiner { uint256 public blocksMined; constructor () public { blocksMined = 0; } function mine() public { blocksMined += 1; } function blockTime() external view returns (uint256) { return block.timestamp; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./AggregatorV3Interface.sol"; contract ChainlinkETHUSDPriceConsumer { AggregatorV3Interface internal priceFeed; constructor() public { priceFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); } /** * Returns the latest price */ function getLatestPrice() public view returns (int) { ( , int price, , , ) = priceFeed.latestRoundData(); return price; } function getDecimals() public view returns (uint8) { return priceFeed.decimals(); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./AggregatorV3Interface.sol"; // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; contract ChainlinkETHUSDPriceConsumerTest { // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // AggregatorV3Interface internal priceFeed; /** * Network: Kovan * Aggregator: ETH/USD * Address: 0x9326BFA02ADD2366b30bacB125260Af641031331 */ /** * Network: Mainnet * Aggregator: ETH/USD * Address: 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 */ constructor() public { // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // priceFeed = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419); } /** * Returns the latest price */ function getLatestPrice() public pure returns (int) { // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // ( // uint80 roundID, // int price, // uint startedAt, // uint timeStamp, // uint80 answeredInRound // ) = priceFeed.latestRoundData(); // // If the round is not complete yet, timestamp is 0 // require(timeStamp > 0, "Round not complete"); // This will return something like 32063000000 // Divide this by getDecimals to get the "true" price // You can can multiply the "true" price by 1e6 to get the frax ecosystem 'price' // return price; return 59000000000; } function getDecimals() public pure returns (uint8) { // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // VERY IMPORTANT: UNCOMMENT THIS LATER // return priceFeed.decimals(); return 8; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.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.0.0, only sets of type `address` (`AddressSet`) and `uint256` * (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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(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(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(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(uint256(_at(set._inner, index))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./Context.sol"; import "./IERC20.sol"; import "./SafeMath.sol"; import "./Address.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @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() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address.approve(address spender, uint256 amount) */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for `accounts`'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of `from`'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of `from`'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./Context.sol"; import "./IERC20.sol"; import "./SafeMath.sol"; import "./Address.sol"; // Due to compiling issues, _name, _symbol, and _decimals were removed /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Custom is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address.approve(address spender, uint256 amount) */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for `accounts`'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of `from`'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of `from`'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./Context.sol"; import "./IERC20.sol"; import "./SafeMath.sol"; import "./Address.sol"; // Due to compiling issues, _name, _symbol, and _decimals were removed /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract FakeCollateral is Context, IERC20 { using SafeMath for uint256; string public symbol; uint8 public decimals; address public creator_address; uint256 public genesis_supply; uint256 private _totalSupply; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) used; constructor( address _creator_address, uint256 _genesis_supply, string memory _symbol, uint8 _decimals ) public { genesis_supply = _genesis_supply; creator_address = _creator_address; symbol = _symbol; decimals = _decimals; _mint(creator_address, genesis_supply); } function faucet() public { if (used[msg.sender] == false) { used[msg.sender] = true; _mint(msg.sender, 1000 * (10 ** uint256(decimals))); } } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address.approve(address spender, uint256 amount) */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 amount) public virtual { _burn(_msgSender(), amount); } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for `accounts`'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal virtual { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of `from`'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of `from`'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:using-hooks.adoc[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./FakeCollateral.sol"; contract FakeCollateral_USDC is FakeCollateral { constructor( address _creator_address, uint256 _genesis_supply, string memory _symbol, uint8 _decimals ) FakeCollateral(_creator_address, _genesis_supply, _symbol, _decimals) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./FakeCollateral.sol"; contract FakeCollateral_USDT is FakeCollateral { constructor( address _creator_address, uint256 _genesis_supply, string memory _symbol, uint8 _decimals ) FakeCollateral(_creator_address, _genesis_supply, _symbol, _decimals) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./FakeCollateral.sol"; contract FakeCollateral_WETH is FakeCollateral { constructor( address _creator_address, uint256 _genesis_supply, string memory _symbol, uint8 _decimals ) FakeCollateral(_creator_address, _genesis_supply, _symbol, _decimals) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './Babylonian.sol'; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) library FixedPoint { // range: [0, 2**112 - 1] // resolution: 1 / 2**112 struct uq112x112 { uint224 _x; } // range: [0, 2**144 - 1] // resolution: 1 / 2**112 struct uq144x112 { uint _x; } uint8 private constant RESOLUTION = 112; uint private constant Q112 = uint(1) << RESOLUTION; uint private constant Q224 = Q112 << RESOLUTION; // encode a uint112 as a UQ112x112 function encode(uint112 x) internal pure returns (uq112x112 memory) { return uq112x112(uint224(x) << RESOLUTION); } // encodes a uint144 as a UQ144x112 function encode144(uint144 x) internal pure returns (uq144x112 memory) { return uq144x112(uint256(x) << RESOLUTION); } // divide a UQ112x112 by a uint112, returning a UQ112x112 function div(uq112x112 memory self, uint112 x) internal pure returns (uq112x112 memory) { require(x != 0, 'FixedPoint: DIV_BY_ZERO'); return uq112x112(self._x / uint224(x)); } // multiply a UQ112x112 by a uint, returning a UQ144x112 // reverts on overflow function mul(uq112x112 memory self, uint y) internal pure returns (uq144x112 memory) { uint z; require(y == 0 || (z = uint(self._x) * y) / y == uint(self._x), "FixedPoint: MULTIPLICATION_OVERFLOW"); return uq144x112(z); } // returns a UQ112x112 which represents the ratio of the numerator to the denominator // equivalent to encode(numerator).div(denominator) function fraction(uint112 numerator, uint112 denominator) internal pure returns (uq112x112 memory) { require(denominator > 0, "FixedPoint: DIV_BY_ZERO"); return uq112x112((uint224(numerator) << RESOLUTION) / denominator); } // decode a UQ112x112 into a uint112 by truncating after the radix point function decode(uq112x112 memory self) internal pure returns (uint112) { return uint112(self._x >> RESOLUTION); } // decode a UQ144x112 into a uint144 by truncating after the radix point function decode144(uq144x112 memory self) internal pure returns (uint144) { return uint144(self._x >> RESOLUTION); } // take the reciprocal of a UQ112x112 function reciprocal(uq112x112 memory self) internal pure returns (uq112x112 memory) { require(self._x != 0, 'FixedPoint: ZERO_RECIPROCAL'); return uq112x112(uint224(Q224 / self._x)); } // square root of a UQ112x112 function sqrt(uq112x112 memory self) internal pure returns (uq112x112 memory) { return uq112x112(uint224(Babylonian.sqrt(uint256(self._x)) << 56)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./Context.sol"; import "./IERC20.sol"; import "./ERC20Custom.sol"; import "./ERC20.sol"; import "./SafeMath.sol"; import "./FXS.sol"; import "./FraxPool.sol"; import "./UniswapPairOracle.sol"; import "./ChainlinkETHUSDPriceConsumer.sol"; import "./AccessControl.sol"; contract FRAXStablecoin is ERC20Custom, AccessControl { using SafeMath for uint256; /* ========== STATE VARIABLES ========== */ enum PriceChoice { FRAX, FXS } ChainlinkETHUSDPriceConsumer private eth_usd_pricer; uint8 private eth_usd_pricer_decimals; UniswapPairOracle private fraxEthOracle; UniswapPairOracle private fxsEthOracle; string public symbol; string public name; uint8 public constant decimals = 18; address public owner_address; address public creator_address; address public timelock_address; // Governance timelock address address public controller_address; // Controller contract to dynamically adjust system parameters automatically address public fxs_address; address public frax_eth_oracle_address; address public fxs_eth_oracle_address; address public weth_address; address public eth_usd_consumer_address; uint256 public constant genesis_supply = 2000000e18; // 2M FRAX (only for testing, genesis supply will be 5k on Mainnet). This is to help with establishing the Uniswap pools, as they need liquidity // The addresses in this array are added by the oracle and these contracts are able to mint frax address[] public frax_pools_array; // Mapping is also used for faster verification mapping(address => bool) public frax_pools; // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; uint256 public global_collateral_ratio; // 6 decimals of precision, e.g. 924102 = 0.924102 uint256 public redemption_fee; // 6 decimals of precision, divide by 1000000 in calculations for fee uint256 public minting_fee; // 6 decimals of precision, divide by 1000000 in calculations for fee uint256 public frax_step; // Amount to change the collateralization ratio by upon refreshCollateralRatio() uint256 public refresh_cooldown; // Seconds to wait before being able to run refreshCollateralRatio() again uint256 public price_target; // The price of FRAX at which the collateral ratio will respond to; this value is only used for the collateral ratio mechanism and not for minting and redeeming which are hardcoded at $1 uint256 public price_band; // The bound above and below the price target at which the refreshCollateralRatio() will not change the collateral ratio address public DEFAULT_ADMIN_ADDRESS; bytes32 public constant COLLATERAL_RATIO_PAUSER = keccak256("COLLATERAL_RATIO_PAUSER"); bool public collateral_ratio_paused = false; /* ========== MODIFIERS ========== */ modifier onlyCollateralRatioPauser() { require(hasRole(COLLATERAL_RATIO_PAUSER, msg.sender)); _; } modifier onlyPools() { require(frax_pools[msg.sender] == true, "Only frax pools can call this function"); _; } modifier onlyByOwnerOrGovernance() { require(msg.sender == owner_address || msg.sender == timelock_address || msg.sender == controller_address, "You are not the owner, controller, or the governance timelock"); _; } modifier onlyByOwnerGovernanceOrPool() { require( msg.sender == owner_address || msg.sender == timelock_address || frax_pools[msg.sender] == true, "You are not the owner, the governance timelock, or a pool"); _; } /* ========== CONSTRUCTOR ========== */ constructor( string memory _name, string memory _symbol, address _creator_address, address _timelock_address ) public { name = _name; symbol = _symbol; creator_address = _creator_address; timelock_address = _timelock_address; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); DEFAULT_ADMIN_ADDRESS = _msgSender(); owner_address = _creator_address; _mint(creator_address, genesis_supply); grantRole(COLLATERAL_RATIO_PAUSER, creator_address); grantRole(COLLATERAL_RATIO_PAUSER, timelock_address); frax_step = 2500; // 6 decimals of precision, equal to 0.25% global_collateral_ratio = 1000000; // Frax system starts off fully collateralized (6 decimals of precision) refresh_cooldown = 3600; // Refresh cooldown period is set to 1 hour (3600 seconds) at genesis price_target = 1000000; // Collateral ratio will adjust according to the $1 price target at genesis price_band = 5000; // Collateral ratio will not adjust if between $0.995 and $1.005 at genesis } /* ========== VIEWS ========== */ // Choice = 'FRAX' or 'FXS' for now function oracle_price(PriceChoice choice) internal view returns (uint256) { // Get the ETH / USD price first, and cut it down to 1e6 precision uint256 eth_usd_price = uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals); uint256 price_vs_eth; if (choice == PriceChoice.FRAX) { price_vs_eth = uint256(fraxEthOracle.consult(weth_address, PRICE_PRECISION)); // How much FRAX if you put in PRICE_PRECISION WETH } else if (choice == PriceChoice.FXS) { price_vs_eth = uint256(fxsEthOracle.consult(weth_address, PRICE_PRECISION)); // How much FXS if you put in PRICE_PRECISION WETH } else revert("INVALID PRICE CHOICE. Needs to be either 0 (FRAX) or 1 (FXS)"); // Will be in 1e6 format return eth_usd_price.mul(PRICE_PRECISION).div(price_vs_eth); } // Returns X FRAX = 1 USD function frax_price() public view returns (uint256) { return oracle_price(PriceChoice.FRAX); } // Returns X FXS = 1 USD function fxs_price() public view returns (uint256) { return oracle_price(PriceChoice.FXS); } function eth_usd_price() public view returns (uint256) { return uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals); } // This is needed to avoid costly repeat calls to different getter functions // It is cheaper gas-wise to just dump everything and only use some of the info function frax_info() public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) { return ( oracle_price(PriceChoice.FRAX), // frax_price() oracle_price(PriceChoice.FXS), // fxs_price() totalSupply(), // totalSupply() global_collateral_ratio, // global_collateral_ratio() globalCollateralValue(), // globalCollateralValue minting_fee, // minting_fee() redemption_fee, // redemption_fee() uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals) //eth_usd_price ); } // Iterate through all frax pools and calculate all value of collateral in all pools globally function globalCollateralValue() public view returns (uint256) { uint256 total_collateral_value_d18 = 0; for (uint i = 0; i < frax_pools_array.length; i++){ // Exclude null addresses if (frax_pools_array[i] != address(0)){ total_collateral_value_d18 = total_collateral_value_d18.add(FraxPool(frax_pools_array[i]).collatDollarBalance()); } } return total_collateral_value_d18; } /* ========== PUBLIC FUNCTIONS ========== */ // There needs to be a time interval that this can be called. Otherwise it can be called multiple times per expansion. uint256 public last_call_time; // Last time the refreshCollateralRatio function was called function refreshCollateralRatio() public { require(collateral_ratio_paused == false, "Collateral Ratio has been paused"); uint256 frax_price_cur = frax_price(); require(block.timestamp - last_call_time >= refresh_cooldown, "Must wait for the refresh cooldown since last refresh"); // Step increments are 0.25% (upon genesis, changable by setFraxStep()) if (frax_price_cur > price_target.add(price_band)) { //decrease collateral ratio if(global_collateral_ratio <= frax_step){ //if within a step of 0, go to 0 global_collateral_ratio = 0; } else { global_collateral_ratio = global_collateral_ratio.sub(frax_step); } } else if (frax_price_cur < price_target.sub(price_band)) { //increase collateral ratio if(global_collateral_ratio.add(frax_step) >= 1000000){ global_collateral_ratio = 1000000; // cap collateral ratio at 1.000000 } else { global_collateral_ratio = global_collateral_ratio.add(frax_step); } } last_call_time = block.timestamp; // Set the time of the last expansion } /* ========== RESTRICTED FUNCTIONS ========== */ // Used by pools when user redeems function pool_burn_from(address b_address, uint256 b_amount) public onlyPools { super._burnFrom(b_address, b_amount); emit FRAXBurned(b_address, msg.sender, b_amount); } // This function is what other frax pools will call to mint new FRAX function pool_mint(address m_address, uint256 m_amount) public onlyPools { super._mint(m_address, m_amount); emit FRAXMinted(msg.sender, m_address, m_amount); } // Adds collateral addresses supported, such as tether and busd, must be ERC20 function addPool(address pool_address) public onlyByOwnerOrGovernance { require(frax_pools[pool_address] == false, "address already exists"); frax_pools[pool_address] = true; frax_pools_array.push(pool_address); } // Remove a pool function removePool(address pool_address) public onlyByOwnerOrGovernance { require(frax_pools[pool_address] == true, "address doesn't exist already"); // Delete from the mapping delete frax_pools[pool_address]; // 'Delete' from the array by setting the address to 0x0 for (uint i = 0; i < frax_pools_array.length; i++){ if (frax_pools_array[i] == pool_address) { frax_pools_array[i] = address(0); // This will leave a null in the array and keep the indices the same break; } } } function setOwner(address _owner_address) external onlyByOwnerOrGovernance { owner_address = _owner_address; } function setRedemptionFee(uint256 red_fee) public onlyByOwnerOrGovernance { redemption_fee = red_fee; } function setMintingFee(uint256 min_fee) public onlyByOwnerOrGovernance { minting_fee = min_fee; } function setFraxStep(uint256 _new_step) public onlyByOwnerOrGovernance { frax_step = _new_step; } function setPriceTarget (uint256 _new_price_target) public onlyByOwnerOrGovernance { price_target = _new_price_target; } function setRefreshCooldown(uint256 _new_cooldown) public onlyByOwnerOrGovernance { refresh_cooldown = _new_cooldown; } function setFXSAddress(address _fxs_address) public onlyByOwnerOrGovernance { fxs_address = _fxs_address; } function setETHUSDOracle(address _eth_usd_consumer_address) public onlyByOwnerOrGovernance { eth_usd_consumer_address = _eth_usd_consumer_address; eth_usd_pricer = ChainlinkETHUSDPriceConsumer(eth_usd_consumer_address); eth_usd_pricer_decimals = eth_usd_pricer.getDecimals(); } function setTimelock(address new_timelock) external onlyByOwnerOrGovernance { timelock_address = new_timelock; } function setController(address _controller_address) external onlyByOwnerOrGovernance { controller_address = _controller_address; } function setPriceBand(uint256 _price_band) external onlyByOwnerOrGovernance { price_band = _price_band; } // Sets the FRAX_ETH Uniswap oracle address function setFRAXEthOracle(address _frax_oracle_addr, address _weth_address) public onlyByOwnerOrGovernance { frax_eth_oracle_address = _frax_oracle_addr; fraxEthOracle = UniswapPairOracle(_frax_oracle_addr); weth_address = _weth_address; } // Sets the FXS_ETH Uniswap oracle address function setFXSEthOracle(address _fxs_oracle_addr, address _weth_address) public onlyByOwnerOrGovernance { fxs_eth_oracle_address = _fxs_oracle_addr; fxsEthOracle = UniswapPairOracle(_fxs_oracle_addr); weth_address = _weth_address; } function toggleCollateralRatio() public onlyCollateralRatioPauser { collateral_ratio_paused = !collateral_ratio_paused; } /* ========== EVENTS ========== */ // Track FRAX burned event FRAXBurned(address indexed from, address indexed to, uint256 amount); // Track FRAX minted event FRAXMinted(address indexed from, address indexed to, uint256 amount); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./SafeMath.sol"; import "./FXS.sol"; import "./Frax.sol"; import "./ERC20.sol"; // import '../../Uniswap/TransferHelper.sol'; import "./UniswapPairOracle.sol"; import "./AccessControl.sol"; // import "../../Utils/StringHelpers.sol"; import "./FraxPoolLibrary.sol"; /* Same as FraxPool.sol, but has some gas optimizations */ contract FraxPool is AccessControl { using SafeMath for uint256; /* ========== STATE VARIABLES ========== */ ERC20 private collateral_token; address private collateral_address; address private owner_address; // address private oracle_address; address private frax_contract_address; address private fxs_contract_address; address private timelock_address; // Timelock address for the governance contract FRAXShares private FXS; FRAXStablecoin private FRAX; // UniswapPairOracle private oracle; UniswapPairOracle private collatEthOracle; address private collat_eth_oracle_address; address private weth_address; uint256 private minting_fee; uint256 private redemption_fee; mapping (address => uint256) public redeemFXSBalances; mapping (address => uint256) public redeemCollateralBalances; uint256 public unclaimedPoolCollateral; uint256 public unclaimedPoolFXS; mapping (address => uint256) public lastRedeemed; // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; uint256 private constant COLLATERAL_RATIO_PRECISION = 1e6; uint256 private constant COLLATERAL_RATIO_MAX = 1e6; // Number of decimals needed to get to 18 uint256 private missing_decimals; // Pool_ceiling is the total units of collateral that a pool contract can hold uint256 public pool_ceiling = 0; // Stores price of the collateral, if price is paused uint256 public pausedPrice = 0; // Bonus rate on FXS minted during recollateralizeFRAX(); 6 decimals of precision, set to 0.75% on genesis uint256 public bonus_rate = 7500; // Number of blocks to wait before being able to collectRedemption() uint256 public redemption_delay = 1; // AccessControl Roles bytes32 private constant MINT_PAUSER = keccak256("MINT_PAUSER"); bytes32 private constant REDEEM_PAUSER = keccak256("REDEEM_PAUSER"); bytes32 private constant BUYBACK_PAUSER = keccak256("BUYBACK_PAUSER"); bytes32 private constant RECOLLATERALIZE_PAUSER = keccak256("RECOLLATERALIZE_PAUSER"); bytes32 private constant COLLATERAL_PRICE_PAUSER = keccak256("COLLATERAL_PRICE_PAUSER"); // AccessControl state variables bool private mintPaused = false; bool private redeemPaused = false; bool private recollateralizePaused = false; bool private buyBackPaused = false; bool private collateralPricePaused = false; /* ========== MODIFIERS ========== */ modifier onlyByOwnerOrGovernance() { require(msg.sender == timelock_address || msg.sender == owner_address, "You are not the owner or the governance timelock"); _; } modifier notRedeemPaused() { require(redeemPaused == false, "Redeeming is paused"); _; } modifier notMintPaused() { require(mintPaused == false, "Minting is paused"); _; } /* ========== CONSTRUCTOR ========== */ constructor( address _frax_contract_address, address _fxs_contract_address, address _collateral_address, address _creator_address, address _timelock_address, uint256 _pool_ceiling ) public { FRAX = FRAXStablecoin(_frax_contract_address); FXS = FRAXShares(_fxs_contract_address); frax_contract_address = _frax_contract_address; fxs_contract_address = _fxs_contract_address; collateral_address = _collateral_address; timelock_address = _timelock_address; owner_address = _creator_address; collateral_token = ERC20(_collateral_address); pool_ceiling = _pool_ceiling; missing_decimals = uint(18).sub(collateral_token.decimals()); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); grantRole(MINT_PAUSER, timelock_address); grantRole(REDEEM_PAUSER, timelock_address); grantRole(RECOLLATERALIZE_PAUSER, timelock_address); grantRole(BUYBACK_PAUSER, timelock_address); grantRole(COLLATERAL_PRICE_PAUSER, timelock_address); } /* ========== VIEWS ========== */ // Returns dollar value of collateral held in this Frax pool function collatDollarBalance() public view returns (uint256) { uint256 eth_usd_price = FRAX.eth_usd_price(); uint256 eth_collat_price = collatEthOracle.consult(weth_address, (PRICE_PRECISION * (10 ** missing_decimals))); uint256 collat_usd_price = eth_usd_price.mul(PRICE_PRECISION).div(eth_collat_price); return (collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral)).mul(10 ** missing_decimals).mul(collat_usd_price).div(PRICE_PRECISION); //.mul(getCollateralPrice()).div(1e6); } // Returns the value of excess collateral held in this Frax pool, compared to what is needed to maintain the global collateral ratio function availableExcessCollatDV() public view returns (uint256) { uint256 total_supply = FRAX.totalSupply(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); uint256 global_collat_value = FRAX.globalCollateralValue(); if (global_collateral_ratio > COLLATERAL_RATIO_PRECISION) global_collateral_ratio = COLLATERAL_RATIO_PRECISION; // Handles an overcollateralized contract with CR > 1 uint256 required_collat_dollar_value_d18 = (total_supply.mul(global_collateral_ratio)).div(COLLATERAL_RATIO_PRECISION); // Calculates collateral needed to back each 1 FRAX with $1 of collateral at current collat ratio if (global_collat_value > required_collat_dollar_value_d18) return global_collat_value.sub(required_collat_dollar_value_d18); else return 0; } /* ========== PUBLIC FUNCTIONS ========== */ // Returns the price of the pool collateral in USD function getCollateralPrice() public view returns (uint256) { if(collateralPricePaused == true){ return pausedPrice; } else { uint256 eth_usd_price = FRAX.eth_usd_price(); return eth_usd_price.mul(PRICE_PRECISION).div(collatEthOracle.consult(weth_address, PRICE_PRECISION * (10 ** missing_decimals))); } } function setCollatETHOracle(address _collateral_weth_oracle_address, address _weth_address) external onlyByOwnerOrGovernance { collat_eth_oracle_address = _collateral_weth_oracle_address; collatEthOracle = UniswapPairOracle(_collateral_weth_oracle_address); weth_address = _weth_address; } // We separate out the 1t1, fractional and algorithmic minting functions for gas efficiency function mint1t1FRAX(uint256 collateral_amount, uint256 FRAX_out_min) external notMintPaused { uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio >= COLLATERAL_RATIO_MAX, "Collateral ratio must be >= 1"); require((collateral_token.balanceOf(address(this))).sub(unclaimedPoolCollateral).add(collateral_amount) <= pool_ceiling, "[Pool's Closed]: Ceiling reached"); (uint256 frax_amount_d18) = FraxPoolLibrary.calcMint1t1FRAX( getCollateralPrice(), minting_fee, collateral_amount_d18 ); //1 FRAX for each $1 worth of collateral require(FRAX_out_min <= frax_amount_d18, "Slippage limit reached"); collateral_token.transferFrom(msg.sender, address(this), collateral_amount); FRAX.pool_mint(msg.sender, frax_amount_d18); } // 0% collateral-backed function mintAlgorithmicFRAX(uint256 fxs_amount_d18, uint256 FRAX_out_min) external notMintPaused { uint256 fxs_price = FRAX.fxs_price(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio == 0, "Collateral ratio must be 0"); (uint256 frax_amount_d18) = FraxPoolLibrary.calcMintAlgorithmicFRAX( minting_fee, fxs_price, // X FXS / 1 USD fxs_amount_d18 ); require(FRAX_out_min <= frax_amount_d18, "Slippage limit reached"); FXS.pool_burn_from(msg.sender, fxs_amount_d18); FRAX.pool_mint(msg.sender, frax_amount_d18); } // Will fail if fully collateralized or fully algorithmic // > 0% and < 100% collateral-backed function mintFractionalFRAX(uint256 collateral_amount, uint256 fxs_amount, uint256 FRAX_out_min) external notMintPaused { uint256 frax_price = FRAX.frax_price(); uint256 fxs_price = FRAX.fxs_price(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio < COLLATERAL_RATIO_MAX && global_collateral_ratio > 0, "Collateral ratio needs to be between .000001 and .999999"); require(collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral).add(collateral_amount) <= pool_ceiling, "Pool ceiling reached, no more FRAX can be minted with this collateral"); uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals); FraxPoolLibrary.MintFF_Params memory input_params = FraxPoolLibrary.MintFF_Params( minting_fee, fxs_price, frax_price, getCollateralPrice(), fxs_amount, collateral_amount_d18, (collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral)), pool_ceiling, global_collateral_ratio ); (uint256 mint_amount, uint256 fxs_needed) = FraxPoolLibrary.calcMintFractionalFRAX(input_params); require(FRAX_out_min <= mint_amount, "Slippage limit reached"); require(fxs_needed <= fxs_amount, "Not enough FXS inputted"); FXS.pool_burn_from(msg.sender, fxs_needed); collateral_token.transferFrom(msg.sender, address(this), collateral_amount); FRAX.pool_mint(msg.sender, mint_amount); } // Redeem collateral. 100% collateral-backed function redeem1t1FRAX(uint256 FRAX_amount, uint256 COLLATERAL_out_min) external notRedeemPaused { uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio == COLLATERAL_RATIO_MAX, "Collateral ratio must be == 1"); // Need to adjust for decimals of collateral uint256 FRAX_amount_precision = FRAX_amount.div(10 ** missing_decimals); (uint256 collateral_needed) = FraxPoolLibrary.calcRedeem1t1FRAX( getCollateralPrice(), FRAX_amount_precision, redemption_fee ); require(collateral_needed <= collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral), "Not enough collateral in pool"); redeemCollateralBalances[msg.sender] = redeemCollateralBalances[msg.sender].add(collateral_needed); unclaimedPoolCollateral = unclaimedPoolCollateral.add(collateral_needed); lastRedeemed[msg.sender] = block.number; require(COLLATERAL_out_min <= collateral_needed, "Slippage limit reached"); // Move all external functions to the end FRAX.pool_burn_from(msg.sender, FRAX_amount); } // Will fail if fully collateralized or algorithmic // Redeem FRAX for collateral and FXS. > 0% and < 100% collateral-backed function redeemFractionalFRAX(uint256 FRAX_amount, uint256 FXS_out_min, uint256 COLLATERAL_out_min) external notRedeemPaused { uint256 fxs_price = FRAX.fxs_price(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio < COLLATERAL_RATIO_MAX && global_collateral_ratio > 0, "Collateral ratio needs to be between .000001 and .999999"); uint256 col_price_usd = getCollateralPrice(); uint256 FRAX_amount_post_fee = FRAX_amount.sub((FRAX_amount.mul(redemption_fee)).div(PRICE_PRECISION)); uint256 fxs_dollar_value_d18 = FRAX_amount_post_fee.sub(FRAX_amount_post_fee.mul(global_collateral_ratio).div(PRICE_PRECISION)); uint256 fxs_amount = fxs_dollar_value_d18.mul(PRICE_PRECISION).div(fxs_price); // Need to adjust for decimals of collateral uint256 FRAX_amount_precision = FRAX_amount_post_fee.div(10 ** missing_decimals); uint256 collateral_dollar_value = FRAX_amount_precision.mul(global_collateral_ratio).div(PRICE_PRECISION); uint256 collateral_amount = collateral_dollar_value.mul(PRICE_PRECISION).div(col_price_usd); redeemCollateralBalances[msg.sender] = redeemCollateralBalances[msg.sender].add(collateral_amount); unclaimedPoolCollateral = unclaimedPoolCollateral.add(collateral_amount); redeemFXSBalances[msg.sender] = redeemFXSBalances[msg.sender].add(fxs_amount); unclaimedPoolFXS = unclaimedPoolFXS.add(fxs_amount); lastRedeemed[msg.sender] = block.number; require(collateral_amount <= collateral_token.balanceOf(address(this)).sub(unclaimedPoolCollateral), "Not enough collateral in pool"); require(COLLATERAL_out_min <= collateral_amount, "Slippage limit reached [collateral]"); require(FXS_out_min <= fxs_amount, "Slippage limit reached [FXS]"); // Move all external functions to the end FRAX.pool_burn_from(msg.sender, FRAX_amount); FXS.pool_mint(address(this), fxs_amount); } // Redeem FRAX for FXS. 0% collateral-backed function redeemAlgorithmicFRAX(uint256 FRAX_amount, uint256 FXS_out_min) external notRedeemPaused { uint256 fxs_price = FRAX.fxs_price(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); require(global_collateral_ratio == 0, "Collateral ratio must be 0"); uint256 fxs_dollar_value_d18 = FRAX_amount; fxs_dollar_value_d18 = fxs_dollar_value_d18.sub((fxs_dollar_value_d18.mul(redemption_fee)).div(PRICE_PRECISION)); //apply redemption fee uint256 fxs_amount = fxs_dollar_value_d18.mul(PRICE_PRECISION).div(fxs_price); redeemFXSBalances[msg.sender] = redeemFXSBalances[msg.sender].add(fxs_amount); unclaimedPoolFXS = unclaimedPoolFXS.add(fxs_amount); lastRedeemed[msg.sender] = block.number; require(FXS_out_min <= fxs_amount, "Slippage limit reached"); // Move all external functions to the end FRAX.pool_burn_from(msg.sender, FRAX_amount); FXS.pool_mint(address(this), fxs_amount); } // After a redemption happens, transfer the newly minted FXS and owed collateral from this pool // contract to the user. Redemption is split into two functions to prevent flash loans from being able // to take out FRAX/collateral from the system, use an AMM to trade the new price, and then mint back into the system. function collectRedemption() external { require((lastRedeemed[msg.sender].add(redemption_delay)) <= block.number, "Must wait for redemption_delay blocks before collecting redemption"); bool sendFXS = false; bool sendCollateral = false; uint FXSAmount; uint CollateralAmount; // Use Checks-Effects-Interactions pattern if(redeemFXSBalances[msg.sender] > 0){ FXSAmount = redeemFXSBalances[msg.sender]; redeemFXSBalances[msg.sender] = 0; unclaimedPoolFXS = unclaimedPoolFXS.sub(FXSAmount); sendFXS = true; } if(redeemCollateralBalances[msg.sender] > 0){ CollateralAmount = redeemCollateralBalances[msg.sender]; redeemCollateralBalances[msg.sender] = 0; unclaimedPoolCollateral = unclaimedPoolCollateral.sub(CollateralAmount); sendCollateral = true; } if(sendFXS == true){ FXS.transfer(msg.sender, FXSAmount); } if(sendCollateral == true){ collateral_token.transfer(msg.sender, CollateralAmount); } } // When the protocol is recollateralizing, we need to give a discount of FXS to hit the new CR target // Thus, if the target collateral ratio is higher than the actual value of collateral, minters get FXS for adding collateral // This function simply rewards anyone that sends collateral to a pool with the same amount of FXS + the bonus rate // Anyone can call this function to recollateralize the protocol and take the extra FXS value from the bonus rate as an arb opportunity function recollateralizeFRAX(uint256 collateral_amount, uint256 FXS_out_min) external { require(recollateralizePaused == false, "Recollateralize is paused"); uint256 collateral_amount_d18 = collateral_amount * (10 ** missing_decimals); uint256 fxs_price = FRAX.fxs_price(); uint256 frax_total_supply = FRAX.totalSupply(); uint256 global_collateral_ratio = FRAX.global_collateral_ratio(); uint256 global_collat_value = FRAX.globalCollateralValue(); (uint256 collateral_units, uint256 amount_to_recollat) = FraxPoolLibrary.calcRecollateralizeFRAXInner( collateral_amount_d18, getCollateralPrice(), global_collat_value, frax_total_supply, global_collateral_ratio ); uint256 collateral_units_precision = collateral_units.div(10 ** missing_decimals); uint256 fxs_paid_back = amount_to_recollat.mul(uint(1e6).add(bonus_rate)).div(fxs_price); require(FXS_out_min <= fxs_paid_back, "Slippage limit reached"); collateral_token.transferFrom(msg.sender, address(this), collateral_units_precision); FXS.pool_mint(msg.sender, fxs_paid_back); } // Function can be called by an FXS holder to have the protocol buy back FXS with excess collateral value from a desired collateral pool // This can also happen if the collateral ratio > 1 function buyBackFXS(uint256 FXS_amount, uint256 COLLATERAL_out_min) external { require(buyBackPaused == false, "Buyback is paused"); uint256 fxs_price = FRAX.fxs_price(); FraxPoolLibrary.BuybackFXS_Params memory input_params = FraxPoolLibrary.BuybackFXS_Params( availableExcessCollatDV(), fxs_price, getCollateralPrice(), FXS_amount ); (uint256 collateral_equivalent_d18) = FraxPoolLibrary.calcBuyBackFXS(input_params); uint256 collateral_precision = collateral_equivalent_d18.div(10 ** missing_decimals); require(COLLATERAL_out_min <= collateral_precision, "Slippage limit reached"); // Give the sender their desired collateral and burn the FXS FXS.pool_burn_from(msg.sender, FXS_amount); collateral_token.transfer(msg.sender, collateral_precision); } /* ========== RESTRICTED FUNCTIONS ========== */ function toggleMinting() external { require(hasRole(MINT_PAUSER, msg.sender)); mintPaused = !mintPaused; } function toggleRedeeming() external { require(hasRole(REDEEM_PAUSER, msg.sender)); redeemPaused = !redeemPaused; } function toggleRecollateralize() external { require(hasRole(RECOLLATERALIZE_PAUSER, msg.sender)); recollateralizePaused = !recollateralizePaused; } function toggleBuyBack() external { require(hasRole(BUYBACK_PAUSER, msg.sender)); buyBackPaused = !buyBackPaused; } function toggleCollateralPrice() external { require(hasRole(COLLATERAL_PRICE_PAUSER, msg.sender)); // If pausing, set paused price; else if unpausing, clear pausedPrice if(collateralPricePaused == false){ pausedPrice = getCollateralPrice(); } else { pausedPrice = 0; } collateralPricePaused = !collateralPricePaused; } // Combined into one function due to 24KiB contract memory limit function setPoolParameters(uint256 new_ceiling, uint256 new_bonus_rate, uint256 new_redemption_delay) external onlyByOwnerOrGovernance { pool_ceiling = new_ceiling; bonus_rate = new_bonus_rate; redemption_delay = new_redemption_delay; minting_fee = FRAX.minting_fee(); redemption_fee = FRAX.redemption_fee(); } function setTimelock(address new_timelock) external onlyByOwnerOrGovernance { timelock_address = new_timelock; } function setOwner(address _owner_address) external onlyByOwnerOrGovernance { owner_address = _owner_address; } /* ========== EVENTS ========== */ }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; pragma experimental ABIEncoderV2; import "./SafeMath.sol"; library FraxPoolLibrary { using SafeMath for uint256; // Constants for various precisions uint256 private constant PRICE_PRECISION = 1e6; // ================ Structs ================ // Needed to lower stack size struct MintFF_Params { uint256 mint_fee; uint256 fxs_price_usd; uint256 frax_price_usd; uint256 col_price_usd; uint256 fxs_amount; uint256 collateral_amount; uint256 collateral_token_balance; uint256 pool_ceiling; uint256 col_ratio; } struct BuybackFXS_Params { uint256 excess_collateral_dollar_value_d18; uint256 fxs_price_usd; uint256 col_price_usd; uint256 FXS_amount; } // ================ Functions ================ function calcMint1t1FRAX(uint256 col_price, uint256 mint_fee, uint256 collateral_amount_d18) public pure returns (uint256) { uint256 col_price_usd = col_price; uint256 c_dollar_value_d18 = (collateral_amount_d18.mul(col_price_usd)).div(1e6); return c_dollar_value_d18.sub((c_dollar_value_d18.mul(mint_fee)).div(1e6)); } function calcMintAlgorithmicFRAX(uint256 mint_fee, uint256 fxs_price_usd, uint256 fxs_amount_d18) public pure returns (uint256) { uint256 fxs_dollar_value_d18 = fxs_amount_d18.mul(fxs_price_usd).div(1e6); return fxs_dollar_value_d18.sub((fxs_dollar_value_d18.mul(mint_fee)).div(1e6)); } // Must be internal because of the struct function calcMintFractionalFRAX(MintFF_Params memory params) internal pure returns (uint256, uint256) { // Since solidity truncates division, every division operation must be the last operation in the equation to ensure minimum error // The contract must check the proper ratio was sent to mint FRAX. We do this by seeing the minimum mintable FRAX based on each amount uint256 fxs_dollar_value_d18; uint256 c_dollar_value_d18; // Scoping for stack concerns { // USD amounts of the collateral and the FXS fxs_dollar_value_d18 = params.fxs_amount.mul(params.fxs_price_usd).div(1e6); c_dollar_value_d18 = params.collateral_amount.mul(params.col_price_usd).div(1e6); } uint calculated_fxs_dollar_value_d18 = (c_dollar_value_d18.mul(1e6).div(params.col_ratio)) .sub(c_dollar_value_d18); uint calculated_fxs_needed = calculated_fxs_dollar_value_d18.mul(1e6).div(params.fxs_price_usd); return ( (c_dollar_value_d18.add(calculated_fxs_dollar_value_d18)).sub(((c_dollar_value_d18.add(calculated_fxs_dollar_value_d18)).mul(params.mint_fee)).div(1e6)), calculated_fxs_needed ); } function calcRedeem1t1FRAX(uint256 col_price_usd, uint256 FRAX_amount, uint256 redemption_fee) public pure returns (uint256) { uint256 collateral_needed_d18 = FRAX_amount.mul(1e6).div(col_price_usd); return collateral_needed_d18.sub((collateral_needed_d18.mul(redemption_fee)).div(1e6)); } // Must be internal because of the struct function calcBuyBackFXS(BuybackFXS_Params memory params) internal pure returns (uint256) { // If the total collateral value is higher than the amount required at the current collateral ratio then buy back up to the possible FXS with the desired collateral require(params.excess_collateral_dollar_value_d18 > 0, "No excess collateral to buy back!"); // Make sure not to take more than is available uint256 fxs_dollar_value_d18 = params.FXS_amount.mul(params.fxs_price_usd).div(1e6); require(fxs_dollar_value_d18 <= params.excess_collateral_dollar_value_d18, "You are trying to buy back more than the excess!"); // Get the equivalent amount of collateral based on the market value of FXS provided uint256 collateral_equivalent_d18 = fxs_dollar_value_d18.mul(1e6).div(params.col_price_usd); //collateral_equivalent_d18 = collateral_equivalent_d18.sub((collateral_equivalent_d18.mul(params.buyback_fee)).div(1e6)); return ( collateral_equivalent_d18 ); } // Returns value of collateral that must increase to reach recollateralization target (if 0 means no recollateralization) function recollateralizeAmount(uint256 total_supply, uint256 global_collateral_ratio, uint256 global_collat_value) public pure returns (uint256) { uint256 target_collat_value = total_supply.mul(global_collateral_ratio).div(1e6); // We want 18 decimals of precision so divide by 1e6; total_supply is 1e18 and global_collateral_ratio is 1e6 // Subtract the current value of collateral from the target value needed, if higher than 0 then system needs to recollateralize uint256 recollateralization_left = target_collat_value.sub(global_collat_value); // If recollateralization is not needed, throws a subtraction underflow return(recollateralization_left); } function calcRecollateralizeFRAXInner( uint256 collateral_amount, uint256 col_price, uint256 global_collat_value, uint256 frax_total_supply, uint256 global_collateral_ratio ) public pure returns (uint256, uint256) { uint256 collat_value_attempted = collateral_amount.mul(col_price).div(1e6); uint256 effective_collateral_ratio = global_collat_value.mul(1e6).div(frax_total_supply); //returns it in 1e6 uint256 recollat_possible = (global_collateral_ratio.mul(frax_total_supply).sub(frax_total_supply.mul(effective_collateral_ratio))).div(1e6); uint256 amount_to_recollat; if(collat_value_attempted <= recollat_possible){ amount_to_recollat = collat_value_attempted; } else { amount_to_recollat = recollat_possible; } return (amount_to_recollat.mul(1e6).div(col_price), amount_to_recollat); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./Context.sol"; import "./ERC20Custom.sol"; import "./IERC20.sol"; import "./Frax.sol"; import "./SafeMath.sol"; import "./AccessControl.sol"; contract FRAXShares is ERC20Custom, AccessControl { using SafeMath for uint256; /* ========== STATE VARIABLES ========== */ string public symbol; string public name; uint8 public constant decimals = 18; address public FRAXStablecoinAdd; uint256 public constant genesis_supply = 100000000e18; // 100M is printed upon genesis uint256 public FXS_DAO_min; // Minimum FXS required to join DAO groups address public owner_address; address public oracle_address; address public timelock_address; // Governance timelock address FRAXStablecoin private FRAX; bool public trackingVotes = true; // Tracking votes (only change if need to disable votes) // A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } // A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; // The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /* ========== MODIFIERS ========== */ modifier onlyPools() { require(FRAX.frax_pools(msg.sender) == true, "Only frax pools can mint new FRAX"); _; } modifier onlyByOwnerOrGovernance() { require(msg.sender == owner_address || msg.sender == timelock_address, "You are not an owner or the governance timelock"); _; } /* ========== CONSTRUCTOR ========== */ constructor( string memory _name, string memory _symbol, address _oracle_address, address _owner_address, address _timelock_address ) public { name = _name; symbol = _symbol; owner_address = _owner_address; oracle_address = _oracle_address; timelock_address = _timelock_address; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _mint(owner_address, genesis_supply); // Do a checkpoint for the owner _writeCheckpoint(owner_address, 0, 0, uint96(genesis_supply)); } /* ========== RESTRICTED FUNCTIONS ========== */ function setOracle(address new_oracle) external onlyByOwnerOrGovernance { oracle_address = new_oracle; } function setTimelock(address new_timelock) external onlyByOwnerOrGovernance { timelock_address = new_timelock; } function setFRAXAddress(address frax_contract_address) external onlyByOwnerOrGovernance { FRAX = FRAXStablecoin(frax_contract_address); } function setFXSMinDAO(uint256 min_FXS) external onlyByOwnerOrGovernance { FXS_DAO_min = min_FXS; } function setOwner(address _owner_address) external onlyByOwnerOrGovernance { owner_address = _owner_address; } function mint(address to, uint256 amount) public onlyPools { _mint(to, amount); } // This function is what other frax pools will call to mint new FXS (similar to the FRAX mint) function pool_mint(address m_address, uint256 m_amount) external onlyPools { if(trackingVotes){ uint32 srcRepNum = numCheckpoints[address(this)]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepNum - 1].votes : 0; uint96 srcRepNew = add96(srcRepOld, uint96(m_amount), "pool_mint new votes overflows"); _writeCheckpoint(address(this), srcRepNum, srcRepOld, srcRepNew); // mint new votes trackVotes(address(this), m_address, uint96(m_amount)); } super._mint(m_address, m_amount); emit FXSMinted(address(this), m_address, m_amount); } // This function is what other frax pools will call to burn FXS function pool_burn_from(address b_address, uint256 b_amount) external onlyPools { if(trackingVotes){ trackVotes(b_address, address(this), uint96(b_amount)); uint32 srcRepNum = numCheckpoints[address(this)]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, uint96(b_amount), "pool_burn_from new votes underflows"); _writeCheckpoint(address(this), srcRepNum, srcRepOld, srcRepNew); // burn votes } super._burnFrom(b_address, b_amount); emit FXSBurned(b_address, address(this), b_amount); } function toggleVotes() external onlyByOwnerOrGovernance { trackingVotes = !trackingVotes; } /* ========== OVERRIDDEN PUBLIC FUNCTIONS ========== */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { if(trackingVotes){ // Transfer votes trackVotes(_msgSender(), recipient, uint96(amount)); } _transfer(_msgSender(), recipient, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { if(trackingVotes){ // Transfer votes trackVotes(sender, recipient, uint96(amount)); } _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /* ========== PUBLIC FUNCTIONS ========== */ /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) public view returns (uint96) { require(blockNumber < block.number, "FXS::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } /* ========== INTERNAL FUNCTIONS ========== */ // From compound's _moveDelegates // Keep track of votes. "Delegates" is a misnomer here function trackVotes(address srcRep, address dstRep, uint96 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "FXS::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "FXS::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint(address voter, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal { uint32 blockNumber = safe32(block.number, "FXS::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[voter][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[voter][nCheckpoints - 1].votes = newVotes; } else { checkpoints[voter][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[voter] = nCheckpoints + 1; } emit VoterVotesChanged(voter, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } /* ========== EVENTS ========== */ /// @notice An event thats emitted when a voters account's vote balance changes event VoterVotesChanged(address indexed voter, uint previousBalance, uint newBalance); // Track FXS burned event FXSBurned(address indexed from, address indexed to, uint256 amount); // Track FXS minted event FXSMinted(address indexed from, address indexed to, uint256 amount); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./FXS.sol"; // From https://compound.finance/docs/governance // and https://github.com/compound-finance/compound-protocol/tree/master/contracts/Governance contract GovernorAlpha { /// @notice The name of this contract string public constant name = "FXS Governor Alpha"; /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed function quorumVotes() public pure returns (uint) { return 4000000e18; } // 4,000,000 = 4% of FXS /// @notice The number of votes required in order for a voter to become a proposer function proposalThreshold() public pure returns (uint) { return 1000000e18; } // 1,000,000 = 1% of FXS /// @notice The maximum number of actions that can be included in a proposal function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions /// @notice The delay before voting on a proposal may take place, once proposed // This also helps protect against flash loan attacks because only the vote balance at the proposal start block is considered function votingDelay() public pure returns (uint) { return 1; } // 1 block /// @notice The duration of voting on a proposal, in blocks // function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks) uint public votingPeriod = 17280; /// @notice The address of the Timelock TimelockInterface public timelock; // The address of the FXS token FRAXShares public fxs; /// @notice The address of the Governor Guardian address public guardian; /// @notice The total number of proposals uint public proposalCount = 0; struct Proposal { // @notice Unique id for looking up a proposal uint id; // @notice Creator of the proposal address proposer; // @notice The timestamp that the proposal will be available for execution, set once the vote succeeds uint eta; // @notice the ordered list of target addresses for calls to be made address[] targets; // @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made uint[] values; // @notice The ordered list of function signatures to be called string[] signatures; // @notice The ordered list of calldata to be passed to each call bytes[] calldatas; // @notice The block at which voting begins: holders must delegate their votes prior to this block uint startBlock; // @notice The block at which voting ends: votes must be cast prior to this block uint endBlock; // @notice Current number of votes in favor of this proposal uint forVotes; // @notice Current number of votes in opposition to this proposal uint againstVotes; // @notice Flag marking whether the proposal has been canceled bool canceled; // @notice Flag marking whether the proposal has been executed bool executed; // @notice Title of the proposal (human-readable) string title; // @notice Description of the proposall (human-readable) string description; // @notice Receipts of ballots for the entire set of voters mapping (address => Receipt) receipts; } /// @notice Ballot receipt record for a voter struct Receipt { // @notice Whether or not a vote has been cast bool hasVoted; // @notice Whether or not the voter supports the proposal bool support; // @notice The number of votes the voter had, which were cast uint96 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired, Executed } /// @notice The official record of all proposals ever proposed mapping (uint => Proposal) public proposals; /// @notice The latest proposal for each proposer mapping (address => uint) public latestProposalIds; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the ballot struct used by the contract bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)"); /// @notice An event emitted when a new proposal is created event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description); /// @notice An event emitted when a vote has been cast on a proposal event VoteCast(address voter, uint proposalId, bool support, uint votes); /// @notice An event emitted when a proposal has been canceled event ProposalCanceled(uint id); /// @notice An event emitted when a proposal has been queued in the Timelock event ProposalQueued(uint id, uint eta); /// @notice An event emitted when a proposal has been executed in the Timelock event ProposalExecuted(uint id); constructor(address timelock_, address fxs_, address guardian_) public { timelock = TimelockInterface(timelock_); fxs = FRAXShares(fxs_); guardian = guardian_; } function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory title, string memory description) public returns (uint) { require(fxs.getPriorVotes(msg.sender, sub256(block.number, 1)) >= proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold"); require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch"); require(targets.length != 0, "GovernorAlpha::propose: must provide actions"); require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions"); uint latestProposalId = latestProposalIds[msg.sender]; if (latestProposalId != 0) { ProposalState proposersLatestProposalState = state(latestProposalId); require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal"); require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal"); } uint startBlock = add256(block.number, votingDelay()); uint endBlock = add256(startBlock, votingPeriod); proposalCount++; Proposal memory newProposal = Proposal({ id: proposalCount, proposer: msg.sender, eta: 0, targets: targets, values: values, signatures: signatures, calldatas: calldatas, startBlock: startBlock, endBlock: endBlock, forVotes: 0, againstVotes: 0, canceled: false, executed: false, title: title, description: description }); proposals[newProposal.id] = newProposal; latestProposalIds[newProposal.proposer] = newProposal.id; emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description); return newProposal.id; } function queue(uint proposalId) public { require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it succeeded"); Proposal storage proposal = proposals[proposalId]; uint eta = add256(block.timestamp, timelock.delay()); for (uint i = 0; i < proposal.targets.length; i++) { _queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta); } proposal.eta = eta; emit ProposalQueued(proposalId, eta); } function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal { require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta"); timelock.queueTransaction(target, value, signature, data, eta); } function execute(uint proposalId) public payable { require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued"); Proposal storage proposal = proposals[proposalId]; proposal.executed = true; for (uint i = 0; i < proposal.targets.length; i++) { timelock.executeTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalExecuted(proposalId); } function cancel(uint proposalId) public { ProposalState state = state(proposalId); require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal"); Proposal storage proposal = proposals[proposalId]; require(msg.sender == guardian || fxs.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer at or above threshold"); proposal.canceled = true; for (uint i = 0; i < proposal.targets.length; i++) { timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta); } emit ProposalCanceled(proposalId); } function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) { Proposal storage p = proposals[proposalId]; return (p.targets, p.values, p.signatures, p.calldatas); } function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) { return proposals[proposalId].receipts[voter]; } function state(uint proposalId) public view returns (ProposalState) { require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id"); Proposal storage proposal = proposals[proposalId]; if (proposal.canceled) { return ProposalState.Canceled; } else if (block.number <= proposal.startBlock) { return ProposalState.Pending; } else if (block.number <= proposal.endBlock) { return ProposalState.Active; } else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) { return ProposalState.Defeated; } else if (proposal.eta == 0) { return ProposalState.Succeeded; } else if (proposal.executed) { return ProposalState.Executed; } else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) { return ProposalState.Expired; } else { return ProposalState.Queued; } } function castVote(uint proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); } function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature"); return _castVote(signatory, proposalId, support); } function _castVote(address voter, uint proposalId, bool support) internal { require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed"); Proposal storage proposal = proposals[proposalId]; Receipt storage receipt = proposal.receipts[voter]; require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted"); uint96 votes = fxs.getPriorVotes(voter, proposal.startBlock); if (support) { proposal.forVotes = add256(proposal.forVotes, votes); } else { proposal.againstVotes = add256(proposal.againstVotes, votes); } receipt.hasVoted = true; receipt.support = support; receipt.votes = votes; emit VoteCast(voter, proposalId, support, votes); } function __acceptAdmin() public { require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian"); timelock.acceptAdmin(); } function __abdicate() public { require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian"); guardian = address(0); } function __setVotingPeriod(uint period) public { require(msg.sender == guardian, "GovernorAlpha::__setVotingPeriod: sender must be gov guardian"); votingPeriod = period; } function __setTimelockAddress(address timelock_) public { require(msg.sender == guardian, "GovernorAlpha::__setTimelockAddress: sender must be gov guardian"); timelock = TimelockInterface(timelock_); } function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public { require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian"); timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public { require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian"); timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta); } function add256(uint256 a, uint256 b) internal pure returns (uint) { uint c = a + b; require(c >= a, "addition overflow"); return c; } function sub256(uint256 a, uint256 b) internal pure returns (uint) { require(b <= a, "subtraction underflow"); return a - b; } function getChainId() internal pure returns (uint) { uint chainId; assembly { chainId := chainid() } return chainId; } } interface TimelockInterface { function delay() external view returns (uint); function GRACE_PERIOD() external view returns (uint); function acceptAdmin() external; function queuedTransactions(bytes32 hash) external view returns (bool); function queueTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external returns (bytes32); function cancelTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external; function executeTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external payable returns (bytes memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./Context.sol"; import "./SafeMath.sol"; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ 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); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; interface IStakingRewards { // Views function lastTimeRewardApplicable() external view returns (uint256); function rewardPerToken() external view returns (uint256); function earned(address account) external view returns (uint256); function getRewardForDuration() external view returns (uint256); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); // Mutative function stake(uint256 amount) external; function withdraw(uint256 amount) external; function getReward() external; //function exit() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; interface IUniswapV2Callee { function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; interface IUniswapV2ERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountETH); function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountETH); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external payable; function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function transferFrom(address src, address dst, uint wad) external returns (bool); function withdraw(uint) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; contract MigrationHelper { address public owner; uint256 public gov_to_timelock_eta; modifier restricted() { if (msg.sender == owner) _; } constructor(address _owner) public { owner = _owner; } function setGovToTimeLockETA(uint256 _eta) public restricted { gov_to_timelock_eta = _eta; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; contract Migrations { address public owner; uint public last_completed_migration; modifier restricted() { if (msg.sender == owner) _; } constructor() public { owner = msg.sender; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; // https://docs.synthetix.io/contracts/Owned contract Owned { address public owner; address public nominatedOwner; constructor(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; // Inheritance import "./Owned.sol"; // https://docs.synthetix.io/contracts/Pausable abstract contract Pausable is Owned { uint public lastPauseTime; bool public paused; constructor() internal { // This contract is abstract, and thus cannot be instantiated directly require(owner != address(0), "Owner must be set"); // Paused will be false, and lastPauseTime will be 0 upon initialisation } /** * @notice Change the paused state of the contract * @dev Only the contract owner may call this. */ function setPaused(bool _paused) external onlyOwner { // Ensure we're actually changing the state before we do anything if (_paused == paused) { return; } // Set our paused state. paused = _paused; // If applicable, set the last pause time. if (paused) { lastPauseTime = now; } // Let everyone know that our pause state has changed. emit PauseChanged(paused); } event PauseChanged(bool isPaused); modifier notPaused { require(!paused, "This action cannot be performed while the contract is paused"); _; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./FraxPool.sol"; contract Pool_USDT is FraxPool { address public USDT_address; constructor( address _frax_contract_address, address _fxs_contract_address, address _collateral_address, address _creator_address, address _timelock_address, uint256 _pool_ceiling ) FraxPool(_frax_contract_address, _fxs_contract_address, _collateral_address, _creator_address, _timelock_address, _pool_ceiling) public { _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); USDT_address = _collateral_address; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; /** * @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]. */ 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 () internal { _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; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; // Inheritance import "./Owned.sol"; // https://docs.synthetix.io/contracts/RewardsDistributionRecipient abstract contract RewardsDistributionRecipient is Owned { address public rewardsDistribution; //function notifyRewardAmount(uint256 reward) external virtual; modifier onlyRewardsDistribution() { require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract"); _; } function setRewardsDistribution(address _rewardsDistribution) external onlyOwner { rewardsDistribution = _rewardsDistribution; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./IERC20.sol"; import "./SafeMath.sol"; import "./Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; 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' // solhint-disable-next-line max-line-length 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).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _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 // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @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) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts 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. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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 mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./StakingRewards.sol"; contract Stake_FRAX_FXS is StakingRewards { constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken, address _frax_address, address _timelock_address, uint256 _pool_weight ) StakingRewards(_owner, _rewardsDistribution, _rewardsToken, _stakingToken, _frax_address, _timelock_address, _pool_weight) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./StakingRewards.sol"; contract Stake_FRAX_USDC is StakingRewards { constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken, address _frax_address, address _timelock_address, uint256 _pool_weight ) StakingRewards(_owner, _rewardsDistribution, _rewardsToken, _stakingToken, _frax_address, _timelock_address, _pool_weight) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./StakingRewards.sol"; contract Stake_FRAX_WETH is StakingRewards { constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken, address _frax_address, address _timelock_address, uint256 _pool_weight ) StakingRewards(_owner, _rewardsDistribution, _rewardsToken, _stakingToken, _frax_address, _timelock_address, _pool_weight) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "./StakingRewards.sol"; contract Stake_FXS_WETH is StakingRewards { constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken, address _frax_address, address _timelock_address, uint256 _pool_weight ) StakingRewards(_owner, _rewardsDistribution, _rewardsToken, _stakingToken, _frax_address, _timelock_address, _pool_weight) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; // Stolen with love from Synthetixio // https://raw.githubusercontent.com/Synthetixio/synthetix/develop/contracts/StakingRewards.sol import "./Math.sol"; import "./SafeMath.sol"; import "./ERC20.sol"; import './TransferHelper.sol'; import "./SafeERC20.sol"; import "./Frax.sol"; import "./ReentrancyGuard.sol"; import "./StringHelpers.sol"; // Inheritance import "./IStakingRewards.sol"; import "./RewardsDistributionRecipient.sol"; import "./Pausable.sol"; contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, ReentrancyGuard, Pausable { using SafeMath for uint256; using SafeERC20 for ERC20; /* ========== STATE VARIABLES ========== */ FRAXStablecoin private FRAX; ERC20 public rewardsToken; ERC20 public stakingToken; uint256 public periodFinish; // Constant for various precisions uint256 private constant PRICE_PRECISION = 1e6; uint256 private constant MULTIPLIER_BASE = 1e6; // Max reward per second uint256 public rewardRate; // uint256 public rewardsDuration = 86400 hours; uint256 public rewardsDuration = 604800; // 7 * 86400 (7 days) uint256 public lastUpdateTime; uint256 public rewardPerTokenStored = 0; uint256 private pool_weight; // This staking pool's percentage of the total FXS being distributed by all pools, 6 decimals of precision address public owner_address; address public timelock_address; // Governance timelock address uint256 public locked_stake_max_multiplier = 3000000; // 6 decimals of precision. 1x = 1000000 uint256 public locked_stake_time_for_max_multiplier = 3 * 365 * 86400; // 3 years uint256 public locked_stake_min_time = 604800; // 7 * 86400 (7 days) string private locked_stake_min_time_str = "604800"; // 7 days on genesis uint256 public cr_boost_max_multiplier = 3000000; // 6 decimals of precision. 1x = 1000000 mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; uint256 private _staking_token_supply = 0; uint256 private _staking_token_boosted_supply = 0; mapping(address => uint256) private _unlocked_balances; mapping(address => uint256) private _locked_balances; mapping(address => uint256) private _boosted_balances; mapping(address => LockedStake[]) private lockedStakes; mapping(address => bool) public greylist; bool public unlockedStakes; // Release lock stakes in case of system migration struct LockedStake { bytes32 kek_id; uint256 start_timestamp; uint256 amount; uint256 ending_timestamp; uint256 multiplier; // 6 decimals of precision. 1x = 1000000 } /* ========== CONSTRUCTOR ========== */ constructor( address _owner, address _rewardsDistribution, address _rewardsToken, address _stakingToken, address _frax_address, address _timelock_address, uint256 _pool_weight ) public Owned(_owner){ owner_address = _owner; rewardsToken = ERC20(_rewardsToken); stakingToken = ERC20(_stakingToken); FRAX = FRAXStablecoin(_frax_address); rewardsDistribution = _rewardsDistribution; lastUpdateTime = block.timestamp; timelock_address = _timelock_address; pool_weight = _pool_weight; rewardRate = 380517503805175038; // (uint256(12000000e18)).div(365 * 86400); // Base emission rate of 12M FXS over the first year rewardRate = rewardRate.mul(pool_weight).div(1e6); unlockedStakes = false; } /* ========== VIEWS ========== */ function totalSupply() external override view returns (uint256) { return _staking_token_supply; } function totalBoostedSupply() external view returns (uint256) { return _staking_token_boosted_supply; } function stakingMultiplier(uint256 secs) public view returns (uint256) { uint256 multiplier = uint(MULTIPLIER_BASE).add(secs.mul(locked_stake_max_multiplier.sub(MULTIPLIER_BASE)).div(locked_stake_time_for_max_multiplier)); if (multiplier > locked_stake_max_multiplier) multiplier = locked_stake_max_multiplier; return multiplier; } function crBoostMultiplier() public view returns (uint256) { uint256 multiplier = uint(MULTIPLIER_BASE).add((uint(MULTIPLIER_BASE).sub(FRAX.global_collateral_ratio())).mul(cr_boost_max_multiplier.sub(MULTIPLIER_BASE)).div(MULTIPLIER_BASE) ); return multiplier; } // Total unlocked and locked liquidity tokens function balanceOf(address account) external override view returns (uint256) { return (_unlocked_balances[account]).add(_locked_balances[account]); } // Total unlocked liquidity tokens function unlockedBalanceOf(address account) external view returns (uint256) { return _unlocked_balances[account]; } // Total locked liquidity tokens function lockedBalanceOf(address account) public view returns (uint256) { return _locked_balances[account]; } // Total 'balance' used for calculating the percent of the pool the account owns // Takes into account the locked stake time multiplier function boostedBalanceOf(address account) external view returns (uint256) { return _boosted_balances[account]; } function lockedStakesOf(address account) external view returns (LockedStake[] memory) { return lockedStakes[account]; } function stakingDecimals() external view returns (uint256) { return stakingToken.decimals(); } function rewardsFor(address account) external view returns (uint256) { // You may have use earned() instead, because of the order in which the contract executes return rewards[account]; } function lastTimeRewardApplicable() public override view returns (uint256) { return Math.min(block.timestamp, periodFinish); } function rewardPerToken() public override view returns (uint256) { if (_staking_token_supply == 0) { return rewardPerTokenStored; } else { return rewardPerTokenStored.add( lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(crBoostMultiplier()).mul(1e18).div(PRICE_PRECISION).div(_staking_token_boosted_supply) ); } } function earned(address account) public override view returns (uint256) { return _boosted_balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]); } // function earned(address account) public override view returns (uint256) { // return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).add(rewards[account]); // } function getRewardForDuration() external override view returns (uint256) { return rewardRate.mul(rewardsDuration).mul(crBoostMultiplier()).div(PRICE_PRECISION); } /* ========== MUTATIVE FUNCTIONS ========== */ function stake(uint256 amount) external override nonReentrant notPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); require(greylist[msg.sender] == false, "address has been greylisted"); // Pull the tokens from the staker TransferHelper.safeTransferFrom(address(stakingToken), msg.sender, address(this), amount); // Staking token supply and boosted supply _staking_token_supply = _staking_token_supply.add(amount); _staking_token_boosted_supply = _staking_token_boosted_supply.add(amount); // Staking token balance and boosted balance _unlocked_balances[msg.sender] = _unlocked_balances[msg.sender].add(amount); _boosted_balances[msg.sender] = _boosted_balances[msg.sender].add(amount); emit Staked(msg.sender, amount); } function stakeLocked(uint256 amount, uint256 secs) external nonReentrant notPaused updateReward(msg.sender) { require(amount > 0, "Cannot stake 0"); require(secs > 0, "Cannot wait for a negative number"); require(greylist[msg.sender] == false, "address has been greylisted"); require(secs >= locked_stake_min_time, StringHelpers.strConcat("Minimum stake time not met (", locked_stake_min_time_str, ")") ); uint256 multiplier = stakingMultiplier(secs); uint256 boostedAmount = amount.mul(multiplier).div(PRICE_PRECISION); lockedStakes[msg.sender].push(LockedStake( keccak256(abi.encodePacked(msg.sender, block.timestamp, amount)), block.timestamp, amount, block.timestamp.add(secs), multiplier )); // Pull the tokens from the staker TransferHelper.safeTransferFrom(address(stakingToken), msg.sender, address(this), amount); // Staking token supply and boosted supply _staking_token_supply = _staking_token_supply.add(amount); _staking_token_boosted_supply = _staking_token_boosted_supply.add(boostedAmount); // Staking token balance and boosted balance _locked_balances[msg.sender] = _locked_balances[msg.sender].add(amount); _boosted_balances[msg.sender] = _boosted_balances[msg.sender].add(boostedAmount); emit StakeLocked(msg.sender, amount, secs); } function withdraw(uint256 amount) public override nonReentrant updateReward(msg.sender) { require(amount > 0, "Cannot withdraw 0"); // Staking token balance and boosted balance _unlocked_balances[msg.sender] = _unlocked_balances[msg.sender].sub(amount); _boosted_balances[msg.sender] = _boosted_balances[msg.sender].sub(amount); // Staking token supply and boosted supply _staking_token_supply = _staking_token_supply.sub(amount); _staking_token_boosted_supply = _staking_token_boosted_supply.sub(amount); // Give the tokens to the withdrawer stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function withdrawLocked(bytes32 kek_id) public nonReentrant updateReward(msg.sender) { LockedStake memory thisStake; thisStake.amount = 0; uint theIndex; for (uint i = 0; i < lockedStakes[msg.sender].length; i++){ if (kek_id == lockedStakes[msg.sender][i].kek_id){ thisStake = lockedStakes[msg.sender][i]; theIndex = i; break; } } require(thisStake.kek_id == kek_id, "Stake not found"); require(block.timestamp >= thisStake.ending_timestamp || unlockedStakes == true, "Stake is still locked!"); uint256 theAmount = thisStake.amount; uint256 boostedAmount = theAmount.mul(thisStake.multiplier).div(PRICE_PRECISION); if (theAmount > 0){ // Staking token balance and boosted balance _locked_balances[msg.sender] = _locked_balances[msg.sender].sub(theAmount); _boosted_balances[msg.sender] = _boosted_balances[msg.sender].sub(boostedAmount); // Staking token supply and boosted supply _staking_token_supply = _staking_token_supply.sub(theAmount); _staking_token_boosted_supply = _staking_token_boosted_supply.sub(boostedAmount); // Remove the stake from the array delete lockedStakes[msg.sender][theIndex]; // Give the tokens to the withdrawer stakingToken.safeTransfer(msg.sender, theAmount); emit WithdrawnLocked(msg.sender, theAmount, kek_id); } } function getReward() public override nonReentrant updateReward(msg.sender) { uint256 reward = rewards[msg.sender]; if (reward > 0) { rewards[msg.sender] = 0; rewardsToken.transfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } /* function exit() external override { withdraw(_balances[msg.sender]); // TODO: Add locked stakes too? getReward(); } */ function renewIfApplicable() external { if (block.timestamp > periodFinish) { retroCatchUp(); } } // If the period expired, renew it function retroCatchUp() internal { // Failsafe check require(block.timestamp > periodFinish, "Period has not expired yet!"); // Ensure the provided reward amount is not more than the balance in the contract. // This keeps the reward rate in the right range, preventing overflows due to // very high values of rewardRate in the earned and rewardsPerToken functions; // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. uint256 num_periods_elapsed = uint256(block.timestamp.sub(periodFinish)) / rewardsDuration; // Floor division to the nearest period uint balance = rewardsToken.balanceOf(address(this)); require(rewardRate.mul(rewardsDuration).mul(crBoostMultiplier()).mul(num_periods_elapsed + 1).div(PRICE_PRECISION) <= balance, "Not enough FXS available for rewards!"); // uint256 old_lastUpdateTime = lastUpdateTime; // uint256 new_lastUpdateTime = block.timestamp; // lastUpdateTime = periodFinish; periodFinish = periodFinish.add((num_periods_elapsed.add(1)).mul(rewardsDuration)); rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); emit RewardsPeriodRenewed(address(stakingToken)); } /* ========== RESTRICTED FUNCTIONS ========== */ /* // This notifies people that the reward is being changed function notifyRewardAmount(uint256 reward) external override onlyRewardsDistribution updateReward(address(0)) { // Needed to make compiler happy // if (block.timestamp >= periodFinish) { // rewardRate = reward.mul(crBoostMultiplier()).div(rewardsDuration).div(PRICE_PRECISION); // } else { // uint256 remaining = periodFinish.sub(block.timestamp); // uint256 leftover = remaining.mul(rewardRate); // rewardRate = reward.mul(crBoostMultiplier()).add(leftover).div(rewardsDuration).div(PRICE_PRECISION); // } // // Ensure the provided reward amount is not more than the balance in the contract. // // This keeps the reward rate in the right range, preventing overflows due to // // very high values of rewardRate in the earned and rewardsPerToken functions; // // Reward + leftover must be less than 2^256 / 10^18 to avoid overflow. // uint balance = rewardsToken.balanceOf(address(this)); // require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high"); // lastUpdateTime = block.timestamp; // periodFinish = block.timestamp.add(rewardsDuration); // emit RewardAdded(reward); } */ // Added to support recovering LP Rewards from other systems to be distributed to holders function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance { // Admin cannot withdraw the staking token from the contract require(tokenAddress != address(stakingToken)); ERC20(tokenAddress).transfer(owner_address, tokenAmount); emit Recovered(tokenAddress, tokenAmount); } function setRewardsDuration(uint256 _rewardsDuration) external onlyByOwnerOrGovernance { require( periodFinish == 0 || block.timestamp > periodFinish, "Previous rewards period must be complete before changing the duration for the new period" ); rewardsDuration = _rewardsDuration; emit RewardsDurationUpdated(rewardsDuration); } function setMultipliers(uint256 _locked_stake_max_multiplier, uint256 _cr_boost_max_multiplier) external onlyByOwnerOrGovernance { require(_locked_stake_max_multiplier >= 1, "Multiplier must be greater than or equal to 1"); require(_cr_boost_max_multiplier >= 1, "Max CR Boost must be greater than or equal to 1"); locked_stake_max_multiplier = _locked_stake_max_multiplier; cr_boost_max_multiplier = _cr_boost_max_multiplier; emit MaxCRBoostMultiplier(cr_boost_max_multiplier); emit LockedStakeMaxMultiplierUpdated(locked_stake_max_multiplier); } function setLockedStakeTimeForMinAndMaxMultiplier(uint256 _locked_stake_time_for_max_multiplier, uint256 _locked_stake_min_time) external onlyByOwnerOrGovernance { require(_locked_stake_time_for_max_multiplier >= 1, "Multiplier Max Time must be greater than or equal to 1"); require(_locked_stake_min_time >= 1, "Multiplier Min Time must be greater than or equal to 1"); locked_stake_time_for_max_multiplier = _locked_stake_time_for_max_multiplier; locked_stake_min_time = _locked_stake_min_time; locked_stake_min_time_str = StringHelpers.uint2str(_locked_stake_min_time); emit LockedStakeTimeForMaxMultiplier(locked_stake_time_for_max_multiplier); emit LockedStakeMinTime(_locked_stake_min_time); } function initializeDefault() external onlyByOwnerOrGovernance { lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(rewardsDuration); emit DefaultInitialization(); } function greylistAddress(address _address) external onlyByOwnerOrGovernance { greylist[_address] = !(greylist[_address]); } function unlockStakes() external onlyByOwnerOrGovernance { unlockedStakes = !unlockedStakes; } function setRewardRate(uint256 _new_rate) external onlyByOwnerOrGovernance { rewardRate = _new_rate; } function setOwnerAndTimelock(address _new_owner, address _new_timelock) external onlyByOwnerOrGovernance { owner_address = _new_owner; timelock_address = _new_timelock; } /* ========== MODIFIERS ========== */ modifier updateReward(address account) { // Need to retro-adjust some things if the period hasn't been renewed, then start a new one if (block.timestamp > periodFinish) { retroCatchUp(); } else { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); } if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } modifier onlyByOwnerOrGovernance() { require(msg.sender == owner_address || msg.sender == timelock_address, "You are not the owner or the governance timelock"); _; } /* ========== EVENTS ========== */ event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event StakeLocked(address indexed user, uint256 amount, uint256 secs); event Withdrawn(address indexed user, uint256 amount); event WithdrawnLocked(address indexed user, uint256 amount, bytes32 kek_id); event RewardPaid(address indexed user, uint256 reward); event RewardsDurationUpdated(uint256 newDuration); event Recovered(address token, uint256 amount); event RewardsPeriodRenewed(address token); event DefaultInitialization(); event LockedStakeMaxMultiplierUpdated(uint256 multiplier); event LockedStakeTimeForMaxMultiplier(uint256 secs); event LockedStakeMinTime(uint256 secs); event MaxCRBoostMultiplier(uint256 multiplier); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; library StringHelpers { function parseAddr(string memory _a) internal pure returns (address _parsedAddress) { bytes memory tmp = bytes(_a); uint160 iaddr = 0; uint160 b1; uint160 b2; for (uint i = 2; i < 2 + 2 * 20; i += 2) { iaddr *= 256; b1 = uint160(uint8(tmp[i])); b2 = uint160(uint8(tmp[i + 1])); if ((b1 >= 97) && (b1 <= 102)) { b1 -= 87; } else if ((b1 >= 65) && (b1 <= 70)) { b1 -= 55; } else if ((b1 >= 48) && (b1 <= 57)) { b1 -= 48; } if ((b2 >= 97) && (b2 <= 102)) { b2 -= 87; } else if ((b2 >= 65) && (b2 <= 70)) { b2 -= 55; } else if ((b2 >= 48) && (b2 <= 57)) { b2 -= 48; } iaddr += (b1 * 16 + b2); } return address(iaddr); } function strCompare(string memory _a, string memory _b) internal pure returns (int _returnCode) { bytes memory a = bytes(_a); bytes memory b = bytes(_b); uint minLength = a.length; if (b.length < minLength) { minLength = b.length; } for (uint i = 0; i < minLength; i ++) { if (a[i] < b[i]) { return -1; } else if (a[i] > b[i]) { return 1; } } if (a.length < b.length) { return -1; } else if (a.length > b.length) { return 1; } else { return 0; } } function indexOf(string memory _haystack, string memory _needle) internal pure returns (int _returnCode) { bytes memory h = bytes(_haystack); bytes memory n = bytes(_needle); if (h.length < 1 || n.length < 1 || (n.length > h.length)) { return -1; } else if (h.length > (2 ** 128 - 1)) { return -1; } else { uint subindex = 0; for (uint i = 0; i < h.length; i++) { if (h[i] == n[0]) { subindex = 1; while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex]) { subindex++; } if (subindex == n.length) { return int(i); } } } return -1; } } function strConcat(string memory _a, string memory _b) internal pure returns (string memory _concatenatedString) { return strConcat(_a, _b, "", "", ""); } function strConcat(string memory _a, string memory _b, string memory _c) internal pure returns (string memory _concatenatedString) { return strConcat(_a, _b, _c, "", ""); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d) internal pure returns (string memory _concatenatedString) { return strConcat(_a, _b, _c, _d, ""); } function strConcat(string memory _a, string memory _b, string memory _c, string memory _d, string memory _e) internal pure returns (string memory _concatenatedString) { bytes memory _ba = bytes(_a); bytes memory _bb = bytes(_b); bytes memory _bc = bytes(_c); bytes memory _bd = bytes(_d); bytes memory _be = bytes(_e); string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length); bytes memory babcde = bytes(abcde); uint k = 0; uint i = 0; for (i = 0; i < _ba.length; i++) { babcde[k++] = _ba[i]; } for (i = 0; i < _bb.length; i++) { babcde[k++] = _bb[i]; } for (i = 0; i < _bc.length; i++) { babcde[k++] = _bc[i]; } for (i = 0; i < _bd.length; i++) { babcde[k++] = _bd[i]; } for (i = 0; i < _be.length; i++) { babcde[k++] = _be[i]; } return string(babcde); } function safeParseInt(string memory _a) internal pure returns (uint _parsedInt) { return safeParseInt(_a, 0); } function safeParseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) break; else _b--; } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { require(!decimals, 'More than one decimal encountered in string!'); decimals = true; } else { revert("Non-numeral character encountered in string!"); } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function parseInt(string memory _a) internal pure returns (uint _parsedInt) { return parseInt(_a, 0); } function parseInt(string memory _a, uint _b) internal pure returns (uint _parsedInt) { bytes memory bresult = bytes(_a); uint mint = 0; bool decimals = false; for (uint i = 0; i < bresult.length; i++) { if ((uint(uint8(bresult[i])) >= 48) && (uint(uint8(bresult[i])) <= 57)) { if (decimals) { if (_b == 0) { break; } else { _b--; } } mint *= 10; mint += uint(uint8(bresult[i])) - 48; } else if (uint(uint8(bresult[i])) == 46) { decimals = true; } } if (_b > 0) { mint *= 10 ** _b; } return mint; } function uint2str(uint _i) internal pure returns (string memory _uintAsString) { if (_i == 0) { return "0"; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (_i != 0) { bstr[k--] = byte(uint8(48 + _i % 10)); _i /= 10; } return string(bstr); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Pair.sol'; import './Babylonian.sol'; import './SafeMath.sol'; import './TransferHelper.sol'; import './IERC20.sol'; import './IUniswapV2Router01.sol'; import './UniswapV2Library.sol'; contract SwapToPrice { using SafeMath for uint256; IUniswapV2Router01 public immutable router; address public immutable factory; constructor(address factory_, IUniswapV2Router01 router_) public { factory = factory_; router = router_; } // computes the direction and magnitude of the profit-maximizing trade function computeProfitMaximizingTrade( uint256 truePriceTokenA, uint256 truePriceTokenB, uint256 reserveA, uint256 reserveB ) pure public returns (bool aToB, uint256 amountIn) { aToB = reserveA.mul(truePriceTokenB) / reserveB < truePriceTokenA; uint256 invariant = reserveA.mul(reserveB); uint256 leftSide = Babylonian.sqrt( invariant.mul(aToB ? truePriceTokenA : truePriceTokenB).mul(1000) / uint256(aToB ? truePriceTokenB : truePriceTokenA).mul(997) ); uint256 rightSide = (aToB ? reserveA.mul(1000) : reserveB.mul(1000)) / 997; // compute the amount that must be sent to move the price to the profit-maximizing price amountIn = leftSide.sub(rightSide); } // swaps an amount of either token such that the trade is profit-maximizing, given an external true price // true price is expressed in the ratio of token A to token B // caller must approve this contract to spend whichever token is intended to be swapped function swapToPrice( address tokenA, address tokenB, uint256 truePriceTokenA, uint256 truePriceTokenB, uint256 maxSpendTokenA, uint256 maxSpendTokenB, address to, uint256 deadline ) public { // true price is expressed as a ratio, so both values must be non-zero require(truePriceTokenA != 0 && truePriceTokenB != 0, "ExampleSwapToPrice: ZERO_PRICE"); // caller can specify 0 for either if they wish to swap in only one direction, but not both require(maxSpendTokenA != 0 || maxSpendTokenB != 0, "ExampleSwapToPrice: ZERO_SPEND"); bool aToB; uint256 amountIn; { (uint256 reserveA, uint256 reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB); (aToB, amountIn) = computeProfitMaximizingTrade( truePriceTokenA, truePriceTokenB, reserveA, reserveB ); } // spend up to the allowance of the token in uint256 maxSpend = aToB ? maxSpendTokenA : maxSpendTokenB; if (amountIn > maxSpend) { amountIn = maxSpend; } address tokenIn = aToB ? tokenA : tokenB; address tokenOut = aToB ? tokenB : tokenA; TransferHelper.safeTransferFrom(tokenIn, msg.sender, address(this), amountIn); TransferHelper.safeApprove(tokenIn, address(router), amountIn); address[] memory path = new address[](2); path[0] = tokenIn; path[1] = tokenOut; router.swapExactTokensForTokens( amountIn, 0, // amountOutMin: we can skip computing this number because the math is tested path, to, deadline ); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./FakeCollateral_USDT.sol"; import "./FakeCollateral_WETH.sol"; import "./UniswapV2Router02_Modified.sol"; /* IGNORE THIS CONTRACT, ONLY USED FOR TESTING PURPOSES */ contract TestSwap { address public USDT_address; address public WETH_address; UniswapV2Router02_Modified public router; FakeCollateral_USDT USDT = FakeCollateral_USDT(USDT); FakeCollateral_WETH WETH = FakeCollateral_WETH(WETH); constructor( address _USDT_address, address _WETH_address, UniswapV2Router02_Modified _router_address ) public { USDT_address = _USDT_address; WETH_address = _WETH_address; router = UniswapV2Router02_Modified(_router_address); } function getPath() public returns (address[] memory) { address[] memory path = new address[](2); path[0] = USDT_address; path[1] = WETH_address; return path; } function swapUSDTforETH(uint256 amountIn, uint256 amountOutMin) public payable { require(USDT.transferFrom(msg.sender, address(this), amountIn), "transferFrom failed."); require(USDT.approve(address(router), amountIn), "approve failed."); address[] memory path = new address[](2); path[0] = USDT_address; path[1] = WETH_address; router.swapExactTokensForETH(amountIn, amountOutMin, path, msg.sender, block.timestamp); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./SafeMath.sol"; contract Timelock { using SafeMath for uint; event NewAdmin(address indexed newAdmin); event NewPendingAdmin(address indexed newPendingAdmin); event NewDelay(uint indexed newDelay); event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta); uint public constant GRACE_PERIOD = 14 days; uint public constant MINIMUM_DELAY = 2 days; uint public constant MAXIMUM_DELAY = 30 days; address public admin; address public pendingAdmin; uint public delay; mapping (bytes32 => bool) public queuedTransactions; constructor(address admin_, uint delay_) public { require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); admin = admin_; delay = delay_; } //function() external payable { } function setDelay(uint delay_) public { require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock."); require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay."); require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay."); delay = delay_; emit NewDelay(delay); } function acceptAdmin() public { require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin."); admin = msg.sender; pendingAdmin = address(0); emit NewAdmin(admin); } function setPendingAdmin(address pendingAdmin_) public { require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock."); pendingAdmin = pendingAdmin_; emit NewPendingAdmin(pendingAdmin); } function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) { require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin."); require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = true; emit QueueTransaction(txHash, target, value, signature, data, eta); return txHash; } function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public { require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); queuedTransactions[txHash] = false; emit CancelTransaction(txHash, target, value, signature, data, eta); } function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) { require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin."); bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta)); require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued."); require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock."); require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale."); queuedTransactions[txHash] = false; bytes memory callData; if (bytes(signature).length == 0) { callData = data; } else { callData = abi.encodePacked(bytes4(keccak256(bytes(signature))), data); } // Execute the call (bool success, bytes memory returnData) = target.call{ value: value }(callData); require(success, "Timelock::executeTransaction: Transaction execution reverted."); emit ExecuteTransaction(txHash, target, value, signature, data, eta); return returnData; } function getBlockTimestamp() internal view returns (uint) { return block.timestamp; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "./ERC20Custom.sol"; import "./ERC20.sol"; import "./SafeMath.sol"; /** * @title TokenVesting * @dev A token holder contract that can release its token balance gradually like a * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the * owner. * * Modified from OpenZeppelin's TokenVesting.sol draft */ contract TokenVesting { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a // cliff period of a year and a duration of four years, are safe to use. // solhint-disable not-rely-on-time using SafeMath for uint256; event TokensReleased(uint256 amount); event TokenVestingRevoked(); // beneficiary of tokens after they are released address private _beneficiary; // owner (grantor) of the tokens address private _owner; // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. uint256 private _cliff; uint256 private _start; uint256 private _duration; address public _FXS_contract_address; ERC20 FXS; address public _timelock_address; bool public _revocable; uint256 private _released; bool public _revoked; /** * @dev Creates a vesting contract that vests its balance of any ERC20 token to the * beneficiary, gradually in a linear fashion until start + duration. By then all * of the balance will have vested. * @param beneficiary address of the beneficiary to whom vested tokens are transferred * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest * @param start the time (as Unix time) at which point vesting starts * @param duration duration in seconds of the period in which the tokens will vest * @param revocable whether the vesting is revocable or not */ constructor( address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable ) public { require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); // solhint-disable-next-line max-line-length require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); require(duration > 0, "TokenVesting: duration is 0"); // solhint-disable-next-line max-line-length require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time"); _beneficiary = beneficiary; _revocable = revocable; _duration = duration; _cliff = start.add(cliffDuration); _start = start; _owner = msg.sender; } function setFXSAddress(address FXS_address) public { require(msg.sender == _owner, "must be set by the owner"); _FXS_contract_address = FXS_address; FXS = ERC20(FXS_address); } function setTimelockAddress(address timelock_address) public { require(msg.sender == _owner, "must be set by the owner"); _timelock_address = timelock_address; } /** * @return the beneficiary of the tokens. */ function getBeneficiary() public view returns (address) { return _beneficiary; } /** * @return the cliff time of the token vesting. */ function getCliff() public view returns (uint256) { return _cliff; } /** * @return the start time of the token vesting. */ function getStart() public view returns (uint256) { return _start; } /** * @return the duration of the token vesting. */ function getDuration() public view returns (uint256) { return _duration; } /** * @return true if the vesting is revocable. */ function getRevocable() public view returns (bool) { return _revocable; } /** * @return the amount of the token released. */ function getReleased() public view returns (uint256) { return _released; } /** * @return true if the token is revoked. */ function getRevoked() public view returns (bool) { return _revoked; } /** * @notice Transfers vested tokens to beneficiary. */ function release() public { require(msg.sender == _beneficiary, "must be the beneficiary to release tokens"); uint256 unreleased = _releasableAmount(); require(unreleased > 0, "TokenVesting: no tokens are due"); _released = _released.add(unreleased); FXS.transfer(_beneficiary, unreleased); emit TokensReleased(unreleased); } /** * @notice Allows the owner to revoke the vesting. Tokens already vested * remain in the contract, the rest are returned to the owner. */ function revoke() public { require(msg.sender == _timelock_address, "Must be called by the timelock contract"); require(_revocable, "TokenVesting: cannot revoke"); require(!_revoked, "TokenVesting: token already revoked"); uint256 balance = FXS.balanceOf(address(this)); uint256 unreleased = _releasableAmount(); uint256 refund = balance.sub(unreleased); _revoked = true; FXS.transfer(_owner, refund); emit TokenVestingRevoked(); } // Added to support recovering possible airdrops function recoverERC20(address tokenAddress, uint256 tokenAmount) external { require(msg.sender == _beneficiary, "Must be called by the beneficiary"); // Cannot recover the staking token or the rewards token require(tokenAddress != _FXS_contract_address, "Cannot withdraw the FXS through this function"); ERC20(tokenAddress).transfer(_beneficiary, tokenAmount); } /** * @dev Calculates the amount that has already vested but hasn't been released yet. */ function _releasableAmount() private view returns (uint256) { return _vestedAmount().sub(_released); } /** * @dev Calculates the amount that has already vested. */ function _vestedAmount() private view returns (uint256) { uint256 currentBalance = FXS.balanceOf(address(this)); uint256 totalBalance = currentBalance.add(_released); if (block.timestamp < _cliff) { return 0; } else if (block.timestamp >= _start.add(_duration) || _revoked) { return totalBalance; } else { return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); } } uint256[44] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false library TransferHelper { function safeApprove(address token, address to, uint value) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED'); } function safeTransfer(address token, address to, uint value) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED'); } function safeTransferFrom(address token, address from, address to, uint value) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED'); } function safeTransferETH(address to, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Factory.sol'; import './IUniswapV2Pair.sol'; import './FixedPoint.sol'; import './UniswapV2OracleLibrary.sol'; import './UniswapV2Library.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle { using FixedPoint for *; address owner_address; address timelock_address; uint public PERIOD = 3600; // 1 hour TWAP (time-weighted average price) IUniswapV2Pair public immutable pair; address public immutable token0; address public immutable token1; uint public price0CumulativeLast; uint public price1CumulativeLast; uint32 public blockTimestampLast; FixedPoint.uq112x112 public price0Average; FixedPoint.uq112x112 public price1Average; modifier onlyByOwnerOrGovernance() { require(msg.sender == owner_address || msg.sender == timelock_address, "You are not an owner or the governance timelock"); _; } constructor(address factory, address tokenA, address tokenB, address _owner_address, address _timelock_address) public { IUniswapV2Pair _pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, tokenA, tokenB)); pair = _pair; token0 = _pair.token0(); token1 = _pair.token1(); price0CumulativeLast = _pair.price0CumulativeLast(); // Fetch the current accumulated price value (1 / 0) price1CumulativeLast = _pair.price1CumulativeLast(); // Fetch the current accumulated price value (0 / 1) uint112 reserve0; uint112 reserve1; (reserve0, reserve1, blockTimestampLast) = _pair.getReserves(); require(reserve0 != 0 && reserve1 != 0, 'UniswapPairOracle: NO_RESERVES'); // Ensure that there's liquidity in the pair owner_address = _owner_address; timelock_address = _timelock_address; } function setOwner(address _owner_address) external onlyByOwnerOrGovernance { owner_address = _owner_address; } function setTimelock(address _timelock_address) external onlyByOwnerOrGovernance { timelock_address = _timelock_address; } function setPeriod(uint _period) external onlyByOwnerOrGovernance { PERIOD = _period; } function update() external { (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) = UniswapV2OracleLibrary.currentCumulativePrices(address(pair)); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // Overflow is desired // Ensure that at least one full period has passed since the last update require(timeElapsed >= PERIOD, 'UniswapPairOracle: PERIOD_NOT_ELAPSED'); // Overflow is desired, casting never truncates // Cumulative price is in (uq112x112 price * seconds) units so we simply wrap it after division by time elapsed price0Average = FixedPoint.uq112x112(uint224((price0Cumulative - price0CumulativeLast) / timeElapsed)); price1Average = FixedPoint.uq112x112(uint224((price1Cumulative - price1CumulativeLast) / timeElapsed)); price0CumulativeLast = price0Cumulative; price1CumulativeLast = price1Cumulative; blockTimestampLast = blockTimestamp; } // Note this will always return 0 before update has been called successfully for the first time. function consult(address token, uint amountIn) external view returns (uint amountOut) { if (token == token0) { amountOut = price0Average.mul(amountIn).decode144(); } else { require(token == token1, 'UniswapPairOracle: INVALID_TOKEN'); amountOut = price1Average.mul(amountIn).decode144(); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_FRAX_FXS is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_FRAX_USDC is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_FRAX_USDT is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_FRAX_WETH is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_FXS_USDC is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_FXS_USDT is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_FXS_WETH is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_USDC_WETH is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './UniswapPairOracle.sol'; // Fixed window oracle that recomputes the average price for the entire period once every period // Note that the price average is only guaranteed to be over at least 1 period, but may be over a longer period contract UniswapPairOracle_USDT_WETH is UniswapPairOracle { constructor(address factory, address tokenA, address tokenB, address owner_address, address timelock_address) UniswapPairOracle(factory, tokenA, tokenB, owner_address, timelock_address) public {} }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2ERC20.sol'; import './SafeMath.sol'; contract UniswapV2ERC20 is IUniswapV2ERC20 { using SafeMath for uint; string public override constant name = 'Uniswap V2'; string public override constant symbol = 'UNI-V2'; uint8 public override constant decimals = 18; uint public override totalSupply; mapping(address => uint) public override balanceOf; mapping(address => mapping(address => uint)) public override allowance; bytes32 public override DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant override PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint) public override nonces; event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); constructor() public { uint chainId; assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), keccak256(bytes(name)), keccak256(bytes('1')), chainId, address(this) ) ); } function _mint(address to, uint value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve(address owner, address spender, uint value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint value) external override returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external override returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external override returns (bool) { if (allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external override { require(deadline >= block.timestamp, 'UniswapV2: EXPIRED'); bytes32 digest = keccak256( abi.encodePacked( '\x19\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE'); _approve(owner, spender, value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Factory.sol'; import './UniswapV2Pair.sol'; contract UniswapV2Factory is IUniswapV2Factory { address public override feeTo; address public override feeToSetter; mapping(address => mapping(address => address)) public override getPair; address[] public override allPairs; event PairCreated(address indexed token0, address indexed token1, address pair, uint); constructor(address _feeToSetter) public { feeToSetter = _feeToSetter; } function allPairsLength() external override view returns (uint) { return allPairs.length; } function createPair(address tokenA, address tokenB) external override returns (address pair) { require(tokenA != tokenB, 'UniswapV2: IDENTICAL_ADDRESSES'); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2: ZERO_ADDRESS'); require(getPair[token0][token1] == address(0), 'UniswapV2: PAIR_EXISTS'); // single check is sufficient bytes memory bytecode = type(UniswapV2Pair).creationCode; bytes32 salt = keccak256(abi.encodePacked(token0, token1)); // This creates a new contract assembly { pair := create2(0, add(bytecode, 32), mload(bytecode), salt) } IUniswapV2Pair(pair).initialize(token0, token1); getPair[token0][token1] = pair; getPair[token1][token0] = pair; // populate mapping in the reverse direction allPairs.push(pair); emit PairCreated(token0, token1, pair, allPairs.length); } function setFeeTo(address _feeTo) external override { require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN'); feeTo = _feeTo; } function setFeeToSetter(address _feeToSetter) external override { require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN'); feeToSetter = _feeToSetter; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Pair.sol'; import './IUniswapV2Factory.sol'; import "./SafeMath.sol"; library UniswapV2Library { using SafeMath for uint; // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES'); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS'); } // Less efficient than the CREATE2 method below function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = IUniswapV2Factory(factory).getPair(token0, token1); } // calculates the CREATE2 address for a pair without making any external calls function pairForCreate2(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash )))); // this matches the CREATE2 in UniswapV2Factory.createPair } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) { require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT'); require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); amountB = amountA.mul(reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserves, returns a required input amount of the other asset function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } } // performs chained getAmountIn calculations on any number of pairs function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Pair.sol'; import './FixedPoint.sol'; // library with helper methods for oracles that are concerned with computing average prices library UniswapV2OracleLibrary { using FixedPoint for *; // helper function that returns the current block timestamp within the range of uint32, i.e. [0, 2**32 - 1] function currentBlockTimestamp() internal view returns (uint32) { return uint32(block.timestamp % 2 ** 32); } // produces the cumulative price using counterfactuals to save gas and avoid a call to sync. function currentCumulativePrices( address pair ) internal view returns (uint price0Cumulative, uint price1Cumulative, uint32 blockTimestamp) { blockTimestamp = currentBlockTimestamp(); price0Cumulative = IUniswapV2Pair(pair).price0CumulativeLast(); price1Cumulative = IUniswapV2Pair(pair).price1CumulativeLast(); // if time has elapsed since the last update on the pair, mock the accumulated price values (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = IUniswapV2Pair(pair).getReserves(); if (blockTimestampLast != blockTimestamp) { // subtraction overflow is desired uint32 timeElapsed = blockTimestamp - blockTimestampLast; // addition overflow is desired // counterfactual price0Cumulative += uint(FixedPoint.fraction(reserve1, reserve0)._x) * timeElapsed; // counterfactual price1Cumulative += uint(FixedPoint.fraction(reserve0, reserve1)._x) * timeElapsed; } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Pair.sol'; import './UniswapV2ERC20.sol'; import './Math.sol'; import './UQ112x112.sol'; import './IERC20.sol'; import './IUniswapV2Factory.sol'; import './IUniswapV2Callee.sol'; contract UniswapV2Pair is IUniswapV2Pair { using SafeMath for uint; using UQ112x112 for uint224; string public override constant name = 'Uniswap V2'; string public override constant symbol = 'UNI-V2'; uint8 public override constant decimals = 18; uint public override totalSupply; mapping(address => uint) public override balanceOf; mapping(address => mapping(address => uint)) public override allowance; uint public override constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); bytes32 public override DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant override PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint) public override nonces; address public override factory; address public override token0; address public override token1; uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint public override price0CumulativeLast; uint public override price1CumulativeLast; uint public override kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint private unlocked = 1; modifier lock() { require(unlocked == 1, 'UniswapV2: LOCKED'); unlocked = 0; _; unlocked = 1; } function getReserves() public override view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function _safeTransfer(address token, address to, uint value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED'); } event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external override { require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check token0 = _token0; token1 = _token1; } // update reserves and, on the first call per block, price accumulators function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW'); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IUniswapV2Factory(factory).feeTo(); feeOn = feeTo != address(0); uint _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numerator = totalSupply.mul(rootK.sub(rootKLast)); uint denominator = rootK.mul(5).add(rootKLast); uint liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external override lock returns (uint liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED'); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external override lock returns (uint amount0, uint amount1) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint balance0 = IERC20(_token0).balanceOf(address(this)); uint balance1 = IERC20(_token1).balanceOf(address(this)); uint liquidity = balanceOf[address(this)]; bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED'); _burn(address(this), liquidity); _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } // this low-level function should be called from a contract which performs important safety checks function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external override lock { require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT'); (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY'); uint balance0; uint balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 = token0; address _token1 = token1; require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO'); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT'); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3)); uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3)); require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K'); } _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } // force balances to match reserves function skim(address to) external override lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external override lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } // Migrated over from UniswapV2ERC20. Needed for ^0.6.0 // =============================================== function _mint(address to, uint value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve(address owner, address spender, uint value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint value) external override returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external override returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external override returns (bool) { if (allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external override { require(deadline >= block.timestamp, 'UniswapV2: EXPIRED'); bytes32 digest = keccak256( abi.encodePacked( '\x19\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE'); _approve(owner, spender, value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Factory.sol'; import './TransferHelper.sol'; import './IUniswapV2Router02.sol'; import './UniswapV2Library.sol'; import './SafeMath.sol'; import './IERC20.sol'; import './IWETH.sol'; contract UniswapV2Router02 is IUniswapV2Router02 { using SafeMath for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED'); _; } constructor(address _factory, address _WETH) public { factory = _factory; WETH = _WETH; } receive() external payable { assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract } // **** ADD LIQUIDITY **** function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin ) internal virtual returns (uint amountA, uint amountB) { // create the pair if it doesn't exist yet if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IUniswapV2Factory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } } function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) { (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin); address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IUniswapV2Pair(pair).mint(to); } function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) { (amountToken, amountETH) = _addLiquidity( token, WETH, amountTokenDesired, msg.value, amountTokenMin, amountETHMin ); address pair = UniswapV2Library.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); assert(IWETH(WETH).transfer(pair, amountETH)); liquidity = IUniswapV2Pair(pair).mint(to); // refund dust eth, if any if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH); } // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to); (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); } function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) { (amountToken, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, amountToken); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline); } function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountToken, uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline); } // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountETH) { (, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this))); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); amountETH = removeLiquidityETHSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountETHMin, to, deadline ); } // **** SWAP **** // requires the initial amount to have already been sent to the first pair function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); uint amountOut = amounts[i + 1]; (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap( amount0Out, amount1Out, to, new bytes(0) ); } } function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); } function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); // refund dust eth, if any if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]); } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)); uint amountInput; uint amountOutput; { // scope to avoid stack too deep errors (uint reserve0, uint reserve1,) = pair.getReserves(); (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput); amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; pair.swap(amount0Out, amount1Out, to, new bytes(0)); } } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn)); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).withdraw(amountOut); TransferHelper.safeTransferETH(to, amountOut); } // **** LIBRARY FUNCTIONS **** function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return UniswapV2Library.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsIn(factory, amountOut, path); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IUniswapV2Factory.sol'; import './TransferHelper.sol'; import './IUniswapV2Router02.sol'; import './UniswapV2Library.sol'; import './SafeMath.sol'; import './IERC20.sol'; import './IWETH.sol'; contract UniswapV2Router02_Modified is IUniswapV2Router02 { using SafeMath for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED'); _; } constructor(address _factory, address _WETH) public { factory = _factory; WETH = _WETH; } receive() external payable { assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract } // **** ADD LIQUIDITY **** function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin ) internal virtual returns (uint amountA, uint amountB) { // create the pair if it doesn't exist yet if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IUniswapV2Factory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } } function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) { (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin); address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IUniswapV2Pair(pair).mint(to); } function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) { (amountToken, amountETH) = _addLiquidity( token, WETH, amountTokenDesired, msg.value, amountTokenMin, amountETHMin ); address pair = UniswapV2Library.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); TransferHelper.safeTransferFrom(WETH, msg.sender, pair, amountETH); // IWETH(WETH).transferFrom(msg.sender, pair, amountETH); // IWETH(WETH).deposit{value: amountETH}(); // assert(IWETH(WETH).transfer(pair, amountETH)); // require(false, "HELLO: HOW ARE YOU TODAY!"); liquidity = IUniswapV2Pair(pair).mint(to); // << PROBLEM IS HERE // refund dust eth, if any if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH); } // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to); (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); } function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) { (amountToken, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, amountToken); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline); } function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountToken, uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline); } // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountETH) { (, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this))); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); amountETH = removeLiquidityETHSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountETHMin, to, deadline ); } // **** SWAP **** // requires the initial amount to have already been sent to the first pair function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); uint amountOut = amounts[i + 1]; (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap( amount0Out, amount1Out, to, new bytes(0) ); } } function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); } function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); // refund dust eth, if any if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]); } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { // for (uint i; i < path.length - 1; i++) { // (address input, address output) = (path[i], path[i + 1]); // (address token0,) = UniswapV2Library.sortTokens(input, output); // IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)); // uint amountInput; // uint amountOutput; // { // scope to avoid stack too deep errors // (uint reserve0, uint reserve1,) = pair.getReserves(); // (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); // amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput); // amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); // } // (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); // address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; // pair.swap(amount0Out, amount1Out, to, new bytes(0)); // } } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { // TransferHelper.safeTransferFrom( // path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn // ); // uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); // _swapSupportingFeeOnTransferTokens(path, to); // require( // IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, // 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' // ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { // require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); // uint amountIn = msg.value; // IWETH(WETH).deposit{value: amountIn}(); // assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn)); // uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); // _swapSupportingFeeOnTransferTokens(path, to); // require( // IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, // 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' // ); } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { // require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); // TransferHelper.safeTransferFrom( // path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn // ); // _swapSupportingFeeOnTransferTokens(path, address(this)); // uint amountOut = IERC20(WETH).balanceOf(address(this)); // require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); // IWETH(WETH).withdraw(amountOut); // TransferHelper.safeTransferETH(to, amountOut); } // **** LIBRARY FUNCTIONS **** function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return UniswapV2Library.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsIn(factory, amountOut, path); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) // range: [0, 2**112 - 1] // resolution: 1 / 2**112 library UQ112x112 { uint224 constant Q112 = 2**112; // encode a uint112 as a UQ112x112 function encode(uint112 y) internal pure returns (uint224 z) { z = uint224(y) * Q112; // never overflows } // divide a UQ112x112 by a uint112, returning a UQ112x112 function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) { z = x / uint224(y); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; import './IWETH.sol'; // Copyright (C) 2015, 2016, 2017 Dapphub // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. contract WETH is IWETH { string public name = "Wrapped Ether"; string public symbol = "WETH"; uint8 public decimals = 18; event Approval(address indexed src, address indexed guy, uint wad); event Transfer(address indexed src, address indexed dst, uint wad); event Deposit(address indexed dst, uint wad); event Withdrawal(address indexed src, uint wad); mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; fallback() external payable { deposit(); } receive() external payable { } constructor (address _creator_address ) public { balanceOf[_creator_address] = 1000000e18; // this is for testing only } function deposit() public override payable { balanceOf[msg.sender] += msg.value; emit Deposit(msg.sender, msg.value); } function withdraw(uint wad) override public { require(balanceOf[msg.sender] >= wad); balanceOf[msg.sender] -= wad; msg.sender.transfer(wad); emit Withdrawal(msg.sender, wad); } function totalSupply() public view returns (uint) { return address(this).balance; } function approve(address guy, uint wad) public returns (bool) { allowance[msg.sender][guy] = wad; emit Approval(msg.sender, guy, wad); return true; } function transfer(address dst, uint wad) public override returns (bool) { return transferFrom(msg.sender, dst, wad); } function transferFrom(address src, address dst, uint wad) public override returns (bool) { require(balanceOf[src] >= wad); if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) { require(allowance[src][msg.sender] >= wad); allowance[src][msg.sender] -= wad; } balanceOf[src] -= wad; balanceOf[dst] += wad; emit Transfer(src, dst, wad); return true; } } /* GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>. */
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_frax_contract_address","type":"address"},{"internalType":"address","name":"_fxs_contract_address","type":"address"},{"internalType":"address","name":"_collateral_address","type":"address"},{"internalType":"address","name":"_creator_address","type":"address"},{"internalType":"address","name":"_timelock_address","type":"address"},{"internalType":"uint256","name":"_pool_ceiling","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"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"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC_address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"availableExcessCollatDV","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bonus_rate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"FXS_amount","type":"uint256"},{"internalType":"uint256","name":"COLLATERAL_out_min","type":"uint256"}],"name":"buyBackFXS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collatDollarBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectRedemption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCollateralPrice","outputs":[{"internalType":"uint256","name":"","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":"address","name":"","type":"address"}],"name":"lastRedeemed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"internalType":"uint256","name":"FRAX_out_min","type":"uint256"}],"name":"mint1t1FRAX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fxs_amount_d18","type":"uint256"},{"internalType":"uint256","name":"FRAX_out_min","type":"uint256"}],"name":"mintAlgorithmicFRAX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"internalType":"uint256","name":"fxs_amount","type":"uint256"},{"internalType":"uint256","name":"FRAX_out_min","type":"uint256"}],"name":"mintFractionalFRAX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pausedPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool_ceiling","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateral_amount","type":"uint256"},{"internalType":"uint256","name":"FXS_out_min","type":"uint256"}],"name":"recollateralizeFRAX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"FRAX_amount","type":"uint256"},{"internalType":"uint256","name":"COLLATERAL_out_min","type":"uint256"}],"name":"redeem1t1FRAX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"FRAX_amount","type":"uint256"},{"internalType":"uint256","name":"FXS_out_min","type":"uint256"}],"name":"redeemAlgorithmicFRAX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"redeemCollateralBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"redeemFXSBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"FRAX_amount","type":"uint256"},{"internalType":"uint256","name":"FXS_out_min","type":"uint256"},{"internalType":"uint256","name":"COLLATERAL_out_min","type":"uint256"}],"name":"redeemFractionalFRAX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redemption_delay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":[{"internalType":"address","name":"_collateral_weth_oracle_address","type":"address"},{"internalType":"address","name":"_weth_address","type":"address"}],"name":"setCollatETHOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner_address","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"new_ceiling","type":"uint256"},{"internalType":"uint256","name":"new_bonus_rate","type":"uint256"},{"internalType":"uint256","name":"new_redemption_delay","type":"uint256"}],"name":"setPoolParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"new_timelock","type":"address"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleBuyBack","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleCollateralPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleMinting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleRecollateralize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toggleRedeeming","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unclaimedPoolCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unclaimedPoolFXS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405260006014819055601555611d4c60165560016017556018805464ffffffffff191690553480156200003457600080fd5b50604051620052f1380380620052f1833981810160405260c08110156200005a57600080fd5b5080516020808301516040808501516060860151608087015160a090970151600880546001600160a01b03808a166001600160a01b0319928316811790935560078054828a1690841681179091556004805484169094178455600580548416909117905560028054828816908416811790915560068054838e16908516179055600380548388169085161790556001805490931617918290556014849055865163313ce56760e01b81529651999a9799959894979693958b958b958b958b958b958b956200018e95929091169363313ce56793818101939291829003018186803b1580156200014857600080fd5b505afa1580156200015d573d6000803e3d6000fd5b505050506040513d60208110156200017457600080fd5b505160129060ff166200037e602090811b620041a317901c565b601355620001b96000620001aa6001600160e01b03620003d116565b6001600160e01b03620003d516565b604080516a26a4a72a2fa820aaa9a2a960a91b8152905190819003600b019020600654620001fa91906001600160a01b03166001600160e01b03620003ee16565b604080516c2922a222a2a6afa820aaa9a2a960991b8152905190819003600d0190206006546200023d91906001600160a01b03166001600160e01b03620003ee16565b604080517f5245434f4c4c41544552414c495a455f50415553455200000000000000000000815290519081900360160190206006546200029091906001600160a01b03166001600160e01b03620003ee16565b604080516d212aaca120a1a5afa820aaa9a2a960911b8152905190819003600e019020600654620002d491906001600160a01b03166001600160e01b03620003ee16565b604080517f434f4c4c41544552414c5f50524943455f504155534552000000000000000000815290519081900360170190206006546200032791906001600160a01b03166001600160e01b03620003ee16565b505050505050620003456000801b620001aa620003d160201b60201c565b5050601880546001600160a01b039093166501000000000002600160281b600160c81b0319909316929092179091555062000655915050565b6000620003c883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506200046460201b60201c565b90505b92915050565b3390565b620003ea82826001600160e01b03620004ff16565b5050565b6000828152602081905260409020600201546200042790620004186001600160e01b03620003d116565b6001600160e01b036200058116565b620003d55760405162461bcd60e51b815260040180806020018281038252602f815260200180620052c2602f913960400191505060405180910390fd5b60008184841115620004f75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015620004bb578181015183820152602001620004a1565b50505050905090810190601f168015620004e95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008281526020818152604090912062000524918390620041e5620005a5821b17901c565b15620003ea576200053d6001600160e01b03620003d116565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408220620003c891849062004207620005c5821b17901c565b6000620003c8836001600160a01b0384166001600160e01b03620005e516565b6000620003c8836001600160a01b0384166001600160e01b036200063d16565b6000620005fc83836001600160e01b036200063d16565b6200063457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620003cb565b506000620003cb565b60009081526001919091016020526040902054151590565b614c5d80620006656000396000f3fe608060405234801561001057600080fd5b50600436106102ad5760003560e01c80637b0461e91161017b578063bdb345cb116100d8578063daa504851161008c578063f61adab211610071578063f61adab21461073b578063f7683bbc14610743578063f9abd26c1461074b576102ad565b8063daa504851461072b578063e2708e2014610733576102ad565b8063c76417d7116100bd578063c76417d7146106a2578063ca15c873146106d5578063d547741f146106f2576102ad565b8063bdb345cb14610677578063c74ec56a1461069a576102ad565b80639010d07c1161012f578063a217fddf11610114578063a217fddf14610609578063abae2c4c14610611578063bdacb30314610644576102ad565b80639010d07c1461057057806391d14854146105bc576102ad565b80637e108af9116101605780637e108af9146104e957806383c7ded71461051257806388d42cf214610535576102ad565b80637b0461e9146104d95780637d55094d146104e1576102ad565b80634c26203c11610229578063645af53c116101dd578063658445a8116101c2578063658445a81461046a5780636f5db87f1461048d5780637a00e0e2146104b0576102ad565b8063645af53c1461043f5780636526a12a14610462576102ad565b806350c9ecd91161020e57806350c9ecd9146103eb5780635bb87b42146103f35780635bd826631461041c576102ad565b80634c26203c146103db5780634c634934146103e3576102ad565b806317284c94116102805780632f2ff15d116102655780632f2ff15d1461036157806336568abe1461039a57806342d15aec146103d3576102ad565b806317284c941461033c578063248a9ca314610344576102ad565b806308a7493d146102b257806312ace5a2146102f757806313af4035146103015780631512842514610334575b600080fd5b6102e5600480360360208110156102c857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610753565b60408051918252519081900360200190f35b6102ff610765565b005b6102ff6004803603602081101561031757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166109dd565b6102e5610ab6565b6102e5610abc565b6102e56004803603602081101561035a57600080fd5b5035610d3c565b6102ff6004803603604081101561037757600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16610d51565b6102ff600480360360408110156103b057600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16610dd7565b6102ff610e6c565b6102e5610eec565b6102e5610ef2565b6102ff610ef8565b6102ff6004803603606081101561040957600080fd5b5080359060208101359060400135610f79565b6102ff6004803603604081101561043257600080fd5b50803590602001356116a7565b6102ff6004803603604081101561045557600080fd5b5080359060200135611b6a565b6102e5611fc6565b6102ff6004803603604081101561048057600080fd5b5080359060200135611fcc565b6102ff600480360360408110156104a357600080fd5b50803590602001356122ed565b6102ff600480360360608110156104c657600080fd5b5080359060208101359060400135612747565b6102e5612921565b6102ff612927565b6102ff600480360360608110156104ff57600080fd5b508035906020810135906040013561299e565b6102ff6004803603604081101561052857600080fd5b5080359060200135613003565b6102ff6004803603604081101561054b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166135ac565b6105936004803603604081101561058657600080fd5b508035906020013561369e565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6105f5600480360360408110156105d257600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff166136c5565b604080519115158252519081900360200190f35b6102e56136e3565b6102e56004803603602081101561062757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166136e8565b6102ff6004803603602081101561065a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166136fa565b6102ff6004803603604081101561068d57600080fd5b50803590602001356137d3565b6102e5613bf2565b6102e5600480360360208110156106b857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16613bf8565b6102e5600480360360208110156106eb57600080fd5b5035613c0a565b6102ff6004803603604081101561070857600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16613c21565b6102ff613c94565b6102ff613d13565b6102e5613dbd565b6102e5613fed565b61059361417e565b600f6020526000908152604090205481565b60175433600090815260126020526040902054439161078a919063ffffffff61422916565b11156107e1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526042815260200180614ad06042913960600191505060405180910390fd5b336000908152600e60205260408120548190819081901561082e57336000908152600e602052604081208054919055601154909250610826908363ffffffff6141a316565b601155600193505b336000908152600f6020526040902054156108735750336000908152600f60205260408120805491905560105461086b908263ffffffff6141a316565b601055600192505b6001841515141561092557600754604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101859052905173ffffffffffffffffffffffffffffffffffffffff9092169163a9059cbb916044808201926020929091908290030181600087803b1580156108f857600080fd5b505af115801561090c573d6000803e3d6000fd5b505050506040513d602081101561092257600080fd5b50505b600183151514156109d757600154604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163a9059cbb916044808201926020929091908290030181600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050506040513d60208110156109d457600080fd5b50505b50505050565b60065473ffffffffffffffffffffffffffffffffffffffff16331480610a1a575060035473ffffffffffffffffffffffffffffffffffffffff1633145b610a6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60175481565b600080600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663345ba24b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b2757600080fd5b505afa158015610b3b573d6000803e3d6000fd5b505050506040513d6020811015610b5157600080fd5b5051600954600b54601354604080517f3ddac95300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9384166004820152600a9290920a620f4240026024830152519394506000939190921691633ddac953916044808301926020929190829003018186803b158015610be157600080fd5b505afa158015610bf5573d6000803e3d6000fd5b505050506040513d6020811015610c0b57600080fd5b505190506000610c3482610c2885620f424063ffffffff61429d16565b9063ffffffff61431016565b9050610d33620f4240610c2883610d27601354600a0a610d27601054600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610cef57600080fd5b505afa158015610d03573d6000803e3d6000fd5b505050506040513d6020811015610d1957600080fd5b50519063ffffffff6141a316565b9063ffffffff61429d16565b93505050505b90565b60009081526020819052604090206002015490565b600082815260208190526040902060020154610d7490610d6f614352565b6136c5565b610dc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614a16602f913960400191505060405180910390fd5b610dd38282614356565b5050565b610ddf614352565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610e62576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614bf9602f913960400191505060405180910390fd5b610dd382826143df565b604080517f5245434f4c4c41544552414c495a455f5041555345520000000000000000000081529051908190036016019020610ea890336136c5565b610eb157600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b60115481565b60165481565b604080517f4255594241434b5f5041555345520000000000000000000000000000000000008152905190819003600e019020610f3490336136c5565b610f3d57600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffff811663010000009182900460ff1615909102179055565b60185460ff1615610feb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4d696e74696e6720697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b600854604080517fb4db0980000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163b4db0980916004808301926020929190829003018186803b15801561105657600080fd5b505afa15801561106a573d6000803e3d6000fd5b505050506040513d602081101561108057600080fd5b5051600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff9092169163e7dced6791600480820192602092909190829003018186803b1580156110f357600080fd5b505afa158015611107573d6000803e3d6000fd5b505050506040513d602081101561111d57600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561119057600080fd5b505afa1580156111a4573d6000803e3d6000fd5b505050506040513d60208110156111ba57600080fd5b50519050620f4240811080156111d05750600081115b611225576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180614a756038913960400191505060405180910390fd5b601454601054600154604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516112b3938b936112a793919273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b158015610cef57600080fd5b9063ffffffff61422916565b111561130a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526045815260200180614bb46045913960600191505060405180910390fd5b601354600a0a860261131a61497f565b604051806101200160405280600c548152602001858152602001868152602001611342613fed565b815260208082018a9052604080830186905260105460015482517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015292516060909501946113cd94929373ffffffffffffffffffffffffffffffffffffffff909216926370a082319260248082019391829003018186803b158015610cef57600080fd5b8152601454602082015260400184905290506000806113eb83614468565b915091508188111561145e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b888111156114cd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4e6f7420656e6f7567682046585320696e707574746564000000000000000000604482015290519081900360640190fd5b600754604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b15801561154657600080fd5b505af115801561155a573d6000803e3d6000fd5b5050600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018f9052905173ffffffffffffffffffffffffffffffffffffffff90921693506323b872dd92506064808201926020929091908290030181600087803b1580156115de57600080fd5b505af11580156115f2573d6000803e3d6000fd5b505050506040513d602081101561160857600080fd5b5050600854604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101859052905173ffffffffffffffffffffffffffffffffffffffff9092169163b4f56b269160448082019260009290919082900301818387803b15801561168357600080fd5b505af1158015611697573d6000803e3d6000fd5b5050505050505050505050505050565b60185460ff161561171957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4d696e74696e6720697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b601354600854604080517f2eb9771b0000000000000000000000000000000000000000000000000000000081529051600a9390930a85029260009273ffffffffffffffffffffffffffffffffffffffff1691632eb9771b916004808301926020929190829003018186803b15801561179057600080fd5b505afa1580156117a4573d6000803e3d6000fd5b505050506040513d60208110156117ba57600080fd5b50519050620f424081101561183057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f436f6c6c61746572616c20726174696f206d757374206265203e3d2031000000604482015290519081900360640190fd5b601454601054600154604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516118b29389936112a793919273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b158015610cef57600080fd5b111561191f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5b506f6f6c277320436c6f7365645d3a204365696c696e672072656163686564604482015290519081900360640190fd5b600073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a4637d7496d4611943613fed565b600c54866040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b15801561198957600080fd5b505af415801561199d573d6000803e3d6000fd5b505050506040513d60208110156119b357600080fd5b5051905080841115611a2657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600154604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101889052905173ffffffffffffffffffffffffffffffffffffffff909216916323b872dd916064808201926020929091908290030181600087803b158015611aa657600080fd5b505af1158015611aba573d6000803e3d6000fd5b505050506040513d6020811015611ad057600080fd5b5050600854604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163b4f56b269160448082019260009290919082900301818387803b158015611b4b57600080fd5b505af1158015611b5f573d6000803e3d6000fd5b505050505050505050565b601854610100900460ff1615611be157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f52656465656d696e672069732070617573656400000000000000000000000000604482015290519081900360640190fd5b600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff1691632eb9771b916004808301926020929190829003018186803b158015611c4c57600080fd5b505afa158015611c60573d6000803e3d6000fd5b505050506040513d6020811015611c7657600080fd5b50519050620f42408114611ceb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f436f6c6c61746572616c20726174696f206d757374206265203d3d2031000000604482015290519081900360640190fd5b6000611d05601354600a0a8561431090919063ffffffff16565b9050600073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a4630a9b920a611d2b613fed565b84600d546040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015611d7157600080fd5b505af4158015611d85573d6000803e3d6000fd5b505050506040513d6020811015611d9b57600080fd5b5051601054600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051939450611e189373ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015610cef57600080fd5b811115611e8657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e6f7420656e6f75676820636f6c6c61746572616c20696e20706f6f6c000000604482015290519081900360640190fd5b336000908152600f6020526040902054611ea6908263ffffffff61422916565b336000908152600f6020526040902055601054611ec9908263ffffffff61422916565b60105533600090815260126020526040902043905580841115611f4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600854604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101889052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b158015611b4b57600080fd5b60145481565b6018546301000000900460ff161561204557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4275796261636b20697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156120b057600080fd5b505afa1580156120c4573d6000803e3d6000fd5b505050506040513d60208110156120da57600080fd5b505190506120e66149cb565b60405180608001604052806120f9613dbd565b815260200183815260200161210c613fed565b8152602001859052905060006121218261454c565b9050600061213d601354600a0a8361431090919063ffffffff16565b9050808511156121ae57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600754604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101899052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b15801561222757600080fd5b505af115801561223b573d6000803e3d6000fd5b5050600154604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff909216935063a9059cbb92506044808201926020929091908290030181600087803b1580156122b957600080fd5b505af11580156122cd573d6000803e3d6000fd5b505050506040513d60208110156122e357600080fd5b5050505050505050565b601854610100900460ff161561236457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f52656465656d696e672069732070617573656400000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156123cf57600080fd5b505afa1580156123e3573d6000803e3d6000fd5b505050506040513d60208110156123f957600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561246c57600080fd5b505afa158015612480573d6000803e3d6000fd5b505050506040513d602081101561249657600080fd5b50519050801561250757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f436f6c6c61746572616c20726174696f206d7573742062652030000000000000604482015290519081900360640190fd5b600084905061253861252b620f4240610c28600d548561429d90919063ffffffff16565b829063ffffffff6141a316565b9050600061255384610c2884620f424063ffffffff61429d16565b336000908152600e6020526040902054909150612576908263ffffffff61422916565b336000908152600e6020526040902055601154612599908263ffffffff61422916565b6011553360009081526012602052604090204390558085111561261d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600854604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101899052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b15801561269657600080fd5b505af11580156126aa573d6000803e3d6000fd5b5050600754604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815230600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff909216935063b4f56b26925060448082019260009290919082900301818387803b15801561272757600080fd5b505af115801561273b573d6000803e3d6000fd5b50505050505050505050565b60065473ffffffffffffffffffffffffffffffffffffffff16331480612784575060035473ffffffffffffffffffffffffffffffffffffffff1633145b6127d9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b601483905560168290556017819055600854604080517fc3355b8d000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163c3355b8d91600480820192602092909190829003018186803b15801561285357600080fd5b505afa158015612867573d6000803e3d6000fd5b505050506040513d602081101561287d57600080fd5b5051600c55600854604080517fcb73999f000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163cb73999f91600480820192602092909190829003018186803b1580156128ed57600080fd5b505afa158015612901573d6000803e3d6000fd5b505050506040513d602081101561291757600080fd5b5051600d55505050565b60105481565b604080517f4d494e545f5041555345520000000000000000000000000000000000000000008152905190819003600b01902061296390336136c5565b61296c57600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b601854610100900460ff1615612a1557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f52656465656d696e672069732070617573656400000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b158015612a8057600080fd5b505afa158015612a94573d6000803e3d6000fd5b505050506040513d6020811015612aaa57600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b158015612b1d57600080fd5b505afa158015612b31573d6000803e3d6000fd5b505050506040513d6020811015612b4757600080fd5b50519050620f424081108015612b5d5750600081115b612bb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180614a756038913960400191505060405180910390fd5b6000612bbc613fed565b90506000612bec612bdf620f4240610c28600d548b61429d90919063ffffffff16565b889063ffffffff6141a316565b90506000612c17612c0a620f4240610c28858863ffffffff61429d16565b839063ffffffff6141a316565b90506000612c3286610c2884620f424063ffffffff61429d16565b90506000612c4e601354600a0a8561431090919063ffffffff16565b90506000612c69620f4240610c28848a63ffffffff61429d16565b90506000612c8487610c2884620f424063ffffffff61429d16565b336000908152600f6020526040902054909150612ca7908263ffffffff61422916565b336000908152600f6020526040902055601054612cca908263ffffffff61422916565b601055336000908152600e6020526040902054612ced908563ffffffff61422916565b336000908152600e6020526040902055601154612d10908563ffffffff61422916565b6011553360009081526012602090815260409182902043905560105460015483517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529351612d9d94929373ffffffffffffffffffffffffffffffffffffffff909216926370a08231926024808301939192829003018186803b158015610cef57600080fd5b811115612e0b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e6f7420656e6f75676820636f6c6c61746572616c20696e20706f6f6c000000604482015290519081900360640190fd5b808a1115612e64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614aad6023913960400191505060405180910390fd5b838b1115612ed357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f536c697070616765206c696d69742072656163686564205b4658535d00000000604482015290519081900360640190fd5b600854604080517fa8a778ae000000000000000000000000000000000000000000000000000000008152336004820152602481018f9052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b158015612f4c57600080fd5b505af1158015612f60573d6000803e3d6000fd5b5050600754604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815230600482015260248101899052905173ffffffffffffffffffffffffffffffffffffffff909216935063b4f56b26925060448082019260009290919082900301818387803b158015612fdd57600080fd5b505af1158015612ff1573d6000803e3d6000fd5b50505050505050505050505050505050565b60185462010000900460ff161561307b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5265636f6c6c61746572616c697a652069732070617573656400000000000000604482015290519081900360640190fd5b601354600854604080517fe7dced670000000000000000000000000000000000000000000000000000000081529051600a9390930a85029260009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156130f257600080fd5b505afa158015613106573d6000803e3d6000fd5b505050506040513d602081101561311c57600080fd5b5051600854604080517f18160ddd000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916318160ddd91600480820192602092909190829003018186803b15801561318f57600080fd5b505afa1580156131a3573d6000803e3d6000fd5b505050506040513d60208110156131b957600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561322c57600080fd5b505afa158015613240573d6000803e3d6000fd5b505050506040513d602081101561325657600080fd5b5051600854604080517fd2d97b06000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff9092169163d2d97b0691600480820192602092909190829003018186803b1580156132c957600080fd5b505afa1580156132dd573d6000803e3d6000fd5b505050506040513d60208110156132f357600080fd5b5051905060008073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a46306058f4a8861331d613fed565b8689896040518663ffffffff1660e01b81526004018086815260200185815260200184815260200183815260200182815260200195505050505050604080518083038186803b15801561336f57600080fd5b505af4158015613383573d6000803e3d6000fd5b505050506040513d604081101561339957600080fd5b50805160209091015160135491935091506000906133c1908490600a0a63ffffffff61431016565b905060006133f188610c286133e4601654620f424061422990919063ffffffff16565b869063ffffffff61429d16565b9050808a111561346257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600154604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101859052905173ffffffffffffffffffffffffffffffffffffffff909216916323b872dd916064808201926020929091908290030181600087803b1580156134e257600080fd5b505af11580156134f6573d6000803e3d6000fd5b505050506040513d602081101561350c57600080fd5b5050600754604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163b4f56b269160448082019260009290919082900301818387803b15801561358757600080fd5b505af115801561359b573d6000803e3d6000fd5b505050505050505050505050505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314806135e9575060035473ffffffffffffffffffffffffffffffffffffffff1633145b61363e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b600a805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182168117909255600980548216909217909155600b8054929093169116179055565b60008281526020819052604081206136bc908363ffffffff61464e16565b90505b92915050565b60008281526020819052604081206136bc908363ffffffff61420716565b600081565b60126020526000908152604090205481565b60065473ffffffffffffffffffffffffffffffffffffffff16331480613737575060035473ffffffffffffffffffffffffffffffffffffffff1633145b61378c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60185460ff161561384557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4d696e74696e6720697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156138b057600080fd5b505afa1580156138c4573d6000803e3d6000fd5b505050506040513d60208110156138da57600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561394d57600080fd5b505afa158015613961573d6000803e3d6000fd5b505050506040513d602081101561397757600080fd5b5051905080156139e857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f436f6c6c61746572616c20726174696f206d7573742062652030000000000000604482015290519081900360640190fd5b600073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a463f69a7aa8600c5485886040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015613a4b57600080fd5b505af4158015613a5f573d6000803e3d6000fd5b505050506040513d6020811015613a7557600080fd5b5051905080841115613ae857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600754604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101889052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b158015613b6157600080fd5b505af1158015613b75573d6000803e3d6000fd5b5050600854604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff909216935063b4f56b26925060448082019260009290919082900301818387803b158015611b4b57600080fd5b60155481565b600e6020526000908152604090205481565b60008181526020819052604081206136bf9061465a565b600082815260208190526040902060020154613c3f90610d6f614352565b610e62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b336030913960400191505060405180910390fd5b604080517f52454445454d5f504155534552000000000000000000000000000000000000008152905190819003600d019020613cd090336136c5565b613cd957600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b604080517f434f4c4c41544552414c5f50524943455f50415553455200000000000000000081529051908190036017019020613d4f90336136c5565b613d5857600080fd5b601854640100000000900460ff16613d7a57613d72613fed565b601555613d80565b60006015555b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff81166401000000009182900460ff1615909102179055565b600080600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015613e2857600080fd5b505afa158015613e3c573d6000803e3d6000fd5b505050506040513d6020811015613e5257600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b158015613ec557600080fd5b505afa158015613ed9573d6000803e3d6000fd5b505050506040513d6020811015613eef57600080fd5b5051600854604080517fd2d97b06000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff9092169163d2d97b0691600480820192602092909190829003018186803b158015613f6257600080fd5b505afa158015613f76573d6000803e3d6000fd5b505050506040513d6020811015613f8c57600080fd5b50519050620f4240821115613fa257620f424091505b6000613fbb620f4240610c28868663ffffffff61429d16565b905080821115613fe057613fd5828263ffffffff6141a316565b945050505050610d39565b6000945050505050610d39565b601854600090640100000000900460ff161515600114156140115750601554610d39565b600854604080517f345ba24b000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163345ba24b916004808301926020929190829003018186803b15801561407c57600080fd5b505afa158015614090573d6000803e3d6000fd5b505050506040513d60208110156140a657600080fd5b5051600954600b54601354604080517f3ddac95300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9384166004820152600a9290920a620f424002602483015251939450614176939190921691633ddac953916044808301926020929190829003018186803b15801561413757600080fd5b505afa15801561414b573d6000803e3d6000fd5b505050506040513d602081101561416157600080fd5b5051610c2883620f424063ffffffff61429d16565b915050610d39565b60185465010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b60006136bc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614665565b60006136bc8373ffffffffffffffffffffffffffffffffffffffff8416614716565b60006136bc8373ffffffffffffffffffffffffffffffffffffffff8416614760565b6000828201838110156136bc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000826142ac575060006136bf565b828202828482816142b957fe5b04146136bc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614b936021913960400191505060405180910390fd5b60006136bc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614778565b3390565b6000828152602081905260409020614374908263ffffffff6141e516565b15610dd357614381614352565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020819052604090206143fd908263ffffffff6147f716565b15610dd35761440a614352565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600080600080614490620f4240610c288760200151886080015161429d90919063ffffffff16565b91506144b4620f4240610c2887606001518860a0015161429d90919063ffffffff16565b905060006144e7826144db886101000151610c28620f42408761429d90919063ffffffff16565b9063ffffffff6141a316565b905060006145098760200151610c28620f42408561429d90919063ffffffff16565b9050614540614530620f4240610c288a60000151610d27878961422990919063ffffffff16565b6144db858563ffffffff61422916565b95509350505050915091565b80516000906145a6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614b126021913960400191505060405180910390fd5b60006145ca620f4240610c288560200151866060015161429d90919063ffffffff16565b8351909150811115614627576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614a456030913960400191505060405180910390fd5b604083015160009061464690610c2884620f424063ffffffff61429d16565b949350505050565b60006136bc8383614819565b60006136bf82614897565b6000818484111561470e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156146d35781810151838201526020016146bb565b50505050905090810190601f1680156147005780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60006147228383614760565b614758575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556136bf565b5060006136bf565b60009081526001919091016020526040902054151590565b600081836147e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526020600482018181528351602484015283519092839260449091019190850190808383600083156146d35781810151838201526020016146bb565b5060008385816147ed57fe5b0495945050505050565b60006136bc8373ffffffffffffffffffffffffffffffffffffffff841661489b565b81546000908210614875576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806149f46022913960400191505060405180910390fd5b82600001828154811061488457fe5b9060005260206000200154905092915050565b5490565b600081815260018301602052604081205480156149755783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106148ec57fe5b906000526020600020015490508087600001848154811061490957fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061493957fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506136bf565b60009150506136bf565b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604051806080016040528060008152602001600081526020016000815260200160008152509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74596f752061726520747279696e6720746f20627579206261636b206d6f7265207468616e207468652065786365737321436f6c6c61746572616c20726174696f206e6565647320746f206265206265747765656e202e30303030303120616e64202e393939393939536c697070616765206c696d69742072656163686564205b636f6c6c61746572616c5d4d757374207761697420666f7220726564656d7074696f6e5f64656c617920626c6f636b73206265666f726520636f6c6c656374696e6720726564656d7074696f6e4e6f2065786365737320636f6c6c61746572616c20746f20627579206261636b21416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65596f7520617265206e6f7420746865206f776e6572206f722074686520676f7665726e616e63652074696d656c6f636b536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77506f6f6c206365696c696e6720726561636865642c206e6f206d6f726520465241582063616e206265206d696e7465642077697468207468697320636f6c6c61746572616c416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212204bc45f9b221d63a53540b282e5eae9175d4d1b4a18cbe5f3f9398eb7fb43b17c64736f6c634300060b0033416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74000000000000000000000000853d955acef822db058eb8505911ed77f175b99e0000000000000000000000003432b6a60d23ca0dfca7761b7ab56459d9c964d0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000b39e2041b042f39b8572b6f84deba99bbb589c8d0000000000000000000000008412ebf45bac1b340bbe8f318b928c466c4e39ca0000000000000000000000000000000000000000000000000000048c27395000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102ad5760003560e01c80637b0461e91161017b578063bdb345cb116100d8578063daa504851161008c578063f61adab211610071578063f61adab21461073b578063f7683bbc14610743578063f9abd26c1461074b576102ad565b8063daa504851461072b578063e2708e2014610733576102ad565b8063c76417d7116100bd578063c76417d7146106a2578063ca15c873146106d5578063d547741f146106f2576102ad565b8063bdb345cb14610677578063c74ec56a1461069a576102ad565b80639010d07c1161012f578063a217fddf11610114578063a217fddf14610609578063abae2c4c14610611578063bdacb30314610644576102ad565b80639010d07c1461057057806391d14854146105bc576102ad565b80637e108af9116101605780637e108af9146104e957806383c7ded71461051257806388d42cf214610535576102ad565b80637b0461e9146104d95780637d55094d146104e1576102ad565b80634c26203c11610229578063645af53c116101dd578063658445a8116101c2578063658445a81461046a5780636f5db87f1461048d5780637a00e0e2146104b0576102ad565b8063645af53c1461043f5780636526a12a14610462576102ad565b806350c9ecd91161020e57806350c9ecd9146103eb5780635bb87b42146103f35780635bd826631461041c576102ad565b80634c26203c146103db5780634c634934146103e3576102ad565b806317284c94116102805780632f2ff15d116102655780632f2ff15d1461036157806336568abe1461039a57806342d15aec146103d3576102ad565b806317284c941461033c578063248a9ca314610344576102ad565b806308a7493d146102b257806312ace5a2146102f757806313af4035146103015780631512842514610334575b600080fd5b6102e5600480360360208110156102c857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610753565b60408051918252519081900360200190f35b6102ff610765565b005b6102ff6004803603602081101561031757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166109dd565b6102e5610ab6565b6102e5610abc565b6102e56004803603602081101561035a57600080fd5b5035610d3c565b6102ff6004803603604081101561037757600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16610d51565b6102ff600480360360408110156103b057600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16610dd7565b6102ff610e6c565b6102e5610eec565b6102e5610ef2565b6102ff610ef8565b6102ff6004803603606081101561040957600080fd5b5080359060208101359060400135610f79565b6102ff6004803603604081101561043257600080fd5b50803590602001356116a7565b6102ff6004803603604081101561045557600080fd5b5080359060200135611b6a565b6102e5611fc6565b6102ff6004803603604081101561048057600080fd5b5080359060200135611fcc565b6102ff600480360360408110156104a357600080fd5b50803590602001356122ed565b6102ff600480360360608110156104c657600080fd5b5080359060208101359060400135612747565b6102e5612921565b6102ff612927565b6102ff600480360360608110156104ff57600080fd5b508035906020810135906040013561299e565b6102ff6004803603604081101561052857600080fd5b5080359060200135613003565b6102ff6004803603604081101561054b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166135ac565b6105936004803603604081101561058657600080fd5b508035906020013561369e565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6105f5600480360360408110156105d257600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff166136c5565b604080519115158252519081900360200190f35b6102e56136e3565b6102e56004803603602081101561062757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166136e8565b6102ff6004803603602081101561065a57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166136fa565b6102ff6004803603604081101561068d57600080fd5b50803590602001356137d3565b6102e5613bf2565b6102e5600480360360208110156106b857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16613bf8565b6102e5600480360360208110156106eb57600080fd5b5035613c0a565b6102ff6004803603604081101561070857600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16613c21565b6102ff613c94565b6102ff613d13565b6102e5613dbd565b6102e5613fed565b61059361417e565b600f6020526000908152604090205481565b60175433600090815260126020526040902054439161078a919063ffffffff61422916565b11156107e1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526042815260200180614ad06042913960600191505060405180910390fd5b336000908152600e60205260408120548190819081901561082e57336000908152600e602052604081208054919055601154909250610826908363ffffffff6141a316565b601155600193505b336000908152600f6020526040902054156108735750336000908152600f60205260408120805491905560105461086b908263ffffffff6141a316565b601055600192505b6001841515141561092557600754604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101859052905173ffffffffffffffffffffffffffffffffffffffff9092169163a9059cbb916044808201926020929091908290030181600087803b1580156108f857600080fd5b505af115801561090c573d6000803e3d6000fd5b505050506040513d602081101561092257600080fd5b50505b600183151514156109d757600154604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163a9059cbb916044808201926020929091908290030181600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050506040513d60208110156109d457600080fd5b50505b50505050565b60065473ffffffffffffffffffffffffffffffffffffffff16331480610a1a575060035473ffffffffffffffffffffffffffffffffffffffff1633145b610a6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60175481565b600080600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663345ba24b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b2757600080fd5b505afa158015610b3b573d6000803e3d6000fd5b505050506040513d6020811015610b5157600080fd5b5051600954600b54601354604080517f3ddac95300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9384166004820152600a9290920a620f4240026024830152519394506000939190921691633ddac953916044808301926020929190829003018186803b158015610be157600080fd5b505afa158015610bf5573d6000803e3d6000fd5b505050506040513d6020811015610c0b57600080fd5b505190506000610c3482610c2885620f424063ffffffff61429d16565b9063ffffffff61431016565b9050610d33620f4240610c2883610d27601354600a0a610d27601054600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610cef57600080fd5b505afa158015610d03573d6000803e3d6000fd5b505050506040513d6020811015610d1957600080fd5b50519063ffffffff6141a316565b9063ffffffff61429d16565b93505050505b90565b60009081526020819052604090206002015490565b600082815260208190526040902060020154610d7490610d6f614352565b6136c5565b610dc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614a16602f913960400191505060405180910390fd5b610dd38282614356565b5050565b610ddf614352565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610e62576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180614bf9602f913960400191505060405180910390fd5b610dd382826143df565b604080517f5245434f4c4c41544552414c495a455f5041555345520000000000000000000081529051908190036016019020610ea890336136c5565b610eb157600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff8116620100009182900460ff1615909102179055565b60115481565b60165481565b604080517f4255594241434b5f5041555345520000000000000000000000000000000000008152905190819003600e019020610f3490336136c5565b610f3d57600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffff811663010000009182900460ff1615909102179055565b60185460ff1615610feb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4d696e74696e6720697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b600854604080517fb4db0980000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163b4db0980916004808301926020929190829003018186803b15801561105657600080fd5b505afa15801561106a573d6000803e3d6000fd5b505050506040513d602081101561108057600080fd5b5051600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff9092169163e7dced6791600480820192602092909190829003018186803b1580156110f357600080fd5b505afa158015611107573d6000803e3d6000fd5b505050506040513d602081101561111d57600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561119057600080fd5b505afa1580156111a4573d6000803e3d6000fd5b505050506040513d60208110156111ba57600080fd5b50519050620f4240811080156111d05750600081115b611225576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180614a756038913960400191505060405180910390fd5b601454601054600154604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516112b3938b936112a793919273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b158015610cef57600080fd5b9063ffffffff61422916565b111561130a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526045815260200180614bb46045913960600191505060405180910390fd5b601354600a0a860261131a61497f565b604051806101200160405280600c548152602001858152602001868152602001611342613fed565b815260208082018a9052604080830186905260105460015482517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015292516060909501946113cd94929373ffffffffffffffffffffffffffffffffffffffff909216926370a082319260248082019391829003018186803b158015610cef57600080fd5b8152601454602082015260400184905290506000806113eb83614468565b915091508188111561145e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b888111156114cd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4e6f7420656e6f7567682046585320696e707574746564000000000000000000604482015290519081900360640190fd5b600754604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b15801561154657600080fd5b505af115801561155a573d6000803e3d6000fd5b5050600154604080517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018f9052905173ffffffffffffffffffffffffffffffffffffffff90921693506323b872dd92506064808201926020929091908290030181600087803b1580156115de57600080fd5b505af11580156115f2573d6000803e3d6000fd5b505050506040513d602081101561160857600080fd5b5050600854604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101859052905173ffffffffffffffffffffffffffffffffffffffff9092169163b4f56b269160448082019260009290919082900301818387803b15801561168357600080fd5b505af1158015611697573d6000803e3d6000fd5b5050505050505050505050505050565b60185460ff161561171957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4d696e74696e6720697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b601354600854604080517f2eb9771b0000000000000000000000000000000000000000000000000000000081529051600a9390930a85029260009273ffffffffffffffffffffffffffffffffffffffff1691632eb9771b916004808301926020929190829003018186803b15801561179057600080fd5b505afa1580156117a4573d6000803e3d6000fd5b505050506040513d60208110156117ba57600080fd5b50519050620f424081101561183057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f436f6c6c61746572616c20726174696f206d757374206265203e3d2031000000604482015290519081900360640190fd5b601454601054600154604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516118b29389936112a793919273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b158015610cef57600080fd5b111561191f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5b506f6f6c277320436c6f7365645d3a204365696c696e672072656163686564604482015290519081900360640190fd5b600073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a4637d7496d4611943613fed565b600c54866040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b15801561198957600080fd5b505af415801561199d573d6000803e3d6000fd5b505050506040513d60208110156119b357600080fd5b5051905080841115611a2657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600154604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101889052905173ffffffffffffffffffffffffffffffffffffffff909216916323b872dd916064808201926020929091908290030181600087803b158015611aa657600080fd5b505af1158015611aba573d6000803e3d6000fd5b505050506040513d6020811015611ad057600080fd5b5050600854604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163b4f56b269160448082019260009290919082900301818387803b158015611b4b57600080fd5b505af1158015611b5f573d6000803e3d6000fd5b505050505050505050565b601854610100900460ff1615611be157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f52656465656d696e672069732070617573656400000000000000000000000000604482015290519081900360640190fd5b600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff1691632eb9771b916004808301926020929190829003018186803b158015611c4c57600080fd5b505afa158015611c60573d6000803e3d6000fd5b505050506040513d6020811015611c7657600080fd5b50519050620f42408114611ceb57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f436f6c6c61746572616c20726174696f206d757374206265203d3d2031000000604482015290519081900360640190fd5b6000611d05601354600a0a8561431090919063ffffffff16565b9050600073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a4630a9b920a611d2b613fed565b84600d546040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015611d7157600080fd5b505af4158015611d85573d6000803e3d6000fd5b505050506040513d6020811015611d9b57600080fd5b5051601054600154604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051939450611e189373ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015610cef57600080fd5b811115611e8657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e6f7420656e6f75676820636f6c6c61746572616c20696e20706f6f6c000000604482015290519081900360640190fd5b336000908152600f6020526040902054611ea6908263ffffffff61422916565b336000908152600f6020526040902055601054611ec9908263ffffffff61422916565b60105533600090815260126020526040902043905580841115611f4d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600854604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101889052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b158015611b4b57600080fd5b60145481565b6018546301000000900460ff161561204557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4275796261636b20697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156120b057600080fd5b505afa1580156120c4573d6000803e3d6000fd5b505050506040513d60208110156120da57600080fd5b505190506120e66149cb565b60405180608001604052806120f9613dbd565b815260200183815260200161210c613fed565b8152602001859052905060006121218261454c565b9050600061213d601354600a0a8361431090919063ffffffff16565b9050808511156121ae57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600754604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101899052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b15801561222757600080fd5b505af115801561223b573d6000803e3d6000fd5b5050600154604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff909216935063a9059cbb92506044808201926020929091908290030181600087803b1580156122b957600080fd5b505af11580156122cd573d6000803e3d6000fd5b505050506040513d60208110156122e357600080fd5b5050505050505050565b601854610100900460ff161561236457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f52656465656d696e672069732070617573656400000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156123cf57600080fd5b505afa1580156123e3573d6000803e3d6000fd5b505050506040513d60208110156123f957600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561246c57600080fd5b505afa158015612480573d6000803e3d6000fd5b505050506040513d602081101561249657600080fd5b50519050801561250757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f436f6c6c61746572616c20726174696f206d7573742062652030000000000000604482015290519081900360640190fd5b600084905061253861252b620f4240610c28600d548561429d90919063ffffffff16565b829063ffffffff6141a316565b9050600061255384610c2884620f424063ffffffff61429d16565b336000908152600e6020526040902054909150612576908263ffffffff61422916565b336000908152600e6020526040902055601154612599908263ffffffff61422916565b6011553360009081526012602052604090204390558085111561261d57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600854604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101899052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b15801561269657600080fd5b505af11580156126aa573d6000803e3d6000fd5b5050600754604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815230600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff909216935063b4f56b26925060448082019260009290919082900301818387803b15801561272757600080fd5b505af115801561273b573d6000803e3d6000fd5b50505050505050505050565b60065473ffffffffffffffffffffffffffffffffffffffff16331480612784575060035473ffffffffffffffffffffffffffffffffffffffff1633145b6127d9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b601483905560168290556017819055600854604080517fc3355b8d000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163c3355b8d91600480820192602092909190829003018186803b15801561285357600080fd5b505afa158015612867573d6000803e3d6000fd5b505050506040513d602081101561287d57600080fd5b5051600c55600854604080517fcb73999f000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff9092169163cb73999f91600480820192602092909190829003018186803b1580156128ed57600080fd5b505afa158015612901573d6000803e3d6000fd5b505050506040513d602081101561291757600080fd5b5051600d55505050565b60105481565b604080517f4d494e545f5041555345520000000000000000000000000000000000000000008152905190819003600b01902061296390336136c5565b61296c57600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00811660ff90911615179055565b601854610100900460ff1615612a1557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f52656465656d696e672069732070617573656400000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b158015612a8057600080fd5b505afa158015612a94573d6000803e3d6000fd5b505050506040513d6020811015612aaa57600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b158015612b1d57600080fd5b505afa158015612b31573d6000803e3d6000fd5b505050506040513d6020811015612b4757600080fd5b50519050620f424081108015612b5d5750600081115b612bb2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180614a756038913960400191505060405180910390fd5b6000612bbc613fed565b90506000612bec612bdf620f4240610c28600d548b61429d90919063ffffffff16565b889063ffffffff6141a316565b90506000612c17612c0a620f4240610c28858863ffffffff61429d16565b839063ffffffff6141a316565b90506000612c3286610c2884620f424063ffffffff61429d16565b90506000612c4e601354600a0a8561431090919063ffffffff16565b90506000612c69620f4240610c28848a63ffffffff61429d16565b90506000612c8487610c2884620f424063ffffffff61429d16565b336000908152600f6020526040902054909150612ca7908263ffffffff61422916565b336000908152600f6020526040902055601054612cca908263ffffffff61422916565b601055336000908152600e6020526040902054612ced908563ffffffff61422916565b336000908152600e6020526040902055601154612d10908563ffffffff61422916565b6011553360009081526012602090815260409182902043905560105460015483517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529351612d9d94929373ffffffffffffffffffffffffffffffffffffffff909216926370a08231926024808301939192829003018186803b158015610cef57600080fd5b811115612e0b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4e6f7420656e6f75676820636f6c6c61746572616c20696e20706f6f6c000000604482015290519081900360640190fd5b808a1115612e64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180614aad6023913960400191505060405180910390fd5b838b1115612ed357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f536c697070616765206c696d69742072656163686564205b4658535d00000000604482015290519081900360640190fd5b600854604080517fa8a778ae000000000000000000000000000000000000000000000000000000008152336004820152602481018f9052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b158015612f4c57600080fd5b505af1158015612f60573d6000803e3d6000fd5b5050600754604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815230600482015260248101899052905173ffffffffffffffffffffffffffffffffffffffff909216935063b4f56b26925060448082019260009290919082900301818387803b158015612fdd57600080fd5b505af1158015612ff1573d6000803e3d6000fd5b50505050505050505050505050505050565b60185462010000900460ff161561307b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f5265636f6c6c61746572616c697a652069732070617573656400000000000000604482015290519081900360640190fd5b601354600854604080517fe7dced670000000000000000000000000000000000000000000000000000000081529051600a9390930a85029260009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156130f257600080fd5b505afa158015613106573d6000803e3d6000fd5b505050506040513d602081101561311c57600080fd5b5051600854604080517f18160ddd000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916318160ddd91600480820192602092909190829003018186803b15801561318f57600080fd5b505afa1580156131a3573d6000803e3d6000fd5b505050506040513d60208110156131b957600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561322c57600080fd5b505afa158015613240573d6000803e3d6000fd5b505050506040513d602081101561325657600080fd5b5051600854604080517fd2d97b06000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff9092169163d2d97b0691600480820192602092909190829003018186803b1580156132c957600080fd5b505afa1580156132dd573d6000803e3d6000fd5b505050506040513d60208110156132f357600080fd5b5051905060008073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a46306058f4a8861331d613fed565b8689896040518663ffffffff1660e01b81526004018086815260200185815260200184815260200183815260200182815260200195505050505050604080518083038186803b15801561336f57600080fd5b505af4158015613383573d6000803e3d6000fd5b505050506040513d604081101561339957600080fd5b50805160209091015160135491935091506000906133c1908490600a0a63ffffffff61431016565b905060006133f188610c286133e4601654620f424061422990919063ffffffff16565b869063ffffffff61429d16565b9050808a111561346257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600154604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101859052905173ffffffffffffffffffffffffffffffffffffffff909216916323b872dd916064808201926020929091908290030181600087803b1580156134e257600080fd5b505af11580156134f6573d6000803e3d6000fd5b505050506040513d602081101561350c57600080fd5b5050600754604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101849052905173ffffffffffffffffffffffffffffffffffffffff9092169163b4f56b269160448082019260009290919082900301818387803b15801561358757600080fd5b505af115801561359b573d6000803e3d6000fd5b505050505050505050505050505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314806135e9575060035473ffffffffffffffffffffffffffffffffffffffff1633145b61363e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b600a805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182168117909255600980548216909217909155600b8054929093169116179055565b60008281526020819052604081206136bc908363ffffffff61464e16565b90505b92915050565b60008281526020819052604081206136bc908363ffffffff61420716565b600081565b60126020526000908152604090205481565b60065473ffffffffffffffffffffffffffffffffffffffff16331480613737575060035473ffffffffffffffffffffffffffffffffffffffff1633145b61378c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b636030913960400191505060405180910390fd5b600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60185460ff161561384557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f4d696e74696e6720697320706175736564000000000000000000000000000000604482015290519081900360640190fd5b600854604080517fe7dced67000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163e7dced67916004808301926020929190829003018186803b1580156138b057600080fd5b505afa1580156138c4573d6000803e3d6000fd5b505050506040513d60208110156138da57600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b15801561394d57600080fd5b505afa158015613961573d6000803e3d6000fd5b505050506040513d602081101561397757600080fd5b5051905080156139e857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f436f6c6c61746572616c20726174696f206d7573742062652030000000000000604482015290519081900360640190fd5b600073a11b9c88e4bf89ad9a70f5d408ffb5a6d5feb6a463f69a7aa8600c5485886040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015613a4b57600080fd5b505af4158015613a5f573d6000803e3d6000fd5b505050506040513d6020811015613a7557600080fd5b5051905080841115613ae857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f536c697070616765206c696d6974207265616368656400000000000000000000604482015290519081900360640190fd5b600754604080517fa8a778ae00000000000000000000000000000000000000000000000000000000815233600482015260248101889052905173ffffffffffffffffffffffffffffffffffffffff9092169163a8a778ae9160448082019260009290919082900301818387803b158015613b6157600080fd5b505af1158015613b75573d6000803e3d6000fd5b5050600854604080517fb4f56b2600000000000000000000000000000000000000000000000000000000815233600482015260248101869052905173ffffffffffffffffffffffffffffffffffffffff909216935063b4f56b26925060448082019260009290919082900301818387803b158015611b4b57600080fd5b60155481565b600e6020526000908152604090205481565b60008181526020819052604081206136bf9061465a565b600082815260208190526040902060020154613c3f90610d6f614352565b610e62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614b336030913960400191505060405180910390fd5b604080517f52454445454d5f504155534552000000000000000000000000000000000000008152905190819003600d019020613cd090336136c5565b613cd957600080fd5b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff81166101009182900460ff1615909102179055565b604080517f434f4c4c41544552414c5f50524943455f50415553455200000000000000000081529051908190036017019020613d4f90336136c5565b613d5857600080fd5b601854640100000000900460ff16613d7a57613d72613fed565b601555613d80565b60006015555b601880547fffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffffffff81166401000000009182900460ff1615909102179055565b600080600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015613e2857600080fd5b505afa158015613e3c573d6000803e3d6000fd5b505050506040513d6020811015613e5257600080fd5b5051600854604080517f2eb9771b000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff90921691632eb9771b91600480820192602092909190829003018186803b158015613ec557600080fd5b505afa158015613ed9573d6000803e3d6000fd5b505050506040513d6020811015613eef57600080fd5b5051600854604080517fd2d97b06000000000000000000000000000000000000000000000000000000008152905192935060009273ffffffffffffffffffffffffffffffffffffffff9092169163d2d97b0691600480820192602092909190829003018186803b158015613f6257600080fd5b505afa158015613f76573d6000803e3d6000fd5b505050506040513d6020811015613f8c57600080fd5b50519050620f4240821115613fa257620f424091505b6000613fbb620f4240610c28868663ffffffff61429d16565b905080821115613fe057613fd5828263ffffffff6141a316565b945050505050610d39565b6000945050505050610d39565b601854600090640100000000900460ff161515600114156140115750601554610d39565b600854604080517f345ba24b000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163345ba24b916004808301926020929190829003018186803b15801561407c57600080fd5b505afa158015614090573d6000803e3d6000fd5b505050506040513d60208110156140a657600080fd5b5051600954600b54601354604080517f3ddac95300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9384166004820152600a9290920a620f424002602483015251939450614176939190921691633ddac953916044808301926020929190829003018186803b15801561413757600080fd5b505afa15801561414b573d6000803e3d6000fd5b505050506040513d602081101561416157600080fd5b5051610c2883620f424063ffffffff61429d16565b915050610d39565b60185465010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b60006136bc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614665565b60006136bc8373ffffffffffffffffffffffffffffffffffffffff8416614716565b60006136bc8373ffffffffffffffffffffffffffffffffffffffff8416614760565b6000828201838110156136bc57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000826142ac575060006136bf565b828202828482816142b957fe5b04146136bc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614b936021913960400191505060405180910390fd5b60006136bc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614778565b3390565b6000828152602081905260409020614374908263ffffffff6141e516565b15610dd357614381614352565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020819052604090206143fd908263ffffffff6147f716565b15610dd35761440a614352565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600080600080614490620f4240610c288760200151886080015161429d90919063ffffffff16565b91506144b4620f4240610c2887606001518860a0015161429d90919063ffffffff16565b905060006144e7826144db886101000151610c28620f42408761429d90919063ffffffff16565b9063ffffffff6141a316565b905060006145098760200151610c28620f42408561429d90919063ffffffff16565b9050614540614530620f4240610c288a60000151610d27878961422990919063ffffffff16565b6144db858563ffffffff61422916565b95509350505050915091565b80516000906145a6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180614b126021913960400191505060405180910390fd5b60006145ca620f4240610c288560200151866060015161429d90919063ffffffff16565b8351909150811115614627576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180614a456030913960400191505060405180910390fd5b604083015160009061464690610c2884620f424063ffffffff61429d16565b949350505050565b60006136bc8383614819565b60006136bf82614897565b6000818484111561470e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156146d35781810151838201526020016146bb565b50505050905090810190601f1680156147005780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60006147228383614760565b614758575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556136bf565b5060006136bf565b60009081526001919091016020526040902054151590565b600081836147e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526020600482018181528351602484015283519092839260449091019190850190808383600083156146d35781810151838201526020016146bb565b5060008385816147ed57fe5b0495945050505050565b60006136bc8373ffffffffffffffffffffffffffffffffffffffff841661489b565b81546000908210614875576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806149f46022913960400191505060405180910390fd5b82600001828154811061488457fe5b9060005260206000200154905092915050565b5490565b600081815260018301602052604081205480156149755783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106148ec57fe5b906000526020600020015490508087600001848154811061490957fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061493957fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506136bf565b60009150506136bf565b6040518061012001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604051806080016040528060008152602001600081526020016000815260200160008152509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74596f752061726520747279696e6720746f20627579206261636b206d6f7265207468616e207468652065786365737321436f6c6c61746572616c20726174696f206e6565647320746f206265206265747765656e202e30303030303120616e64202e393939393939536c697070616765206c696d69742072656163686564205b636f6c6c61746572616c5d4d757374207761697420666f7220726564656d7074696f6e5f64656c617920626c6f636b73206265666f726520636f6c6c656374696e6720726564656d7074696f6e4e6f2065786365737320636f6c6c61746572616c20746f20627579206261636b21416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65596f7520617265206e6f7420746865206f776e6572206f722074686520676f7665726e616e63652074696d656c6f636b536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77506f6f6c206365696c696e6720726561636865642c206e6f206d6f726520465241582063616e206265206d696e7465642077697468207468697320636f6c6c61746572616c416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a26469706673582212204bc45f9b221d63a53540b282e5eae9175d4d1b4a18cbe5f3f9398eb7fb43b17c64736f6c634300060b0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000853d955acef822db058eb8505911ed77f175b99e0000000000000000000000003432b6a60d23ca0dfca7761b7ab56459d9c964d0000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000b39e2041b042f39b8572b6f84deba99bbb589c8d0000000000000000000000008412ebf45bac1b340bbe8f318b928c466c4e39ca0000000000000000000000000000000000000000000000000000048c27395000
-----Decoded View---------------
Arg [0] : _frax_contract_address (address): 0x853d955aCEf822Db058eb8505911ED77F175b99e
Arg [1] : _fxs_contract_address (address): 0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0
Arg [2] : _collateral_address (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Arg [3] : _creator_address (address): 0xb39e2041b042f39b8572B6F84dEba99BbB589c8d
Arg [4] : _timelock_address (address): 0x8412ebf45bAC1B340BbE8F318b928C466c4E39CA
Arg [5] : _pool_ceiling (uint256): 5000000000000
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000853d955acef822db058eb8505911ed77f175b99e
Arg [1] : 0000000000000000000000003432b6a60d23ca0dfca7761b7ab56459d9c964d0
Arg [2] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [3] : 000000000000000000000000b39e2041b042f39b8572b6f84deba99bbb589c8d
Arg [4] : 0000000000000000000000008412ebf45bac1b340bbe8f318b928c466c4e39ca
Arg [5] : 0000000000000000000000000000000000000000000000000000048c27395000
Deployed Bytecode Sourcemap
83:556:35:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1233:60:18;;;;;;;;;;;;;;;;-1:-1:-1;1233:60:18;;;;:::i;:::-;;;;;;;;;;;;;;;;15231:1145;;;:::i;:::-;;20809:122;;;;;;;;;;;;;;;;-1:-1:-1;20809:122:18;;;;:::i;2176:35::-;;;:::i;4613:539::-;;;:::i;4323:112:0:-;;;;;;;;;;;;;;;;-1:-1:-1;4323:112:0;;:::i;4685:223::-;;;;;;;;;;;;;;;;-1:-1:-1;4685:223:0;;;;;;;;;:::i;5859:205::-;;;;;;;;;;;;;;;;-1:-1:-1;5859:205:0;;;;;;;;;:::i;19532:167:18:-;;;:::i;1343:31::-;;;:::i;2064:32::-;;;:::i;19709:135::-;;;:::i;8813:1592::-;;;;;;;;;;;;;;;;-1:-1:-1;8813:1592:18;;;;;;;;;;;;:::i;7028:964::-;;;;;;;;;;;;;;;;-1:-1:-1;7028:964:18;;;;;;;:::i;10460:1174::-;;;;;;;;;;;;;;;;-1:-1:-1;10460:1174:18;;;;;;;:::i;1820:31::-;;;:::i;18301:895::-;;;;;;;;;;;;;;;;-1:-1:-1;18301:895:18;;;;;;;:::i;13858:1037::-;;;;;;;;;;;;;;;;-1:-1:-1;13858:1037:18;;;;;;;:::i;20319:354::-;;;;;;;;;;;;;;;;-1:-1:-1;20319:354:18;;;;;;;;;;;;:::i;1299:38::-;;;:::i;19256:126::-;;;:::i;11773:2030::-;;;;;;;;;;;;;;;;-1:-1:-1;11773:2030:18;;;;;;;;;;;;:::i;16878:1220::-;;;;;;;;;;;;;;;;-1:-1:-1;16878:1220:18;;;;;;;:::i;6608:317::-;;;;;;;;;;;;;;;;-1:-1:-1;6608:317:18;;;;;;;;;;;:::i;4006:136:0:-;;;;;;;;;;;;;;;;-1:-1:-1;4006:136:0;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;2991:137;;;;;;;;;;;;;;;;-1:-1:-1;2991:137:0;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;1698:49;;;:::i;1380:48:18:-;;;;;;;;;;;;;;;;-1:-1:-1;1380:48:18;;;;:::i;20679:124::-;;;;;;;;;;;;;;;;-1:-1:-1;20679:124:18;;;;:::i;8026:678::-;;;;;;;;;;;;;;;;-1:-1:-1;8026:678:18;;;;;;;:::i;1916:30::-;;;:::i;1174:53::-;;;;;;;;;;;;;;;;-1:-1:-1;1174:53:18;;;;:::i;3296:125:0:-;;;;;;;;;;;;;;;;-1:-1:-1;3296:125:0;;:::i;5142:226::-;;;;;;;;;;;;;;;;-1:-1:-1;5142:226:0;;;;;;;;;:::i;19392:134:18:-;;;:::i;19850:394::-;;;:::i;5295:823::-;;;:::i;6233:369::-;;;:::i;120:27:35:-;;;:::i;1233:60:18:-;;;;;;;;;;;;;:::o;15231:1145::-;15317:16;;15301:10;15288:24;;;;:12;:24;;;;;;15339:12;;15288:46;;:24;:46;:28;:46;:::i;:::-;15287:64;;15279:143;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;15627:10;15432:12;15609:29;;;:17;:29;;;;;;15432:12;;;;;;15609:33;15606:243;;15687:10;15669:29;;;;:17;:29;;;;;;;15712:33;;;15778:16;;15669:29;;-1:-1:-1;15778:31:18;;15669:29;15778:31;:20;:31;:::i;:::-;15759:16;:50;15834:4;;-1:-1:-1;15606:243:18;15895:10;15909:1;15870:36;;;:24;:36;;;;;;:40;15867:299;;-1:-1:-1;15969:10:18;15944:36;;;;:24;:36;;;;;;;15994:40;;;16074:23;;:45;;15944:36;16074:45;:27;:45;:::i;:::-;16048:23;:71;16151:4;;-1:-1:-1;15867:299:18;16190:4;16179:15;;;;16176:79;;;16209:3;;:35;;;;;;16222:10;16209:35;;;;;;;;;;;;:3;;;;;:12;;:35;;;;;;;;;;;;;;;:3;;:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;16176:79:18;16285:4;16267:22;;;;16264:106;;;16304:16;;:55;;;;;;16330:10;16304:55;;;;;;;;;;;;:16;;;;;:25;;:55;;;;;;;;;;;;;;;:16;;:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;16264:106:18;15231:1145;;;;:::o;20809:122::-;3011:16;;;;2997:10;:30;;:61;;-1:-1:-1;3045:13:18;;;;3031:10;:27;2997:61;2989:122;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;20894:13:::1;:30:::0;;;::::1;;::::0;;;::::1;::::0;;;::::1;::::0;;20809:122::o;2176:35::-;;;;:::o;4613:539::-;4665:7;4684:21;4708:4;;;;;;;;;;;:18;;;:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;4708:20:18;4765:15;;4789:12;;4829:16;;4765:83;;;;;;:15;4789:12;;;4765:83;;;;4823:2;:22;;;;1518:3;4804:42;4765:83;;;;;4708:20;;-1:-1:-1;;;4765:15:18;;;;;:23;;:83;;;;;4708:20;;4765:83;;;;;;;:15;:83;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;4765:83:18;;-1:-1:-1;4859:24:18;4886:56;4765:83;4886:34;:13;1518:3;4886:34;:17;:34;:::i;:::-;:38;:56;:38;:56;:::i;:::-;4859:83;;4959:143;1518:3;4959:122;5064:16;4959:100;5042:16;;5036:2;:22;4960:70;5006:23;;4960:16;;;;;;;;;;;:26;;;4995:4;4960:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;4960:41:18;;:70;:45;:70;:::i;:::-;4959:76;:100;:76;:100;:::i;:143::-;4952:150;;;;;4613:539;;:::o;4323:112:0:-;4380:7;4406:12;;;;;;;;;;:22;;;;4323:112::o;4685:223::-;4776:6;:12;;;;;;;;;;:22;;;4768:45;;4800:12;:10;:12::i;:::-;4768:7;:45::i;:::-;4760:105;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4876:25;4887:4;4893:7;4876:10;:25::i;:::-;4685:223;;:::o;5859:205::-;5956:12;:10;:12::i;:::-;5945:23;;:7;:23;;;5937:83;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6031:26;6043:4;6049:7;6031:11;:26::i;19532:167:18:-;2512:35;;;;;;;;;;;;;;;;19592:43;;19624:10;19592:7;:43::i;:::-;19584:52;;;;;;19671:21;;;19646:46;;;19671:21;;;;;;;19670:22;19646:46;;;;;;19532:167::o;1343:31::-;;;;:::o;2064:32::-;;;;:::o;19709:135::-;2429:27;;;;;;;;;;;;;;;;19761:35;;19785:10;19761:7;:35::i;:::-;19753:44;;;;;;19824:13;;;19807:30;;;19824:13;;;;;;;19823:14;19807:30;;;;;;19709:135::o;8813:1592::-;3292:10;;;;:19;3284:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8964:4:::1;::::0;:17:::1;::::0;;;;;;;8943:18:::1;::::0;8964:4:::1;;::::0;:15:::1;::::0;:17:::1;::::0;;::::1;::::0;::::1;::::0;;;;;;;;:4;:17;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;8964:17:18;9011:4:::1;::::0;:16:::1;::::0;;;;;;;8964:17;;-1:-1:-1;8991:17:18::1;::::0;9011:4:::1;::::0;;::::1;::::0;:14:::1;::::0;:16:::1;::::0;;::::1;::::0;8964:17:::1;::::0;9011:16;;;;;;;;:4;:16;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;9011:16:18;9071:4:::1;::::0;:30:::1;::::0;;;;;;;9011:16;;-1:-1:-1;9037:31:18::1;::::0;9071:4:::1;::::0;;::::1;::::0;:28:::1;::::0;:30:::1;::::0;;::::1;::::0;9011:16:::1;::::0;9071:30;;;;;;;;:4;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;9071:30:18;;-1:-1:-1;1638:3:18::1;9120:46:::0;::::1;:77:::0;::::1;;;;9196:1;9170:23;:27;9120:77;9112:146;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9373:12;::::0;9322:23:::1;::::0;9276:16:::1;::::0;:41:::1;::::0;;;;;9311:4:::1;9276:41;::::0;::::1;::::0;;;:93:::1;::::0;9351:17;;9276:70:::1;::::0;9322:23;;9276:16:::1;::::0;;::::1;::::0;:26:::1;::::0;:41;;;;;::::1;::::0;;;;;;;;:16;:41;::::1;;::::0;::::1;;;;::::0;::::1;:70;:74:::0;:93:::1;:74;:93;:::i;:::-;:109;;9268:191;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9529:16;::::0;9523:2:::1;:22;9502:44:::0;::::1;9556:49;;:::i;:::-;9608:354;;;;;;;;9651:11;;9608:354;;;;9677:9;9608:354;;;;9700:10;9608:354;;;;9724:20;:18;:20::i;:::-;9608:354:::0;;::::1;::::0;;::::1;::::0;;;;;;;;;;9864:23:::1;::::0;9818:16:::1;::::0;:41;;;;;9853:4:::1;9818:41;::::0;::::1;::::0;;;9608:354;;;;;9818:70:::1;::::0;9864:23;;9818:16:::1;::::0;;::::1;::::0;:26:::1;::::0;:41;;;;;;;;;;;:16;:41;::::1;;::::0;::::1;;;;::::0;::::1;:70;9608:354:::0;;9903:12:::1;::::0;9608:354:::1;::::0;::::1;::::0;;;;;;9556:406;-1:-1:-1;;;10017:52:18::1;9556:406:::0;10017:38:::1;:52::i;:::-;9973:96;;;;10104:11;10088:12;:27;;10080:62;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;10174:10;10160;:24;;10152:60;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;10222:3;::::0;:42:::1;::::0;;;;;10241:10:::1;10222:42;::::0;::::1;::::0;;;;;;;;;:3:::1;::::0;;::::1;::::0;:18:::1;::::0;:42;;;;;:3:::1;::::0;:42;;;;;;;;:3;;:42;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;10274:16:18::1;::::0;:75:::1;::::0;;;;;10304:10:::1;10274:75;::::0;::::1;::::0;10324:4:::1;10274:75:::0;;;;;;;;;;;;:16:::1;::::0;;::::1;::::0;-1:-1:-1;10274:29:18::1;::::0;-1:-1:-1;10274:75:18;;;;;::::1;::::0;;;;;;;;;:16:::1;::::0;:75;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;;10359:4:18::1;::::0;:39:::1;::::0;;;;;10374:10:::1;10359:39;::::0;::::1;::::0;;;;;;;;;:4:::1;::::0;;::::1;::::0;:14:::1;::::0;:39;;;;;:4:::1;::::0;:39;;;;;;;;:4;;:39;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;3343:1;;;;;;;8813:1592:::0;;;:::o;7028:964::-;3292:10;;;;:19;3284:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7190:16:::1;::::0;7251:4:::1;::::0;:30:::1;::::0;;;;;;;7184:2:::1;:22:::0;;;::::1;7163:44:::0;::::1;::::0;7131:29:::1;::::0;7251:4:::1;;::::0;:28:::1;::::0;:30:::1;::::0;;::::1;::::0;::::1;::::0;;;;;;;;:4;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;7251:30:18;;-1:-1:-1;1638:3:18::1;7300:47:::0;::::1;;7292:89;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;7498:12;::::0;7447:23:::1;::::0;7400:16:::1;::::0;:41:::1;::::0;;;;;7435:4:::1;7400:41;::::0;::::1;::::0;;;7399:95:::1;::::0;7476:17;;7399:72:::1;::::0;7447:23;;7400:16:::1;::::0;;::::1;::::0;:26:::1;::::0;:41;;;;;::::1;::::0;;;;;;;;:16;:41;::::1;;::::0;::::1;;;;::::0;::::1;7399:95;:111;;7391:156;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;;;;;;;::::1;::::0;;;;;;;;;;;;;::::1;;7567:23;7594:15;:31;7639:20;:18;:20::i;:::-;7673:11;;7698:21;7594:135;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;7594:135:18;;-1:-1:-1;7789:31:18;;::::1;;7781:66;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;7857:16;::::0;:75:::1;::::0;;;;;7887:10:::1;7857:75;::::0;::::1;::::0;7907:4:::1;7857:75:::0;;;;;;;;;;;;:16:::1;::::0;;::::1;::::0;:29:::1;::::0;:75;;;;;::::1;::::0;;;;;;;;;:16:::1;::::0;:75;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;;7942:4:18::1;::::0;:43:::1;::::0;;;;;7957:10:::1;7942:43;::::0;::::1;::::0;;;;;;;;;:4:::1;::::0;;::::1;::::0;:14:::1;::::0;:43;;;;;:4:::1;::::0;:43;;;;;;;;:4;;:43;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;3343:1;;;7028:964:::0;;:::o;10460:1174::-;3180:12;;;;;;;:21;3172:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10601:4:::1;::::0;:30:::1;::::0;;;;;;;10567:31:::1;::::0;10601:4:::1;;::::0;:28:::1;::::0;:30:::1;::::0;;::::1;::::0;::::1;::::0;;;;;;;;:4;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;10601:30:18;;-1:-1:-1;1638:3:18::1;10649:47:::0;::::1;10641:89;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;10794:29;10826:39;10848:16;;10842:2;:22;10826:11;:15;;:39;;;;:::i;:::-;10794:71;;10876:25;10905:15;:33;10952:20;:18;:20::i;:::-;10986:21;11021:14;;10905:140;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;10905:140:18;11131:23:::1;::::0;11085:16:::1;::::0;:41:::1;::::0;;;;;11120:4:::1;11085:41;::::0;::::1;::::0;;;10905:140;;-1:-1:-1;11085:70:18::1;::::0;:16:::1;::::0;;::::1;::::0;:26:::1;::::0;:41;;;;;10905:140:::1;::::0;11085:41;;;;;;;;:16;:41;::::1;;::::0;::::1;;;;::::0;::::1;:70;11064:17;:91;;11056:133;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;11264:10;11239:36;::::0;;;:24:::1;:36;::::0;;;;;:59:::1;::::0;11280:17;11239:59:::1;:40;:59;:::i;:::-;11225:10;11200:36;::::0;;;:24:::1;:36;::::0;;;;:98;11334:23:::1;::::0;:46:::1;::::0;11362:17;11334:46:::1;:27;:46;:::i;:::-;11308:23;:72:::0;11403:10:::1;11390:24;::::0;;;:12:::1;:24;::::0;;;;11417:12:::1;11390:39:::0;;11448;;::::1;;11440:74;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;11583:4;::::0;:44:::1;::::0;;;;;11603:10:::1;11583:44;::::0;::::1;::::0;;;;;;;;;:4:::1;::::0;;::::1;::::0;:19:::1;::::0;:44;;;;;:4:::1;::::0;:44;;;;;;;;:4;;:44;::::1;;::::0;::::1;;;;::::0;::::1;1820:31:::0;;;;:::o;18301:895::-;18396:13;;;;;;;:22;18388:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;18470:4;;:16;;;;;;;;18450:17;;18470:4;;;:14;;:16;;;;;;;;;;;;;;:4;:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;18470:16:18;;-1:-1:-1;18505:53:18;;:::i;:::-;18561:163;;;;;;;;18608:25;:23;:25::i;:::-;18561:163;;;;18647:9;18561:163;;;;18670:20;:18;:20::i;:::-;18561:163;;;;;;;18505:219;-1:-1:-1;;18773:44:18;18505:219;18773:30;:44::i;:::-;18735:82;;18827:28;18858:53;18894:16;;18888:2;:22;18858:25;:29;;:53;;;;:::i;:::-;18827:84;;18952:20;18930:18;:42;;18922:77;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;19078:3;;:42;;;;;;19097:10;19078:42;;;;;;;;;;;;:3;;;;;:18;;:42;;;;;:3;;:42;;;;;;;;:3;;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;19130:16:18;;:59;;;;;;19156:10;19130:59;;;;;;;;;;;;:16;;;;;-1:-1:-1;19130:25:18;;-1:-1:-1;19130:59:18;;;;;;;;;;;;;;;:16;;:59;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;;;18301:895:18:o;13858:1037::-;3180:12;;;;;;;:21;3172:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;13986:4:::1;::::0;:16:::1;::::0;;;;;;;13966:17:::1;::::0;13986:4:::1;;::::0;:14:::1;::::0;:16:::1;::::0;;::::1;::::0;::::1;::::0;;;;;;;;:4;:16;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;13986:16:18;14046:4:::1;::::0;:30:::1;::::0;;;;;;;13986:16;;-1:-1:-1;14012:31:18::1;::::0;14046:4:::1;::::0;;::::1;::::0;:28:::1;::::0;:30:::1;::::0;;::::1;::::0;13986:16:::1;::::0;14046:30;;;;;;;;:4;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;14046:30:18;;-1:-1:-1;14095:28:18;;14087:67:::1;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;14165:28;14196:11;14165:42;;14240:89;14265:63;1518:3;14266:40;14291:14;;14266:20;:24;;:40;;;;:::i;14265:63::-;14240:20:::0;;:89:::1;:24;:89;:::i;:::-;14217:112:::0;-1:-1:-1;14363:18:18::1;14384:56;14430:9:::0;14384:41:::1;14217:112:::0;1518:3:::1;14384:41;:24;:41;:::i;:56::-;14509:10;14491:29;::::0;;;:17:::1;:29;::::0;;;;;14363:77;;-1:-1:-1;14491:45:18::1;::::0;14363:77;14491:45:::1;:33;:45;:::i;:::-;14477:10;14459:29;::::0;;;:17:::1;:29;::::0;;;;:77;14565:16:::1;::::0;:32:::1;::::0;14586:10;14565:32:::1;:20;:32;:::i;:::-;14546:16;:51:::0;14629:10:::1;14616:24;::::0;;;:12:::1;:24;::::0;;;;14643:12:::1;14616:39:::0;;14682:25;;::::1;;14674:60;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;14794:4;::::0;:44:::1;::::0;;;;;14814:10:::1;14794:44;::::0;::::1;::::0;;;;;;;;;:4:::1;::::0;;::::1;::::0;:19:::1;::::0;:44;;;;;:4:::1;::::0;:44;;;;;;;;:4;;:44;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;14848:3:18::1;::::0;:40:::1;::::0;;;;;14870:4:::1;14848:40;::::0;::::1;::::0;;;;;;;;;:3:::1;::::0;;::::1;::::0;-1:-1:-1;14848:13:18::1;::::0;-1:-1:-1;14848:40:18;;;;;:3:::1;::::0;:40;;;;;;;;:3;;:40;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;3235:1;;;;13858:1037:::0;;:::o;20319:354::-;3011:16;;;;2997:10;:30;;:61;;-1:-1:-1;3045:13:18;;;;3031:10;:27;2997:61;2989:122;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;20464:12:::1;:26:::0;;;20500:10:::1;:27:::0;;;20537:16:::1;:39:::0;;;20600:4:::1;::::0;:18:::1;::::0;;;;;;;:4:::1;::::0;;::::1;::::0;:16:::1;::::0;:18:::1;::::0;;::::1;::::0;::::1;::::0;;;;;;;;;:4;:18;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;20600:18:18;20586:11:::1;:32:::0;20645:4:::1;::::0;:21:::1;::::0;;;;;;;:4:::1;::::0;;::::1;::::0;:19:::1;::::0;:21:::1;::::0;;::::1;::::0;20600:18:::1;::::0;20645:21;;;;;;;;:4;:21;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;20645:21:18;20628:14:::1;:38:::0;-1:-1:-1;;;20319:354:18:o;1299:38::-;;;;:::o;19256:126::-;2284:24;;;;;;;;;;;;;;;;19308:32;;19329:10;19308:7;:32::i;:::-;19300:41;;;;;;19365:10;;;19351:24;;;19365:10;;;;19364:11;19351:24;;;19256:126::o;11773:2030::-;3180:12;;;;;;;:21;3172:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11928:4:::1;::::0;:16:::1;::::0;;;;;;;11908:17:::1;::::0;11928:4:::1;;::::0;:14:::1;::::0;:16:::1;::::0;;::::1;::::0;::::1;::::0;;;;;;;;:4;:16;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;11928:16:18;11988:4:::1;::::0;:30:::1;::::0;;;;;;;11928:16;;-1:-1:-1;11954:31:18::1;::::0;11988:4:::1;::::0;;::::1;::::0;:28:::1;::::0;:30:::1;::::0;;::::1;::::0;11928:16:::1;::::0;11988:30;;;;;;;;:4;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;11988:30:18;;-1:-1:-1;1638:3:18::1;12037:46:::0;::::1;:77:::0;::::1;;;;12113:1;12087:23;:27;12037:77;12029:146;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12185:21;12209:20;:18;:20::i;:::-;12185:44;;12240:28;12271:71;12287:54;1518:3;12288:31;12304:14;;12288:11;:15;;:31;;;;:::i;12287:54::-;12271:11:::0;;:71:::1;:15;:71;:::i;:::-;12240:102:::0;-1:-1:-1;12352:28:18::1;12383:96;12408:70;1518:3;12408:49;12240:102:::0;12433:23;12408:49:::1;:24;:49;:::i;:70::-;12383:20:::0;;:96:::1;:24;:96;:::i;:::-;12352:127:::0;-1:-1:-1;12489:18:18::1;12510:56;12556:9:::0;12510:41:::1;12352:127:::0;1518:3:::1;12510:41;:24;:41;:::i;:56::-;12489:77;;12630:29;12662:48;12693:16;;12687:2;:22;12662:20;:24;;:48;;;;:::i;:::-;12630:80:::0;-1:-1:-1;12720:31:18::1;12754:71;1518:3;12754:50;12630:80:::0;12780:23;12754:50:::1;:25;:50;:::i;:71::-;12720:105:::0;-1:-1:-1;12835:25:18::1;12863:63;12912:13:::0;12863:44:::1;12720:105:::0;1518:3:::1;12863:44;:27;:44;:::i;:63::-;13001:10;12976:36;::::0;;;:24:::1;:36;::::0;;;;;12835:91;;-1:-1:-1;12976:59:18::1;::::0;12835:91;12976:59:::1;:40;:59;:::i;:::-;12962:10;12937:36;::::0;;;:24:::1;:36;::::0;;;;:98;13071:23:::1;::::0;:46:::1;::::0;13099:17;13071:46:::1;:27;:46;:::i;:::-;13045:23;:72:::0;13178:10:::1;13160:29;::::0;;;:17:::1;:29;::::0;;;;;:45:::1;::::0;13194:10;13160:45:::1;:33;:45;:::i;:::-;13146:10;13128:29;::::0;;;:17:::1;:29;::::0;;;;:77;13234:16:::1;::::0;:32:::1;::::0;13255:10;13234:32:::1;:20;:32;:::i;:::-;13215:16;:51:::0;13290:10:::1;13277:24;::::0;;;:12:::1;:24;::::0;;;;;;;;13304:12:::1;13277:39:::0;;13402:23:::1;::::0;13356:16:::1;::::0;:41;;;;;13391:4:::1;13356:41;::::0;::::1;::::0;;;:70:::1;::::0;13402:23;;13277:24:::1;13356:16:::0;;::::1;::::0;:26:::1;::::0;:41;;;;;13277:24;;13356:41;;;;;:16;:41;::::1;;::::0;::::1;;;;::::0;::::1;:70;13335:17;:91;;13327:133;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;13500:17;13478:18;:39;;13470:87;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;13590:10;13575:11;:25;;13567:66;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;13702:4;::::0;:44:::1;::::0;;;;;13722:10:::1;13702:44;::::0;::::1;::::0;;;;;;;;;:4:::1;::::0;;::::1;::::0;:19:::1;::::0;:44;;;;;:4:::1;::::0;:44;;;;;;;;:4;;:44;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;13756:3:18::1;::::0;:40:::1;::::0;;;;;13778:4:::1;13756:40;::::0;::::1;::::0;;;;;;;;;:3:::1;::::0;;::::1;::::0;-1:-1:-1;13756:13:18::1;::::0;-1:-1:-1;13756:40:18;;;;;:3:::1;::::0;:40;;;;;;;;:3;;:40;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;3235:1;;;;;;;;;11773:2030:::0;;;:::o;16878:1220::-;16982:21;;;;;;;:30;16974:68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;17111:16;;17158:4;;:16;;;;;;;;17105:2;:22;;;;17084:44;;;17052:29;;17158:4;;;:14;;:16;;;;;;;;;;;;;;:4;:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17158:16:18;17212:4;;:18;;;;;;;;17158:16;;-1:-1:-1;17184:25:18;;17212:4;;;;;:16;;:18;;;;;17158:16;;17212:18;;;;;;;;:4;:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17212:18:18;17274:4;;:30;;;;;;;;17212:18;;-1:-1:-1;17240:31:18;;17274:4;;;;;:28;;:30;;;;;17212:18;;17274:30;;;;;;;;:4;:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17274:30:18;17344:4;;:28;;;;;;;;17274:30;;-1:-1:-1;17314:27:18;;17344:4;;;;;:26;;:28;;;;;17274:30;;17344:28;;;;;;;;:4;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17344:28:18;;-1:-1:-1;17392:24:18;;17448:15;:44;17506:21;17541:20;:18;:20::i;:::-;17575:19;17608:17;17639:23;17448:224;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17448:224:18;;;;;;;17748:16;;17448:224;;-1:-1:-1;17448:224:18;-1:-1:-1;17684:34:18;;17721:44;;17448:224;;17742:2;:22;17721:44;:20;:44;:::i;:::-;17684:81;;17776:21;17800:64;17854:9;17800:49;17823:25;17837:10;;17828:3;17823:13;;:25;;;;:::i;:::-;17800:18;;:49;:22;:49;:::i;:64::-;17776:88;;17898:13;17883:11;:28;;17875:63;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;17948:16;;:84;;;;;;17978:10;17948:84;;;;17998:4;17948:84;;;;;;;;;;;;:16;;;;;:29;;:84;;;;;;;;;;;;;;;:16;;:84;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;18042:3:18;;:40;;;;;;18056:10;18042:40;;;;;;;;;;;;:3;;;;;:13;;:40;;;;;:3;;:40;;;;;;;;:3;;:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;16878:1220;;;;;;;;;;;:::o;6608:317::-;3011:16;;;;2997:10;:30;;:61;;-1:-1:-1;3045:13:18;;;;3031:10;:27;2997:61;2989:122;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6743:25:::1;:59:::0;;::::1;::::0;;::::1;::::0;;;::::1;::::0;::::1;::::0;;;6812:15:::1;:68:::0;;;::::1;::::0;;::::1;::::0;;;6890:12:::1;:28:::0;;;;;::::1;::::0;::::1;;::::0;;6608:317::o;4006:136:0:-;4079:7;4105:12;;;;;;;;;;:30;;4129:5;4105:30;:23;:30;:::i;:::-;4098:37;;4006:136;;;;;:::o;2991:137::-;3060:4;3083:12;;;;;;;;;;:38;;3113:7;3083:38;:29;:38;:::i;1698:49::-;1743:4;1698:49;:::o;1380:48:18:-;;;;;;;;;;;;;:::o;20679:124::-;3011:16;;;;2997:10;:30;;:61;;-1:-1:-1;3045:13:18;;;;3031:10;:27;2997:61;2989:122;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;20765:16:::1;:31:::0;;;::::1;;::::0;;;::::1;::::0;;;::::1;::::0;;20679:124::o;8026:678::-;3292:10;;;;:19;3284:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8154:4:::1;::::0;:16:::1;::::0;;;;;;;8134:17:::1;::::0;8154:4:::1;;::::0;:14:::1;::::0;:16:::1;::::0;;::::1;::::0;::::1;::::0;;;;;;;;:4;:16;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;8154:16:18;8214:4:::1;::::0;:30:::1;::::0;;;;;;;8154:16;;-1:-1:-1;8180:31:18::1;::::0;8214:4:::1;::::0;;::::1;::::0;:28:::1;::::0;:30:::1;::::0;;::::1;::::0;8154:16:::1;::::0;8214:30;;;;;;;;:4;:30;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;8214:30:18;;-1:-1:-1;8262:28:18;;8254:67:::1;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;8341:23;8368:15;:39;8421:11;;8447:9;8487:14;8368:143;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;8368:143:18;;-1:-1:-1;8530:31:18;;::::1;;8522:66;;;::::0;;::::1;::::0;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;::::1;::::0;;;;;;;;;;;;;::::1;;8598:3;::::0;:46:::1;::::0;;;;;8617:10:::1;8598:46;::::0;::::1;::::0;;;;;;;;;:3:::1;::::0;;::::1;::::0;:18:::1;::::0;:46;;;;;:3:::1;::::0;:46;;;;;;;;:3;;:46;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;8654:4:18::1;::::0;:43:::1;::::0;;;;;8669:10:::1;8654:43;::::0;::::1;::::0;;;;;;;;;:4:::1;::::0;;::::1;::::0;-1:-1:-1;8654:14:18::1;::::0;-1:-1:-1;8654:43:18;;;;;:4:::1;::::0;:43;;;;;;;;:4;;:43;::::1;;::::0;::::1;;;;::::0;::::1;1916:30:::0;;;;:::o;1174:53::-;;;;;;;;;;;;;:::o;3296:125:0:-;3359:7;3385:12;;;;;;;;;;:29;;:27;:29::i;5142:226::-;5234:6;:12;;;;;;;;;;:22;;;5226:45;;5258:12;:10;:12::i;5226:45::-;5218:106;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;19392:134:18;2355:26;;;;;;;;;;;;;;;;19446:34;;19469:10;19446:7;:34::i;:::-;19438:43;;;;;;19507:12;;;19491:28;;;19507:12;;;;;;;19506:13;19491:28;;;;;;19392:134::o;19850:394::-;2604:36;;;;;;;;;;;;;;;;19910:44;;19943:10;19910:7;:44::i;:::-;19902:53;;;;;;20046:21;;;;;;;20043:139;;20105:20;:18;:20::i;:::-;20091:11;:34;20043:139;;;20170:1;20156:11;:15;20043:139;20216:21;;;20191:46;;;20216:21;;;;;;;20215:22;20191:46;;;;;;19850:394::o;5295:823::-;5351:7;5370:20;5393:4;;;;;;;;;;;:16;;;:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5393:18:18;5455:4;;:30;;;;;;;;5393:18;;-1:-1:-1;5421:31:18;;5455:4;;;;;:28;;:30;;;;;5393:18;;5455:30;;;;;;;;:4;:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5455:30:18;5525:4;;:28;;;;;;;;5455:30;;-1:-1:-1;5495:27:18;;5525:4;;;;;:26;;:28;;;;;5455:30;;5525:28;;;;;;;;:4;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5525:28:18;;-1:-1:-1;1581:3:18;5568:52;;5564:110;;;1581:3;5622:52;;5564:110;5738:40;5781:75;1581:3;5782:41;:12;5799:23;5782:41;:16;:41;:::i;5781:75::-;5738:118;;5990:32;5968:19;:54;5964:147;;;6031:57;:19;6055:32;6031:57;:23;:57;:::i;:::-;6024:64;;;;;;;;5964:147;6110:1;6103:8;;;;;;;;6233:369;6306:21;;6284:7;;6306:21;;;;;:29;;6331:4;6306:29;6303:293;;;-1:-1:-1;6357:11:18;;6350:18;;6303:293;6423:4;;:20;;;;;;;;6399:21;;6423:4;;;:18;;:20;;;;;;;;;;;;;;:4;:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6423:20:18;6503:15;;6527:12;;6566:16;;6503:81;;;;;;:15;6527:12;;;6503:81;;;;6560:2;:22;;;;1518:3;6541:42;6503:81;;;;;6423:20;;-1:-1:-1;6464:121:18;;6503:15;;;;;:23;;:81;;;;;6423:20;;6503:81;;;;;;;:15;:81;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6503:81:18;6464:34;:13;1518:3;6464:34;:17;:34;:::i;:121::-;6457:128;;;;;120:27:35;;;;;;;;;:::o;1306:134:40:-;1364:7;1390:43;1394:1;1397;1390:43;;;;;;;;;;;;;;;;;:3;:43::i;4864:141:10:-;4934:4;4957:41;4962:3;4982:14;;;4957:4;:41::i;5401:156::-;5481:4;5504:46;5514:3;5534:14;;;5504:9;:46::i;866:176:40:-;924:7;955:5;;;978:6;;;;970:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2191:459;2249:7;2490:6;2486:45;;-1:-1:-1;2519:1:40;2512:8;;2486:45;2553:5;;;2557:1;2553;:5;:1;2576:5;;;;;:10;2568:56;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3105:130;3163:7;3189:39;3193:1;3196;3189:39;;;;;;;;;;;;;;;;;:3;:39::i;767:104:7:-;854:10;767:104;:::o;7066:184:0:-;7139:6;:12;;;;;;;;;;:33;;7164:7;7139:33;:24;:33;:::i;:::-;7135:109;;;7220:12;:10;:12::i;:::-;7193:40;;7211:7;7193:40;;7205:4;7193:40;;;;;;;;;;7066:184;;:::o;7256:188::-;7330:6;:12;;;;;;;;;;:36;;7358:7;7330:36;:27;:36;:::i;:::-;7326:112;;;7414:12;:10;:12::i;:::-;7387:40;;7405:7;7387:40;;7399:4;7387:40;;;;;;;;;;7256:188;;:::o;1620:1278:19:-;1704:7;1713;2014:28;2052:26;2233:52;2281:3;2233:43;2255:6;:20;;;2233:6;:17;;;:21;;:43;;;;:::i;:52::-;2210:75;;2320:59;2375:3;2320:50;2349:6;:20;;;2320:6;:24;;;:28;;:50;;;;:::i;:59::-;2299:80;;2400:36;2460:96;2537:18;2461:49;2493:6;:16;;;2461:27;2484:3;2461:18;:22;;:27;;;;:::i;:49::-;2460:76;:96;:76;:96;:::i;:::-;2400:156;;2567:26;2596:66;2641:6;:20;;;2596:40;2632:3;2596:31;:35;;:40;;;;:::i;:66::-;2567:95;;2694:152;2756:89;2841:3;2757:78;2819:6;:15;;;2758:55;2781:31;2758:18;:22;;:55;;;;:::i;2756:89::-;2695:55;:18;2718:31;2695:55;:22;:55;:::i;2694:152::-;2673:218;-1:-1:-1;2860:21:19;-1:-1:-1;;;;1620:1278:19;;;:::o;3265:1051::-;3545:41;;3345:7;;3537:91;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3695:28;3726:52;3774:3;3726:43;3748:6;:20;;;3726:6;:17;;;:21;;:43;;;;:::i;:52::-;3820:41;;3695:83;;-1:-1:-1;3796:65:19;;;3788:126;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4089:20;;;;4019:33;;4055:55;;:29;:20;4080:3;4055:29;:24;:29;:::i;:55::-;4019:91;3265:1051;-1:-1:-1;;;;3265:1051:19:o;6085:147:10:-;6159:7;6201:22;6205:3;6217:5;6201:3;:22::i;5638:115::-;5701:7;5727:19;5735:3;5727:7;:19::i;1764:187:40:-;1850:7;1885:12;1877:6;;;;1869:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;1920:5:40;;;1764:187::o;1611:404:10:-;1674:4;1695:21;1705:3;1710:5;1695:9;:21::i;:::-;1690:319;;-1:-1:-1;1732:23:10;;;;;;;;:11;:23;;;;;;;;;;;;;1912:18;;1890:19;;;:12;;;:19;;;;;;:40;;;;1944:11;;1690:319;-1:-1:-1;1993:5:10;1986:12;;3776:127;3849:4;3872:19;;;:12;;;;;:19;;;;;;:24;;;3776:127::o;3750:338:40:-;3836:7;3936:12;3929:5;3921:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3959:9;3975:1;3971;:5;;;;;;;3750:338;-1:-1:-1;;;;;3750:338:40:o;5173:147:10:-;5246:4;5269:44;5277:3;5297:14;;;5269:7;:44::i;4423:201::-;4517:18;;4490:7;;4517:26;-1:-1:-1;4509:73:10;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4599:3;:11;;4611:5;4599:18;;;;;;;;;;;;;;;;4592:25;;4423:201;;;;:::o;3984:107::-;4066:18;;3984:107::o;2183:1512::-;2249:4;2386:19;;;:12;;;:19;;;;;;2420:15;;2416:1273;;2849:18;;2801:14;;;;;2849:22;;;;2777:21;;2849:3;;:22;;3131;;;;;;;;;;;;;;3111:42;;3274:9;3245:3;:11;;3257:13;3245:26;;;;;;;;;;;;;;;;;;;:38;;;;3349:23;;;3391:1;3349:12;;;:23;;;;;;3375:17;;;3349:43;;3498:17;;3349:3;;3498:17;;;;;;;;;;;;;;;;;;;;;;3590:3;:12;;:19;3603:5;3590:19;;;;;;;;;;;3583:26;;;3631:4;3624:11;;;;;;;;2416:1273;3673:5;3666:12;;;;;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o
Swarm Source
ipfs://4bc45f9b221d63a53540b282e5eae9175d4d1b4a18cbe5f3f9398eb7fb43b17c
Loading...
Loading
Loading...
Loading
OVERVIEW
Old/deprecated main protocol contract for Frax Finance.Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 100.00% | $0.999478 | 2,430.9201 | $2,429.65 |
Loading...
Loading
[ 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.