From f940754a61c4aae10a55327cf9a296b41cfda0e2 Mon Sep 17 00:00:00 2001 From: danilo neves cruz Date: Mon, 24 Jul 2023 16:44:56 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20optimism:=20deploy=20previewer?= =?UTF-8?q?=20rewards=20hotfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/weak-icons-stare.md | 5 + .openzeppelin/optimism.json | 134 ++++++++++++++++++ deployments/optimism/DebtPreviewer.json | 65 ++------- .../DebtPreviewer_Implementation.json | 36 ++--- deployments/optimism/Previewer.json | 31 ++-- .../optimism/Previewer_Implementation.json | 30 ++-- 6 files changed, 188 insertions(+), 113 deletions(-) create mode 100644 .changeset/weak-icons-stare.md diff --git a/.changeset/weak-icons-stare.md b/.changeset/weak-icons-stare.md new file mode 100644 index 000000000..4a0498df4 --- /dev/null +++ b/.changeset/weak-icons-stare.md @@ -0,0 +1,5 @@ +--- +"@exactly/protocol": patch +--- + +🚀 optimism: deploy previewer rewards hotfix diff --git a/.openzeppelin/optimism.json b/.openzeppelin/optimism.json index 1b3e5ad6c..2a2bcadd1 100644 --- a/.openzeppelin/optimism.json +++ b/.openzeppelin/optimism.json @@ -8544,6 +8544,140 @@ } } } + }, + "0x86f6D8b717D49527Db3126F31Bdd3B0047694bf9": { + "address": "0x86f6D8b717D49527Db3126F31Bdd3B0047694bf9", + "layout": { + "solcVersion": "0.8.17", + "storage": [], + "types": {} + } + }, + "0x3744877F596db480c52AA89D8c8B1c67678fEB93": { + "address": "0x3744877F596db480c52AA89D8c8B1c67678fEB93", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "poolFees", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint24))", + "contract": "DebtPreviewer", + "src": "contracts/periphery/DebtPreviewer.sol:36" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint24))": { + "label": "mapping(address => mapping(address => uint24))", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_uint24)": { + "label": "mapping(address => uint24)", + "numberOfBytes": "32" + }, + "t_uint24": { + "label": "uint24", + "numberOfBytes": "3" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "0xa15566E9cF856F3780706715A1b1EfB2918304aF": { + "address": "0xa15566E9cF856F3780706715A1b1EfB2918304aF", + "layout": { + "solcVersion": "0.8.17", + "storage": [], + "types": {} + } + }, + "0xA6b60fb117809b05263c126691c707FB19713825": { + "address": "0xA6b60fb117809b05263c126691c707FB19713825", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "poolFees", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint24))", + "contract": "DebtPreviewer", + "src": "contracts/periphery/DebtPreviewer.sol:36" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint24))": { + "label": "mapping(address => mapping(address => uint24))", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_uint24)": { + "label": "mapping(address => uint24)", + "numberOfBytes": "32" + }, + "t_uint24": { + "label": "uint24", + "numberOfBytes": "3" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/deployments/optimism/DebtPreviewer.json b/deployments/optimism/DebtPreviewer.json index 5ee89d229..ff44af112 100644 --- a/deployments/optimism/DebtPreviewer.json +++ b/deployments/optimism/DebtPreviewer.json @@ -360,7 +360,7 @@ { "components": [ { - "internalType": "address", + "internalType": "contract ERC20", "name": "asset", "type": "address" }, @@ -736,67 +736,18 @@ "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a", "0x9241c920000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000005000000000000000000000000420000000000000000000000000000000000000600000000000000000000000042000000000000000000000000000000000000420000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c3160700000000000000000000000042000000000000000000000000000000000000420000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000420000000000000000000000000000000000000600000000000000000000000042000000000000000000000000000000000000060000000000000000000000001f32b1c2345538c0c6f582fcb022739c4a194ebb0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316070000000000000000000000001f32b1c2345538c0c6f582fcb022739c4a194ebb00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000bb80000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000001f4" ], - "numDeployments": 1, - "solcInputHash": "dfc279e9e31715ccd57d7e53eae538e0", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405260405162000b5038038062000b5083398101604081905262000026916200038b565b828162000036828260006200004d565b50620000449050826200008a565b50505062000489565b6200005883620000e5565b600082511180620000665750805b1562000085576200008383836200012760201b6200022e1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f620000b562000156565b604080516001600160a01b03928316815291841660208301520160405180910390a1620000e2816200018f565b50565b620000f081620001ed565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200014f838360405180606001604052806027815260200162000b296027913962000247565b9392505050565b60006200018060008051602062000b0983398151915260001b620002c660201b620001ea1760201c565b546001600160a01b0316919050565b6001600160a01b038116620001a357600080fd5b80620001cc60008051602062000b0983398151915260001b620002c660201b620001ea1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6200020381620002c960201b6200025a1760201c565b6200020d57600080fd5b80620001cc7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b620002c660201b620001ea1760201c565b6060600080856001600160a01b0316856040516200026691906200046b565b600060405180830381855af49150503d8060008114620002a3576040519150601f19603f3d011682016040523d82523d6000602084013e620002a8565b606091505b509092509050620002bc86838387620002d8565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200030857825160000362000300576001600160a01b0385163b6200030057600080fd5b508162000314565b6200031483836200031c565b949350505050565b8151156200032d5781518083602001fd5b600080fd5b80516001600160a01b03811681146200034a57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200038257818101518382015260200162000368565b50506000910152565b600080600060608486031215620003a157600080fd5b620003ac8462000332565b9250620003bc6020850162000332565b60408501519092506001600160401b0380821115620003da57600080fd5b818601915086601f830112620003ef57600080fd5b8151818111156200040457620004046200034f565b604051601f8201601f19908116603f011681019083821181831017156200042f576200042f6200034f565b816040528281528960208487010111156200044957600080fd5b6200045c83602083016020880162000365565b80955050505050509250925092565b600082516200047f81846020870162000365565b9190910192915050565b61067080620004996000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b610080366004610546565b610118565b61005b610093366004610561565b610155565b3480156100a457600080fd5b506100ad6101bc565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e4366004610546565b6101ed565b3480156100f557600080fd5b506100ad61020d565b610106610269565b610116610111610285565b61028f565b565b6101206102b3565b6001600160a01b0316330361014d5761014a816040518060200160405280600081525060006102e6565b50565b61014a6100fe565b61015d6102b3565b6001600160a01b031633036101b4576101af8383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506102e6915050565b505050565b6101af6100fe565b60006101c66102b3565b6001600160a01b031633036101e2576101dd610285565b905090565b6101ea6100fe565b90565b6101f56102b3565b6001600160a01b0316330361014d5761014a81610311565b60006102176102b3565b6001600160a01b031633036101e2576101dd6102b3565b6060610253838360405180606001604052806027815260200161061460279139610365565b9392505050565b6001600160a01b03163b151590565b6102716102b3565b6001600160a01b0316330361011657600080fd5b60006101dd6103dd565b3660008037600080366000845af43d6000803e8080156102ae573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b6102ef83610405565b6000825111806102fc5750805b156101af5761030b838361022e565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61033a6102b3565b604080516001600160a01b03928316815291841660208301520160405180910390a161014a81610445565b6060600080856001600160a01b03168560405161038291906105e4565b600060405180830381855af49150503d80600081146103bd576040519150601f19603f3d011682016040523d82523d6000602084013e6103c2565b606091505b50915091506103d38683838761049c565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6102d7565b61040e816104da565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045857600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b606083156104c85782516000036104c1576001600160a01b0385163b6104c157600080fd5b50816104d2565b6104d28383610515565b949350505050565b6001600160a01b0381163b6104ee57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61047b565b8151156105255781518083602001fd5b600080fd5b80356001600160a01b038116811461054157600080fd5b919050565b60006020828403121561055857600080fd5b6102538261052a565b60008060006040848603121561057657600080fd5b61057f8461052a565b9250602084013567ffffffffffffffff8082111561059c57600080fd5b818601915086601f8301126105b057600080fd5b8135818111156105bf57600080fd5b8760208285010111156105d157600080fd5b6020830194508093505050509250925092565b6000825160005b8181101561060557602081860181015185830152016105eb565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203011748945e626a6c7d6bd1969f4e5640e829c89504a5d4e52671d90f482851564736f6c63430008110033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b610080366004610546565b610118565b61005b610093366004610561565b610155565b3480156100a457600080fd5b506100ad6101bc565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e4366004610546565b6101ed565b3480156100f557600080fd5b506100ad61020d565b610106610269565b610116610111610285565b61028f565b565b6101206102b3565b6001600160a01b0316330361014d5761014a816040518060200160405280600081525060006102e6565b50565b61014a6100fe565b61015d6102b3565b6001600160a01b031633036101b4576101af8383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506102e6915050565b505050565b6101af6100fe565b60006101c66102b3565b6001600160a01b031633036101e2576101dd610285565b905090565b6101ea6100fe565b90565b6101f56102b3565b6001600160a01b0316330361014d5761014a81610311565b60006102176102b3565b6001600160a01b031633036101e2576101dd6102b3565b6060610253838360405180606001604052806027815260200161061460279139610365565b9392505050565b6001600160a01b03163b151590565b6102716102b3565b6001600160a01b0316330361011657600080fd5b60006101dd6103dd565b3660008037600080366000845af43d6000803e8080156102ae573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b6102ef83610405565b6000825111806102fc5750805b156101af5761030b838361022e565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61033a6102b3565b604080516001600160a01b03928316815291841660208301520160405180910390a161014a81610445565b6060600080856001600160a01b03168560405161038291906105e4565b600060405180830381855af49150503d80600081146103bd576040519150601f19603f3d011682016040523d82523d6000602084013e6103c2565b606091505b50915091506103d38683838761049c565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6102d7565b61040e816104da565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045857600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b606083156104c85782516000036104c1576001600160a01b0385163b6104c157600080fd5b50816104d2565b6104d28383610515565b949350505050565b6001600160a01b0381163b6104ee57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61047b565b8151156105255781518083602001fd5b600080fd5b80356001600160a01b038116811461054157600080fd5b919050565b60006020828403121561055857600080fd5b6102538261052a565b60008060006040848603121561057657600080fd5b61057f8461052a565b9250602084013567ffffffffffffffff8082111561059c57600080fd5b818601915086601f8301126105b057600080fd5b8135818111156105bf57600080fd5b8760208285010111156105d157600080fd5b6020830194508093505050509250925092565b6000825160005b8181101561060557602081860181015185830152016105eb565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203011748945e626a6c7d6bd1969f4e5640e829c89504a5d4e52671d90f482851564736f6c63430008110033", - "execute": { - "methodName": "initialize", - "args": [ - [ - [ - {}, - {} - ], - [ - {}, - {} - ], - [ - {}, - {} - ], - [ - {}, - {} - ], - [ - {}, - {} - ] - ], - [ - 3000, - 3000, - 500, - 100, - 500 - ] - ] - }, - "implementation": "0x950bf56757264941d7Bc7b9110A1C965Ae1b498D", + "numDeployments": 3, + "solcInputHash": "0f3d5a71c203a330ccec578b8f3450f8", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to fully implement transparency without decoding reverts caused by selector clashes between the proxy and the implementation. WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.\",\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/IERC1967.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\\n *\\n * _Available since v4.8.3._\\n */\\ninterface IERC1967 {\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Emitted when the beacon is changed.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n}\\n\",\"keccak256\":\"0x3cbef5ebc24b415252e2f8c0c9254555d30d9f085603b4b80d9b5ed20ab87e90\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/IERC1967.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n */\\nabstract contract ERC1967Upgrade is IERC1967 {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3b21ae06bf5957f73fa16754b0669c77b7abd8ba6c072d35c3281d446fdb86c2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}\\n * does not implement this interface directly, and some of its functions are implemented by an internal dispatch\\n * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not\\n * include them in the ABI so this interface must be used to interact with it.\\n */\\ninterface ITransparentUpgradeableProxy is IERC1967 {\\n function admin() external view returns (address);\\n\\n function implementation() external view returns (address);\\n\\n function changeAdmin(address) external;\\n\\n function upgradeTo(address) external;\\n\\n function upgradeToAndCall(address, bytes memory) external payable;\\n}\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n *\\n * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not\\n * inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch\\n * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to\\n * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the\\n * implementation.\\n *\\n * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler\\n * will not check that there are no selector conflicts, due to the note above. A selector clash between any new function\\n * and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could\\n * render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n *\\n * CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the\\n * implementation provides a function with the same selector.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior\\n */\\n function _fallback() internal virtual override {\\n if (msg.sender == _getAdmin()) {\\n bytes memory ret;\\n bytes4 selector = msg.sig;\\n if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {\\n ret = _dispatchUpgradeTo();\\n } else if (selector == ITransparentUpgradeableProxy.upgradeToAndCall.selector) {\\n ret = _dispatchUpgradeToAndCall();\\n } else if (selector == ITransparentUpgradeableProxy.changeAdmin.selector) {\\n ret = _dispatchChangeAdmin();\\n } else if (selector == ITransparentUpgradeableProxy.admin.selector) {\\n ret = _dispatchAdmin();\\n } else if (selector == ITransparentUpgradeableProxy.implementation.selector) {\\n ret = _dispatchImplementation();\\n } else {\\n revert(\\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n }\\n assembly {\\n return(add(ret, 0x20), mload(ret))\\n }\\n } else {\\n super._fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function _dispatchAdmin() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address admin = _getAdmin();\\n return abi.encode(admin);\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function _dispatchImplementation() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address implementation = _implementation();\\n return abi.encode(implementation);\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _dispatchChangeAdmin() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address newAdmin = abi.decode(msg.data[4:], (address));\\n _changeAdmin(newAdmin);\\n\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n */\\n function _dispatchUpgradeTo() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address newImplementation = abi.decode(msg.data[4:], (address));\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n */\\n function _dispatchUpgradeToAndCall() private returns (bytes memory) {\\n (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));\\n _upgradeToAndCall(newImplementation, data, true);\\n\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to\\n * emulate some proxy functions being non-payable while still allowing value to pass through.\\n */\\n function _requireZeroValue() private {\\n require(msg.value == 0);\\n }\\n}\\n\",\"keccak256\":\"0x168e36d7e616bd41f6abab4a83009da64513ae9e638aa6d5980066e2a92db689\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x006dd67219697fe68d7fbfdea512e7c4cb64a43565ed86171d67e844982da6fa\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```solidity\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\\n * _Available since v4.9 for `string`, `bytes`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n struct StringSlot {\\n string value;\\n }\\n\\n struct BytesSlot {\\n bytes value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\\n */\\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\\n */\\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := store.slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\\n */\\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\\n */\\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := store.slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf09e68aa0dc6722a25bc46490e8d48ed864466d17313b8a0b254c36b54e49899\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405260405162000bb938038062000bb983398101604081905262000026916200038b565b828162000036828260006200004d565b50620000449050826200008a565b50505062000489565b6200005883620000e5565b600082511180620000665750805b1562000085576200008383836200012760201b620000f01760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f620000b562000156565b604080516001600160a01b03928316815291841660208301520160405180910390a1620000e2816200018f565b50565b620000f081620001ed565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200014f838360405180606001604052806027815260200162000b926027913962000247565b9392505050565b60006200018060008051602062000b7283398151915260001b620002c660201b6200011c1760201c565b546001600160a01b0316919050565b6001600160a01b038116620001a357600080fd5b80620001cc60008051602062000b7283398151915260001b620002c660201b6200011c1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6200020381620002c960201b6200011f1760201c565b6200020d57600080fd5b80620001cc7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b620002c660201b6200011c1760201c565b6060600080856001600160a01b0316856040516200026691906200046b565b600060405180830381855af49150503d8060008114620002a3576040519150601f19603f3d011682016040523d82523d6000602084013e620002a8565b606091505b509092509050620002bc86838387620002d8565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200030857825160000362000300576001600160a01b0385163b6200030057600080fd5b508162000314565b6200031483836200031c565b949350505050565b8151156200032d5781518083602001fd5b600080fd5b80516001600160a01b03811681146200034a57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200038257818101518382015260200162000368565b50506000910152565b600080600060608486031215620003a157600080fd5b620003ac8462000332565b9250620003bc6020850162000332565b60408501519092506001600160401b0380821115620003da57600080fd5b818601915086601f830112620003ef57600080fd5b8151818111156200040457620004046200034f565b604051601f8201601f19908116603f011681019083821181831017156200042f576200042f6200034f565b816040528281528960208487010111156200044957600080fd5b6200045c83602083016020880162000365565b80955050505050509250925092565b600082516200047f81846020870162000365565b9190910192915050565b6106d980620004996000396000f3fe60806040523661001357610011610017565b005b6100115b61001f61012e565b6001600160a01b031633036100e65760606001600160e01b0319600035166364d3180d60e11b810161005a57610053610161565b91506100de565b63587086bd60e11b6001600160e01b031982160161007a576100536101b8565b63070d7c6960e41b6001600160e01b031982160161009a576100536101fe565b621eb96f60e61b6001600160e01b03198216016100b95761005361022f565b63a39f25e560e01b6001600160e01b03198216016100d95761005361026f565b600080fd5b815160208301f35b6100ee610283565b565b6060610115838360405180606001604052806027815260200161067d60279139610293565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b606061016b61030b565b600061017a3660048184610514565b810190610187919061055a565b90506101a481604051806020016040528060008152506000610316565b505060408051602081019091526000815290565b60606000806101ca3660048184610514565b8101906101d7919061058b565b915091506101e782826001610316565b604051806020016040528060008152509250505090565b606061020861030b565b60006102173660048184610514565b810190610224919061055a565b90506101a481610342565b606061023961030b565b600061024361012e565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b606061027961030b565b6000610243610399565b6100ee61028e610399565b6103a8565b6060600080856001600160a01b0316856040516102b0919061064d565b600060405180830381855af49150503d80600081146102eb576040519150601f19603f3d011682016040523d82523d6000602084013e6102f0565b606091505b5091509150610301868383876103cc565b9695505050505050565b34156100ee57600080fd5b61031f8361040a565b60008251118061032c5750805b1561033d5761033b83836100f0565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61036b61012e565b604080516001600160a01b03928316815291841660208301520160405180910390a16103968161044a565b50565b60006103a36104a1565b905090565b3660008037600080366000845af43d6000803e8080156103c7573d6000f35b3d6000fd5b606083156103f85782516000036103f1576001600160a01b0385163b6103f157600080fd5b5081610402565b61040283836104c9565b949350505050565b610413816104d9565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045d57600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610152565b8151156100d95781518083602001fd5b6001600160a01b0381163b6104ed57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610480565b6000808585111561052457600080fd5b8386111561053157600080fd5b5050820193919092039150565b80356001600160a01b038116811461055557600080fd5b919050565b60006020828403121561056c57600080fd5b6101158261053e565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059e57600080fd5b6105a78361053e565b9150602083013567ffffffffffffffff808211156105c457600080fd5b818501915085601f8301126105d857600080fd5b8135818111156105ea576105ea610575565b604051601f8201601f19908116603f0116810190838211818310171561061257610612610575565b8160405282815288602084870101111561062b57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b8181101561066e5760208186018101518583015201610654565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b01b6cfc5e4b180efda020a05b771d034ebbaca7fb66eb1a85ef640af48786fb64736f6c63430008110033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040523661001357610011610017565b005b6100115b61001f61012e565b6001600160a01b031633036100e65760606001600160e01b0319600035166364d3180d60e11b810161005a57610053610161565b91506100de565b63587086bd60e11b6001600160e01b031982160161007a576100536101b8565b63070d7c6960e41b6001600160e01b031982160161009a576100536101fe565b621eb96f60e61b6001600160e01b03198216016100b95761005361022f565b63a39f25e560e01b6001600160e01b03198216016100d95761005361026f565b600080fd5b815160208301f35b6100ee610283565b565b6060610115838360405180606001604052806027815260200161067d60279139610293565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b606061016b61030b565b600061017a3660048184610514565b810190610187919061055a565b90506101a481604051806020016040528060008152506000610316565b505060408051602081019091526000815290565b60606000806101ca3660048184610514565b8101906101d7919061058b565b915091506101e782826001610316565b604051806020016040528060008152509250505090565b606061020861030b565b60006102173660048184610514565b810190610224919061055a565b90506101a481610342565b606061023961030b565b600061024361012e565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b606061027961030b565b6000610243610399565b6100ee61028e610399565b6103a8565b6060600080856001600160a01b0316856040516102b0919061064d565b600060405180830381855af49150503d80600081146102eb576040519150601f19603f3d011682016040523d82523d6000602084013e6102f0565b606091505b5091509150610301868383876103cc565b9695505050505050565b34156100ee57600080fd5b61031f8361040a565b60008251118061032c5750805b1561033d5761033b83836100f0565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61036b61012e565b604080516001600160a01b03928316815291841660208301520160405180910390a16103968161044a565b50565b60006103a36104a1565b905090565b3660008037600080366000845af43d6000803e8080156103c7573d6000f35b3d6000fd5b606083156103f85782516000036103f1576001600160a01b0385163b6103f157600080fd5b5081610402565b61040283836104c9565b949350505050565b610413816104d9565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045d57600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610152565b8151156100d95781518083602001fd5b6001600160a01b0381163b6104ed57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610480565b6000808585111561052457600080fd5b8386111561053157600080fd5b5050820193919092039150565b80356001600160a01b038116811461055557600080fd5b919050565b60006020828403121561056c57600080fd5b6101158261053e565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059e57600080fd5b6105a78361053e565b9150602083013567ffffffffffffffff808211156105c457600080fd5b818501915085601f8301126105d857600080fd5b8135818111156105ea576105ea610575565b604051601f8201601f19908116603f0116810190838211818310171561061257610612610575565b8160405282815288602084870101111561062b57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b8181101561066e5760208186018101518583015201610654565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b01b6cfc5e4b180efda020a05b771d034ebbaca7fb66eb1a85ef640af48786fb64736f6c63430008110033", + "implementation": "0xA6b60fb117809b05263c126691c707FB19713825", "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to fully implement transparency without decoding reverts caused by selector clashes between the proxy and the implementation. WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.", "kind": "dev", "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, "constructor": { "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." } }, "version": 1 diff --git a/deployments/optimism/DebtPreviewer_Implementation.json b/deployments/optimism/DebtPreviewer_Implementation.json index ff95caae8..41b9ee6da 100644 --- a/deployments/optimism/DebtPreviewer_Implementation.json +++ b/deployments/optimism/DebtPreviewer_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x950bf56757264941d7Bc7b9110A1C965Ae1b498D", + "address": "0xA6b60fb117809b05263c126691c707FB19713825", "abi": [ { "inputs": [ @@ -253,7 +253,7 @@ { "components": [ { - "internalType": "address", + "internalType": "contract ERC20", "name": "asset", "type": "address" }, @@ -549,19 +549,19 @@ "type": "function" } ], - "transactionHash": "0x80e936846077f909039d80bafecfa89e06844348d41408be16e5501a24e02409", + "transactionHash": "0x0760bb5945618dec6ee7c38f32b112fc1c1c9fd92c047baf47677dfa44799f60", "receipt": { "to": null, "from": "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a", - "contractAddress": "0x950bf56757264941d7Bc7b9110A1C965Ae1b498D", - "transactionIndex": 15, - "gasUsed": "5274949", + "contractAddress": "0xA6b60fb117809b05263c126691c707FB19713825", + "transactionIndex": 4, + "gasUsed": "5351884", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x717150705aa140912a82279027172fc4ef1992ea70a26d66ca3777f69062e00a", - "transactionHash": "0x80e936846077f909039d80bafecfa89e06844348d41408be16e5501a24e02409", + "blockHash": "0x8ad630b9b0ca302c76e2074957367debce88f2904a7c39af1e09e6a28f626e79", + "transactionHash": "0x0760bb5945618dec6ee7c38f32b112fc1c1c9fd92c047baf47677dfa44799f60", "logs": [], - "blockNumber": 107172027, - "cumulativeGasUsed": "7345165", + "blockNumber": 107320140, + "cumulativeGasUsed": "6297537", "status": 1, "byzantium": true }, @@ -569,11 +569,11 @@ "0x675d410dcf6f343219AAe8d1DDE0BFAB46f52106", "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6" ], - "numDeployments": 1, - "solcInputHash": "dfc279e9e31715ccd57d7e53eae538e0", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract DebtManager\",\"name\":\"debtManager_\",\"type\":\"address\"},{\"internalType\":\"contract IUniswapQuoter\",\"name\":\"uniswapV3Quoter_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidPreview\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"debtManager\",\"outputs\":[{\"internalType\":\"contract DebtManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenB\",\"type\":\"address\"}],\"internalType\":\"struct Pool[]\",\"name\":\"pools\",\"type\":\"tuple[]\"},{\"internalType\":\"uint24[]\",\"name\":\"fees\",\"type\":\"uint24[]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minHealthFactor\",\"type\":\"uint256\"}],\"name\":\"leverage\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"principal\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"maxRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minDeposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxWithdraw\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"token0\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"token1\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"}],\"internalType\":\"struct PoolKey\",\"name\":\"pool\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"sqrtPriceX96\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"contract ERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"liquidity\",\"type\":\"uint256\"}],\"internalType\":\"struct AvailableAsset[]\",\"name\":\"availableAssets\",\"type\":\"tuple[]\"}],\"internalType\":\"struct Leverage\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"int256\",\"name\":\"assets\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"targetRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"depositRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nativeRate\",\"type\":\"uint256\"}],\"name\":\"leverageRates\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"native\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"}],\"internalType\":\"struct RewardRate[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"}],\"internalType\":\"struct Rates\",\"name\":\"rates\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"poolFees\",\"outputs\":[{\"internalType\":\"uint24\",\"name\":\"\",\"type\":\"uint24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"withdraw\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minHealthFactor\",\"type\":\"uint256\"}],\"name\":\"previewDeleverage\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"principal\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"maxRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapRatio\",\"type\":\"uint256\"}],\"internalType\":\"struct Limit\",\"name\":\"limit\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"assetIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"assetOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"}],\"name\":\"previewInputSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minHealthFactor\",\"type\":\"uint256\"}],\"name\":\"previewLeverage\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"principal\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"maxRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapRatio\",\"type\":\"uint256\"}],\"internalType\":\"struct Limit\",\"name\":\"limit\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketIn\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"}],\"name\":\"previewOutputSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"uniswapV3Quoter\",\"outputs\":[{\"internalType\":\"contract IUniswapQuoter\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"initialize((address,address)[],uint24[])\":{\"details\":\"can only be called once.\"},\"leverage(address,address,address,uint256)\":{\"params\":{\"account\":\"The account operating with the `DebtManager`.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"minHealthFactor\":\"The minimum health factor that the account must have after the leverage.\"},\"returns\":{\"_0\":\"extended leverage data.\"}},\"leverageRates(address,address,address,int256,uint256,uint256,uint256)\":{\"params\":{\"account\":\"The account to preview.\",\"assets\":\"The amount of assets that should be added or substracted to the principal.\",\"depositRate\":\"The current deposit rate of the deposit market.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"nativeRate\":\"The current native rate of the deposit market.\",\"targetRatio\":\"The target ratio to preview.\"}},\"previewDeleverage(address,address,address,uint256,uint256,uint256)\":{\"params\":{\"account\":\"The account that will be deleveraged.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"minHealthFactor\":\"The minimum health factor that the account must have after the leverage.\",\"ratio\":\"The ratio to be previewed.\",\"withdraw\":\"The amount of assets that will be withdrawn from the principal.\"}},\"previewInputSwap(address,address,uint256,uint24)\":{\"params\":{\"amountIn\":\"The exact amount of `assetIn` to be swapped.\",\"assetIn\":\"The address of the token to be swapped.\",\"assetOut\":\"The address of the token to receive.\",\"fee\":\"The fee of the pool that will be used to swap the assets.\"},\"returns\":{\"_0\":\"amountOut The amount of `assetOut` received.\"}},\"previewLeverage(address,address,address,uint256,uint256,uint256)\":{\"params\":{\"account\":\"The account that will be leveraged.\",\"deposit\":\"The amount of assets that will be added to the principal.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"minHealthFactor\":\"The minimum health factor that the account must have after the leverage.\",\"ratio\":\"The ratio to be previewed.\"}},\"previewOutputSwap(address,address,uint256,uint24)\":{\"params\":{\"amountOut\":\"The exact amount of `amountOut` to be swapped.\",\"fee\":\"The fee of the pool that will be used to swap the assets.\",\"marketIn\":\"The Market of the underlying asset to be swapped.\",\"marketOut\":\"The Market of the underlying asset to receive.\"},\"returns\":{\"_0\":\"amountIn The amount of `amountIn` received.\"}}},\"stateVariables\":{\"MAX_SQRT_RATIO\":{\"details\":\"The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\"},\"MIN_SQRT_RATIO\":{\"details\":\"The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\"},\"debtManager\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"uniswapV3Quoter\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"DebtPreviewer\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"debtManager()\":{\"notice\":\"DebtManager contract to be used to get Auditor, BalancerVault and UniswapV3Factory addresses.\"},\"initialize((address,address)[],uint24[])\":{\"notice\":\"Initializes the contract.\"},\"leverage(address,address,address,uint256)\":{\"notice\":\"Returns extended data useful to leverage or deleverage an account principal position.\"},\"leverageRates(address,address,address,int256,uint256,uint256,uint256)\":{\"notice\":\"returns rates based on inputs and leverage ratio impact on the borrow market\"},\"poolFees(address,address)\":{\"notice\":\"Mapping of Uniswap pools to their respective pool fee.\"},\"previewDeleverage(address,address,address,uint256,uint256,uint256)\":{\"notice\":\"Returns the maximum ratio that an account can deleverage its principal minus `assets` amount.\"},\"previewInputSwap(address,address,uint256,uint24)\":{\"notice\":\"Returns the output received for a given exact amount of a single pool swap.\"},\"previewLeverage(address,address,address,uint256,uint256,uint256)\":{\"notice\":\"Returns the maximum ratio that an account can leverage its principal plus `assets` amount.\"},\"previewOutputSwap(address,address,uint256,uint24)\":{\"notice\":\"Returns the input for an exact amount out of a single pool swap.\"},\"uniswapV3Quoter()\":{\"notice\":\"Quoter contract to be used to preview the amount of assets to be swapped.\"}},\"notice\":\"Contract to be consumed by Exactly's front-end dApp as a helper for `DebtManager`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/DebtPreviewer.sol\":\"DebtPreviewer\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControlUpgradeable.sol\\\";\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../utils/StringsUpgradeable.sol\\\";\\nimport \\\"../utils/introspection/ERC165Upgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\\n function __AccessControl_init() internal onlyInitializing {\\n }\\n\\n function __AccessControl_init_unchained() internal onlyInitializing {\\n }\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n StringsUpgradeable.toHexString(account),\\n \\\" is missing role \\\",\\n StringsUpgradeable.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xe8f27a3e3e25067334e76799f03d4de6d8f8535c3fc4806468228a9ebd5de51a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControlUpgradeable {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0xb8f5302f12138c5561362e88a78d061573e6298b7a1a5afe84a1e2c8d4d5aeaa\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n _requireNotPaused();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n _requirePaused();\\n _;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x40c636b4572ff5f1dc50cf22097e93c0723ee14eff87e99ac2b02636eeca1250\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x4e733d3164f73f461eaf9d8087a7ad1ea180bdc8ba0d3d61b0e1ae16d8e63dff\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xcc70d8e2281fb3ff69e8ab242500f10142cd0a7fa8dd9e45882be270d4d09024\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/draft-IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n function safeTransfer(\\n IERC20Upgradeable token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20Upgradeable token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20Upgradeable token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x220c4a5af915e656be2aaa85ca57505d102418e476b1e2ef6c62e0c6ac143871\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0x6b9a5d35b744b25529a2856a8093e7c03fb35a34b1c4fb5499e560f8ade140da\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\\n function __ERC165_init() internal onlyInitializing {\\n }\\n\\n function __ERC165_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165Upgradeable).interfaceId;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x9a3b990bd56d139df3e454a9edf1c64668530b5a77fc32eb063bc206f958274a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"contracts/Auditor.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract Auditor is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n\\n /// @notice Address that a market should have as price feed to consider as base price and avoid external price call.\\n address public constant BASE_FEED = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\\n /// @notice Target health factor that the account should have after it's liquidated to prevent cascade liquidations.\\n uint256 public constant TARGET_HEALTH = 1.25e18;\\n /// @notice Maximum value the liquidator can send and still have granular control of max assets.\\n /// Above this threshold, they should send `type(uint256).max`.\\n uint256 public constant ASSETS_THRESHOLD = type(uint256).max / 1e18;\\n\\n /// @notice Decimals that the answer of all price feeds should have.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable priceDecimals;\\n /// @notice Base factor to scale the price returned by the feed to 18 decimals.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable baseFactor;\\n /// @notice Base price used if the feed to fetch the price from is `BASE_FEED`.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable basePrice;\\n\\n /// @notice Tracks the markets' indexes that an account has entered as collateral.\\n mapping(address => uint256) public accountMarkets;\\n /// @notice Stores market parameters per each enabled market.\\n mapping(Market => MarketData) public markets;\\n /// @notice Array of all enabled markets.\\n Market[] public marketList;\\n\\n /// @notice Liquidation incentive factors for the liquidator and the lenders of the market where the debt is repaid.\\n LiquidationIncentive public liquidationIncentive;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(uint256 priceDecimals_) {\\n priceDecimals = priceDecimals_;\\n baseFactor = 10 ** (18 - priceDecimals_);\\n basePrice = 10 ** priceDecimals_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(LiquidationIncentive memory liquidationIncentive_) external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setLiquidationIncentive(liquidationIncentive_);\\n }\\n\\n /// @notice Allows assets of a certain market to be used as collateral for borrowing other assets.\\n /// @param market market to enabled as collateral.\\n function enterMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) != 0) return;\\n accountMarkets[msg.sender] = marketMap | marketMask;\\n\\n emit MarketEntered(market, msg.sender);\\n }\\n\\n /// @notice Removes market from sender's account liquidity calculation.\\n /// @dev Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral\\n /// for an outstanding borrow.\\n /// @param market market to be disabled as collateral.\\n function exitMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n (uint256 assets, uint256 debt) = market.accountSnapshot(msg.sender);\\n\\n // fail if the sender has a borrow balance\\n if (debt != 0) revert RemainingDebt();\\n\\n // fail if the sender is not permitted to redeem all of their assets\\n checkShortfall(market, msg.sender, assets);\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) == 0) return;\\n accountMarkets[msg.sender] = marketMap & ~marketMask;\\n\\n emit MarketExited(market, msg.sender);\\n }\\n\\n /// @notice Returns account's liquidity calculation.\\n /// @param account account in which the liquidity will be calculated.\\n /// @param marketToSimulate market in which to simulate withdraw operation.\\n /// @param withdrawAmount amount to simulate as withdraw.\\n /// @return sumCollateral sum of all collateral, already multiplied by each adjust factor (denominated in base).\\n /// @return sumDebtPlusEffects sum of all debt divided by adjust factor considering withdrawal (denominated in base).\\n function accountLiquidity(\\n address account,\\n Market marketToSimulate,\\n uint256 withdrawAmount\\n ) public view returns (uint256 sumCollateral, uint256 sumDebtPlusEffects) {\\n AccountLiquidity memory vars; // holds all our calculation results\\n\\n // for each asset the account is in\\n uint256 marketMap = accountMarkets[account];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 baseUnit = 10 ** m.decimals;\\n uint256 adjustFactor = m.adjustFactor;\\n\\n // read the balances\\n (vars.balance, vars.borrowBalance) = market.accountSnapshot(account);\\n\\n // get the normalized price of the asset (18 decimals)\\n vars.price = assetPrice(m.priceFeed);\\n\\n // sum all the collateral prices\\n sumCollateral += vars.balance.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n\\n // sum all the debt\\n sumDebtPlusEffects += vars.borrowBalance.mulDivUp(vars.price, baseUnit).divWadUp(adjustFactor);\\n\\n // simulate the effects of withdrawing from a pool\\n if (market == marketToSimulate) {\\n // calculate the effects of redeeming markets\\n // (having less collateral is the same as having more debt for this calculation)\\n if (withdrawAmount != 0) {\\n sumDebtPlusEffects += withdrawAmount.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n }\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Validates that the current state of the position and system are valid.\\n /// @dev To be called after adding the borrowed debt to the account position.\\n /// @param market address of the market where the borrow is made.\\n /// @param borrower address of the account that will repay the debt.\\n function checkBorrow(Market market, address borrower) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[borrower];\\n uint256 marketMask = 1 << m.index;\\n\\n // validate borrow state\\n if ((marketMap & marketMask) == 0) {\\n // only markets may call checkBorrow if borrower not in market\\n if (msg.sender != address(market)) revert NotMarket();\\n\\n accountMarkets[borrower] = marketMap | marketMask;\\n emit MarketEntered(market, borrower);\\n }\\n\\n // verify that current liquidity is not short\\n (uint256 collateral, uint256 debt) = accountLiquidity(borrower, Market(address(0)), 0);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Checks if the account has liquidity shortfall.\\n /// @param market address of the market where the operation will happen.\\n /// @param account address of the account to check for possible shortfall.\\n /// @param amount amount that the account wants to withdraw or transfer.\\n function checkShortfall(Market market, address account, uint256 amount) public view {\\n // if the account is not 'in' the market, bypass the liquidity check\\n if ((accountMarkets[account] & (1 << markets[market].index)) == 0) return;\\n\\n // otherwise, perform a hypothetical liquidity check to guard against shortfall\\n (uint256 collateral, uint256 debt) = accountLiquidity(account, market, amount);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Allows/rejects liquidation of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt is being repaid.\\n /// @param seizeMarket market from where the liquidator will seize assets.\\n /// @param borrower address in which the assets are being liquidated.\\n /// @param maxLiquidatorAssets maximum amount of debt the liquidator is willing to accept.\\n /// @return maxRepayAssets capped amount of debt the liquidator is allowed to repay.\\n function checkLiquidation(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 maxLiquidatorAssets\\n ) external view returns (uint256 maxRepayAssets) {\\n // if markets are listed, they have the same auditor\\n if (!markets[repayMarket].isListed || !markets[seizeMarket].isListed) revert MarketNotListed();\\n\\n MarketVars memory repay;\\n LiquidityVars memory base;\\n uint256 marketMap = accountMarkets[borrower];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage marketData = markets[market];\\n MarketVars memory m = MarketVars({\\n price: assetPrice(marketData.priceFeed),\\n adjustFactor: marketData.adjustFactor,\\n baseUnit: 10 ** marketData.decimals\\n });\\n\\n if (market == repayMarket) repay = m;\\n\\n (uint256 collateral, uint256 debt) = market.accountSnapshot(borrower);\\n\\n uint256 value = debt.mulDivUp(m.price, m.baseUnit);\\n base.totalDebt += value;\\n base.adjustedDebt += value.divWadUp(m.adjustFactor);\\n\\n value = collateral.mulDivDown(m.price, m.baseUnit);\\n base.totalCollateral += value;\\n base.adjustedCollateral += value.mulWadDown(m.adjustFactor);\\n if (market == seizeMarket) base.seizeAvailable = value;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n if (base.adjustedCollateral >= base.adjustedDebt) revert InsufficientShortfall();\\n\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n uint256 adjustFactor = base.adjustedCollateral.mulWadDown(base.totalDebt).divWadUp(\\n base.adjustedDebt.mulWadUp(base.totalCollateral)\\n );\\n uint256 closeFactor = (TARGET_HEALTH - base.adjustedCollateral.divWadUp(base.adjustedDebt)).divWadUp(\\n TARGET_HEALTH - adjustFactor.mulWadDown(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n );\\n maxRepayAssets = Math.min(\\n Math\\n .min(\\n base.totalDebt.mulWadUp(Math.min(1e18, closeFactor)),\\n base.seizeAvailable.divWadUp(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n )\\n .mulDivUp(repay.baseUnit, repay.price),\\n maxLiquidatorAssets < ASSETS_THRESHOLD\\n ? maxLiquidatorAssets.divWadDown(1e18 + memIncentive.lenders)\\n : maxLiquidatorAssets\\n );\\n }\\n\\n /// @notice Allow/rejects seizing of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market where the assets will be seized.\\n function checkSeize(Market repayMarket, Market seizeMarket) external view {\\n // if markets are listed, they also point to the same Auditor\\n if (!markets[seizeMarket].isListed || !markets[repayMarket].isListed) revert MarketNotListed();\\n }\\n\\n /// @notice Calculates the amount of collateral to be seized when a position is undercollateralized.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market from where the assets will be seized by the liquidator.\\n /// @param borrower account in which assets are being seized.\\n /// @param actualRepayAssets amount being repaid.\\n /// @return lendersAssets amount to be added for other lenders as a compensation of bad debt clearing.\\n /// @return seizeAssets amount that can be seized by the liquidator.\\n function calculateSeize(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 actualRepayAssets\\n ) external view returns (uint256 lendersAssets, uint256 seizeAssets) {\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n lendersAssets = actualRepayAssets.mulWadDown(memIncentive.lenders);\\n\\n // read prices for borrowed and collateral markets\\n uint256 priceBorrowed = assetPrice(markets[repayMarket].priceFeed);\\n uint256 priceCollateral = assetPrice(markets[seizeMarket].priceFeed);\\n uint256 baseAmount = actualRepayAssets.mulDivUp(priceBorrowed, 10 ** markets[repayMarket].decimals);\\n\\n seizeAssets = Math.min(\\n baseAmount.mulDivUp(10 ** markets[seizeMarket].decimals, priceCollateral).mulWadUp(\\n 1e18 + memIncentive.liquidator + memIncentive.lenders\\n ),\\n seizeMarket.maxWithdraw(borrower)\\n );\\n }\\n\\n /// @notice Checks if account has debt with no collateral, if so then call `clearBadDebt` from each market.\\n /// @dev Collateral is multiplied by price and adjust factor to be accurately evaluated as positive collateral asset.\\n /// @param account account in which debt is being checked.\\n function handleBadDebt(address account) external {\\n uint256 memMarketMap = accountMarkets[account];\\n uint256 marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 assets = market.maxWithdraw(account);\\n if (assets.mulDivDown(assetPrice(m.priceFeed), 10 ** m.decimals).mulWadDown(m.adjustFactor) > 0) return;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) marketList[i].clearBadDebt(account);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the asset price of a price feed.\\n /// @dev If Chainlink's asset price is <= 0 the call is reverted.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price.\\n /// @return The price of the asset scaled to 18-digit decimals.\\n function assetPrice(IPriceFeed priceFeed) public view returns (uint256) {\\n if (address(priceFeed) == BASE_FEED) return basePrice;\\n\\n int256 price = priceFeed.latestAnswer();\\n if (price <= 0) revert InvalidPrice();\\n return uint256(price) * baseFactor;\\n }\\n\\n /// @notice Retrieves all markets.\\n function allMarkets() external view returns (Market[] memory) {\\n return marketList;\\n }\\n\\n /// @notice Enables a certain market.\\n /// @dev Enabling more than 256 markets will cause an overflow when casting market index to uint8.\\n /// @param market market to add to the protocol.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n /// @param adjustFactor market's adjust factor for the underlying asset.\\n function enableMarket(\\n Market market,\\n IPriceFeed priceFeed,\\n uint128 adjustFactor\\n ) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (market.auditor() != this) revert AuditorMismatch();\\n if (markets[market].isListed) revert MarketAlreadyListed();\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n\\n uint8 decimals = market.decimals();\\n markets[market] = MarketData({\\n isListed: true,\\n adjustFactor: adjustFactor,\\n decimals: decimals,\\n index: uint8(marketList.length),\\n priceFeed: priceFeed\\n });\\n\\n marketList.push(market);\\n\\n emit MarketListed(market, decimals);\\n emit PriceFeedSet(market, priceFeed);\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the adjust factor for a certain market.\\n /// @param market address of the market to change adjust factor for.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n function setAdjustFactor(Market market, uint128 adjustFactor) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (!markets[market].isListed) revert MarketNotListed();\\n\\n markets[market].adjustFactor = adjustFactor;\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the Chainlink Price Feed Aggregator source for a market.\\n /// @param market market address of the asset.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n function setPriceFeed(Market market, IPriceFeed priceFeed) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n markets[market].priceFeed = priceFeed;\\n emit PriceFeedSet(market, priceFeed);\\n }\\n\\n /// @notice Sets liquidation incentive (liquidator and lenders) for the whole ecosystem.\\n /// @param liquidationIncentive_ new liquidation incentive.\\n function setLiquidationIncentive(\\n LiquidationIncentive memory liquidationIncentive_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n liquidationIncentive = liquidationIncentive_;\\n emit LiquidationIncentiveSet(liquidationIncentive_);\\n }\\n\\n /// @notice Emitted when a new market is listed for borrow/lending.\\n /// @param market address of the market that was listed.\\n /// @param decimals decimals of the market's underlying asset.\\n event MarketListed(Market indexed market, uint8 decimals);\\n\\n /// @notice Emitted when an account enters a market to use his deposit as collateral for a loan.\\n /// @param market address of the market that the account entered.\\n /// @param account address of the account that just entered a market.\\n event MarketEntered(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when an account leaves a market.\\n /// Means that they would stop using their deposit as collateral and won't ask for any loans in this market.\\n /// @param market address of the market that the account just left.\\n /// @param account address of the account that just left a market.\\n event MarketExited(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when a adjust factor is changed by admin.\\n /// @param market address of the market that has a new adjust factor.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n event AdjustFactorSet(Market indexed market, uint256 adjustFactor);\\n\\n /// @notice Emitted when a new liquidationIncentive has been set.\\n /// @param liquidationIncentive represented with 18 decimals.\\n event LiquidationIncentiveSet(LiquidationIncentive liquidationIncentive);\\n\\n /// @notice Emitted when a market and prie feed is changed by admin.\\n /// @param market address of the asset used to get the price.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n event PriceFeedSet(Market indexed market, IPriceFeed indexed priceFeed);\\n\\n /// @notice Stores the market parameters used for liquidity calculations.\\n /// @param adjustFactor used to asses the lending power of the market's underlying asset.\\n /// @param decimals number of decimals of the market's underlying asset.\\n /// @param index index of the market in the `marketList`.\\n /// @param isListed true if the market is enabled.\\n /// @param priceFeed address of the price feed used to query the asset's price.\\n struct MarketData {\\n uint128 adjustFactor;\\n uint8 decimals;\\n uint8 index;\\n bool isListed;\\n IPriceFeed priceFeed;\\n }\\n\\n /// @notice Stores the liquidator and lenders factors used in liquidations to calculate the amount to seize.\\n /// @param liquidator factor used to calculate the extra bonus a liquidator can seize.\\n /// @param lenders factor used to calculate the bonus that the pool lenders receive.\\n struct LiquidationIncentive {\\n uint128 liquidator;\\n uint128 lenders;\\n }\\n\\n /// @notice Used as memory access to temporary store account liquidity data.\\n /// @param balance collateral balance of the account.\\n /// @param borrowBalance borrow balance of the account.\\n /// @param price asset price returned by the price feed with 18 decimals.\\n struct AccountLiquidity {\\n uint256 balance;\\n uint256 borrowBalance;\\n uint256 price;\\n }\\n}\\n\\nerror AuditorMismatch();\\nerror InsufficientAccountLiquidity();\\nerror InsufficientShortfall();\\nerror InvalidPrice();\\nerror InvalidPriceFeed();\\nerror MarketAlreadyListed();\\nerror MarketNotListed();\\nerror NotMarket();\\nerror RemainingDebt();\\n\\nstruct MarketVars {\\n uint256 price;\\n uint256 baseUnit;\\n uint128 adjustFactor;\\n}\\n\\nstruct LiquidityVars {\\n uint256 totalDebt;\\n uint256 totalCollateral;\\n uint256 adjustedDebt;\\n uint256 adjustedCollateral;\\n uint256 seizeAvailable;\\n}\\n\",\"keccak256\":\"0x93d487fdf861e8f58edca8058bffec88f31d280846420faec8e3e7049d3068fd\",\"license\":\"BUSL-1.1\"},\"contracts/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\ncontract InterestRateModel {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n\\n /// @notice Threshold to define which method should be used to calculate the interest rates.\\n /// @dev When `eta` (`delta / alpha`) is lower than this value, use simpson's rule for approximation.\\n uint256 internal constant PRECISION_THRESHOLD = 7.5e14;\\n\\n /// @notice Scale factor of the fixed curve.\\n uint256 public immutable fixedCurveA;\\n /// @notice Origin intercept of the fixed curve.\\n int256 public immutable fixedCurveB;\\n /// @notice Asymptote of the fixed curve.\\n uint256 public immutable fixedMaxUtilization;\\n\\n /// @notice Scale factor of the floating curve.\\n uint256 public immutable floatingCurveA;\\n /// @notice Origin intercept of the floating curve.\\n int256 public immutable floatingCurveB;\\n /// @notice Asymptote of the floating curve.\\n uint256 public immutable floatingMaxUtilization;\\n\\n constructor(\\n uint256 fixedCurveA_,\\n int256 fixedCurveB_,\\n uint256 fixedMaxUtilization_,\\n uint256 floatingCurveA_,\\n int256 floatingCurveB_,\\n uint256 floatingMaxUtilization_\\n ) {\\n assert(fixedMaxUtilization_ > 1e18);\\n assert(floatingMaxUtilization_ > 1e18);\\n\\n fixedCurveA = fixedCurveA_;\\n fixedCurveB = fixedCurveB_;\\n fixedMaxUtilization = fixedMaxUtilization_;\\n\\n floatingCurveA = floatingCurveA_;\\n floatingCurveB = floatingCurveB_;\\n floatingMaxUtilization = floatingMaxUtilization_;\\n\\n // reverts if it's an invalid curve (such as one yielding a negative interest rate).\\n fixedRate(0, 0);\\n floatingRate(0);\\n }\\n\\n /// @notice Gets the rate to borrow a certain amount at a certain maturity with supply/demand values in the fixed rate\\n /// pool and assets from the backup supplier.\\n /// @param maturity maturity date for calculating days left to maturity.\\n /// @param amount the current borrow's amount.\\n /// @param borrowed ex-ante amount borrowed from this fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay (represented with 18 decimals).\\n function fixedBorrowRate(\\n uint256 maturity,\\n uint256 amount,\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256) {\\n if (block.timestamp >= maturity) revert AlreadyMatured();\\n\\n uint256 potentialAssets = supplied + backupAssets;\\n uint256 utilizationAfter = (borrowed + amount).divWadUp(potentialAssets);\\n\\n if (utilizationAfter > 1e18) revert UtilizationExceeded();\\n\\n uint256 utilizationBefore = borrowed.divWadDown(potentialAssets);\\n\\n return fixedRate(utilizationBefore, utilizationAfter).mulDivDown(maturity - block.timestamp, 365 days);\\n }\\n\\n /// @notice Returns the current annualized fixed rate to borrow with supply/demand values in the fixed rate pool and\\n /// assets from the backup supplier.\\n /// @param borrowed amount borrowed from the fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay, with 18 decimals precision.\\n /// @return utilization current utilization rate, with 18 decimals precision.\\n function minFixedRate(\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256 rate, uint256 utilization) {\\n utilization = borrowed.divWadUp(supplied + backupAssets);\\n rate = fixedRate(utilization, utilization);\\n }\\n\\n /// @notice Returns the interest rate integral from `u0` to `u1`, using the analytical solution (ln).\\n /// @dev Uses the fixed rate curve parameters.\\n /// Handles special case where delta utilization tends to zero, using simpson's rule.\\n /// @param utilizationBefore ex-ante utilization rate, with 18 decimals precision.\\n /// @param utilizationAfter ex-post utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function fixedRate(uint256 utilizationBefore, uint256 utilizationAfter) internal view returns (uint256) {\\n uint256 alpha = fixedMaxUtilization - utilizationBefore;\\n uint256 delta = utilizationAfter - utilizationBefore;\\n int256 r = int256(\\n delta.divWadDown(alpha) < PRECISION_THRESHOLD\\n ? (fixedCurveA.divWadDown(alpha) +\\n fixedCurveA.mulDivDown(4e18, fixedMaxUtilization - ((utilizationAfter + utilizationBefore) / 2)) +\\n fixedCurveA.divWadDown(fixedMaxUtilization - utilizationAfter)) / 6\\n : fixedCurveA.mulDivDown(\\n uint256(int256(alpha.divWadDown(fixedMaxUtilization - utilizationAfter)).lnWad()),\\n delta\\n )\\n ) + fixedCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n\\n /// @notice Returns the interest rate for an utilization rate.\\n /// @dev Uses the floating rate curve parameters.\\n /// @param utilization utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function floatingRate(uint256 utilization) public view returns (uint256) {\\n int256 r = int256(floatingCurveA.divWadDown(floatingMaxUtilization - utilization)) + floatingCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n}\\n\\nerror AlreadyMatured();\\nerror UtilizationExceeded();\\n\",\"keccak256\":\"0xfb1d32f03bb869906ce577bb0e4cbc3e141006c7087f4e826ce513a9c4582f57\",\"license\":\"BUSL-1.1\"},\"contracts/Market.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { ERC4626, ERC20, SafeTransferLib } from \\\"solmate/src/mixins/ERC4626.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"./RewardsController.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\n\\ncontract Market is Initializable, AccessControlUpgradeable, PausableUpgradeable, ERC4626 {\\n using FixedPointMathLib for int256;\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint128;\\n using SafeTransferLib for ERC20;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for uint256;\\n\\n bytes32 public constant PAUSER_ROLE = keccak256(\\\"PAUSER_ROLE\\\");\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n\\n /// @notice Tracks account's fixed deposit positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedDepositPositions;\\n /// @notice Tracks account's fixed borrow positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedBorrowPositions;\\n /// @notice Tracks fixed pools state by maturity.\\n mapping(uint256 => FixedLib.Pool) public fixedPools;\\n\\n /// @notice Tracks fixed deposit and borrow map and floating borrow shares of an account.\\n mapping(address => Account) public accounts;\\n\\n /// @notice Amount of assets lent by the floating pool to the fixed pools.\\n uint256 public floatingBackupBorrowed;\\n /// @notice Amount of assets lent by the floating pool to accounts.\\n uint256 public floatingDebt;\\n\\n /// @notice Accumulated earnings from extraordinary sources to be gradually distributed.\\n uint256 public earningsAccumulator;\\n /// @notice Rate per second to be charged to delayed fixed pools borrowers after maturity.\\n uint256 public penaltyRate;\\n /// @notice Rate charged to the fixed pool to be retained by the floating pool for initially providing liquidity.\\n uint256 public backupFeeRate;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is higher.\\n uint256 public dampSpeedUp;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is lower.\\n uint256 public dampSpeedDown;\\n\\n /// @notice Number of fixed pools to be active at the same time.\\n uint8 public maxFuturePools;\\n /// @notice Last time the accumulator distributed earnings.\\n uint32 public lastAccumulatorAccrual;\\n /// @notice Last time the floating debt was updated.\\n uint32 public lastFloatingDebtUpdate;\\n /// @notice Last time the floating assets average was updated.\\n uint32 public lastAverageUpdate;\\n\\n /// @notice Interest rate model contract used to get the borrow rates.\\n InterestRateModel public interestRateModel;\\n\\n /// @notice Factor used for gradual accrual of earnings to the floating pool.\\n uint128 public earningsAccumulatorSmoothFactor;\\n /// @notice Percentage factor that represents the liquidity reserves that can't be borrowed.\\n uint128 public reserveFactor;\\n\\n /// @notice Amount of floating assets deposited to the pool.\\n uint256 public floatingAssets;\\n /// @notice Average of the floating assets to get fixed borrow rates and prevent rate manipulation.\\n uint256 public floatingAssetsAverage;\\n\\n /// @notice Total amount of floating borrow shares assigned to floating borrow accounts.\\n uint256 public totalFloatingBorrowShares;\\n\\n /// @dev gap from deprecated state.\\n /// @custom:oz-renamed-from floatingUtilization\\n uint256 private __gap;\\n\\n /// @notice Address of the treasury that will receive the allocated earnings.\\n address public treasury;\\n /// @notice Rate to be charged by the treasury to floating and fixed borrows.\\n uint256 public treasuryFeeRate;\\n\\n /// @notice Address of the rewards controller that will accrue rewards for accounts operating with the Market.\\n RewardsController public rewardsController;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(ERC20 asset_, Auditor auditor_) ERC4626(asset_, \\\"\\\", \\\"\\\") {\\n auditor = auditor_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(\\n uint8 maxFuturePools_,\\n uint128 earningsAccumulatorSmoothFactor_,\\n InterestRateModel interestRateModel_,\\n uint256 penaltyRate_,\\n uint256 backupFeeRate_,\\n uint128 reserveFactor_,\\n uint256 dampSpeedUp_,\\n uint256 dampSpeedDown_\\n ) external initializer {\\n __AccessControl_init();\\n __Pausable_init();\\n\\n string memory assetSymbol = asset.symbol();\\n name = string.concat(\\\"exactly \\\", assetSymbol);\\n symbol = string.concat(\\\"exa\\\", assetSymbol);\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n lastAverageUpdate = uint32(block.timestamp);\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setMaxFuturePools(maxFuturePools_);\\n setEarningsAccumulatorSmoothFactor(earningsAccumulatorSmoothFactor_);\\n setInterestRateModel(interestRateModel_);\\n setPenaltyRate(penaltyRate_);\\n setBackupFeeRate(backupFeeRate_);\\n setReserveFactor(reserveFactor_);\\n setDampSpeed(dampSpeedUp_, dampSpeedDown_);\\n }\\n\\n /// @notice Borrows a certain amount from the floating pool.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return borrowShares shares corresponding to the borrowed assets.\\n function borrow(\\n uint256 assets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 borrowShares) {\\n spendAllowance(borrower, assets);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n\\n borrowShares = previewBorrow(assets);\\n\\n uint256 newFloatingDebt = floatingDebt + assets;\\n floatingDebt = newFloatingDebt;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed, also considering the reserves\\n if (floatingBackupBorrowed + newFloatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n\\n totalFloatingBorrowShares += borrowShares;\\n accounts[borrower].floatingBorrowShares += borrowShares;\\n\\n emit Borrow(msg.sender, receiver, borrower, assets, borrowShares);\\n emitMarketUpdate();\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Repays a certain amount of assets to the floating pool.\\n /// @param assets assets to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepay the actual amount that should be transferred into the protocol.\\n /// @return borrowShares subtracted shares from the borrower's accountability.\\n function repay(\\n uint256 assets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepay, uint256 borrowShares) {\\n (actualRepay, borrowShares) = noTransferRefund(previewRepay(assets), borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), actualRepay);\\n }\\n\\n /// @notice Repays a certain amount of shares to the floating pool.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return assets subtracted assets from the borrower's accountability.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function refund(\\n uint256 borrowShares,\\n address borrower\\n ) external whenNotPaused returns (uint256 assets, uint256 actualShares) {\\n (assets, actualShares) = noTransferRefund(borrowShares, borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Allows to (partially) repay a floating borrow. It does not transfer assets.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower the address of the account that has the debt.\\n /// @return assets the actual amount that should be transferred into the protocol.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function noTransferRefund(\\n uint256 borrowShares,\\n address borrower\\n ) internal returns (uint256 assets, uint256 actualShares) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n Account storage account = accounts[borrower];\\n uint256 accountBorrowShares = account.floatingBorrowShares;\\n actualShares = Math.min(borrowShares, accountBorrowShares);\\n assets = previewRefund(actualShares);\\n\\n if (assets == 0) revert ZeroRepay();\\n\\n floatingDebt -= assets;\\n account.floatingBorrowShares = accountBorrowShares - actualShares;\\n totalFloatingBorrowShares -= actualShares;\\n\\n emit Repay(msg.sender, borrower, assets, actualShares);\\n }\\n\\n /// @notice Deposits a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be deposited.\\n /// @param assets amount to receive from the msg.sender.\\n /// @param minAssetsRequired minimum amount of assets required by the depositor for the transaction to be accepted.\\n /// @param receiver address that will be able to withdraw the deposited assets.\\n /// @return positionAssets total amount of assets (principal + fee) to be withdrawn at maturity.\\n function depositAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 minAssetsRequired,\\n address receiver\\n ) external whenNotPaused returns (uint256 positionAssets) {\\n if (assets == 0) revert ZeroDeposit();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n (uint256 fee, uint256 backupFee) = pool.calculateDeposit(assets, backupFeeRate);\\n positionAssets = assets + fee;\\n if (positionAssets < minAssetsRequired) revert Disagreement();\\n\\n floatingBackupBorrowed -= pool.deposit(assets);\\n pool.unassignedEarnings -= fee + backupFee;\\n earningsAccumulator += backupFee;\\n\\n // update account's position\\n FixedLib.Position storage position = fixedDepositPositions[maturity][receiver];\\n\\n // if account doesn't have a current position, add it to the list\\n if (position.principal == 0) {\\n Account storage account = accounts[receiver];\\n account.fixedDeposits = account.fixedDeposits.setMaturity(maturity);\\n }\\n\\n position.principal += assets;\\n position.fee += fee;\\n\\n floatingAssets += backupEarnings;\\n\\n emit DepositAtMaturity(maturity, msg.sender, receiver, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Borrows a certain amount from a maturity.\\n /// @param maturity maturity date for repayment.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return assetsOwed total amount of assets (principal + fee) to be repaid at maturity.\\n function borrowAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 maxAssets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 assetsOwed) {\\n if (assets == 0) revert ZeroBorrow();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n uint256 fee = assets.mulWadDown(\\n interestRateModel.fixedBorrowRate(maturity, assets, pool.borrowed, pool.supplied, previewFloatingAssetsAverage())\\n );\\n assetsOwed = assets + fee;\\n\\n // validate that the account is not taking arbitrary fees\\n if (assetsOwed > maxAssets) revert Disagreement();\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n spendAllowance(borrower, assetsOwed);\\n\\n {\\n uint256 backupDebtAddition = pool.borrow(assets);\\n if (backupDebtAddition > 0) {\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed + backupDebtAddition;\\n depositToTreasury(updateFloatingDebt());\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n }\\n\\n {\\n // if account doesn't have a current position, add it to the list\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n if (position.principal == 0) {\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.setMaturity(maturity);\\n }\\n\\n // calculate what portion of the fees are to be accrued and what portion goes to earnings accumulator\\n (uint256 newUnassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(fee),\\n assets\\n );\\n if (newUnassignedEarnings > 0) pool.unassignedEarnings += newUnassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n fixedBorrowPositions[maturity][borrower] = FixedLib.Position(position.principal + assets, position.fee + fee);\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit BorrowAtMaturity(maturity, msg.sender, receiver, borrower, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Withdraws a certain amount from a maturity.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param maturity maturity date where the assets will be withdrawn.\\n /// @param positionAssets position size to be reduced.\\n /// @param minAssetsRequired minimum amount required by the account (if discount included for early withdrawal).\\n /// @param receiver address that will receive the withdrawn assets.\\n /// @param owner address that previously deposited the assets.\\n /// @return assetsDiscounted amount of assets withdrawn (can include a discount for early withdraw).\\n function withdrawAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 minAssetsRequired,\\n address receiver,\\n address owner\\n ) external returns (uint256 assetsDiscounted) {\\n if (positionAssets == 0) revert ZeroWithdraw();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedDepositPositions[maturity][owner];\\n\\n if (positionAssets > position.principal + position.fee) positionAssets = position.principal + position.fee;\\n\\n // verify if there are any penalties/fee for the account because of early withdrawal, if so discount\\n if (block.timestamp < maturity) {\\n assetsDiscounted = positionAssets.divWadDown(\\n 1e18 +\\n interestRateModel.fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n previewFloatingAssetsAverage()\\n )\\n );\\n } else {\\n assetsDiscounted = positionAssets;\\n }\\n\\n if (assetsDiscounted < minAssetsRequired) revert Disagreement();\\n\\n spendAllowance(owner, assetsDiscounted);\\n\\n {\\n // remove the supply from the fixed rate pool\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed +\\n pool.withdraw(\\n FixedLib.Position(position.principal, position.fee).scaleProportionally(positionAssets).principal\\n );\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets) revert InsufficientProtocolLiquidity();\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n\\n // all the fees go to unassigned or to the floating pool\\n (uint256 unassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(positionAssets - assetsDiscounted),\\n assetsDiscounted\\n );\\n pool.unassignedEarnings += unassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n // the account gets discounted the full amount\\n position.reduceProportionally(positionAssets);\\n if (position.principal | position.fee == 0) {\\n delete fixedDepositPositions[maturity][owner];\\n Account storage account = accounts[owner];\\n account.fixedDeposits = account.fixedDeposits.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedDepositPositions[maturity][owner] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit WithdrawAtMaturity(maturity, msg.sender, receiver, owner, positionAssets, assetsDiscounted);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransfer(receiver, assetsDiscounted);\\n }\\n\\n /// @notice Repays a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be repaid.\\n /// @param positionAssets amount to be paid for the borrower's debt.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepayAssets the actual amount that was transferred into the protocol.\\n function repayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepayAssets) {\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n actualRepayAssets = noTransferRepayAtMaturity(maturity, positionAssets, maxAssets, borrower, true);\\n emitMarketUpdate();\\n\\n asset.safeTransferFrom(msg.sender, address(this), actualRepayAssets);\\n }\\n\\n /// @notice Allows to (partially) repay a fixed rate position. It does not transfer assets.\\n /// @param maturity the maturity to access the pool.\\n /// @param positionAssets the amount of debt of the pool that should be paid.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower the address of the account that has the debt.\\n /// @param canDiscount should early repay discounts be applied.\\n /// @return actualRepayAssets the actual amount that should be transferred into the protocol.\\n function noTransferRepayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower,\\n bool canDiscount\\n ) internal returns (uint256 actualRepayAssets) {\\n if (positionAssets == 0) revert ZeroRepay();\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedBorrowPositions[maturity][borrower];\\n\\n uint256 debtCovered = Math.min(positionAssets, position.principal + position.fee);\\n\\n uint256 principalCovered = FixedLib\\n .Position(position.principal, position.fee)\\n .scaleProportionally(debtCovered)\\n .principal;\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n // early repayment allows a discount from the unassigned earnings\\n if (block.timestamp < maturity) {\\n if (canDiscount) {\\n // calculate the deposit fee considering the amount of debt the account'll pay\\n (uint256 discountFee, uint256 backupFee) = pool.calculateDeposit(principalCovered, backupFeeRate);\\n\\n // remove the fee from unassigned earnings\\n pool.unassignedEarnings -= discountFee + backupFee;\\n\\n // the fee charged to the fixed pool supplier goes to the earnings accumulator\\n earningsAccumulator += backupFee;\\n\\n // the fee gets discounted from the account through `actualRepayAssets`\\n actualRepayAssets = debtCovered - discountFee;\\n } else {\\n actualRepayAssets = debtCovered;\\n }\\n } else {\\n actualRepayAssets = debtCovered + debtCovered.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n\\n // all penalties go to the earnings accumulator\\n earningsAccumulator += actualRepayAssets - debtCovered;\\n }\\n\\n // verify that the account agrees to this discount or penalty\\n if (actualRepayAssets > maxAssets) revert Disagreement();\\n\\n // reduce the borrowed from the pool and might decrease the floating backup borrowed\\n floatingBackupBorrowed -= pool.repay(principalCovered);\\n\\n // update the account position\\n position.reduceProportionally(debtCovered);\\n if (position.principal | position.fee == 0) {\\n delete fixedBorrowPositions[maturity][borrower];\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedBorrowPositions[maturity][borrower] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, actualRepayAssets, debtCovered);\\n emitFixedEarningsUpdate(maturity);\\n }\\n\\n /// @notice Liquidates undercollateralized fixed/floating (or both) position(s).\\n /// @dev Msg.sender liquidates borrower's position(s) and repays a certain amount of debt for the floating pool,\\n /// or/and for multiple fixed pools, seizing a portion of borrower's collateral.\\n /// @param borrower account that has an outstanding debt across floating or fixed pools.\\n /// @param maxAssets maximum amount of debt that the liquidator is willing to accept. (it can be less)\\n /// @param seizeMarket market from which the collateral will be seized to give to the liquidator.\\n /// @return repaidAssets actual amount repaid.\\n function liquidate(\\n address borrower,\\n uint256 maxAssets,\\n Market seizeMarket\\n ) external whenNotPaused returns (uint256 repaidAssets) {\\n if (msg.sender == borrower) revert SelfLiquidation();\\n\\n maxAssets = auditor.checkLiquidation(this, seizeMarket, borrower, maxAssets);\\n if (maxAssets == 0) revert ZeroRepay();\\n\\n Account storage account = accounts[borrower];\\n\\n {\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0 && maxAssets != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 actualRepay;\\n if (block.timestamp < maturity) {\\n actualRepay = noTransferRepayAtMaturity(maturity, maxAssets, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n } else {\\n uint256 position;\\n {\\n FixedLib.Position storage p = fixedBorrowPositions[maturity][borrower];\\n position = p.principal + p.fee;\\n }\\n uint256 debt = position + position.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n actualRepay = debt > maxAssets ? maxAssets.mulDivDown(position, debt) : maxAssets;\\n\\n if (actualRepay == 0) maxAssets = 0;\\n else {\\n actualRepay = noTransferRepayAtMaturity(maturity, actualRepay, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n }\\n }\\n repaidAssets += actualRepay;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n if (maxAssets > 0 && account.floatingBorrowShares > 0) {\\n uint256 borrowShares = previewRepay(maxAssets);\\n if (borrowShares > 0) {\\n (uint256 actualRepayAssets, ) = noTransferRefund(borrowShares, borrower);\\n repaidAssets += actualRepayAssets;\\n }\\n }\\n\\n // reverts on failure\\n (uint256 lendersAssets, uint256 seizeAssets) = auditor.calculateSeize(this, seizeMarket, borrower, repaidAssets);\\n earningsAccumulator += lendersAssets;\\n\\n if (address(seizeMarket) == address(this)) {\\n internalSeize(this, msg.sender, borrower, seizeAssets);\\n } else {\\n seizeMarket.seize(msg.sender, borrower, seizeAssets);\\n\\n emitMarketUpdate();\\n }\\n\\n emit Liquidate(msg.sender, borrower, repaidAssets, lendersAssets, seizeMarket, seizeAssets);\\n\\n auditor.handleBadDebt(borrower);\\n\\n asset.safeTransferFrom(msg.sender, address(this), repaidAssets + lendersAssets);\\n }\\n\\n /// @notice Clears floating and fixed debt for an account spreading the losses to the `earningsAccumulator`.\\n /// @dev Can only be called from the auditor.\\n /// @param borrower account with insufficient collateral to be cleared the debt.\\n function clearBadDebt(address borrower) external {\\n if (msg.sender != address(auditor)) revert NotAuditor();\\n\\n floatingAssets += accrueAccumulatedEarnings();\\n Account storage account = accounts[borrower];\\n uint256 accumulator = earningsAccumulator;\\n uint256 totalBadDebt = 0;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 badDebt = position.principal + position.fee;\\n if (accumulator >= badDebt) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n accumulator -= badDebt;\\n totalBadDebt += badDebt;\\n floatingBackupBorrowed -= fixedPools[maturity].repay(position.principal);\\n delete fixedBorrowPositions[maturity][borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, badDebt, badDebt);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n if (account.floatingBorrowShares > 0 && (accumulator = previewRepay(accumulator)) > 0) {\\n (uint256 badDebt, ) = noTransferRefund(accumulator, borrower);\\n totalBadDebt += badDebt;\\n }\\n if (totalBadDebt > 0) {\\n earningsAccumulator -= totalBadDebt;\\n emit SpreadBadDebt(borrower, totalBadDebt);\\n }\\n emitMarketUpdate();\\n }\\n\\n /// @notice Public function to seize a certain amount of assets.\\n /// @dev Public function for liquidator to seize borrowers assets in the floating pool.\\n /// This function will only be called from another Market, on `liquidation` calls.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function seize(address liquidator, address borrower, uint256 assets) external whenNotPaused {\\n internalSeize(Market(msg.sender), liquidator, borrower, assets);\\n }\\n\\n /// @notice Internal function to seize a certain amount of assets.\\n /// @dev Internal function for liquidator to seize borrowers assets in the floating pool.\\n /// Will only be called from this Market on `liquidation` or through `seize` calls from another Market.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param seizeMarket address which is calling the seize function (see `seize` public function).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function internalSeize(Market seizeMarket, address liquidator, address borrower, uint256 assets) internal {\\n if (assets == 0) revert ZeroWithdraw();\\n\\n // reverts on failure\\n auditor.checkSeize(seizeMarket, this);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(borrower);\\n uint256 shares = previewWithdraw(assets);\\n beforeWithdraw(assets, shares);\\n _burn(borrower, shares);\\n emit Withdraw(msg.sender, liquidator, borrower, assets, shares);\\n emit Seize(liquidator, borrower, assets);\\n emitMarketUpdate();\\n\\n asset.safeTransfer(liquidator, assets);\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param assets amount of assets to be withdrawn from the floating pool.\\n function beforeWithdraw(uint256 assets, uint256) internal override {\\n updateFloatingAssetsAverage();\\n depositToTreasury(updateFloatingDebt());\\n uint256 earnings = accrueAccumulatedEarnings();\\n uint256 newFloatingAssets = floatingAssets + earnings - assets;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed\\n if (floatingBackupBorrowed + floatingDebt > newFloatingAssets) revert InsufficientProtocolLiquidity();\\n floatingAssets = newFloatingAssets;\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @param assets amount of assets to be deposited to the floating pool.\\n function afterDeposit(uint256 assets, uint256) internal override whenNotPaused {\\n updateFloatingAssetsAverage();\\n uint256 treasuryFee = updateFloatingDebt();\\n uint256 earnings = accrueAccumulatedEarnings();\\n floatingAssets += earnings + assets;\\n depositToTreasury(treasuryFee);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Withdraws the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param assets amount of underlying to be withdrawn.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return shares amount of shares redeemed for underlying asset.\\n function withdraw(uint256 assets, address receiver, address owner) public override returns (uint256 shares) {\\n auditor.checkShortfall(this, owner, assets);\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n shares = super.withdraw(assets, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Redeems the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param shares amount of shares to be redeemed for underlying asset.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return assets amount of underlying asset that was withdrawn.\\n function redeem(uint256 shares, address receiver, address owner) public override returns (uint256 assets) {\\n auditor.checkShortfall(this, owner, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n assets = super.redeem(shares, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n function _mint(address to, uint256 amount) internal override {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(to);\\n super._mint(to, amount);\\n }\\n\\n /// @notice Moves amount of shares from the caller's account to `to`.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that the caller doesn't have shortfall after transferring.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transfer(address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, msg.sender, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(msg.sender);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transfer(to, shares);\\n }\\n\\n /// @notice Moves amount of shares from `from` to `to` using the allowance mechanism.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that `from` address doesn't have shortfall after transferring.\\n /// @param from address from which the assets will be transferred.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transferFrom(address from, address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, from, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(from);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transferFrom(from, to, shares);\\n }\\n\\n /// @notice Gets current snapshot for an account across all maturities.\\n /// @param account account to return status snapshot in the specified maturity date.\\n /// @return the amount deposited to the floating pool and the amount owed to floating and fixed pools.\\n function accountSnapshot(address account) external view returns (uint256, uint256) {\\n return (convertToAssets(balanceOf[account]), previewDebt(account));\\n }\\n\\n /// @notice Gets all borrows and penalties for an account.\\n /// @param borrower account to return status snapshot for fixed and floating borrows.\\n /// @return debt the total debt, denominated in number of assets.\\n function previewDebt(address borrower) public view returns (uint256 debt) {\\n Account storage account = accounts[borrower];\\n uint256 memPenaltyRate = penaltyRate;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n // calculate all maturities using the base maturity and the following bits representing the following intervals\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 positionAssets = position.principal + position.fee;\\n\\n debt += positionAssets;\\n\\n if (block.timestamp > maturity) {\\n debt += positionAssets.mulWadDown((block.timestamp - maturity) * memPenaltyRate);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n // calculate floating borrowed debt\\n uint256 shares = account.floatingBorrowShares;\\n if (shares > 0) debt += previewRefund(shares);\\n }\\n\\n /// @notice Charges treasury fee to certain amount of earnings.\\n /// @param earnings amount of earnings.\\n /// @return earnings minus the fees charged by the treasury.\\n function chargeTreasuryFee(uint256 earnings) internal returns (uint256) {\\n uint256 fee = earnings.mulWadDown(treasuryFeeRate);\\n depositToTreasury(fee);\\n return earnings - fee;\\n }\\n\\n /// @notice Collects all earnings that are charged to borrowers that make use of fixed pool deposits' assets.\\n /// @param earnings amount of earnings.\\n function collectFreeLunch(uint256 earnings) internal {\\n if (earnings == 0) return;\\n\\n if (treasuryFeeRate > 0) {\\n depositToTreasury(earnings);\\n } else {\\n earningsAccumulator += earnings;\\n }\\n }\\n\\n /// @notice Deposits amount of assets on behalf of the treasury address.\\n /// @param fee amount of assets to be deposited.\\n function depositToTreasury(uint256 fee) internal {\\n if (fee > 0) {\\n _mint(treasury, previewDeposit(fee));\\n floatingAssets += fee;\\n }\\n }\\n\\n /// @notice Calculates the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings to be distributed from the accumulator.\\n function accumulatedEarnings() internal view returns (uint256 earnings) {\\n uint256 elapsed = block.timestamp - lastAccumulatorAccrual;\\n if (elapsed == 0) return 0;\\n return\\n earningsAccumulator.mulDivDown(\\n elapsed,\\n elapsed + earningsAccumulatorSmoothFactor.mulWadDown(maxFuturePools * FixedLib.INTERVAL)\\n );\\n }\\n\\n /// @notice Accrues the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings distributed from the accumulator.\\n function accrueAccumulatedEarnings() internal returns (uint256 earnings) {\\n earnings = accumulatedEarnings();\\n\\n earningsAccumulator -= earnings;\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n emit AccumulatorAccrual(block.timestamp);\\n }\\n\\n /// @notice Updates the `floatingAssetsAverage`.\\n function updateFloatingAssetsAverage() internal {\\n floatingAssetsAverage = previewFloatingAssetsAverage();\\n lastAverageUpdate = uint32(block.timestamp);\\n }\\n\\n /// @notice Returns the current `floatingAssetsAverage` without updating the storage variable.\\n /// @return projected `floatingAssetsAverage`.\\n function previewFloatingAssetsAverage() public view returns (uint256) {\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 memFloatingAssetsAverage = floatingAssetsAverage;\\n uint256 dampSpeedFactor = memFloatingAssets < memFloatingAssetsAverage ? dampSpeedDown : dampSpeedUp;\\n uint256 averageFactor = uint256(1e18 - (-int256(dampSpeedFactor * (block.timestamp - lastAverageUpdate))).expWad());\\n return memFloatingAssetsAverage.mulWadDown(1e18 - averageFactor) + averageFactor.mulWadDown(memFloatingAssets);\\n }\\n\\n /// @notice Updates the floating pool borrows' variables.\\n /// @return treasuryFee amount of fees charged by the treasury to the new calculated floating debt.\\n function updateFloatingDebt() internal returns (uint256 treasuryFee) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n\\n memFloatingDebt += newDebt;\\n treasuryFee = newDebt.mulWadDown(treasuryFeeRate);\\n floatingAssets = memFloatingAssets + newDebt - treasuryFee;\\n floatingDebt = memFloatingDebt;\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n emit FloatingDebtUpdate(block.timestamp, floatingUtilization);\\n }\\n\\n /// @notice Calculates the total floating debt, considering elapsed time since last update and current interest rate.\\n /// @return actual floating debt plus projected interest.\\n function totalFloatingBorrowAssets() public view returns (uint256) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n return memFloatingDebt + newDebt;\\n }\\n\\n /// @notice Calculates the floating pool balance plus earnings to be accrued at current timestamp\\n /// from maturities and accumulator.\\n /// @return actual floatingAssets plus earnings to be accrued at current timestamp.\\n function totalAssets() public view override returns (uint256) {\\n unchecked {\\n uint256 memMaxFuturePools = maxFuturePools;\\n uint256 backupEarnings = 0;\\n\\n uint256 latestMaturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL);\\n uint256 maxMaturity = latestMaturity + memMaxFuturePools * FixedLib.INTERVAL;\\n\\n for (uint256 maturity = latestMaturity; maturity <= maxMaturity; maturity += FixedLib.INTERVAL) {\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (maturity > lastAccrual) {\\n backupEarnings += block.timestamp < maturity\\n ? pool.unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual)\\n : pool.unassignedEarnings;\\n }\\n }\\n\\n return\\n floatingAssets +\\n backupEarnings +\\n accumulatedEarnings() +\\n (totalFloatingBorrowAssets() - floatingDebt).mulWadDown(1e18 - treasuryFeeRate);\\n }\\n }\\n\\n /// @notice Simulates the effects of a borrow at the current time, given current contract conditions.\\n /// @param assets amount of assets to borrow.\\n /// @return amount of shares that will be asigned to the account after the borrow.\\n function previewBorrow(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a repay at the current time, given current contract conditions.\\n /// @param assets amount of assets to repay.\\n /// @return amount of shares that will be subtracted from the account after the repay.\\n function previewRepay(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a refund at the current time, given current contract conditions.\\n /// @param shares amount of shares to subtract from caller's accountability.\\n /// @return amount of assets that will be repaid.\\n function previewRefund(uint256 shares) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalFloatingBorrowAssets(), supply);\\n }\\n\\n /// @notice Checks msg.sender's allowance over account's assets.\\n /// @param account account in which the allowance will be checked.\\n /// @param assets assets from account that msg.sender wants to operate on.\\n function spendAllowance(address account, uint256 assets) internal {\\n if (msg.sender != account) {\\n uint256 allowed = allowance[account][msg.sender]; // saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[account][msg.sender] = allowed - previewWithdraw(assets);\\n }\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed amount of the fixed pool.\\n function fixedPoolBorrowed(uint256 maturity) external view returns (uint256) {\\n return fixedPools[maturity].borrowed;\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed and supplied amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed and supplied amount of the fixed pool.\\n function fixedPoolBalance(uint256 maturity) external view returns (uint256, uint256) {\\n return (fixedPools[maturity].borrowed, fixedPools[maturity].supplied);\\n }\\n\\n /// @notice Emits MarketUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitMarketUpdate() internal {\\n emit MarketUpdate(\\n block.timestamp,\\n totalSupply,\\n floatingAssets,\\n totalFloatingBorrowShares,\\n floatingDebt,\\n earningsAccumulator\\n );\\n }\\n\\n /// @notice Emits FixedEarningsUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitFixedEarningsUpdate(uint256 maturity) internal {\\n emit FixedEarningsUpdate(block.timestamp, maturity, fixedPools[maturity].unassignedEarnings);\\n }\\n\\n /// @notice Sets the rate charged to the fixed depositors that the floating pool suppliers will retain for initially\\n /// providing liquidity.\\n /// @param backupFeeRate_ percentage amount represented with 18 decimals.\\n function setBackupFeeRate(uint256 backupFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n backupFeeRate = backupFeeRate_;\\n emit BackupFeeRateSet(backupFeeRate_);\\n }\\n\\n /// @notice Sets the damp speed used to update the floatingAssetsAverage.\\n /// @param up damp speed up, represented with 18 decimals.\\n /// @param down damp speed down, represented with 18 decimals.\\n function setDampSpeed(uint256 up, uint256 down) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n updateFloatingAssetsAverage();\\n dampSpeedUp = up;\\n dampSpeedDown = down;\\n emit DampSpeedSet(up, down);\\n }\\n\\n /// @notice Sets the factor used when smoothly accruing earnings to the floating pool.\\n /// @param earningsAccumulatorSmoothFactor_ represented with 18 decimals.\\n function setEarningsAccumulatorSmoothFactor(\\n uint128 earningsAccumulatorSmoothFactor_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n floatingAssets += accrueAccumulatedEarnings();\\n emitMarketUpdate();\\n earningsAccumulatorSmoothFactor = earningsAccumulatorSmoothFactor_;\\n emit EarningsAccumulatorSmoothFactorSet(earningsAccumulatorSmoothFactor_);\\n }\\n\\n /// @notice Sets the interest rate model to be used to calculate rates.\\n /// @param interestRateModel_ new interest rate model.\\n function setInterestRateModel(InterestRateModel interestRateModel_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(interestRateModel) != address(0)) depositToTreasury(updateFloatingDebt());\\n\\n interestRateModel = interestRateModel_;\\n emitMarketUpdate();\\n emit InterestRateModelSet(interestRateModel_);\\n }\\n\\n /// @notice Sets the rewards controller to update account rewards when operating with the Market.\\n /// @param rewardsController_ new rewards controller.\\n function setRewardsController(RewardsController rewardsController_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n rewardsController = rewardsController_;\\n emit RewardsControllerSet(rewardsController_);\\n }\\n\\n /// @notice Sets the protocol's max future pools for fixed borrowing and lending.\\n /// @dev If value is decreased, VALID maturities will become NOT_READY.\\n /// @param futurePools number of pools to be active at the same time.\\n function setMaxFuturePools(uint8 futurePools) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n maxFuturePools = futurePools;\\n emit MaxFuturePoolsSet(futurePools);\\n }\\n\\n /// @notice Sets the penalty rate per second.\\n /// @param penaltyRate_ percentage represented with 18 decimals.\\n function setPenaltyRate(uint256 penaltyRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n penaltyRate = penaltyRate_;\\n emit PenaltyRateSet(penaltyRate_);\\n }\\n\\n /// @notice Sets the percentage that represents the liquidity reserves that can't be borrowed.\\n /// @param reserveFactor_ parameter represented with 18 decimals.\\n function setReserveFactor(uint128 reserveFactor_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n reserveFactor = reserveFactor_;\\n emit ReserveFactorSet(reserveFactor_);\\n }\\n\\n /// @notice Sets the treasury variables.\\n /// @param treasury_ address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate_ represented with 18 decimals.\\n function setTreasury(address treasury_, uint256 treasuryFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n depositToTreasury(updateFloatingDebt());\\n treasury = treasury_;\\n treasuryFeeRate = treasuryFeeRate_;\\n emit TreasurySet(treasury_, treasuryFeeRate_);\\n }\\n\\n /// @notice Sets the pause state to true in case of emergency, triggered by an authorized account.\\n function pause() external onlyRole(PAUSER_ROLE) {\\n _pause();\\n }\\n\\n /// @notice Sets the pause state to false when threat is gone, triggered by an authorized account.\\n function unpause() external onlyRole(PAUSER_ROLE) {\\n _unpause();\\n }\\n\\n /// @notice Event emitted when an account borrows amount of assets from a floating pool.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of assets that were borrowed.\\n /// @param shares amount of borrow shares assigned to the account.\\n event Borrow(\\n address indexed caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /// @notice Emitted when an account repays amount of assets to a floating pool.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of assets that was repaid.\\n /// @param shares amount of borrow shares that were subtracted from the account's accountability.\\n event Repay(address indexed caller, address indexed borrower, uint256 assets, uint256 shares);\\n\\n /// @notice Emitted when an account deposits an amount of an asset to a certain fixed rate pool,\\n /// collecting fees at the end of the period.\\n /// @param maturity maturity at which the account will be able to collect his deposit + his fee.\\n /// @param caller address which deposited the assets.\\n /// @param owner address that will be able to withdraw the deposited assets.\\n /// @param assets amount of the asset that were deposited.\\n /// @param fee is the extra amount that it will be collected at maturity.\\n event DepositAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed owner,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account withdraws from a fixed rate pool.\\n /// @param maturity maturity where the account withdraw its deposits.\\n /// @param caller address which withdraw the asset.\\n /// @param receiver address which will be collecting the assets.\\n /// @param owner address which had the assets withdrawn.\\n /// @param positionAssets position size reduced.\\n /// @param assets amount of assets withdrawn (can include a discount for early withdraw).\\n event WithdrawAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 positionAssets,\\n uint256 assets\\n );\\n\\n /// @notice Emitted when an account borrows amount of an asset from a certain maturity date.\\n /// @param maturity maturity in which the account will have to repay the loan.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of the asset that were borrowed.\\n /// @param fee extra amount that will need to be paid at maturity.\\n event BorrowAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account repays its borrows after maturity.\\n /// @param maturity maturity where the account repaid its borrowed amounts.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount that was repaid.\\n /// @param positionAssets amount of the debt that was covered in this repayment (penalties could have been repaid).\\n event RepayAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed borrower,\\n uint256 assets,\\n uint256 positionAssets\\n );\\n\\n /// @notice Emitted when an account's position had a liquidation.\\n /// @param receiver address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of the asset that were repaid.\\n /// @param lendersAssets incentive paid to lenders.\\n /// @param seizeMarket address of the asset that were seized by the liquidator.\\n /// @param seizedAssets amount seized of the collateral.\\n event Liquidate(\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 lendersAssets,\\n Market indexed seizeMarket,\\n uint256 seizedAssets\\n );\\n\\n /// @notice Emitted when an account's collateral has been seized.\\n /// @param liquidator address which seized this collateral.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount seized of the collateral.\\n event Seize(address indexed liquidator, address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when an account is cleared from bad debt.\\n /// @param borrower address which was cleared from bad debt.\\n /// @param assets amount that was subtracted from the borrower's debt and spread to the `earningsAccumulator`.\\n event SpreadBadDebt(address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when the backupFeeRate parameter is changed by admin.\\n /// @param backupFeeRate rate charged to the fixed pools to be accrued by the floating depositors.\\n event BackupFeeRateSet(uint256 backupFeeRate);\\n\\n /// @notice Emitted when the damp speeds are changed by admin.\\n /// @param dampSpeedUp represented with 18 decimals.\\n /// @param dampSpeedDown represented with 18 decimals.\\n event DampSpeedSet(uint256 dampSpeedUp, uint256 dampSpeedDown);\\n\\n /// @notice Emitted when the earningsAccumulatorSmoothFactor is changed by admin.\\n /// @param earningsAccumulatorSmoothFactor factor represented with 18 decimals.\\n event EarningsAccumulatorSmoothFactorSet(uint256 earningsAccumulatorSmoothFactor);\\n\\n /// @notice Emitted when the interestRateModel is changed by admin.\\n /// @param interestRateModel new interest rate model to be used to calculate rates.\\n event InterestRateModelSet(InterestRateModel indexed interestRateModel);\\n\\n /// @notice Emitted when the maxFuturePools is changed by admin.\\n /// @param maxFuturePools represented with 0 decimals.\\n event MaxFuturePoolsSet(uint256 maxFuturePools);\\n\\n /// @notice Emitted when the penaltyRate is changed by admin.\\n /// @param penaltyRate penaltyRate percentage per second represented with 18 decimals.\\n event PenaltyRateSet(uint256 penaltyRate);\\n\\n /// @notice Emitted when the reserveFactor is changed by admin.\\n /// @param reserveFactor reserveFactor percentage.\\n event ReserveFactorSet(uint256 reserveFactor);\\n\\n /// @notice Emitted when the treasury variables are changed by admin.\\n /// @param treasury address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate represented with 18 decimals.\\n event TreasurySet(address indexed treasury, uint256 treasuryFeeRate);\\n\\n /// @notice Emitted when the rewardsController is changed by admin.\\n /// @param rewardsController new rewards controller to update account rewards when operating with the Market.\\n event RewardsControllerSet(RewardsController indexed rewardsController);\\n\\n /// @notice Emitted when market state is updated.\\n /// @param timestamp current timestamp.\\n /// @param floatingDepositShares total floating supply shares.\\n /// @param floatingAssets total floating supply assets.\\n /// @param floatingBorrowShares total floating borrow shares.\\n /// @param floatingDebt total floating borrow assets.\\n /// @param earningsAccumulator earnings accumulator.\\n event MarketUpdate(\\n uint256 timestamp,\\n uint256 floatingDepositShares,\\n uint256 floatingAssets,\\n uint256 floatingBorrowShares,\\n uint256 floatingDebt,\\n uint256 earningsAccumulator\\n );\\n\\n /// @notice Emitted when the earnings of a maturity are updated.\\n /// @param timestamp current timestamp.\\n /// @param maturity maturity date where the earnings were updated.\\n /// @param unassignedEarnings pending unassigned earnings.\\n event FixedEarningsUpdate(uint256 timestamp, uint256 indexed maturity, uint256 unassignedEarnings);\\n\\n /// @notice Emitted when accumulator distributes earnings.\\n /// @param timestamp current timestamp.\\n event AccumulatorAccrual(uint256 timestamp);\\n\\n /// @notice Emitted when the floating debt is updated.\\n /// @param timestamp current timestamp.\\n /// @param utilization new floating utilization.\\n event FloatingDebtUpdate(uint256 timestamp, uint256 utilization);\\n\\n /// @notice Stores fixed deposits and fixed borrows map and floating borrow shares of an account.\\n /// @param fixedDeposits encoded map maturity dates where the account supplied to.\\n /// @param fixedBorrows encoded map maturity dates where the account borrowed from.\\n /// @param floatingBorrowShares number of floating borrow shares assigned to the account.\\n struct Account {\\n uint256 fixedDeposits;\\n uint256 fixedBorrows;\\n uint256 floatingBorrowShares;\\n }\\n}\\n\\nerror Disagreement();\\nerror InsufficientProtocolLiquidity();\\nerror NotAuditor();\\nerror SelfLiquidation();\\nerror ZeroBorrow();\\nerror ZeroDeposit();\\nerror ZeroRepay();\\nerror ZeroWithdraw();\\n\",\"keccak256\":\"0x94894ef0aeac99df31979475878d006fb676a9d795d9cfc3b3b1ed321ed672d8\",\"license\":\"BUSL-1.1\"},\"contracts/RewardsController.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/src/utils/SafeTransferLib.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract RewardsController is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint64;\\n using FixedPointMathLib for int256;\\n using SafeTransferLib for ERC20;\\n\\n /// @notice Max utilization supported by the sigmoid function not to cause a division by zero (1e18 = WAD).\\n uint256 public constant UTILIZATION_CAP = 1e18 - 1;\\n /// @notice Tracks the reward distribution data for a given market.\\n mapping(Market => Distribution) public distribution;\\n /// @notice Tracks enabled asset rewards.\\n mapping(ERC20 => bool) public rewardEnabled;\\n /// @notice Stores registered asset rewards.\\n ERC20[] public rewardList;\\n /// @notice Stores Markets with distributions set.\\n Market[] public marketList;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev Can only be called once.\\n function initialize() external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded deposit.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleDeposit(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n ops[0] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n update(account, market, dist.availableRewards[r], ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded borrow.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleBorrow(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n (, , uint256 accountFloatingBorrowShares) = market.accounts(account);\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n ERC20 reward = dist.availableRewards[r];\\n ops[0] = AccountOperation({\\n operation: true,\\n balance: accountFloatingBorrowShares + accountFixedBorrowShares(market, account, dist.rewards[reward].start)\\n });\\n update(account, Market(msg.sender), reward, ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Claims all `msg.sender` rewards to the given account.\\n /// @param to The address to send the rewards to.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claimAll(address to) external returns (ERC20[] memory rewardsList, uint256[] memory claimedAmounts) {\\n return claim(allMarketsOperations(), to, rewardList);\\n }\\n\\n /// @notice Claims `msg.sender` rewards for the given operations and reward assets to the given account.\\n /// @param marketOps The operations to claim rewards for.\\n /// @param to The address to send the rewards to.\\n /// @param rewardsList The list of rewards assets to claim.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claim(\\n MarketOperation[] memory marketOps,\\n address to,\\n ERC20[] memory rewardsList\\n ) public returns (ERC20[] memory, uint256[] memory claimedAmounts) {\\n uint256 rewardsCount = rewardsList.length;\\n claimedAmounts = new uint256[](rewardsCount);\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n uint256 availableRewards = dist.availableRewardsCount;\\n for (uint128 r = 0; r < availableRewards; ) {\\n update(\\n msg.sender,\\n marketOperation.market,\\n dist.availableRewards[r],\\n accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n msg.sender,\\n dist.rewards[dist.availableRewards[r]].start\\n )\\n );\\n unchecked {\\n ++r;\\n }\\n }\\n for (uint256 r = 0; r < rewardsCount; ) {\\n RewardData storage rewardData = dist.rewards[rewardsList[r]];\\n for (uint256 o = 0; o < marketOperation.operations.length; ) {\\n uint256 rewardAmount = rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued;\\n if (rewardAmount != 0) {\\n claimedAmounts[r] += rewardAmount;\\n rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued = 0;\\n }\\n unchecked {\\n ++o;\\n }\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n for (uint256 r = 0; r < rewardsList.length; ) {\\n uint256 claimedAmount = claimedAmounts[r];\\n if (claimedAmount > 0) {\\n rewardsList[r].safeTransfer(to, claimedAmount);\\n emit Claim(msg.sender, rewardsList[r], to, claimedAmount);\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n return (rewardsList, claimedAmounts);\\n }\\n\\n /// @notice Gets the configuration of a given distribution.\\n /// @param market The market to get the distribution configuration for.\\n /// @param reward The reward asset.\\n /// @return The distribution configuration.\\n function rewardConfig(Market market, ERC20 reward) external view returns (Config memory) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return\\n Config({\\n market: market,\\n reward: reward,\\n priceFeed: rewardData.priceFeed,\\n start: rewardData.start,\\n distributionPeriod: rewardData.end - rewardData.start,\\n targetDebt: rewardData.targetDebt,\\n totalDistribution: rewardData.totalDistribution,\\n undistributedFactor: rewardData.undistributedFactor,\\n flipSpeed: rewardData.flipSpeed,\\n compensationFactor: rewardData.compensationFactor,\\n transitionFactor: rewardData.transitionFactor,\\n borrowAllocationWeightFactor: rewardData.borrowAllocationWeightFactor,\\n depositAllocationWeightAddend: rewardData.depositAllocationWeightAddend,\\n depositAllocationWeightFactor: rewardData.depositAllocationWeightFactor\\n });\\n }\\n\\n /// @notice Gets the amount of reward assets that are being distributed for a Market.\\n /// @param market Market to get the number of available rewards to distribute.\\n /// @return The amount reward assets set to a Market.\\n function availableRewardsCount(Market market) external view returns (uint256) {\\n return distribution[market].availableRewardsCount;\\n }\\n\\n /// @notice Gets the account data of a given account, Market, operation and reward asset.\\n /// @param account The account to get the operation data from.\\n /// @param market The market in which the operation was made.\\n /// @param operation True if the operation was a borrow, false if it was a deposit.\\n /// @param reward The reward asset.\\n /// @return accrued The accrued amount.\\n /// @return index The account index.\\n function accountOperation(\\n address account,\\n Market market,\\n bool operation,\\n ERC20 reward\\n ) external view returns (uint256, uint256) {\\n Account storage operationAccount = distribution[market].rewards[reward].accounts[account][operation];\\n return (operationAccount.accrued, operationAccount.index);\\n }\\n\\n /// @notice Gets the distribution `start`, `end` and `lastUpdate` value of a given market and reward.\\n /// @param market The market to get the distribution times.\\n /// @param reward The reward asset.\\n /// @return The distribution `start`, `end` and `lastUpdate` time.\\n function distributionTime(Market market, ERC20 reward) external view returns (uint32, uint32, uint32) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.start, rewardData.end, rewardData.lastUpdate);\\n }\\n\\n /// @notice Retrieves all rewards addresses.\\n function allRewards() external view returns (ERC20[] memory) {\\n return rewardList;\\n }\\n\\n /// @notice Gets all market and operations.\\n /// @return marketOps The list of market operations.\\n function allMarketsOperations() public view returns (MarketOperation[] memory marketOps) {\\n Market[] memory markets = marketList;\\n marketOps = new MarketOperation[](markets.length);\\n for (uint256 m = 0; m < markets.length; ) {\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[m] = MarketOperation({ market: markets[m], operations: ops });\\n unchecked {\\n ++m;\\n }\\n }\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account and reward asset.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function allClaimable(address account, ERC20 reward) external view returns (uint256 unclaimedRewards) {\\n return claimable(allMarketsOperations(), account, reward);\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account, Market operations and reward asset.\\n /// @param marketOps The list of Market operations to get the accrued and pending rewards from.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function claimable(\\n MarketOperation[] memory marketOps,\\n address account,\\n ERC20 reward\\n ) public view returns (uint256 unclaimedRewards) {\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n RewardData storage rewardData = dist.rewards[reward];\\n if (dist.availableRewardsCount == 0) {\\n unchecked {\\n ++i;\\n }\\n continue;\\n }\\n\\n AccountOperation[] memory ops = accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n account,\\n rewardData.start\\n );\\n uint256 balance;\\n for (uint256 o = 0; o < ops.length; ) {\\n unclaimedRewards += rewardData.accounts[account][ops[o].operation].accrued;\\n balance += ops[o].balance;\\n unchecked {\\n ++o;\\n }\\n }\\n if (balance > 0) {\\n unclaimedRewards += pendingRewards(\\n account,\\n reward,\\n AccountMarketOperation({ market: marketOperation.market, accountOperations: ops })\\n );\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Iterates and accrues all rewards for the operations of the given account in the given market.\\n /// @param account The account to accrue the rewards for.\\n /// @param market The Market in which the operations where made.\\n /// @param reward The reward asset.\\n /// @param ops The operations to accrue the rewards for.\\n function update(address account, Market market, ERC20 reward, AccountOperation[] memory ops) internal {\\n uint256 baseUnit = distribution[market].baseUnit;\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n {\\n uint256 lastUpdate = rewardData.lastUpdate;\\n // `lastUpdate` can be greater than `block.timestamp` if distribution is set to start on a future date\\n if (block.timestamp > lastUpdate) {\\n (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) = previewAllocation(\\n rewardData,\\n market,\\n block.timestamp - lastUpdate\\n );\\n if (borrowIndex > type(uint128).max || depositIndex > type(uint128).max) revert IndexOverflow();\\n rewardData.borrowIndex = uint128(borrowIndex);\\n rewardData.depositIndex = uint128(depositIndex);\\n rewardData.lastUpdate = uint32(block.timestamp);\\n rewardData.lastUndistributed = newUndistributed;\\n emit IndexUpdate(market, reward, borrowIndex, depositIndex, newUndistributed, block.timestamp);\\n }\\n }\\n\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 i = 0; i < ops.length; ) {\\n AccountOperation memory op = ops[i];\\n Account storage accountData = operationAccount[op.operation];\\n uint256 accountIndex = accountData.index;\\n uint256 newAccountIndex;\\n if (op.operation) {\\n newAccountIndex = rewardData.borrowIndex;\\n } else {\\n newAccountIndex = rewardData.depositIndex;\\n }\\n if (accountIndex != newAccountIndex) {\\n accountData.index = uint128(newAccountIndex);\\n if (op.balance != 0) {\\n uint256 rewardsAccrued = accountRewards(op.balance, newAccountIndex, accountIndex, baseUnit);\\n accountData.accrued += uint128(rewardsAccrued);\\n emit Accrue(market, reward, account, op.operation, accountIndex, newAccountIndex, rewardsAccrued);\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the equivalent of borrow shares from fixed pool principal borrows of an account.\\n /// @param market The Market to get the fixed borrows from.\\n /// @param account The account that borrowed from fixed pools.\\n /// @return fixedDebt The fixed borrow shares.\\n function accountFixedBorrowShares(\\n Market market,\\n address account,\\n uint32 start\\n ) internal view returns (uint256 fixedDebt) {\\n uint256 firstMaturity = start - (start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 principal, ) = market.fixedBorrowPositions(maturity, account);\\n fixedDebt += principal;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n fixedDebt = market.previewRepay(fixedDebt);\\n }\\n\\n /// @notice Gets the reward indexes and last amount of undistributed rewards for a given market and reward asset.\\n /// @param market The market to get the reward indexes for.\\n /// @param reward The reward asset to get the reward indexes for.\\n /// @return borrowIndex The index for the floating and fixed borrow operation.\\n /// @return depositIndex The index for the floating deposit operation.\\n /// @return lastUndistributed The last amount of undistributed rewards.\\n function rewardIndexes(Market market, ERC20 reward) external view returns (uint256, uint256, uint256) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.borrowIndex, rewardData.depositIndex, rewardData.lastUndistributed);\\n }\\n\\n /// @notice Calculates the rewards not accrued yet for the given operations of a given account and reward asset.\\n /// @param account The account to get the pending rewards for.\\n /// @param reward The reward asset to get the pending rewards for.\\n /// @param ops The operations to get the pending rewards for.\\n /// @return rewards The pending rewards for the given operations.\\n function pendingRewards(\\n address account,\\n ERC20 reward,\\n AccountMarketOperation memory ops\\n ) internal view returns (uint256 rewards) {\\n RewardData storage rewardData = distribution[ops.market].rewards[reward];\\n uint256 baseUnit = distribution[ops.market].baseUnit;\\n uint256 lastUpdate = rewardData.lastUpdate;\\n (uint256 borrowIndex, uint256 depositIndex, ) = previewAllocation(\\n rewardData,\\n ops.market,\\n block.timestamp > lastUpdate ? block.timestamp - lastUpdate : 0\\n );\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 o = 0; o < ops.accountOperations.length; ) {\\n uint256 nextIndex;\\n if (ops.accountOperations[o].operation) {\\n nextIndex = borrowIndex;\\n } else {\\n nextIndex = depositIndex;\\n }\\n\\n rewards += accountRewards(\\n ops.accountOperations[o].balance,\\n nextIndex,\\n operationAccount[ops.accountOperations[o].operation].index,\\n baseUnit\\n );\\n unchecked {\\n ++o;\\n }\\n }\\n }\\n\\n /// @notice Calculates and returns the new amount of rewards given by the difference between the `accountIndex` and\\n /// the `globalIndex`.\\n /// @param balance The account's balance in the operation's pool.\\n /// @param globalIndex Current index of the distribution.\\n /// @param accountIndex Last index stored for the account.\\n /// @param baseUnit One unit of the Market's asset (10**decimals).\\n /// @return The amount of new rewards to be accrued by the account.\\n function accountRewards(\\n uint256 balance,\\n uint256 globalIndex,\\n uint256 accountIndex,\\n uint256 baseUnit\\n ) internal pure returns (uint256) {\\n return balance.mulDivDown(globalIndex - accountIndex, baseUnit);\\n }\\n\\n /// @notice Retrieves projected distribution indexes and new undistributed amount for a given `deltaTime`.\\n /// @param market The market to calculate the indexes for.\\n /// @param reward The reward asset to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n Market market,\\n ERC20 reward,\\n uint256 deltaTime\\n ) external view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n return previewAllocation(distribution[market].rewards[reward], market, deltaTime);\\n }\\n\\n /// @notice Calculates and returns the distribution indexes and new undistributed tokens for a given `rewardData`.\\n /// @param rewardData The distribution's data.\\n /// @param market The market to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n RewardData storage rewardData,\\n Market market,\\n uint256 deltaTime\\n ) internal view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n TotalMarketBalance memory m;\\n m.debt = market.totalFloatingBorrowAssets();\\n m.supply = market.totalAssets();\\n TimeVars memory t;\\n t.start = rewardData.start;\\n t.end = rewardData.end;\\n {\\n uint256 firstMaturity = t.start - (t.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n uint256 fixedDebt;\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 borrowed, uint256 supplied) = market.fixedPoolBalance(maturity);\\n fixedDebt += borrowed;\\n m.supply += supplied;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n m.debt += fixedDebt;\\n m.fixedBorrowShares = market.previewRepay(fixedDebt);\\n }\\n uint256 target;\\n {\\n uint256 targetDebt = rewardData.targetDebt;\\n target = m.debt < targetDebt ? m.debt.divWadDown(targetDebt) : 1e18;\\n }\\n uint256 rewards;\\n {\\n uint256 releaseRate = rewardData.releaseRate;\\n uint256 lastUndistributed = rewardData.lastUndistributed;\\n t.period = t.end - t.start;\\n uint256 distributionFactor = t.period > 0\\n ? rewardData.undistributedFactor.mulDivDown(target, t.period * 1e18)\\n : 0;\\n if (block.timestamp <= t.end) {\\n if (distributionFactor > 0) {\\n uint256 exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n } else if (rewardData.lastUpdate > t.end) {\\n newUndistributed =\\n lastUndistributed -\\n lastUndistributed.mulWadUp(1e18 - uint256((-int256(distributionFactor * deltaTime)).expWad()));\\n rewards = uint256(-(int256(newUndistributed) - int256(lastUndistributed)));\\n } else {\\n uint256 exponential;\\n deltaTime = t.end - rewardData.lastUpdate;\\n if (distributionFactor > 0) {\\n exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n exponential = uint256((-int256(distributionFactor * (block.timestamp - t.end))).expWad());\\n newUndistributed = newUndistributed - newUndistributed.mulWadUp(1e18 - exponential);\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n }\\n if (rewards == 0) return (rewardData.borrowIndex, rewardData.depositIndex, newUndistributed);\\n }\\n {\\n AllocationVars memory v;\\n v.utilization = m.supply > 0 ? Math.min(m.debt.divWadDown(m.supply), UTILIZATION_CAP) : 0;\\n v.transitionFactor = rewardData.transitionFactor;\\n v.flipSpeed = rewardData.flipSpeed;\\n v.borrowAllocationWeightFactor = rewardData.borrowAllocationWeightFactor;\\n v.sigmoid = v.utilization > 0\\n ? uint256(1e18).divWadDown(\\n 1e18 +\\n uint256(\\n (-(v.flipSpeed *\\n (int256(v.utilization.divWadDown(1e18 - v.utilization)).lnWad() -\\n int256(v.transitionFactor.divWadDown(1e18 - v.transitionFactor)).lnWad())) / 1e18).expWad()\\n )\\n )\\n : 0;\\n v.borrowRewardRule = rewardData\\n .compensationFactor\\n .mulWadDown(\\n market.interestRateModel().floatingRate(v.utilization).mulWadDown(\\n 1e18 - v.utilization.mulWadUp(1e18 - market.treasuryFeeRate())\\n ) + v.borrowAllocationWeightFactor\\n )\\n .mulWadDown(1e18 - v.sigmoid);\\n v.depositRewardRule =\\n rewardData.depositAllocationWeightAddend.mulWadDown(1e18 - v.sigmoid) +\\n rewardData.depositAllocationWeightFactor.mulWadDown(v.sigmoid);\\n v.borrowAllocation = v.borrowRewardRule.divWadDown(v.borrowRewardRule + v.depositRewardRule);\\n v.depositAllocation = 1e18 - v.borrowAllocation;\\n {\\n uint256 totalDepositSupply = market.totalSupply();\\n uint256 totalBorrowSupply = market.totalFloatingBorrowShares() + m.fixedBorrowShares;\\n uint256 baseUnit = distribution[market].baseUnit;\\n borrowIndex =\\n rewardData.borrowIndex +\\n (totalBorrowSupply > 0 ? rewards.mulWadDown(v.borrowAllocation).mulDivDown(baseUnit, totalBorrowSupply) : 0);\\n depositIndex =\\n rewardData.depositIndex +\\n (\\n totalDepositSupply > 0\\n ? rewards.mulWadDown(v.depositAllocation).mulDivDown(baseUnit, totalDepositSupply)\\n : 0\\n );\\n }\\n }\\n }\\n\\n /// @notice Get account balances of the given Market operations.\\n /// @param market The address of the Market.\\n /// @param ops List of operations to retrieve account balance.\\n /// @param account Account to get the balance from.\\n /// @param distributionStart Timestamp of the start of the distribution to correctly get the rewarded fixed pools.\\n /// @return accountBalanceOps contains a list with account balance per each operation.\\n function accountBalanceOperations(\\n Market market,\\n bool[] memory ops,\\n address account,\\n uint32 distributionStart\\n ) internal view returns (AccountOperation[] memory accountBalanceOps) {\\n accountBalanceOps = new AccountOperation[](ops.length);\\n for (uint256 i = 0; i < ops.length; ) {\\n if (ops[i]) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n accountBalanceOps[i] = AccountOperation({\\n operation: true,\\n balance: floatingBorrowShares + accountFixedBorrowShares(market, account, distributionStart)\\n });\\n } else {\\n accountBalanceOps[i] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Withdraws the contract's balance of the given asset to the given address.\\n /// @param asset The asset to withdraw.\\n /// @param to The address to withdraw the asset to.\\n function withdraw(ERC20 asset, address to) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n asset.safeTransfer(to, asset.balanceOf(address(this)));\\n }\\n\\n /// @notice Enables or updates the reward distribution for the given markets and rewards.\\n /// @param configs The configurations to update each RewardData with.\\n function config(Config[] memory configs) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n for (uint256 i = 0; i < configs.length; ) {\\n // transitionFactor cannot be eq or higher than 1e18 to avoid division by zero or underflow\\n if (configs[i].transitionFactor >= 1e18) revert InvalidConfig();\\n // depositAllocationWeightFactor cannot be zero to avoid division by zero when sigmoid equals 1e18\\n if (configs[i].depositAllocationWeightFactor == 0) revert InvalidConfig();\\n\\n Distribution storage dist = distribution[configs[i].market];\\n RewardData storage rewardData = dist.rewards[configs[i].reward];\\n\\n if (dist.baseUnit == 0) {\\n // never initialized before, adding to the list of markets\\n marketList.push(configs[i].market);\\n }\\n if (!rewardEnabled[configs[i].reward]) {\\n // add reward address to global rewards list if still not enabled\\n rewardEnabled[configs[i].reward] = true;\\n rewardList.push(configs[i].reward);\\n }\\n if (rewardData.lastUpdate == 0) {\\n // add reward address to distribution data's available rewards if distribution is new\\n dist.availableRewards[dist.availableRewardsCount++] = configs[i].reward;\\n dist.baseUnit = 10 ** configs[i].market.decimals();\\n // set initial parameters if distribution is new\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n } else {\\n uint32 start = rewardData.start;\\n uint32 end = rewardData.end;\\n // update global indexes before updating distribution values\\n bool[] memory ops = new bool[](1);\\n ops[0] = true;\\n update(\\n address(0),\\n configs[i].market,\\n configs[i].reward,\\n accountBalanceOperations(configs[i].market, ops, address(0), start)\\n );\\n // properly update release rate\\n if (block.timestamp < end) {\\n uint256 released = 0;\\n uint256 elapsed = 0;\\n if (block.timestamp > start) {\\n released =\\n rewardData.lastConfigReleased +\\n rewardData.releaseRate *\\n (block.timestamp - rewardData.lastConfig);\\n elapsed = block.timestamp - start;\\n if (configs[i].totalDistribution <= released || configs[i].distributionPeriod <= elapsed) {\\n revert InvalidConfig();\\n }\\n rewardData.lastConfigReleased = released;\\n }\\n\\n rewardData.releaseRate =\\n (configs[i].totalDistribution - released) /\\n (configs[i].distributionPeriod - elapsed);\\n } else if (rewardData.start != configs[i].start) {\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n rewardData.lastConfigReleased = 0;\\n }\\n }\\n rewardData.lastConfig = uint32(block.timestamp);\\n rewardData.end = rewardData.start + uint32(configs[i].distributionPeriod);\\n rewardData.priceFeed = configs[i].priceFeed;\\n // set emission and distribution parameters\\n rewardData.totalDistribution = configs[i].totalDistribution;\\n rewardData.targetDebt = configs[i].targetDebt;\\n rewardData.undistributedFactor = configs[i].undistributedFactor;\\n rewardData.flipSpeed = configs[i].flipSpeed;\\n rewardData.compensationFactor = configs[i].compensationFactor;\\n rewardData.borrowAllocationWeightFactor = configs[i].borrowAllocationWeightFactor;\\n rewardData.depositAllocationWeightAddend = configs[i].depositAllocationWeightAddend;\\n rewardData.transitionFactor = configs[i].transitionFactor;\\n rewardData.depositAllocationWeightFactor = configs[i].depositAllocationWeightFactor;\\n\\n emit DistributionSet(configs[i].market, configs[i].reward, configs[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n struct TotalMarketBalance {\\n uint256 debt;\\n uint256 supply;\\n uint256 fixedBorrowShares;\\n }\\n\\n struct TimeVars {\\n uint256 start;\\n uint256 end;\\n uint256 period;\\n }\\n\\n struct AllocationVars {\\n uint256 utilization;\\n uint256 sigmoid;\\n uint256 borrowRewardRule;\\n uint256 depositRewardRule;\\n uint256 borrowAllocation;\\n uint256 depositAllocation;\\n uint256 transitionFactor;\\n int256 flipSpeed;\\n uint256 borrowAllocationWeightFactor;\\n }\\n\\n struct AccountOperation {\\n bool operation;\\n uint256 balance;\\n }\\n\\n struct MarketOperation {\\n Market market;\\n bool[] operations;\\n }\\n\\n struct AccountMarketOperation {\\n Market market;\\n AccountOperation[] accountOperations;\\n }\\n\\n struct Account {\\n // liquidity index of the reward distribution for the account\\n uint128 index;\\n // amount of accrued rewards for the account since last account index update\\n uint128 accrued;\\n }\\n\\n struct Config {\\n Market market;\\n ERC20 reward;\\n IPriceFeed priceFeed;\\n uint32 start;\\n uint256 distributionPeriod;\\n uint256 targetDebt;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n }\\n\\n struct RewardData {\\n // distribution model\\n uint256 targetDebt;\\n uint256 releaseRate;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n uint256 lastUndistributed;\\n // allocation model\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n // liquidity indexes of the reward distribution\\n uint128 borrowIndex;\\n uint128 depositIndex;\\n // distribution timestamps\\n uint32 start;\\n uint32 end;\\n uint32 lastUpdate;\\n // config helpers\\n uint32 lastConfig;\\n uint256 lastConfigReleased;\\n // price feed\\n IPriceFeed priceFeed;\\n // account addresses and their rewards data (index & accrued)\\n mapping(address => mapping(bool => Account)) accounts;\\n }\\n\\n struct Distribution {\\n // reward assets and their data\\n mapping(ERC20 => RewardData) rewards;\\n // list of reward asset addresses for the market\\n mapping(uint128 => ERC20) availableRewards;\\n // count of reward tokens for the market\\n uint8 availableRewardsCount;\\n // base unit of the market\\n uint256 baseUnit;\\n }\\n\\n /// @notice Emitted when rewards are accrued by an account.\\n /// @param market Market where the operation was made.\\n /// @param reward reward asset.\\n /// @param account account that accrued the rewards.\\n /// @param operation true if the operation was a borrow, false if it was a deposit.\\n /// @param accountIndex previous account index.\\n /// @param operationIndex new operation index that is assigned to the `accountIndex`.\\n /// @param rewardsAccrued amount of rewards accrued.\\n event Accrue(\\n Market indexed market,\\n ERC20 indexed reward,\\n address indexed account,\\n bool operation,\\n uint256 accountIndex,\\n uint256 operationIndex,\\n uint256 rewardsAccrued\\n );\\n\\n /// @notice Emitted when rewards are claimed by an account.\\n /// @param account account that claimed the rewards.\\n /// @param reward reward asset.\\n /// @param to account that received the rewards.\\n /// @param amount amount of rewards claimed.\\n event Claim(address indexed account, ERC20 indexed reward, address indexed to, uint256 amount);\\n\\n /// @notice Emitted when a distribution is set.\\n /// @param market Market whose distribution was set.\\n /// @param reward reward asset to be distributed when operating with the Market.\\n /// @param config configuration struct containing the distribution parameters.\\n event DistributionSet(Market indexed market, ERC20 indexed reward, Config config);\\n\\n /// @notice Emitted when the distribution indexes are updated.\\n /// @param market Market of the distribution.\\n /// @param reward reward asset.\\n /// @param borrowIndex index of the borrow operations of a distribution.\\n /// @param depositIndex index of the deposit operations of a distribution.\\n /// @param newUndistributed amount of undistributed rewards.\\n /// @param lastUpdate current timestamp.\\n event IndexUpdate(\\n Market indexed market,\\n ERC20 indexed reward,\\n uint256 borrowIndex,\\n uint256 depositIndex,\\n uint256 newUndistributed,\\n uint256 lastUpdate\\n );\\n}\\n\\nerror IndexOverflow();\\nerror InvalidConfig();\\n\",\"keccak256\":\"0x1542122ea5dfca16000fa7e476201de82eef8ff8d7f44601274e1ed12c60344f\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/DebtManager.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { SafeTransferLib } from \\\"solmate/src/utils/SafeTransferLib.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { AddressUpgradeable as Address } from \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\nimport {\\n SafeERC20Upgradeable as SafeERC20,\\n IERC20PermitUpgradeable\\n} from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport { Market, ERC20, FixedLib, Disagreement } from \\\"../Market.sol\\\";\\nimport { Auditor, IPriceFeed, MarketNotListed } from \\\"../Auditor.sol\\\";\\n\\n/// @title DebtManager\\n/// @notice Contract for efficient debt management of accounts interacting with Exactly Protocol.\\ncontract DebtManager is Initializable {\\n using FixedPointMathLib for uint256;\\n using SafeTransferLib for ERC20;\\n using SafeERC20 for IERC20PermitUpgradeable;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for FixedLib.Pool;\\n using Address for address;\\n\\n /// @notice Auditor contract that lists the markets that can be leveraged.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n /// @notice Permit2 contract to be used to transfer assets from accounts.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IPermit2 public immutable permit2;\\n /// @notice Balancer's vault contract that is used to take flash loans.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IBalancerVault public immutable balancerVault;\\n /// @notice Factory contract to be used to compute the address of the Uniswap V3 pool.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable uniswapV3Factory;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IPermit2 permit2_, IBalancerVault balancerVault_, address uniswapV3Factory_) {\\n auditor = auditor_;\\n permit2 = permit2_;\\n balancerVault = balancerVault_;\\n uniswapV3Factory = uniswapV3Factory_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize() external initializer {\\n Market[] memory markets = auditor.allMarkets();\\n for (uint256 i = 0; i < markets.length; ++i) approve(markets[i]);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n function leverage(Market market, uint256 deposit, uint256 ratio) public msgSender {\\n transferIn(market, deposit);\\n noTransferLeverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `market` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function leverage(\\n Market market,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit2 calldata assetPermit\\n ) external permit(market, borrowAssets, marketPermit) permitTransfer(market.asset(), deposit, assetPermit) msgSender {\\n noTransferLeverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `market` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function leverage(\\n Market market,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit calldata assetPermit\\n ) external permit(market, borrowAssets, marketPermit) permit(market.asset(), deposit, assetPermit) {\\n leverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `market` on behalf of `_msgSender`.\\n /// Permit `value` should be `borrowAssets`.\\n function leverage(\\n Market market,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 borrowAssets,\\n Permit calldata marketPermit\\n ) external permit(market, borrowAssets, marketPermit) msgSender {\\n market.asset().safeTransferFrom(msg.sender, address(this), deposit);\\n noTransferLeverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n function noTransferLeverage(Market market, uint256 deposit, uint256 ratio) internal {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n uint256 loopCount;\\n {\\n uint256 collateral = market.maxWithdraw(sender);\\n uint256 targetDeposit = (collateral + deposit - floatingBorrowAssets(market)).mulWadDown(ratio);\\n int256 amount = int256(targetDeposit) - int256(collateral + deposit);\\n if (amount <= 0) {\\n market.deposit(deposit, sender);\\n return;\\n }\\n loopCount = uint256(amount).mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n amounts[0] = uint256(amount).mulDivUp(1, loopCount);\\n }\\n bytes[] memory calls = new bytes[](2 * loopCount);\\n uint256 callIndex = 0;\\n for (uint256 i = 0; i < loopCount; ) {\\n calls[callIndex++] = abi.encodeCall(market.deposit, (i == 0 ? amounts[0] + deposit : amounts[0], sender));\\n calls[callIndex++] = abi.encodeCall(\\n market.borrow,\\n (amounts[0], i + 1 == loopCount ? address(balancerVault) : address(this), sender)\\n );\\n unchecked {\\n ++i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, call(abi.encode(market, calls)));\\n }\\n\\n /// @notice Deleverages `_msgSender`'s position to a `ratio` via flash loan from Balancer's vault.\\n /// @param market The Market to deleverage the position out.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The ratio of the borrow that will be repaid, represented with 18 decimals.\\n /// @param permitAssets The amount of assets to allow this contract to withdraw on behalf of `_msgSender`.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `permitAssets`.\\n function deleverage(\\n Market market,\\n uint256 withdraw,\\n uint256 ratio,\\n uint256 permitAssets,\\n Permit calldata p\\n ) external permit(market, permitAssets, p) {\\n deleverage(market, withdraw, ratio);\\n }\\n\\n /// @notice Deleverages `_msgSender`'s position to a `ratio` via flash loan from Balancer's vault.\\n /// @param market The Market to deleverage the position out.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n function deleverage(Market market, uint256 withdraw, uint256 ratio) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n uint256 collateral = market.maxWithdraw(sender) - withdraw;\\n uint256 amount = collateral - (collateral - floatingBorrowAssets(market)).mulWadDown(ratio);\\n\\n r.loopCount = amount.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n r.amounts[0] = amount.mulDivUp(1, r.loopCount);\\n r.calls = new bytes[](2 * r.loopCount + (withdraw == 0 ? 0 : 1));\\n uint256 callIndex = 0;\\n for (uint256 i = 0; i < r.loopCount; ) {\\n r.calls[callIndex++] = abi.encodeCall(market.repay, (r.amounts[0], sender));\\n r.calls[callIndex++] = abi.encodeCall(\\n market.withdraw,\\n (r.amounts[0], i + 1 == r.loopCount ? address(balancerVault) : address(this), sender)\\n );\\n unchecked {\\n ++i;\\n }\\n }\\n if (withdraw != 0) r.calls[callIndex] = abi.encodeCall(market.withdraw, (withdraw, sender, sender));\\n\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n function crossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96\\n ) external msgSender {\\n transferIn(marketIn, deposit);\\n noTransferCrossLeverage(marketIn, marketOut, fee, deposit, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `marketOut` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function crossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit2 calldata assetPermit\\n )\\n external\\n permit(marketOut, borrowAssets, marketPermit)\\n permitTransfer(marketIn.asset(), deposit, assetPermit)\\n msgSender\\n {\\n noTransferCrossLeverage(marketIn, marketOut, fee, deposit, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `marketOut` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function crossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit calldata assetPermit\\n ) external permit(marketOut, borrowAssets, marketPermit) permit(marketIn.asset(), deposit, assetPermit) msgSender {\\n transferIn(marketIn, deposit);\\n noTransferCrossLeverage(marketIn, marketOut, fee, deposit, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n function noTransferCrossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96\\n ) internal {\\n LeverageVars memory v;\\n v.assetIn = address(marketIn.asset());\\n v.assetOut = address(marketOut.asset());\\n v.sender = _msgSender;\\n\\n v.amount =\\n crossPrincipal(marketIn, marketOut, deposit, v.sender).mulWadDown(ratio) -\\n marketIn.maxWithdraw(v.sender) -\\n deposit;\\n if (v.amount > 0) {\\n PoolKey memory poolKey = PoolAddress.getPoolKey(v.assetIn, v.assetOut, fee);\\n IUniswapV3Pool(PoolAddress.computeAddress(uniswapV3Factory, poolKey)).swap(\\n address(this),\\n v.assetOut == poolKey.token0,\\n -int256(v.amount),\\n sqrtPriceLimitX96,\\n abi.encode(\\n SwapCallbackData({\\n marketIn: marketIn,\\n marketOut: marketOut,\\n assetIn: v.assetIn,\\n assetOut: v.assetOut,\\n principal: deposit,\\n account: v.sender,\\n fee: fee,\\n leverage: true\\n })\\n )\\n );\\n } else {\\n marketIn.deposit(deposit, v.sender);\\n }\\n }\\n\\n /// @notice Cross-deleverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to withdraw the leveraged position.\\n /// @param marketOut The Market to repay the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The number of times that the current principal will end up leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n function crossDeleverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 withdraw,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96\\n ) public msgSender {\\n LeverageVars memory v;\\n v.assetIn = address(marketIn.asset());\\n v.assetOut = address(marketOut.asset());\\n v.sender = _msgSender;\\n\\n v.amount =\\n floatingBorrowAssets(marketOut) -\\n (\\n ratio > 1e18\\n ? previewAssetsOut(\\n marketIn,\\n marketOut,\\n (crossPrincipal(marketIn, marketOut, 0, v.sender) - withdraw).mulWadDown(ratio - 1e18)\\n )\\n : 0\\n );\\n\\n PoolKey memory poolKey = PoolAddress.getPoolKey(v.assetIn, v.assetOut, fee);\\n IUniswapV3Pool(PoolAddress.computeAddress(uniswapV3Factory, poolKey)).swap(\\n address(this),\\n v.assetIn == poolKey.token0,\\n -int256(v.amount),\\n sqrtPriceLimitX96,\\n abi.encode(\\n SwapCallbackData({\\n marketIn: marketIn,\\n marketOut: marketOut,\\n assetIn: v.assetIn,\\n assetOut: v.assetOut,\\n principal: withdraw,\\n account: v.sender,\\n fee: fee,\\n leverage: false\\n })\\n )\\n );\\n }\\n\\n /// @notice Cross-deleverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to withdraw the leveraged position.\\n /// @param marketOut The Market to repay the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The number of times that the current principal will end up leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n /// @param permitAssets The amount of assets to allow.\\n /// @param p Arguments for the permit call to `marketIn` on behalf of `_msgSender`.\\n /// Permit `value` should be `permitAssets`.\\n function crossDeleverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 withdraw,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96,\\n uint256 permitAssets,\\n Permit calldata p\\n ) external permit(marketIn, permitAssets, p) {\\n crossDeleverage(marketIn, marketOut, fee, withdraw, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to another fixed pool.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n function rollFixed(\\n Market market,\\n uint256 repayMaturity,\\n uint256 borrowMaturity,\\n uint256 maxRepayAssets,\\n uint256 maxBorrowAssets,\\n uint256 percentage\\n ) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n (r.repayAssets, r.positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n\\n r.loopCount = r.repayAssets.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n if (r.loopCount > 1 && repayMaturity == borrowMaturity) revert InvalidOperation();\\n\\n r.amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n r.positionAssets = r.positionAssets / r.loopCount;\\n r.calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.repayAtMaturity,\\n (repayMaturity, r.positionAssets, type(uint256).max, sender)\\n );\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n r.amounts[0],\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n if (\\n newPrincipal + newFee >\\n (\\n maxBorrowAssets < type(uint256).max - r.principal - r.fee\\n ? maxBorrowAssets + r.principal + r.fee\\n : type(uint256).max\\n ) ||\\n newPrincipal >\\n (maxRepayAssets < type(uint256).max - r.principal ? maxRepayAssets + r.principal : type(uint256).max)\\n ) {\\n revert Disagreement();\\n }\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to another fixed pool\\n /// after calling `market.permit`.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `maxBorrowAssets`.\\n function rollFixed(\\n Market market,\\n uint256 repayMaturity,\\n uint256 borrowMaturity,\\n uint256 maxRepayAssets,\\n uint256 maxBorrowAssets,\\n uint256 percentage,\\n Permit calldata p\\n ) external permit(market, maxBorrowAssets, p) {\\n rollFixed(market, repayMaturity, borrowMaturity, maxRepayAssets, maxBorrowAssets, percentage);\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to a floating position.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n function rollFixedToFloating(\\n Market market,\\n uint256 repayMaturity,\\n uint256 maxRepayAssets,\\n uint256 percentage\\n ) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n r.principal = floatingBorrowAssets(market);\\n (uint256 repayAssets, uint256 positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n r.loopCount = repayAssets.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n positionAssets = positionAssets / r.loopCount;\\n\\n r.amounts[0] = repayAssets.mulDivUp(1, r.loopCount);\\n r.calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.repayAtMaturity,\\n (repayMaturity, positionAssets, type(uint256).max, sender)\\n );\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.borrow,\\n (r.amounts[0], r.i + 1 == r.loopCount ? address(balancerVault) : address(this), sender)\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n if (maxRepayAssets < floatingBorrowAssets(market) - r.principal) revert Disagreement();\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to a floating position\\n /// after calling `market.permit`.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `maxRepayAssets`.\\n function rollFixedToFloating(\\n Market market,\\n uint256 repayMaturity,\\n uint256 maxRepayAssets,\\n uint256 percentage,\\n Permit calldata p\\n ) external permit(market, maxRepayAssets, p) {\\n rollFixedToFloating(market, repayMaturity, maxRepayAssets, percentage);\\n }\\n\\n /// @notice Rolls a percentage of the floating position of `_msgSender` to a fixed position.\\n /// @param market The Market to roll the position in.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n function rollFloatingToFixed(\\n Market market,\\n uint256 borrowMaturity,\\n uint256 maxBorrowAssets,\\n uint256 percentage\\n ) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n r.repayAssets = floatingBorrowAssets(market);\\n if (percentage < 1e18) r.repayAssets = r.repayAssets.mulWadDown(percentage);\\n r.loopCount = r.repayAssets.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n\\n r.amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n r.calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n r.calls[r.callIndex++] = abi.encodeCall(market.repay, (r.amounts[0], sender));\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n r.amounts[0],\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n if (maxBorrowAssets < newPrincipal + newFee - r.principal - r.fee) revert Disagreement();\\n }\\n\\n /// @notice Rolls a percentage of the floating position of `_msgSender` to a fixed position\\n /// after calling `market.permit`.\\n /// @param market The Market to roll the position in.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `maxBorrowAssets`.\\n function rollFloatingToFixed(\\n Market market,\\n uint256 borrowMaturity,\\n uint256 maxBorrowAssets,\\n uint256 percentage,\\n Permit calldata p\\n ) external permit(market, maxBorrowAssets, p) {\\n rollFloatingToFixed(market, borrowMaturity, maxBorrowAssets, percentage);\\n }\\n\\n /// @notice Calculates the actual repay and position assets of a repay operation at maturity.\\n /// @param market The Market to calculate the actual repay and position assets.\\n /// @param maturity The maturity of the fixed pool in which the position is being repaid.\\n /// @param percentage The percentage of the position that will be repaid, represented with 18 decimals.\\n /// @return actualRepay The actual amount of assets that will be repaid.\\n /// @return positionAssets The amount of principal and fee to be covered.\\n function repayAtMaturityAssets(\\n Market market,\\n uint256 maturity,\\n uint256 percentage\\n ) internal view returns (uint256 actualRepay, uint256 positionAssets) {\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedBorrowPositions(maturity, _msgSender);\\n positionAssets = percentage < 1e18\\n ? percentage.mulWadDown(position.principal + position.fee)\\n : position.principal + position.fee;\\n if (block.timestamp < maturity) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(maturity);\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n maturity - pool.lastAccrual\\n );\\n (uint256 yield, ) = pool.calculateDeposit(\\n position.scaleProportionally(positionAssets).principal,\\n market.backupFeeRate()\\n );\\n actualRepay = positionAssets - yield;\\n } else {\\n actualRepay = positionAssets + positionAssets.mulWadDown((block.timestamp - maturity) * market.penaltyRate());\\n }\\n }\\n\\n /// @notice Hash of the call data that will be used to verify that the flash loan is originated from `this`.\\n bytes32 private callHash;\\n\\n /// @notice Hashes the data and stores its value in `callHash`.\\n /// @param data The calldata to be hashed.\\n /// @return Same calldata that was passed as an argument.\\n function call(bytes memory data) internal returns (bytes memory) {\\n callHash = keccak256(data);\\n return data;\\n }\\n\\n /// @notice Calculates the crossed principal amount for a given `sender` in the input and output markets.\\n /// @param marketIn The Market to withdraw the leveraged position.\\n /// @param marketOut The Market to repay the leveraged position.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param sender The account that will be deleveraged.\\n function crossPrincipal(\\n Market marketIn,\\n Market marketOut,\\n uint256 deposit,\\n address sender\\n ) internal view returns (uint256) {\\n (, , , , IPriceFeed priceFeedIn) = auditor.markets(marketIn);\\n (, , , , IPriceFeed priceFeedOut) = auditor.markets(marketOut);\\n\\n return\\n marketIn.maxWithdraw(sender) +\\n deposit -\\n floatingBorrowAssets(marketOut)\\n .mulDivDown(auditor.assetPrice(priceFeedOut), 10 ** marketOut.decimals())\\n .mulDivDown(10 ** marketIn.decimals(), auditor.assetPrice(priceFeedIn));\\n }\\n\\n /// @notice Returns the amount of `marketOut` underlying assets considering `amountIn` and both assets oracle prices.\\n /// @param marketIn The market of the assets accounted as `amountIn`.\\n /// @param marketOut The market of the assets that will be returned.\\n /// @param amountIn The amount of `marketIn` underlying assets.\\n function previewAssetsOut(Market marketIn, Market marketOut, uint256 amountIn) internal view returns (uint256) {\\n (, , , , IPriceFeed priceFeedIn) = auditor.markets(marketIn);\\n (, , , , IPriceFeed priceFeedOut) = auditor.markets(marketOut);\\n\\n return\\n amountIn.mulDivDown(auditor.assetPrice(priceFeedIn), 10 ** marketIn.decimals()).mulDivDown(\\n 10 ** marketOut.decimals(),\\n auditor.assetPrice(priceFeedOut)\\n );\\n }\\n\\n /// @notice Callback function called by the Balancer Vault contract when a flash loan is initiated.\\n /// @dev Only the Balancer Vault contract is allowed to call this function.\\n /// @param userData Additional data provided by the borrower for the flash loan.\\n function receiveFlashLoan(ERC20[] memory, uint256[] memory, uint256[] memory, bytes memory userData) external {\\n bytes32 memCallHash = callHash;\\n assert(msg.sender == address(balancerVault) && memCallHash != bytes32(0) && memCallHash == keccak256(userData));\\n callHash = bytes32(0);\\n\\n (Market market, bytes[] memory calls) = abi.decode(userData, (Market, bytes[]));\\n for (uint256 i = 0; i < calls.length; ) {\\n address(market).functionCall(calls[i], \\\"\\\");\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Callback function called by the Uniswap V3 pool contract when a swap is initiated.\\n /// @dev Only the Uniswap V3 pool contract is allowed to call this function.\\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\\n function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {\\n SwapCallbackData memory s = abi.decode(data, (SwapCallbackData));\\n PoolKey memory poolKey = PoolAddress.getPoolKey(s.assetIn, s.assetOut, s.fee);\\n assert(msg.sender == PoolAddress.computeAddress(uniswapV3Factory, poolKey));\\n\\n if (s.leverage) {\\n s.marketIn.deposit(\\n s.principal + uint256(-(s.assetIn == poolKey.token0 ? amount0Delta : amount1Delta)),\\n s.account\\n );\\n s.marketOut.borrow(uint256(s.assetIn == poolKey.token1 ? amount0Delta : amount1Delta), msg.sender, s.account);\\n } else {\\n s.marketOut.repay(uint256(-(s.assetIn == poolKey.token1 ? amount0Delta : amount1Delta)), s.account);\\n s.marketIn.withdraw(uint256(s.assetIn == poolKey.token1 ? amount1Delta : amount0Delta), msg.sender, s.account);\\n s.marketIn.withdraw(s.principal, s.account, s.account);\\n }\\n }\\n\\n address private _msgSender;\\n\\n modifier msgSender() {\\n if (_msgSender == address(0)) _msgSender = msg.sender;\\n _;\\n delete _msgSender;\\n }\\n\\n /// @notice Calls `token.permit` on behalf of `permit.account`.\\n /// @param token The `ERC20` to call `permit`.\\n /// @param assets The amount of assets to allow.\\n /// @param p Arguments for the permit call.\\n modifier permit(\\n ERC20 token,\\n uint256 assets,\\n Permit calldata p\\n ) {\\n IERC20PermitUpgradeable(address(token)).safePermit(p.account, address(this), assets, p.deadline, p.v, p.r, p.s);\\n {\\n address sender = _msgSender;\\n if (sender == address(0)) _msgSender = p.account;\\n else assert(p.account == sender);\\n }\\n _;\\n assert(_msgSender == address(0));\\n }\\n\\n /// @notice Calls `permit2.permitTransferFrom` to transfer `_msgSender` assets.\\n /// @param token The `ERC20` to transfer from `_msgSender` to this contract.\\n /// @param assets The amount of assets to transfer from `_msgSender`.\\n /// @param p2 Arguments for the permit2 call.\\n modifier permitTransfer(\\n ERC20 token,\\n uint256 assets,\\n Permit2 calldata p2\\n ) {\\n {\\n address sender = _msgSender;\\n permit2.permitTransferFrom(\\n IPermit2.PermitTransferFrom(\\n IPermit2.TokenPermissions(address(token), assets),\\n uint256(keccak256(abi.encode(sender, token, assets, p2.deadline))),\\n p2.deadline\\n ),\\n IPermit2.SignatureTransferDetails(address(this), assets),\\n sender,\\n p2.signature\\n );\\n }\\n _;\\n }\\n\\n /// @notice Approves the Market to spend the contract's balance of the underlying asset.\\n /// @dev The Market must be listed by the Auditor in order to be valid for approval.\\n /// @param market The Market to spend the contract's balance.\\n function approve(Market market) public {\\n (, , , bool isListed, ) = auditor.markets(market);\\n if (!isListed) revert MarketNotListed();\\n\\n market.asset().safeApprove(address(market), type(uint256).max);\\n }\\n\\n function transferIn(Market market, uint256 assets) internal {\\n if (assets != 0) market.asset().safeTransferFrom(_msgSender, address(this), assets);\\n }\\n\\n function floatingBorrowAssets(Market market) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(_msgSender);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n}\\n\\nerror InvalidOperation();\\n\\nstruct Permit {\\n address account;\\n uint256 deadline;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n}\\n\\nstruct Permit2 {\\n uint256 deadline;\\n bytes signature;\\n}\\n\\nstruct SwapCallbackData {\\n Market marketIn;\\n Market marketOut;\\n address assetIn;\\n address assetOut;\\n address account;\\n uint256 principal;\\n uint24 fee;\\n bool leverage;\\n}\\n\\nstruct RollVars {\\n uint256[] amounts;\\n ERC20[] tokens;\\n bytes[] calls;\\n uint256 positionAssets;\\n uint256 repayAssets;\\n uint256 callIndex;\\n uint256 loopCount;\\n uint256 principal;\\n uint256 fee;\\n uint256 i;\\n}\\n\\nstruct LeverageVars {\\n address sender;\\n address assetIn;\\n address assetOut;\\n uint256 amount;\\n}\\n\\ninterface IBalancerVault {\\n function flashLoan(\\n address recipient,\\n ERC20[] memory tokens,\\n uint256[] memory amounts,\\n bytes memory userData\\n ) external;\\n}\\n\\ninterface IPermit2 {\\n struct TokenPermissions {\\n address token;\\n uint256 amount;\\n }\\n\\n struct PermitTransferFrom {\\n TokenPermissions permitted;\\n uint256 nonce;\\n uint256 deadline;\\n }\\n\\n struct SignatureTransferDetails {\\n address to;\\n uint256 requestedAmount;\\n }\\n\\n function permitTransferFrom(\\n PermitTransferFrom memory permit,\\n SignatureTransferDetails calldata transferDetails,\\n address owner,\\n bytes calldata signature\\n ) external;\\n\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\\ninterface IUniswapV3Pool {\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n}\\n\\n// https://github.com/Uniswap/v3-periphery/pull/271\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n function getPoolKey(address tokenA, address tokenB, uint24 fee) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({ token0: tokenA, token1: tokenB, fee: fee });\\n }\\n\\n function computeAddress(address uniswapV3Factory, PoolKey memory key) internal pure returns (address pool) {\\n assert(key.token0 < key.token1);\\n pool = address(\\n uint160(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex\\\"ff\\\",\\n uniswapV3Factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n )\\n );\\n }\\n}\\n\\nstruct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n}\\n\",\"keccak256\":\"0x3d0573ed373ae09bc255004e48ed74343437c3e36ec679fdd80557d61d9bb456\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/DebtPreviewer.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { Previewer, FixedLib } from \\\"./Previewer.sol\\\";\\nimport {\\n ERC20,\\n Market,\\n Auditor,\\n IPriceFeed,\\n DebtManager,\\n IUniswapV3Pool,\\n PoolAddress,\\n PoolKey\\n} from \\\"./DebtManager.sol\\\";\\n\\n/// @title DebtPreviewer\\n/// @notice Contract to be consumed by Exactly's front-end dApp as a helper for `DebtManager`.\\ncontract DebtPreviewer is Initializable {\\n using FixedPointMathLib for uint256;\\n\\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\\n\\n /// @notice DebtManager contract to be used to get Auditor, BalancerVault and UniswapV3Factory addresses.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n DebtManager public immutable debtManager;\\n /// @notice Quoter contract to be used to preview the amount of assets to be swapped.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IUniswapQuoter public immutable uniswapV3Quoter;\\n /// @notice Mapping of Uniswap pools to their respective pool fee.\\n mapping(address => mapping(address => uint24)) public poolFees;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(DebtManager debtManager_, IUniswapQuoter uniswapV3Quoter_) {\\n debtManager = debtManager_;\\n uniswapV3Quoter = uniswapV3Quoter_;\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(Pool[] memory pools, uint24[] memory fees) external initializer {\\n assert(pools.length == fees.length);\\n for (uint256 i = 0; i < pools.length; ) {\\n PoolKey memory poolKey = PoolAddress.getPoolKey(pools[i].tokenA, pools[i].tokenB, fees[i]);\\n poolFees[poolKey.token0][poolKey.token1] = poolKey.fee;\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Returns the output received for a given exact amount of a single pool swap.\\n /// @param assetIn The address of the token to be swapped.\\n /// @param assetOut The address of the token to receive.\\n /// @param amountIn The exact amount of `assetIn` to be swapped.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @return amountOut The amount of `assetOut` received.\\n function previewInputSwap(\\n address assetIn,\\n address assetOut,\\n uint256 amountIn,\\n uint24 fee\\n ) external returns (uint256) {\\n return\\n uniswapV3Quoter.quoteExactInputSingle(\\n assetIn,\\n assetOut,\\n fee,\\n amountIn,\\n assetIn == PoolAddress.getPoolKey(assetIn, assetOut, fee).token0 ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1\\n );\\n }\\n\\n /// @notice Returns the input for an exact amount out of a single pool swap.\\n /// @param marketIn The Market of the underlying asset to be swapped.\\n /// @param marketOut The Market of the underlying asset to receive.\\n /// @param amountOut The exact amount of `amountOut` to be swapped.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @return amountIn The amount of `amountIn` received.\\n function previewOutputSwap(\\n Market marketIn,\\n Market marketOut,\\n uint256 amountOut,\\n uint24 fee\\n ) public returns (uint256) {\\n address assetIn = address(marketIn.asset());\\n address assetOut = address(marketOut.asset());\\n return\\n amountOut > 0\\n ? uniswapV3Quoter.quoteExactOutputSingle(\\n assetIn,\\n assetOut,\\n fee,\\n amountOut,\\n assetIn == PoolAddress.getPoolKey(assetIn, assetOut, fee).token0 ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1\\n )\\n : 0;\\n }\\n\\n /// @notice Returns extended data useful to leverage or deleverage an account principal position.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account operating with the `DebtManager`.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n /// @return extended leverage data.\\n function leverage(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 minHealthFactor\\n ) external returns (Leverage memory) {\\n (, , uint256 floatingBorrowShares) = marketBorrow.accounts(account);\\n uint256 deposit = marketDeposit.maxWithdraw(account);\\n uint256 memMinDeposit = minDeposit(marketDeposit, marketBorrow, account, minHealthFactor);\\n int256 principal = crossPrincipal(marketDeposit, marketBorrow, account);\\n PoolKey memory poolKey = PoolAddress.getPoolKey(address(marketDeposit.asset()), address(marketBorrow.asset()), 0);\\n poolKey.fee = poolFees[poolKey.token0][poolKey.token1];\\n uint256 sqrtPriceX96;\\n if (marketDeposit != marketBorrow) {\\n (sqrtPriceX96, , , , , , ) = IUniswapV3Pool(PoolAddress.computeAddress(debtManager.uniswapV3Factory(), poolKey))\\n .slot0();\\n }\\n\\n return\\n Leverage({\\n borrow: marketBorrow.previewRefund(floatingBorrowShares),\\n deposit: deposit,\\n principal: principal,\\n ratio: principal > 0 ? deposit.divWadDown(uint256(principal)) : 0,\\n maxRatio: maxRatio(\\n marketDeposit,\\n marketBorrow,\\n account,\\n principal > 0 ? uint256(principal) : 0,\\n minHealthFactor\\n ),\\n minDeposit: deposit >= memMinDeposit ? 0 : memMinDeposit - deposit,\\n maxWithdraw: principal > 0 ? maxWithdraw(marketDeposit, marketBorrow, account) : 0,\\n pool: poolKey,\\n sqrtPriceX96: sqrtPriceX96,\\n availableAssets: balancerAvailableLiquidity()\\n });\\n }\\n\\n /// @notice Returns minimum deposit based on account's current debt and a given health factor.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account operating with the markets.\\n /// @param minHealthFactor The health factor that the account must have with the minimum deposit, isolated.\\n function minDeposit(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 minHealthFactor\\n ) internal view returns (uint256) {\\n MinDepositVars memory vars;\\n Auditor auditor = debtManager.auditor();\\n (vars.adjustFactorIn, , , , vars.priceFeedIn) = auditor.markets(marketDeposit);\\n (vars.adjustFactorOut, , , , vars.priceFeedOut) = auditor.markets(marketBorrow);\\n\\n return\\n minHealthFactor\\n .mulWadDown(floatingBorrowAssets(marketBorrow, account))\\n .mulDivDown(auditor.assetPrice(vars.priceFeedOut), 10 ** marketBorrow.decimals())\\n .divWadDown(vars.adjustFactorOut.mulWadDown(vars.adjustFactorIn))\\n .mulDivUp(10 ** marketDeposit.decimals(), auditor.assetPrice(vars.priceFeedIn));\\n }\\n\\n /// @notice Returns the maximum ratio that an account can leverage its principal plus `assets` amount.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account that will be leveraged.\\n /// @param deposit The amount of assets that will be added to the principal.\\n /// @param ratio The ratio to be previewed.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n function previewLeverage(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 minHealthFactor\\n ) external returns (Limit memory limit) {\\n uint256 currentRatio;\\n (limit.principal, currentRatio, limit.maxRatio) = previewRatio(\\n marketDeposit,\\n marketBorrow,\\n account,\\n int256(deposit),\\n minHealthFactor\\n );\\n\\n limit.ratio = (ratio < currentRatio || ratio > limit.maxRatio) ? currentRatio : ratio;\\n PoolKey memory poolKey = PoolAddress.getPoolKey(address(marketDeposit.asset()), address(marketBorrow.asset()), 0);\\n poolKey.fee = poolFees[poolKey.token0][poolKey.token1];\\n if (limit.principal <= 0) {\\n limit.borrow = floatingBorrowAssets(marketBorrow, account);\\n limit.deposit = marketDeposit.maxWithdraw(account) + deposit;\\n return limit;\\n }\\n limit.deposit = uint256(limit.principal).mulWadUp(limit.ratio);\\n if (marketDeposit == marketBorrow) {\\n limit.borrow = uint256(limit.principal).mulWadDown(limit.ratio - 1e18);\\n limit.swapRatio = 1e18;\\n return limit;\\n }\\n uint256 assetsSwap = limit.deposit - marketDeposit.maxWithdraw(account) - deposit;\\n limit.borrow =\\n floatingBorrowAssets(marketBorrow, account) +\\n previewOutputSwap(marketBorrow, marketDeposit, assetsSwap, poolKey.fee);\\n limit.swapRatio = assetsSwap > 0 && previewAssetsOut(marketDeposit, marketBorrow, assetsSwap) > 0\\n ? previewOutputSwap(marketBorrow, marketDeposit, assetsSwap, poolKey.fee).divWadDown(\\n previewAssetsOut(marketDeposit, marketBorrow, assetsSwap)\\n )\\n : 1e18;\\n }\\n\\n /// @notice Returns the maximum ratio that an account can deleverage its principal minus `assets` amount.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account that will be deleveraged.\\n /// @param withdraw The amount of assets that will be withdrawn from the principal.\\n /// @param ratio The ratio to be previewed.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n function previewDeleverage(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 withdraw,\\n uint256 ratio,\\n uint256 minHealthFactor\\n ) external returns (Limit memory limit) {\\n if ((limit.principal = crossPrincipal(marketDeposit, marketBorrow, account)) < 0) revert InvalidPreview();\\n uint256 memMaxWithdraw = maxWithdraw(marketDeposit, marketBorrow, account);\\n if (withdraw <= uint256(limit.principal)) {\\n limit.principal -= int256(withdraw);\\n limit.maxRatio = maxRatio(marketDeposit, marketBorrow, account, uint256(limit.principal), minHealthFactor);\\n } else if (withdraw <= memMaxWithdraw) {\\n limit.principal = int256(memMaxWithdraw - withdraw);\\n limit.maxRatio = limit.principal > 0\\n ? maxRatio(marketDeposit, marketBorrow, account, uint256(limit.principal), minHealthFactor)\\n : 1e18;\\n } else revert InvalidPreview();\\n\\n limit.ratio = ratio > limit.maxRatio ? limit.maxRatio : ratio;\\n\\n uint256 borrowRepay = floatingBorrowAssets(marketBorrow, account) -\\n previewAssetsOut(marketDeposit, marketBorrow, uint256(limit.principal).mulWadDown(limit.ratio - 1e18));\\n\\n PoolKey memory poolKey = PoolAddress.getPoolKey(address(marketDeposit.asset()), address(marketBorrow.asset()), 0);\\n poolKey.fee = poolFees[poolKey.token0][poolKey.token1];\\n limit.borrow = floatingBorrowAssets(marketBorrow, account) - borrowRepay;\\n if (marketDeposit == marketBorrow) {\\n limit.deposit = marketDeposit.maxWithdraw(account) - withdraw - borrowRepay;\\n limit.swapRatio = 1e18;\\n return limit;\\n }\\n\\n limit.deposit =\\n marketDeposit.maxWithdraw(account) -\\n withdraw -\\n previewOutputSwap(marketDeposit, marketBorrow, borrowRepay, poolKey.fee);\\n limit.swapRatio = previewAssetsOut(marketBorrow, marketDeposit, borrowRepay) > 0\\n ? previewOutputSwap(marketDeposit, marketBorrow, borrowRepay, poolKey.fee).divWadDown(\\n previewAssetsOut(marketBorrow, marketDeposit, borrowRepay)\\n )\\n : 1e18;\\n }\\n\\n /// @notice Returns principal, current ratio and max ratio, considering assets to add or substract.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account to preview the ratio.\\n /// @param assets The amount of assets that will be added or subtracted to the principal.\\n /// @param minHealthFactor The minimum health factor that the account should have with the max ratio.\\n function previewRatio(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n int256 assets,\\n uint256 minHealthFactor\\n ) internal view returns (int256 principal, uint256 current, uint256 max) {\\n principal = crossPrincipal(marketDeposit, marketBorrow, account) + assets;\\n if (principal > 0) {\\n current = uint256(int256(marketDeposit.maxWithdraw(account)) + assets).divWadUp(uint256(principal));\\n max = maxRatio(marketDeposit, marketBorrow, account, uint256(principal), minHealthFactor);\\n } else {\\n max = maxRatio(marketDeposit, marketBorrow, account, 0, minHealthFactor);\\n }\\n }\\n\\n /// @notice Returns the amount of `marketBorrow` underlying assets considering `amountIn` and assets oracle prices.\\n /// @param marketDeposit The market of the assets accounted as `amountIn`.\\n /// @param marketBorrow The market of the assets that will be returned.\\n /// @param amountIn The amount of `marketDeposit` underlying assets.\\n function previewAssetsOut(\\n Market marketDeposit,\\n Market marketBorrow,\\n uint256 amountIn\\n ) internal view returns (uint256) {\\n (, , , , IPriceFeed priceFeedIn) = debtManager.auditor().markets(marketDeposit);\\n (, , , , IPriceFeed priceFeedOut) = debtManager.auditor().markets(marketBorrow);\\n return\\n amountIn.mulDivDown(debtManager.auditor().assetPrice(priceFeedIn), 10 ** marketDeposit.decimals()).mulDivDown(\\n 10 ** marketBorrow.decimals(),\\n debtManager.auditor().assetPrice(priceFeedOut)\\n );\\n }\\n\\n /// @notice Returns the maximum ratio that an account can leverage its principal position.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account that will be leveraged.\\n /// @param principal The principal amount that will be leveraged.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n function maxRatio(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 principal,\\n uint256 minHealthFactor\\n ) internal view returns (uint256) {\\n RatioVars memory r;\\n Auditor auditor = debtManager.auditor();\\n\\n uint256 marketMap = auditor.accountMarkets(account);\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = auditor.marketList(i);\\n Auditor.MarketData memory m;\\n Auditor.AccountLiquidity memory vars;\\n (m.adjustFactor, m.decimals, , , m.priceFeed) = auditor.markets(market);\\n vars.price = auditor.assetPrice(m.priceFeed);\\n (, vars.borrowBalance) = market.accountSnapshot(account);\\n\\n if (market == marketBorrow) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n vars.borrowBalance -= market.previewRefund(floatingBorrowShares);\\n }\\n r.adjustedDebt += vars.borrowBalance.mulDivUp(vars.price, 10 ** m.decimals).divWadUp(m.adjustFactor);\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n (r.adjustFactorIn, , , , ) = auditor.markets(marketDeposit);\\n (r.adjustFactorOut, , , , ) = auditor.markets(marketBorrow);\\n (, , , , IPriceFeed priceFeedIn) = auditor.markets(marketDeposit);\\n r.adjustedDebt = r.adjustedDebt.mulWadDown(r.adjustFactorOut).mulDivDown(\\n 10 ** marketDeposit.decimals(),\\n auditor.assetPrice(priceFeedIn)\\n );\\n if (\\n principal == 0 ||\\n r.adjustedDebt > principal ||\\n (principal - r.adjustedDebt).divWadDown(\\n principal - principal.mulWadDown(r.adjustFactorIn).mulWadDown(r.adjustFactorOut).divWadDown(minHealthFactor)\\n ) <\\n 1e18\\n ) {\\n return minHealthFactor.divWadDown(minHealthFactor - r.adjustFactorIn.mulWadDown(r.adjustFactorOut));\\n }\\n return\\n (principal - r.adjustedDebt).divWadDown(\\n principal - principal.mulWadDown(r.adjustFactorIn).mulWadDown(r.adjustFactorOut).divWadDown(minHealthFactor)\\n );\\n }\\n\\n function floatingBorrowAssets(Market market, address account) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n\\n /// @notice Returns the maximum amount that an account can withdraw when leveraged, repaying the full borrow.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account to preview.\\n function maxWithdraw(Market marketDeposit, Market marketBorrow, address account) internal returns (uint256) {\\n Auditor auditor = debtManager.auditor();\\n\\n MaxWithdrawVars memory mw;\\n mw.marketMap = auditor.accountMarkets(account);\\n for (mw.i = 0; mw.marketMap != 0; mw.marketMap >>= 1) {\\n if (mw.marketMap & 1 != 0) {\\n Auditor.MarketData memory md;\\n Auditor.AccountLiquidity memory vars;\\n\\n mw.market = auditor.marketList(mw.i);\\n (md.adjustFactor, md.decimals, , , md.priceFeed) = auditor.markets(mw.market);\\n (vars.balance, vars.borrowBalance) = mw.market.accountSnapshot(account);\\n vars.price = auditor.assetPrice(md.priceFeed);\\n\\n mw.adjustedCollateral += vars.balance.mulDivDown(vars.price, 10 ** md.decimals).mulWadDown(md.adjustFactor);\\n mw.adjustedDebt += vars.borrowBalance.mulDivUp(vars.price, 10 ** md.decimals).divWadUp(md.adjustFactor);\\n\\n uint256 borrowAssets = floatingBorrowAssets(marketBorrow, account);\\n\\n if (mw.market == marketBorrow) {\\n mw.adjustedRepay = borrowAssets.mulDivUp(vars.price, 10 ** md.decimals).divWadUp(md.adjustFactor);\\n }\\n if (mw.market == marketDeposit) {\\n mw.adjustedPrincipalToRepayDebt = (\\n borrowAssets > 0 && marketBorrow != marketDeposit\\n ? previewOutputSwap(marketDeposit, marketBorrow, borrowAssets, 500)\\n : borrowAssets\\n ).mulDivDown(vars.price, 10 ** md.decimals).mulWadDown(md.adjustFactor);\\n mw.adjustedPrincipal =\\n (mw.market.maxWithdraw(account)).mulDivDown(vars.price, 10 ** md.decimals).mulWadDown(md.adjustFactor) -\\n mw.adjustedPrincipalToRepayDebt;\\n }\\n }\\n unchecked {\\n ++mw.i;\\n }\\n }\\n (mw.adjustFactorIn, , , , mw.priceFeedIn) = auditor.markets(marketDeposit);\\n\\n return\\n Math\\n .min(\\n mw.adjustedCollateral + mw.adjustedRepay - mw.adjustedDebt - mw.adjustedPrincipalToRepayDebt,\\n mw.adjustedPrincipal\\n )\\n .mulDivDown(10 ** marketDeposit.decimals(), auditor.assetPrice(mw.priceFeedIn))\\n .divWadDown(mw.adjustFactorIn);\\n }\\n\\n /// @notice Calculates the crossed principal amount for a given `account` in the input and output markets.\\n /// @param marketDeposit The Market to withdraw the leveraged position.\\n /// @param marketBorrow The Market to repay the leveraged position.\\n /// @param account The account that will be deleveraged.\\n function crossPrincipal(Market marketDeposit, Market marketBorrow, address account) internal view returns (int256) {\\n (, , , , IPriceFeed priceFeedIn) = debtManager.auditor().markets(marketDeposit);\\n (, , , , IPriceFeed priceFeedOut) = debtManager.auditor().markets(marketBorrow);\\n\\n return\\n int256(marketDeposit.maxWithdraw(account)) -\\n int256(\\n floatingBorrowAssets(marketBorrow, account)\\n .mulDivDown(debtManager.auditor().assetPrice(priceFeedOut), 10 ** marketBorrow.decimals())\\n .mulDivDown(10 ** marketDeposit.decimals(), debtManager.auditor().assetPrice(priceFeedIn))\\n );\\n }\\n\\n /// @notice Returns Balancer Vault's available liquidity of each enabled underlying asset.\\n function balancerAvailableLiquidity() internal view returns (AvailableAsset[] memory availableAssets) {\\n uint256 marketsCount = debtManager.auditor().allMarkets().length;\\n availableAssets = new AvailableAsset[](marketsCount);\\n\\n for (uint256 i = 0; i < marketsCount; ) {\\n ERC20 asset = debtManager.auditor().marketList(i).asset();\\n availableAssets[i] = AvailableAsset({\\n asset: asset,\\n liquidity: asset.balanceOf(address(debtManager.balancerVault()))\\n });\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice returns rates based on inputs and leverage ratio impact on the borrow market\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account to preview.\\n /// @param assets The amount of assets that should be added or substracted to the principal.\\n /// @param targetRatio The target ratio to preview.\\n /// @param depositRate The current deposit rate of the deposit market.\\n /// @param nativeRate The current native rate of the deposit market.\\n function leverageRates(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n int256 assets,\\n uint256 targetRatio,\\n uint256 depositRate,\\n uint256 nativeRate\\n ) external view returns (Rates memory rates) {\\n (int256 principal, uint256 currentRatio, ) = previewRatio(marketDeposit, marketBorrow, account, assets, 1e18);\\n if (principal <= 0) revert InvalidPreview();\\n\\n uint256 utilization;\\n if (targetRatio < currentRatio) {\\n uint256 depositDecrease = uint256(principal).mulWadDown(currentRatio - targetRatio);\\n utilization = (marketBorrow.totalFloatingBorrowAssets() -\\n previewAssetsOut(marketDeposit, marketBorrow, depositDecrease)).divWadUp(\\n marketBorrow.totalAssets() - (marketDeposit == marketBorrow ? depositDecrease : 0)\\n );\\n } else {\\n uint256 depositIncrease = uint256(principal).mulWadDown(targetRatio - currentRatio);\\n utilization = (marketBorrow.totalFloatingBorrowAssets() +\\n previewAssetsOut(marketDeposit, marketBorrow, depositIncrease)).divWadUp(\\n marketBorrow.totalAssets() + (marketDeposit == marketBorrow ? depositIncrease : 0)\\n );\\n }\\n rates.borrow = marketBorrow.interestRateModel().floatingRate(utilization).mulWadDown(targetRatio - 1e18);\\n rates.deposit = depositRate.mulWadDown(targetRatio);\\n rates.native = nativeRate.mulWadDown(targetRatio);\\n rates.rewards = calculateRewards(\\n rewardRates(marketDeposit),\\n marketDeposit == marketBorrow ? new RewardRate[](0) : rewardRates(marketBorrow),\\n marketDeposit == marketBorrow,\\n targetRatio\\n );\\n }\\n\\n function calculateRewards(\\n RewardRate[] memory depositRewards,\\n RewardRate[] memory borrowRewards,\\n bool sameMarket,\\n uint256 targetRatio\\n ) internal pure returns (RewardRate[] memory result) {\\n result = new RewardRate[](depositRewards.length + borrowRewards.length);\\n uint256 i;\\n for (; i < depositRewards.length; ) {\\n result[i].deposit = depositRewards[i].deposit.mulWadDown(targetRatio);\\n if (sameMarket) {\\n result[i].borrow = depositRewards[i].borrow.mulWadDown(targetRatio - 1e18);\\n }\\n result[i].asset = depositRewards[i].asset;\\n result[i].assetName = depositRewards[i].assetName;\\n result[i].assetSymbol = depositRewards[i].assetSymbol;\\n unchecked {\\n ++i;\\n }\\n }\\n if (!sameMarket) {\\n for (i = 0; i < borrowRewards.length; ) {\\n result[i + depositRewards.length].borrow = borrowRewards[i].borrow.mulWadDown(targetRatio - 1e18);\\n result[i + depositRewards.length].asset = borrowRewards[i].asset;\\n result[i + depositRewards.length].assetName = borrowRewards[i].assetName;\\n result[i + depositRewards.length].assetSymbol = borrowRewards[i].assetSymbol;\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n }\\n\\n function rewardRates(Market market) internal view returns (RewardRate[] memory rewards) {\\n Previewer.RewardsVars memory r;\\n r.controller = market.rewardsController();\\n if (address(r.controller) != address(0)) {\\n (, r.underlyingDecimals, , , r.underlyingPriceFeed) = market.auditor().markets(market);\\n unchecked {\\n r.underlyingBaseUnit = 10 ** r.underlyingDecimals;\\n }\\n r.deltaTime = 1 hours;\\n r.rewardList = r.controller.allRewards();\\n rewards = new RewardRate[](r.rewardList.length);\\n for (r.i = 0; r.i < r.rewardList.length; ) {\\n r.config = r.controller.rewardConfig(market, r.rewardList[r.i]);\\n (r.borrowIndex, r.depositIndex, ) = r.controller.rewardIndexes(market, r.rewardList[r.i]);\\n (r.projectedBorrowIndex, r.projectedDepositIndex, ) = r.controller.previewAllocation(\\n market,\\n r.rewardList[r.i],\\n block.timestamp > r.config.start ? r.deltaTime : 0\\n );\\n (r.start, , ) = r.controller.distributionTime(market, r.rewardList[r.i]);\\n r.firstMaturity = r.start - (r.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n r.maxMaturity =\\n block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n r.maturities = new uint256[]((r.maxMaturity - r.firstMaturity) / FixedLib.INTERVAL + 1);\\n r.start = 0;\\n for (r.maturity = r.firstMaturity; r.maturity <= r.maxMaturity; ) {\\n (uint256 borrowed, ) = market.fixedPoolBalance(r.maturity);\\n r.fixedDebt += borrowed;\\n r.maturities[r.start] = r.maturity;\\n unchecked {\\n r.maturity += FixedLib.INTERVAL;\\n ++r.start;\\n }\\n }\\n rewards[r.i] = RewardRate({\\n asset: address(r.rewardList[r.i]),\\n assetName: r.rewardList[r.i].name(),\\n assetSymbol: r.rewardList[r.i].symbol(),\\n borrow: (market.totalFloatingBorrowAssets() + r.fixedDebt) > 0\\n ? (r.projectedBorrowIndex - r.borrowIndex)\\n .mulDivDown(market.totalFloatingBorrowShares() + market.previewRepay(r.fixedDebt), r.underlyingBaseUnit)\\n .mulWadDown(market.auditor().assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n (market.totalFloatingBorrowAssets() + r.fixedDebt).mulWadDown(\\n market.auditor().assetPrice(r.underlyingPriceFeed)\\n )\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n deposit: market.totalAssets() > 0\\n ? (r.projectedDepositIndex - r.depositIndex)\\n .mulDivDown(market.totalSupply(), r.underlyingBaseUnit)\\n .mulWadDown(market.auditor().assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n market.totalAssets().mulWadDown(market.auditor().assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0\\n });\\n unchecked {\\n ++r.i;\\n }\\n }\\n }\\n }\\n}\\n\\nerror InvalidPreview();\\n\\nstruct Leverage {\\n uint256 ratio;\\n uint256 borrow;\\n uint256 deposit;\\n int256 principal;\\n uint256 maxRatio;\\n uint256 minDeposit;\\n uint256 maxWithdraw;\\n PoolKey pool;\\n uint256 sqrtPriceX96;\\n AvailableAsset[] availableAssets;\\n}\\n\\nstruct AvailableAsset {\\n ERC20 asset;\\n uint256 liquidity;\\n}\\n\\nstruct Pool {\\n address tokenA;\\n address tokenB;\\n}\\n\\nstruct Limit {\\n uint256 ratio;\\n uint256 borrow;\\n uint256 deposit;\\n int256 principal;\\n uint256 maxRatio;\\n uint256 swapRatio;\\n}\\n\\nstruct RatioVars {\\n uint256 adjustedDebt;\\n uint256 adjustFactorIn;\\n uint256 adjustFactorOut;\\n}\\n\\nstruct MaxWithdrawVars {\\n uint256 adjustedDebt;\\n uint256 adjustedRepay;\\n uint256 adjustedPrincipal;\\n uint256 adjustedCollateral;\\n uint256 adjustedPrincipalToRepayDebt;\\n IPriceFeed priceFeedIn;\\n uint256 marketMap;\\n uint256 adjustFactorIn;\\n uint256 adjustFactorOut;\\n uint256 i;\\n Market market;\\n}\\n\\nstruct MinDepositVars {\\n uint256 adjustFactorIn;\\n uint256 adjustFactorOut;\\n IPriceFeed priceFeedIn;\\n IPriceFeed priceFeedOut;\\n}\\n\\nstruct Rates {\\n uint256 native;\\n uint256 borrow;\\n uint256 deposit;\\n RewardRate[] rewards;\\n}\\n\\nstruct RewardRate {\\n address asset;\\n string assetName;\\n string assetSymbol;\\n uint256 borrow;\\n uint256 deposit;\\n}\\n\\ninterface IUniswapQuoter {\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0x25830a147d4c0343aae9bf8c55bf2fe021da2d305450d4eaed8c81a85df96509\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/Previewer.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { InterestRateModel as IRM, AlreadyMatured } from \\\"../InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"../RewardsController.sol\\\";\\nimport { FixedLib } from \\\"../utils/FixedLib.sol\\\";\\nimport { Auditor, IPriceFeed } from \\\"../Auditor.sol\\\";\\nimport { Market } from \\\"../Market.sol\\\";\\n\\n/// @title Previewer\\n/// @notice Contract to be consumed by Exactly's front-end dApp.\\ncontract Previewer {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for uint256;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IPriceFeed public immutable basePriceFeed;\\n\\n struct MarketAccount {\\n // market\\n Market market;\\n string symbol;\\n uint8 decimals;\\n address asset;\\n string assetName;\\n string assetSymbol;\\n InterestRateModel interestRateModel;\\n uint256 usdPrice;\\n uint256 penaltyRate;\\n uint256 adjustFactor;\\n uint8 maxFuturePools;\\n FixedPool[] fixedPools;\\n RewardRate[] rewardRates;\\n uint256 floatingBorrowRate;\\n uint256 floatingUtilization;\\n uint256 floatingBackupBorrowed;\\n uint256 floatingAvailableAssets;\\n uint256 totalFloatingBorrowAssets;\\n uint256 totalFloatingDepositAssets;\\n uint256 totalFloatingBorrowShares;\\n uint256 totalFloatingDepositShares;\\n // account\\n bool isCollateral;\\n uint256 maxBorrowAssets;\\n uint256 floatingBorrowShares;\\n uint256 floatingBorrowAssets;\\n uint256 floatingDepositShares;\\n uint256 floatingDepositAssets;\\n FixedPosition[] fixedDepositPositions;\\n FixedPosition[] fixedBorrowPositions;\\n ClaimableReward[] claimableRewards;\\n }\\n\\n struct RewardRate {\\n address asset;\\n string assetName;\\n string assetSymbol;\\n uint256 usdPrice;\\n uint256 borrow;\\n uint256 floatingDeposit;\\n uint256[] maturities;\\n }\\n\\n struct ClaimableReward {\\n address asset;\\n string assetName;\\n string assetSymbol;\\n uint256 amount;\\n }\\n\\n struct InterestRateModel {\\n address id;\\n uint256 fixedCurveA;\\n int256 fixedCurveB;\\n uint256 fixedMaxUtilization;\\n uint256 floatingCurveA;\\n int256 floatingCurveB;\\n uint256 floatingMaxUtilization;\\n }\\n\\n struct FixedPosition {\\n uint256 maturity;\\n uint256 previewValue;\\n FixedLib.Position position;\\n }\\n\\n struct FixedPreview {\\n uint256 maturity;\\n uint256 assets;\\n uint256 utilization;\\n }\\n\\n struct FixedPool {\\n uint256 maturity;\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 available;\\n uint256 utilization;\\n uint256 depositRate;\\n uint256 minBorrowRate;\\n uint256 optimalDeposit;\\n }\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IPriceFeed basePriceFeed_) {\\n auditor = auditor_;\\n basePriceFeed = basePriceFeed_;\\n }\\n\\n /// @notice Function to get a certain account extended data.\\n /// @param account address which the extended data will be calculated.\\n /// @return data extended accountability of all markets for the account.\\n function exactly(address account) external view returns (MarketAccount[] memory data) {\\n uint256 markets = auditor.accountMarkets(account);\\n uint256 maxValue = auditor.allMarkets().length;\\n (uint256 adjustedCollateral, uint256 adjustedDebt) = auditor.accountLiquidity(account, Market(address(0)), 0);\\n uint256 basePrice = address(basePriceFeed) != address(0)\\n ? uint256(basePriceFeed.latestAnswer()) * 10 ** (18 - basePriceFeed.decimals())\\n : 1e18;\\n data = new MarketAccount[](maxValue);\\n for (uint256 i = 0; i < maxValue; ++i) {\\n Market market = auditor.marketList(i);\\n Market.Account memory a;\\n Auditor.MarketData memory m;\\n (a.fixedDeposits, a.fixedBorrows, a.floatingBorrowShares) = market.accounts(account);\\n (m.adjustFactor, m.decimals, m.index, m.isListed, m.priceFeed) = auditor.markets(market);\\n IRM irm = market.interestRateModel();\\n data[i] = MarketAccount({\\n // market\\n market: market,\\n symbol: market.symbol(),\\n decimals: m.decimals,\\n asset: address(market.asset()),\\n assetName: market.asset().name(),\\n assetSymbol: market.asset().symbol(),\\n interestRateModel: InterestRateModel({\\n id: address(irm),\\n fixedCurveA: irm.fixedCurveA(),\\n fixedCurveB: irm.fixedCurveB(),\\n fixedMaxUtilization: irm.fixedMaxUtilization(),\\n floatingCurveA: irm.floatingCurveA(),\\n floatingCurveB: irm.floatingCurveB(),\\n floatingMaxUtilization: irm.floatingMaxUtilization()\\n }),\\n usdPrice: auditor.assetPrice(m.priceFeed).mulWadDown(basePrice),\\n penaltyRate: market.penaltyRate(),\\n adjustFactor: m.adjustFactor,\\n maxFuturePools: market.maxFuturePools(),\\n fixedPools: fixedPools(market),\\n rewardRates: rewardRates(market, basePrice),\\n floatingBorrowRate: irm.floatingRate(\\n market.floatingAssets() > 0 ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18) : 0\\n ),\\n floatingUtilization: market.floatingAssets() > 0\\n ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18)\\n : 0,\\n floatingBackupBorrowed: market.floatingBackupBorrowed(),\\n floatingAvailableAssets: floatingAvailableAssets(market),\\n totalFloatingBorrowAssets: market.totalFloatingBorrowAssets(),\\n totalFloatingDepositAssets: market.totalAssets(),\\n totalFloatingBorrowShares: market.totalFloatingBorrowShares(),\\n totalFloatingDepositShares: market.totalSupply(),\\n // account\\n isCollateral: markets & (1 << i) != 0 ? true : false,\\n maxBorrowAssets: adjustedCollateral >= adjustedDebt\\n ? (adjustedCollateral - adjustedDebt).mulDivUp(10 ** m.decimals, auditor.assetPrice(m.priceFeed)).mulWadUp(\\n m.adjustFactor\\n )\\n : 0,\\n floatingBorrowShares: a.floatingBorrowShares,\\n floatingBorrowAssets: maxRepay(market, account),\\n floatingDepositShares: market.balanceOf(account),\\n floatingDepositAssets: market.maxWithdraw(account),\\n fixedDepositPositions: fixedPositions(\\n market,\\n account,\\n a.fixedDeposits,\\n market.fixedDepositPositions,\\n this.previewWithdrawAtMaturity\\n ),\\n fixedBorrowPositions: fixedPositions(\\n market,\\n account,\\n a.fixedBorrows,\\n market.fixedBorrowPositions,\\n this.previewRepayAtMaturity\\n ),\\n claimableRewards: claimableRewards(market, account)\\n });\\n }\\n }\\n\\n /// @notice Gets the assets plus yield offered by a maturity when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be deposited.\\n /// @param assets amount of assets that will be deposited.\\n /// @return amount plus yield that the depositor will receive after maturity.\\n function previewDepositAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n if (block.timestamp > maturity) revert AlreadyMatured();\\n (uint256 borrowed, uint256 supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fixedDepositYield(market, maturity, assets),\\n utilization: memFloatingAssetsAverage > 0 ? borrowed.divWadUp(supplied + assets + memFloatingAssetsAverage) : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus yield offered by all VALID maturities when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be deposited.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewDepositAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n previews[i] = previewDepositAtMaturity(market, maturity, assets);\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount plus fees to be repaid at maturity when borrowing certain amount of assets.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be borrowed.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return positionAssets amount plus fees that the depositor will repay at maturity.\\n function previewBorrowAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n uint256 fees = assets.mulWadDown(\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n assets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n );\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fees,\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed + assets).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus fees offered by all VALID maturities when borrowing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewBorrowAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n try this.previewBorrowAtMaturity(market, maturity, assets) returns (FixedPreview memory preview) {\\n previews[i] = preview;\\n } catch {\\n previews[i] = FixedPreview({ maturity: maturity, assets: type(uint256).max, utilization: type(uint256).max });\\n }\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount to be withdrawn for a certain positionAmount of assets at maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be withdrawn.\\n /// @param positionAssets amount of assets that will be tried to withdraw.\\n /// @return withdrawAssets amount that will be withdrawn.\\n function previewWithdrawAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address owner\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedDepositPositions(maturity, owner);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets.divWadDown(\\n 1e18 +\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n )\\n : positionAssets,\\n utilization: memFloatingAssetsAverage > 0\\n ? pool.borrowed.divWadUp(pool.supplied + memFloatingAssetsAverage - principal)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets that will be repaid when repaying a certain amount at the current maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be repaid.\\n /// @param positionAssets amount of assets that will be subtracted from the position.\\n /// @param borrower address of the borrower.\\n /// @return repayAssets amount of assets that will be repaid.\\n function previewRepayAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address borrower\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedBorrowPositions(maturity, borrower);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets - fixedDepositYield(market, maturity, principal)\\n : positionAssets + positionAssets.mulWadDown((block.timestamp - maturity) * market.penaltyRate()),\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed - principal).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n function fixedPools(Market market) internal view returns (FixedPool[] memory pools) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n pools = new FixedPool[](market.maxFuturePools());\\n for (uint256 i = 0; i < market.maxFuturePools(); i++) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)\\n );\\n (uint256 minBorrowRate, uint256 utilization) = (market.previewFloatingAssetsAverage() + pool.supplied) > 0\\n ? market.interestRateModel().minFixedRate(pool.borrowed, pool.supplied, market.previewFloatingAssetsAverage())\\n : (0, 0);\\n\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n (block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)) - pool.lastAccrual\\n );\\n pools[i] = FixedPool({\\n maturity: block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1),\\n borrowed: pool.borrowed,\\n supplied: pool.supplied,\\n available: Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()) -\\n Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()),\\n market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt\\n ),\\n market.previewFloatingAssetsAverage()\\n ) +\\n pool.supplied -\\n Math.min(pool.supplied, pool.borrowed),\\n utilization: utilization,\\n optimalDeposit: pool.borrowed - Math.min(pool.borrowed, pool.supplied),\\n depositRate: uint256(365 days).mulDivDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied) > 0\\n ? (pool.unassignedEarnings.mulWadDown(1e18 - market.backupFeeRate())).divWadDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied)\\n )\\n : 0,\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1) - block.timestamp\\n ),\\n minBorrowRate: minBorrowRate\\n });\\n }\\n }\\n\\n function rewardRates(Market market, uint256 basePrice) internal view returns (RewardRate[] memory rewards) {\\n RewardsVars memory r;\\n r.controller = market.rewardsController();\\n if (address(r.controller) != address(0)) {\\n (, r.underlyingDecimals, , , r.underlyingPriceFeed) = auditor.markets(market);\\n unchecked {\\n r.underlyingBaseUnit = 10 ** r.underlyingDecimals;\\n }\\n r.deltaTime = 1 hours;\\n r.rewardList = r.controller.allRewards();\\n rewards = new RewardRate[](r.rewardList.length);\\n for (r.i = 0; r.i < r.rewardList.length; ++r.i) {\\n r.config = r.controller.rewardConfig(market, r.rewardList[r.i]);\\n (r.borrowIndex, r.depositIndex, ) = r.controller.rewardIndexes(market, r.rewardList[r.i]);\\n (r.projectedBorrowIndex, r.projectedDepositIndex, ) = r.controller.previewAllocation(\\n market,\\n r.rewardList[r.i],\\n block.timestamp > r.config.start ? r.deltaTime : 0\\n );\\n (r.start, , ) = r.controller.distributionTime(market, r.rewardList[r.i]);\\n r.firstMaturity = r.start - (r.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n r.maxMaturity =\\n block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n r.maturities = new uint256[]((r.maxMaturity - r.firstMaturity) / FixedLib.INTERVAL + 1);\\n r.start = 0;\\n for (r.maturity = r.firstMaturity; r.maturity <= r.maxMaturity; ) {\\n (uint256 borrowed, ) = market.fixedPoolBalance(r.maturity);\\n r.fixedDebt += borrowed;\\n r.maturities[r.start] = r.maturity;\\n unchecked {\\n r.maturity += FixedLib.INTERVAL;\\n ++r.start;\\n }\\n }\\n rewards[r.i] = RewardRate({\\n asset: address(r.rewardList[r.i]),\\n assetName: r.rewardList[r.i].name(),\\n assetSymbol: r.rewardList[r.i].symbol(),\\n usdPrice: auditor.assetPrice(r.config.priceFeed).mulWadDown(basePrice),\\n borrow: (market.totalFloatingBorrowAssets() + r.fixedDebt) > 0\\n ? (r.projectedBorrowIndex - r.borrowIndex)\\n .mulDivDown(market.totalFloatingBorrowShares() + market.previewRepay(r.fixedDebt), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n (market.totalFloatingBorrowAssets() + r.fixedDebt).mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n floatingDeposit: market.totalAssets() > 0\\n ? (r.projectedDepositIndex - r.depositIndex)\\n .mulDivDown(market.totalSupply(), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n market.totalAssets().mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n maturities: r.maturities\\n });\\n }\\n }\\n }\\n\\n function claimableRewards(Market market, address account) internal view returns (ClaimableReward[] memory rewards) {\\n RewardsController rewardsController = market.rewardsController();\\n if (address(rewardsController) != address(0)) {\\n ERC20[] memory rewardList = rewardsController.allRewards();\\n\\n rewards = new ClaimableReward[](rewardList.length);\\n RewardsController.MarketOperation[] memory marketOps = new RewardsController.MarketOperation[](1);\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[0] = RewardsController.MarketOperation({ market: market, operations: ops });\\n\\n for (uint256 i = 0; i < rewardList.length; ++i) {\\n rewards[i] = ClaimableReward({\\n asset: address(rewardList[i]),\\n assetName: rewardList[i].name(),\\n assetSymbol: rewardList[i].symbol(),\\n amount: rewardsController.claimable(marketOps, account, rewardList[i])\\n });\\n }\\n }\\n }\\n\\n function floatingAvailableAssets(Market market) internal view returns (uint256) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n uint256 maxAssets = (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor());\\n return maxAssets - Math.min(maxAssets, market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt);\\n }\\n\\n function fixedPositions(\\n Market market,\\n address account,\\n uint256 packedMaturities,\\n function(uint256, address) external view returns (uint256, uint256) getPosition,\\n function(Market, uint256, uint256, address) external view returns (FixedPreview memory) previewValue\\n ) internal view returns (FixedPosition[] memory userMaturityPositions) {\\n uint256 userMaturityCount = 0;\\n FixedPosition[] memory allMaturityPositions = new FixedPosition[](224);\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 positionAssets;\\n {\\n (uint256 principal, uint256 fee) = getPosition(maturity, account);\\n positionAssets = principal + fee;\\n allMaturityPositions[userMaturityCount].position = FixedLib.Position(principal, fee);\\n }\\n try previewValue(market, maturity, positionAssets, account) returns (FixedPreview memory fixedPreview) {\\n allMaturityPositions[userMaturityCount].previewValue = fixedPreview.assets;\\n } catch {\\n allMaturityPositions[userMaturityCount].previewValue = positionAssets;\\n }\\n allMaturityPositions[userMaturityCount].maturity = maturity;\\n ++userMaturityCount;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n\\n userMaturityPositions = new FixedPosition[](userMaturityCount);\\n for (uint256 i = 0; i < userMaturityCount; ++i) userMaturityPositions[i] = allMaturityPositions[i];\\n }\\n\\n function fixedDepositYield(Market market, uint256 maturity, uint256 assets) internal view returns (uint256 yield) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(maturity);\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n maturity - pool.lastAccrual\\n );\\n (yield, ) = pool.calculateDeposit(assets, market.backupFeeRate());\\n }\\n\\n function maxRepay(Market market, address borrower) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(borrower);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n\\n function newFloatingDebt(Market market) internal view returns (uint256) {\\n uint256 memFloatingDebt = market.floatingDebt();\\n uint256 memFloatingAssets = market.floatingAssets();\\n uint256 floatingUtilization = memFloatingAssets > 0\\n ? Math.min(memFloatingDebt.divWadUp(memFloatingAssets), 1e18)\\n : 0;\\n return\\n memFloatingDebt.mulWadDown(\\n market.interestRateModel().floatingRate(floatingUtilization).mulDivDown(\\n block.timestamp - market.lastFloatingDebtUpdate(),\\n 365 days\\n )\\n );\\n }\\n\\n struct RewardsVars {\\n RewardsController controller;\\n uint256 lastUpdate;\\n uint256 depositIndex;\\n uint256 borrowIndex;\\n uint256 projectedDepositIndex;\\n uint256 projectedBorrowIndex;\\n uint256 underlyingBaseUnit;\\n uint256[] maturities;\\n IPriceFeed underlyingPriceFeed;\\n RewardsController.Config config;\\n ERC20[] rewardList;\\n uint256 underlyingDecimals;\\n uint256 deltaTime;\\n uint256 i;\\n uint256 start;\\n uint256 maturity;\\n uint256 fixedDebt;\\n uint256 maxMaturity;\\n uint256 firstMaturity;\\n }\\n}\\n\\nerror InvalidRewardsLength();\\n\",\"keccak256\":\"0x8bcae310e44d6135ca8fe3a0d13735e9a9da40e8c9957063d07cdef508c03da7\",\"license\":\"BUSL-1.1\"},\"contracts/utils/FixedLib.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\nlibrary FixedLib {\\n using FixedPointMathLib for uint256;\\n\\n uint256 internal constant INTERVAL = 4 weeks;\\n\\n /// @notice Gets the amount of revenue sharing between the backup supplier and the new fixed pool supplier.\\n /// @param pool fixed rate pool.\\n /// @param amount amount being provided by the fixed pool supplier.\\n /// @param backupFeeRate rate charged to the fixed pool supplier to be accrued by the backup supplier.\\n /// @return yield amount to be offered to the fixed pool supplier.\\n /// @return backupFee yield to be accrued by the backup supplier for initially providing the liquidity.\\n function calculateDeposit(\\n Pool memory pool,\\n uint256 amount,\\n uint256 backupFeeRate\\n ) internal pure returns (uint256 yield, uint256 backupFee) {\\n uint256 memBackupSupplied = backupSupplied(pool);\\n if (memBackupSupplied != 0) {\\n yield = pool.unassignedEarnings.mulDivDown(Math.min(amount, memBackupSupplied), memBackupSupplied);\\n backupFee = yield.mulWadDown(backupFeeRate);\\n yield -= backupFee;\\n }\\n }\\n\\n /// @notice Registers an operation to add supply to a fixed rate pool and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be added to the supply.\\n /// @param amount amount to be added to the supply.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function deposit(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.supplied = supplied + amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to reduce borrowed amount from a fixed rate pool\\n /// and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be repaid.\\n /// @param amount amount to be added to the fixed rate pool.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function repay(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.borrowed = borrowed - amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to increase borrowed amount of a fixed rate pool\\n /// and potentially increase backup debt.\\n /// @param pool fixed rate pool where an amount will be borrowed.\\n /// @param amount amount to be borrowed from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function borrow(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 newBorrowed = borrowed + amount;\\n\\n backupDebtAddition = newBorrowed - Math.min(Math.max(borrowed, pool.supplied), newBorrowed);\\n pool.borrowed = newBorrowed;\\n }\\n\\n /// @notice Registers an operation to reduce supply from a fixed rate pool and potentially increase backup debt.\\n /// @param pool fixed rate pool where amount will be withdrawn.\\n /// @param amountToDiscount amount to be withdrawn from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function withdraw(Pool storage pool, uint256 amountToDiscount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n uint256 newSupply = supplied - amountToDiscount;\\n\\n backupDebtAddition = Math.min(supplied, borrowed) - Math.min(newSupply, borrowed);\\n pool.supplied = newSupply;\\n }\\n\\n /// @notice Accrues backup earnings from `unassignedEarnings` based on the `lastAccrual` time.\\n /// @param pool fixed rate pool where earnings will be accrued.\\n /// @param maturity maturity date of the pool.\\n /// @return backupEarnings amount of earnings to be distributed to the backup supplier.\\n function accrueEarnings(Pool storage pool, uint256 maturity) internal returns (uint256 backupEarnings) {\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (block.timestamp < maturity) {\\n uint256 unassignedEarnings = pool.unassignedEarnings;\\n pool.lastAccrual = block.timestamp;\\n backupEarnings = unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual);\\n pool.unassignedEarnings = unassignedEarnings - backupEarnings;\\n } else if (lastAccrual == maturity) {\\n backupEarnings = 0;\\n } else {\\n pool.lastAccrual = maturity;\\n backupEarnings = pool.unassignedEarnings;\\n pool.unassignedEarnings = 0;\\n }\\n }\\n\\n /// @notice Calculates the amount that a fixed rate pool borrowed from the backup supplier.\\n /// @param pool fixed rate pool.\\n /// @return amount borrowed from the fixed rate pool.\\n function backupSupplied(Pool memory pool) internal pure returns (uint256) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n return borrowed - Math.min(borrowed, supplied);\\n }\\n\\n /// @notice Modify positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it. Needs for the amount to be less than the principal and the fee\\n /// @param position original position to be scaled.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return scaled position.\\n function scaleProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 principal = amount.mulDivDown(position.principal, position.principal + position.fee);\\n position.principal = principal;\\n position.fee = amount - principal;\\n return position;\\n }\\n\\n /// @notice Reduce positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it.\\n /// @param position original position to be reduced.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return reduced position.\\n function reduceProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 positionAssets = position.principal + position.fee;\\n uint256 newPositionAssets = positionAssets - amount;\\n position.principal = newPositionAssets.mulDivDown(position.principal, positionAssets);\\n position.fee = newPositionAssets - position.principal;\\n return position;\\n }\\n\\n /// @notice Calculates what proportion of earnings would `borrowAmount` represent considering `backupSupplied`.\\n /// @param earnings amount to be distributed.\\n /// @param borrowAmount amount that will be checked if came from the backup supplier or fixed rate pool.\\n /// @return unassignedEarnings earnings to be added to `unassignedEarnings`.\\n /// @return backupEarnings earnings to be distributed to the backup supplier.\\n function distributeEarnings(\\n Pool memory pool,\\n uint256 earnings,\\n uint256 borrowAmount\\n ) internal pure returns (uint256 unassignedEarnings, uint256 backupEarnings) {\\n backupEarnings = borrowAmount == 0\\n ? 0\\n : earnings.mulDivDown(borrowAmount - Math.min(backupSupplied(pool), borrowAmount), borrowAmount);\\n unassignedEarnings = earnings - backupEarnings;\\n }\\n\\n /// @notice Adds a maturity date to the borrow or supply positions of the account.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity the new maturity where the account will borrow or supply to.\\n /// @return updated encoded maturity dates.\\n function setMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n // initialize the maturity with also the 1st bit on the 33th position set\\n if (encoded == 0) return maturity | (1 << 32);\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n if (maturity < baseMaturity) {\\n // if the new maturity is lower than the base, set it as the new base\\n // wipe clean the last 32 bits, shift the amount of `INTERVAL` and set the new value with the 33rd bit set\\n uint256 range = (baseMaturity - maturity) / INTERVAL;\\n if (encoded >> (256 - range) != 0) revert MaturityOverflow();\\n encoded = ((encoded >> 32) << (32 + range));\\n return maturity | encoded | (1 << 32);\\n } else {\\n uint256 range = (maturity - baseMaturity) / INTERVAL;\\n if (range > 223) revert MaturityOverflow();\\n return encoded | (1 << (32 + range));\\n }\\n }\\n\\n /// @notice Remove maturity from account's borrow or supplied positions.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity maturity date to be removed.\\n /// @return updated encoded maturity dates.\\n function clearMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n if (encoded == 0 || encoded == maturity | (1 << 32)) return 0;\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n // if the baseMaturity is the one being cleaned\\n if (maturity == baseMaturity) {\\n // wipe 32 bytes + 1 for the old base flag\\n uint256 packed = encoded >> 33;\\n uint256 range = 1;\\n while ((packed & 1) == 0 && packed != 0) {\\n unchecked {\\n ++range;\\n }\\n packed >>= 1;\\n }\\n encoded = ((encoded >> (32 + range)) << 32);\\n return (maturity + (range * INTERVAL)) | encoded;\\n } else {\\n // otherwise just clear the bit\\n return encoded & ~(1 << (32 + ((maturity - baseMaturity) / INTERVAL)));\\n }\\n }\\n\\n /// @notice Verifies that a maturity is `VALID`, `MATURED`, `NOT_READY` or `INVALID`.\\n /// @dev if expected state doesn't match the calculated one, it reverts with a custom error `UnmatchedPoolState`.\\n /// @param maturity timestamp of the maturity date to be verified.\\n /// @param maxPools number of pools available in the time horizon.\\n /// @param requiredState state required by the caller to be verified (see `State` for description).\\n /// @param alternativeState state required by the caller to be verified (see `State` for description).\\n function checkPoolState(uint256 maturity, uint8 maxPools, State requiredState, State alternativeState) internal view {\\n State state;\\n if (maturity % INTERVAL != 0) {\\n state = State.INVALID;\\n } else if (maturity <= block.timestamp) {\\n state = State.MATURED;\\n } else if (maturity > block.timestamp - (block.timestamp % INTERVAL) + (INTERVAL * maxPools)) {\\n state = State.NOT_READY;\\n } else {\\n state = State.VALID;\\n }\\n\\n if (state != requiredState && state != alternativeState) {\\n if (alternativeState == State.NONE) revert UnmatchedPoolState(uint8(state), uint8(requiredState));\\n\\n revert UnmatchedPoolStates(uint8(state), uint8(requiredState), uint8(alternativeState));\\n }\\n }\\n\\n /// @notice Stores the accountability of a fixed interest rate pool.\\n /// @param borrowed total amount borrowed from the pool.\\n /// @param supplied total amount supplied to the pool.\\n /// @param unassignedEarnings total amount of earnings not yet distributed and accrued.\\n /// @param lastAccrual timestamp for the last time that some earnings have been distributed to the backup supplier.\\n struct Pool {\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 unassignedEarnings;\\n uint256 lastAccrual;\\n }\\n\\n /// @notice Stores principal and fee of a borrow or a supply position of a account in a fixed rate pool.\\n /// @param principal amount borrowed or supplied to the fixed rate pool.\\n /// @param fee amount of fees to be repaid or earned at the maturity of the fixed rate pool.\\n struct Position {\\n uint256 principal;\\n uint256 fee;\\n }\\n\\n enum State {\\n NONE,\\n INVALID,\\n MATURED,\\n VALID,\\n NOT_READY\\n }\\n}\\n\\nerror MaturityOverflow();\\nerror UnmatchedPoolState(uint8 state, uint8 requiredState);\\nerror UnmatchedPoolStates(uint8 state, uint8 requiredState, uint8 alternativeState);\\n\",\"keccak256\":\"0x34f461426e416de7b4d38263269571d0274dda55df2e580e920196096b166c01\",\"license\":\"BUSL-1.1\"},\"contracts/utils/IPriceFeed.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\ninterface IPriceFeed {\\n function decimals() external view returns (uint8);\\n\\n function latestAnswer() external view returns (int256);\\n}\\n\",\"keccak256\":\"0xce1b3c2ebe700449e2e3c7637ffaf85e574eed3f79925feee22426b2c43fc667\",\"license\":\"BUSL-1.1\"},\"solmate/src/mixins/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\nimport {SafeTransferLib} from \\\"../utils/SafeTransferLib.sol\\\";\\nimport {FixedPointMathLib} from \\\"../utils/FixedPointMathLib.sol\\\";\\n\\n/// @notice Minimal ERC4626 tokenized Vault implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol)\\nabstract contract ERC4626 is ERC20 {\\n using SafeTransferLib for ERC20;\\n using FixedPointMathLib for uint256;\\n\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /*//////////////////////////////////////////////////////////////\\n IMMUTABLES\\n //////////////////////////////////////////////////////////////*/\\n\\n ERC20 public immutable asset;\\n\\n constructor(\\n ERC20 _asset,\\n string memory _name,\\n string memory _symbol\\n ) ERC20(_name, _symbol, _asset.decimals()) {\\n asset = _asset;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {\\n // Check for rounding error since we round down in previewDeposit.\\n require((shares = previewDeposit(assets)) != 0, \\\"ZERO_SHARES\\\");\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {\\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function withdraw(\\n uint256 assets,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 shares) {\\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\\n\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n function redeem(\\n uint256 shares,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 assets) {\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n // Check for rounding error since we round down in previewRedeem.\\n require((assets = previewRedeem(shares)) != 0, \\\"ZERO_ASSETS\\\");\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ACCOUNTING LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function totalAssets() public view virtual returns (uint256);\\n\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\\n }\\n\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);\\n }\\n\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return convertToShares(assets);\\n }\\n\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);\\n }\\n\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());\\n }\\n\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return convertToAssets(shares);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LIMIT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return convertToAssets(balanceOf[owner]);\\n }\\n\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf[owner];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL HOOKS LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}\\n\\n function afterDeposit(uint256 assets, uint256 shares) internal virtual {}\\n}\\n\",\"keccak256\":\"0xa0e0c28a727524fa94e7e6c1f4c793a6bd1e6d1bc652b7b02b343ebaf4cd774b\",\"license\":\"MIT\"},\"solmate/src/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0x43aa1509bb753f053143530705d9c4eee415691d26a4779769bf028a74e6ac69\",\"license\":\"MIT\"},\"solmate/src/utils/FixedPointMathLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Arithmetic library with operations for fixed-point numbers.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)\\nlibrary FixedPointMathLib {\\n /*//////////////////////////////////////////////////////////////\\n SIMPLIFIED FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\\n\\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\\n }\\n\\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\\n }\\n\\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\\n }\\n\\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\\n }\\n\\n function powWad(int256 x, int256 y) internal pure returns (int256) {\\n // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)\\n return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.\\n }\\n\\n function expWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n // When the result is < 0.5 we return zero. This happens when\\n // x <= floor(log(0.5e18) * 1e18) ~ -42e18\\n if (x <= -42139678854452767551) return 0;\\n\\n // When the result is > (2**255 - 1) / 1e18 we can not represent it as an\\n // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.\\n if (x >= 135305999368893231589) revert(\\\"EXP_OVERFLOW\\\");\\n\\n // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96\\n // for more intermediate precision and a binary basis. This base conversion\\n // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.\\n x = (x << 78) / 5**18;\\n\\n // Reduce range of x to (-\\u00bd ln 2, \\u00bd ln 2) * 2**96 by factoring out powers\\n // of two such that exp(x) = exp(x') * 2**k, where k is an integer.\\n // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).\\n int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;\\n x = x - k * 54916777467707473351141471128;\\n\\n // k is in the range [-61, 195].\\n\\n // Evaluate using a (6, 7)-term rational approximation.\\n // p is made monic, we'll multiply by a scale factor later.\\n int256 y = x + 1346386616545796478920950773328;\\n y = ((y * x) >> 96) + 57155421227552351082224309758442;\\n int256 p = y + x - 94201549194550492254356042504812;\\n p = ((p * y) >> 96) + 28719021644029726153956944680412240;\\n p = p * x + (4385272521454847904659076985693276 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n int256 q = x - 2855989394907223263936484059900;\\n q = ((q * x) >> 96) + 50020603652535783019961831881945;\\n q = ((q * x) >> 96) - 533845033583426703283633433725380;\\n q = ((q * x) >> 96) + 3604857256930695427073651918091429;\\n q = ((q * x) >> 96) - 14423608567350463180887372962807573;\\n q = ((q * x) >> 96) + 26449188498355588339934803723976023;\\n\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial won't have zeros in the domain as all its roots are complex.\\n // No scaling is necessary because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r should be in the range (0.09, 0.25) * 2**96.\\n\\n // We now need to multiply r by:\\n // * the scale factor s = ~6.031367120.\\n // * the 2**k factor from the range reduction.\\n // * the 1e18 / 2**96 factor for base conversion.\\n // We do this all at once, with an intermediate result in 2**213\\n // basis, so the final right shift is always by a positive amount.\\n r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));\\n }\\n }\\n\\n function lnWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n // We want to convert x from 10**18 fixed point to 2**96 fixed point.\\n // We do this by multiplying by 2**96 / 10**18. But since\\n // ln(x * C) = ln(x) + ln(C), we can simply do nothing here\\n // and add ln(2**96 / 10**18) at the end.\\n\\n // Reduce range of x to (1, 2) * 2**96\\n // ln(2^k * x) = k * ln(2) + ln(x)\\n int256 k = int256(log2(uint256(x))) - 96;\\n x <<= uint256(159 - k);\\n x = int256(uint256(x) >> 159);\\n\\n // Evaluate using a (8, 8)-term rational approximation.\\n // p is made monic, we will multiply by a scale factor later.\\n int256 p = x + 3273285459638523848632254066296;\\n p = ((p * x) >> 96) + 24828157081833163892658089445524;\\n p = ((p * x) >> 96) + 43456485725739037958740375743393;\\n p = ((p * x) >> 96) - 11111509109440967052023855526967;\\n p = ((p * x) >> 96) - 45023709667254063763336534515857;\\n p = ((p * x) >> 96) - 14706773417378608786704636184526;\\n p = p * x - (795164235651350426258249787498 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n // q is monic by convention.\\n int256 q = x + 5573035233440673466300451813936;\\n q = ((q * x) >> 96) + 71694874799317883764090561454958;\\n q = ((q * x) >> 96) + 283447036172924575727196451306956;\\n q = ((q * x) >> 96) + 401686690394027663651624208769553;\\n q = ((q * x) >> 96) + 204048457590392012362485061816622;\\n q = ((q * x) >> 96) + 31853899698501571402653359427138;\\n q = ((q * x) >> 96) + 909429971244387300277376558375;\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial is known not to have zeros in the domain.\\n // No scaling required because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r is in the range (0, 0.125) * 2**96\\n\\n // Finalization, we need to:\\n // * multiply by the scale factor s = 5.549\\u2026\\n // * add ln(2**96 / 10**18)\\n // * add k * ln(2)\\n // * multiply by 10**18 / 2**96 = 5**18 >> 78\\n\\n // mul s * 5e18 * 2**96, base is now 5**18 * 2**192\\n r *= 1677202110996718588342820967067443963516166;\\n // add ln(2) * k * 5e18 * 2**192\\n r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;\\n // add ln(2**96 / 10**18) * 5e18 * 2**192\\n r += 600920179829731861736702779321621459595472258049074101567377883020018308;\\n // base conversion: mul 2**18 / 2**192\\n r >>= 174;\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n LOW LEVEL FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function mulDivDown(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // Divide z by the denominator.\\n z := div(z, denominator)\\n }\\n }\\n\\n function mulDivUp(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // First, divide z - 1 by the denominator and add 1.\\n // We allow z - 1 to underflow if z is 0, because we multiply the\\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\\n }\\n }\\n\\n function rpow(\\n uint256 x,\\n uint256 n,\\n uint256 scalar\\n ) internal pure returns (uint256 z) {\\n assembly {\\n switch x\\n case 0 {\\n switch n\\n case 0 {\\n // 0 ** 0 = 1\\n z := scalar\\n }\\n default {\\n // 0 ** n = 0\\n z := 0\\n }\\n }\\n default {\\n switch mod(n, 2)\\n case 0 {\\n // If n is even, store scalar in z for now.\\n z := scalar\\n }\\n default {\\n // If n is odd, store x in z for now.\\n z := x\\n }\\n\\n // Shifting right by 1 is like dividing by 2.\\n let half := shr(1, scalar)\\n\\n for {\\n // Shift n right by 1 before looping to halve it.\\n n := shr(1, n)\\n } n {\\n // Shift n right by 1 each iteration to halve it.\\n n := shr(1, n)\\n } {\\n // Revert immediately if x ** 2 would overflow.\\n // Equivalent to iszero(eq(div(xx, x), x)) here.\\n if shr(128, x) {\\n revert(0, 0)\\n }\\n\\n // Store x squared.\\n let xx := mul(x, x)\\n\\n // Round to the nearest number.\\n let xxRound := add(xx, half)\\n\\n // Revert if xx + half overflowed.\\n if lt(xxRound, xx) {\\n revert(0, 0)\\n }\\n\\n // Set x to scaled xxRound.\\n x := div(xxRound, scalar)\\n\\n // If n is even:\\n if mod(n, 2) {\\n // Compute z * x.\\n let zx := mul(z, x)\\n\\n // If z * x overflowed:\\n if iszero(eq(div(zx, x), z)) {\\n // Revert if x is non-zero.\\n if iszero(iszero(x)) {\\n revert(0, 0)\\n }\\n }\\n\\n // Round to the nearest number.\\n let zxRound := add(zx, half)\\n\\n // Revert if zx + half overflowed.\\n if lt(zxRound, zx) {\\n revert(0, 0)\\n }\\n\\n // Return properly scaled zxRound.\\n z := div(zxRound, scalar)\\n }\\n }\\n }\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n GENERAL NUMBER UTILITIES\\n //////////////////////////////////////////////////////////////*/\\n\\n function sqrt(uint256 x) internal pure returns (uint256 z) {\\n assembly {\\n let y := x // We start y at x, which will help us make our initial estimate.\\n\\n z := 181 // The \\\"correct\\\" value is 1, but this saves a multiplication later.\\n\\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\\n\\n // We check y >= 2^(k + 8) but shift right by k bits\\n // each branch to ensure that if x >= 256, then y >= 256.\\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\\n y := shr(128, y)\\n z := shl(64, z)\\n }\\n if iszero(lt(y, 0x1000000000000000000)) {\\n y := shr(64, y)\\n z := shl(32, z)\\n }\\n if iszero(lt(y, 0x10000000000)) {\\n y := shr(32, y)\\n z := shl(16, z)\\n }\\n if iszero(lt(y, 0x1000000)) {\\n y := shr(16, y)\\n z := shl(8, z)\\n }\\n\\n // Goal was to get z*z*y within a small factor of x. More iterations could\\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\\n\\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\\n\\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\\n\\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\\n\\n // There is no overflow risk here since y < 2^136 after the first branch above.\\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\\n\\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n\\n // If x+1 is a perfect square, the Babylonian method cycles between\\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\\n z := sub(z, lt(div(x, z), z))\\n }\\n }\\n\\n function log2(uint256 x) internal pure returns (uint256 r) {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n assembly {\\n r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))\\n r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))\\n r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\\n r := or(r, shl(4, lt(0xffff, shr(r, x))))\\n r := or(r, shl(3, lt(0xff, shr(r, x))))\\n r := or(r, shl(2, lt(0xf, shr(r, x))))\\n r := or(r, shl(1, lt(0x3, shr(r, x))))\\n r := or(r, lt(0x1, shr(r, x)))\\n }\\n }\\n\\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := mod(x, y)\\n }\\n }\\n\\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := div(x, y)\\n }\\n }\\n\\n /// @dev Will return 0 instead of reverting if y is zero.\\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // Add 1 to x * y if x % y > 0.\\n z := add(gt(mod(x, y), 0), div(x, y))\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0bf1d4f3999a4471e0fded0a2f67e7fe328e2a27385348571b1fc0a8d9c9f62e\",\"license\":\"MIT\"},\"solmate/src/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Caution! This library won't check that a token has code, responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(4, from) // Append the \\\"from\\\" argument.\\n mstore(36, to) // Append the \\\"to\\\" argument.\\n mstore(68, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because that's the total length of our calldata (4 + 32 * 3)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 100, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x5f2e1158c68c1f3d15b80e8a7dd92b6849f873066969562ad33c0abb80e536ff\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60c06040523480156200001157600080fd5b5060405162005fbd38038062005fbd833981016040819052620000349162000065565b6001600160a01b039182166080521660a052620000a4565b6001600160a01b03811681146200006257600080fd5b50565b600080604083850312156200007957600080fd5b825162000086816200004c565b602084015190925062000099816200004c565b809150509250929050565b60805160a051615e7c620001416000396000818161012d01528181610251015261157401526000818161018c01528181610f12015281816116fe015281816117f40152818161195801528181611a4901528181611c2c0152818161240901528181612bf501528181612ceb01528181612e4f01528181612f40015281816145f401528181614a7601528181614bcd0152614d490152615e7c6000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80639241c920116100665780639241c920146101ae578063926da1b4146101c3578063a9563e4f146101e3578063ecd0cca014610227578063fcc5815b1461023a57600080fd5b8063372f554f146100a357806337ad93f1146100c95780634d20d0f8146101285780635ce3d8331461016757806360b3a03314610187575b600080fd5b6100b66100b1366004615118565b61024d565b6040519081526020015b60405180910390f35b6100dc6100d7366004615169565b610369565b6040516100c09190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c0565b61017a6101753660046151ce565b61079c565b6040516100c0919061528c565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6101c16101bc36600461548c565b610bfa565b005b6101d66101d136600461557a565b610d7c565b6040516100c0919061561a565b6102136101f13660046156c3565b600160209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff90911681526020016100c0565b6100dc610235366004615169565b61113c565b6100b6610248366004615118565b611496565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f7729d438686858761028d8b8b8a61168e565b516001600160a01b038c81169116146102c4576102bf600173fffd8963efd1fc6a506488495d951d5263988d26615712565b6102d4565b6102d46401000276a36001615739565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561033c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103609190615759565b95945050505050565b6103a26040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006103af8888886116f9565b6060830181905212156103d5576040516342a7200160e11b815260040160405180910390fd5b60006103e2888888611c27565b9050816060015185116104235784826060018181516104019190615772565b915081815250506104198888888560600151876123df565b608083015261047a565b808511610461576104348582615792565b6060830181905260001261045057670de0b6b3a7640000610419565b6104198888888560600151876123df565b6040516342a7200160e11b815260040160405180910390fd5b8160800151841161048b5783610491565b81608001515b8083526000906104c6908a908a906104c1906104b690670de0b6b3a764000090615792565b606088015190612bd2565b612bf0565b6104d089896130a1565b6104da9190615792565b905060006105ac8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054391906157b0565b8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a591906157b0565b600061168e565b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528190205462ffffff16908201529050816105f08a8a6130a1565b6105fa9190615792565b60208501526001600160a01b03808a16908b16036106af5760405163ce96cb7760e01b81526001600160a01b038981166004830152839189918d169063ce96cb7790602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106809190615759565b61068a9190615792565b6106949190615792565b60408501525050670de0b6b3a764000060a083015250610792565b6106bf8a8a848460400151611496565b60405163ce96cb7760e01b81526001600160a01b038a811660048301528991908d169063ce96cb7790602401602060405180830381865afa158015610708573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072c9190615759565b6107369190615792565b6107409190615792565b604085015260006107528a8c85612bf0565b1161076557670de0b6b3a7640000610789565b6107896107738a8c85612bf0565b6107838c8c868660400151611496565b90613186565b60a08501525050505b9695505050505050565b6107c76040518060800160405280600081526020016000815260200160008152602001606081525090565b6000806107df8a8a8a8a670de0b6b3a764000061319b565b509150915060008213610805576040516342a7200160e11b815260040160405180910390fd5b60008187101561093d57600061082561081e8985615792565b8590612bd2565b90506109358b6001600160a01b03168d6001600160a01b03161461084a57600061084c565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561088a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ae9190615759565b6108b89190615792565b6108c38e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109259190615759565b61092f9190615792565b90613270565b915050610a5a565b600061094c61081e848a615792565b9050610a568b6001600160a01b03168d6001600160a01b031614610971576000610973565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d59190615759565b6109df91906157d4565b6109ea8e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4c9190615759565b61092f91906157d4565b9150505b610b45610a6f670de0b6b3a764000089615792565b8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad191906157b0565b6001600160a01b03166384a87466846040518263ffffffff1660e01b8152600401610afe91815260200190565b602060405180830381865afa158015610b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3f9190615759565b90612bd2565b6020850152610b548688612bd2565b6040850152610b638588612bd2565b8452610be6610b718c613285565b8b6001600160a01b03168d6001600160a01b031614610b9857610b938c613285565b610bcb565b6040805160008082526020820190925290610bc9565b610bb6614ed7565b815260200190600190039081610bae5790505b505b8c6001600160a01b03168e6001600160a01b0316148a61426e565b606085015250919998505050505050505050565b600054610100900460ff1615808015610c1a5750600054600160ff909116105b80610c345750303b158015610c34575060005460ff166001145b610c3d57600080fd5b6000805460ff191660011790558015610c60576000805461ff0019166101001790555b8151835114610c7157610c716157e7565b60005b8351811015610d30576000610cdd858381518110610c9457610c946157fd565b602002602001015160000151868481518110610cb257610cb26157fd565b602002602001015160200151868581518110610cd057610cd06157fd565b602002602001015161168e565b60408181015182516001600160a01b039081166000908152600160208181528583209681015190931682529490915291909120805462ffffff191662ffffff909216919091179055919091019050610c74565b508015610d77576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b610d84614f0f565b604051632f2e037160e11b81526001600160a01b03848116600483015260009190861690635e5c06e290602401606060405180830381865afa158015610dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df29190615813565b60405163ce96cb7760e01b81526001600160a01b03888116600483015291945060009350908916915063ce96cb7790602401602060405180830381865afa158015610e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e659190615759565b90506000610e75888888886145cd565b90506000610e848989896116f9565b90506000610ec98a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b80516001600160a01b03908116600090815260016020908152604080832082860151851684529091528082205462ffffff16908401529192508b8116908b161461100d57610f987f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635b5491826040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9291906157b0565b83614984565b6001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015610fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff99190615874565b50506001600160a01b039094169450505050505b60405180610140016040528060008513611028576000611032565b6110328786613186565b81526020018b6001600160a01b03166347dffde0896040518263ffffffff1660e01b815260040161106591815260200190565b602060405180830381865afa158015611082573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a69190615759565b81526020018681526020018481526020016110d48d8d8d600089136110cc5760006110ce565b885b8e6123df565b8152602001858710156110f0576110eb8787615792565b6110f3565b60005b815260200160008513611107576000611112565b6111128d8d8d611c27565b815260200183815260200182815260200161112b614a70565b90529b9a5050505050505050505050565b6111756040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000611184888888888761319b565b608085015260608401919091529050808410806111a45750816080015184115b6111ae57836111b0565b805b826000018181525050600061125e896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122091906157b0565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528181205462ffffff1691830191909152606085015191925012611338576112af88886130a1565b602084015260405163ce96cb7760e01b81526001600160a01b0388811660048301528791908b169063ce96cb7790602401602060405180830381865afa1580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113219190615759565b61132b91906157d4565b6040840152506107929050565b8251606084015161134891614e5f565b60408401526001600160a01b03808916908a160361139e5782516113849061137990670de0b6b3a764000090615792565b606085015190612bd2565b60208401525050670de0b6b3a764000060a0820152610792565b60405163ce96cb7760e01b81526001600160a01b03888116600483015260009188918c169063ce96cb7790602401602060405180830381865afa1580156113e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140d9190615759565b856040015161141c9190615792565b6114269190615792565b9050611438898b838560400151611496565b6114428a8a6130a1565b61144c91906157d4565b6020850152801580159061146a575060006114688b8b84612bf0565b115b61147c57670de0b6b3a7640000610789565b61078961148a8b8b84612bf0565b6107838b8d8587604001515b600080856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fb91906157b0565b90506000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561153d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156191906157b0565b905060008511611572576000611683565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166330d07f21838387896115b088888c61168e565b516001600160a01b038981169116146115e7576115e2600173fffd8963efd1fc6a506488495d951d5263988d26615712565b6115f7565b6115f76401000276a36001615739565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561165f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116839190615759565b979650505050505050565b6040805160608101825260008082526020820181905291810191909152826001600160a01b0316846001600160a01b031611156116c9579192915b50604080516060810182526001600160a01b03948516815292909316602083015262ffffff169181019190915290565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156117c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ea9190615906565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611850573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187491906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156118bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e09190615906565b945050505050611bb3866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194b919061597d565b61195690600a615a7c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119d891906157b0565b604051631710760b60e31b81526001600160a01b038681166004830152919091169063b883b05890602401602060405180830381865afa158015611a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a449190615759565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac991906157b0565b604051631710760b60e31b81526001600160a01b038781166004830152919091169063b883b05890602401602060405180830381865afa158015611b11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b359190615759565b896001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b97919061597d565b611ba290600a615a7c565b611bac8b8b6130a1565b9190614e74565b60405163ce96cb7760e01b81526001600160a01b03868116600483015288169063ce96cb7790602401602060405180830381865afa158015611bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1d9190615759565b6107929190615772565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cac91906157b0565b9050611d1d604051806101600160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b60405160016263e28d60e11b031981526001600160a01b03858116600483015283169063ff383ae690602401602060405180830381865afa158015611d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8a9190615759565b60c082015260006101208201525b60c08101511561222a5760c08101516001161561220b576040805160a081018252600080825260208083018290528284018290526060808401839052608084018390528451908101855282815290810182905292830152906101208301516040516308cae55b60e21b815260048101919091526001600160a01b0385169063232b956c90602401602060405180830381865afa158015611e3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6091906157b0565b6001600160a01b039081166101408501819052604051638e8f294b60e01b8152600481019190915290851690638e8f294b9060240160a060405180830381865afa158015611eb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed69190615906565b6001600160a01b03908116608088015260ff93909316602087015250506001600160801b0391909116835261014084015160405163014a296f60e01b8152888316600482015291169063014a296f906024016040805180830381865afa158015611f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f689190615a8b565b602083015281526080820151604051631710760b60e31b81526001600160a01b0391821660048201529085169063b883b05890602401602060405180830381865afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fdf9190615759565b6040820181905282516020840151612015926001600160801b0390921691610b3f9161200c90600a615a7c565b85519190614e74565b8360600181815161202691906157d4565b90525081516040820151602084015161205e926001600160801b03169161092f9161205290600a615a7c565b60208601519190614e93565b8351849061206d9083906157d4565b905250600061207c88886130a1565b9050876001600160a01b03168461014001516001600160a01b0316036120d4576120ce83600001516001600160801b031661092f84604001518660200151600a6120c69190615a7c565b859190614e93565b60208501525b886001600160a01b03168461014001516001600160a01b0316036122075761215683600001516001600160801b0316610b3f84604001518660200151600a61211c9190615a7c565b60008611801561213e57508d6001600160a01b03168d6001600160a01b031614155b6121485785611bac565b611bac8e8e886101f4611496565b608085018190528351604084015160208601516121f7926001600160801b031691610b3f9161218690600a615a7c565b6101408a015160405163ce96cb7760e01b81526001600160a01b038f811660048301529091169063ce96cb7790602401602060405180830381865afa1580156121d3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bac9190615759565b6122019190615792565b60408501525b5050505b61012081018051600190810190915260c08201805190911c9052611d98565b604051638e8f294b60e01b81526001600160a01b038781166004830152831690638e8f294b9060240160a060405180830381865afa158015612270573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122949190615906565b6001600160a01b0390811660a08701526001600160801b0390941660e086018190526040805163313ce56760e01b81529051610792969295506107839450918c16925063313ce5679160048083019260209291908290030181865afa158015612301573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612325919061597d565b61233090600a615a7c565b60a0850151604051631710760b60e31b81526001600160a01b0391821660048201529087169063b883b05890602401602060405180830381865afa15801561237c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a09190615759565b611bac86608001518760000151886020015189606001516123c191906157d4565b6123cb9190615792565b6123d59190615792565b8760400151614ec1565b600061240560405180606001604052806000815260200160008152602001600081525090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612465573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248991906157b0565b60405160016263e28d60e11b031981526001600160a01b03888116600483015291925060009183169063ff383ae690602401602060405180830381865afa1580156124d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fc9190615759565b905060005b8115612894576001821615612888576040516308cae55b60e21b8152600481018290526000906001600160a01b0385169063232b956c90602401602060405180830381865afa158015612558573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257c91906157b0565b90506125af6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6125d360405180606001604052806000815260200160008152602001600081525090565b604051638e8f294b60e01b81526001600160a01b038481166004830152871690638e8f294b9060240160a060405180830381865afa158015612619573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263d9190615906565b6001600160a01b039081166080880181905260ff9490941660208801526001600160801b039490941686525050604051631710760b60e31b815260048101919091529087169063b883b05890602401602060405180830381865afa1580156126a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126cd9190615759565b6040828101919091525163014a296f60e01b81526001600160a01b038c8116600483015284169063014a296f906024016040805180830381865afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273d9190615a8b565b6020830152506001600160a01b03808d169084160361284857604051632f2e037160e11b81526001600160a01b038c8116600483015260009190851690635e5c06e290602401606060405180830381865afa1580156127a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c49190615813565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561280e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128329190615759565b826020018181516128439190615792565b905250505b61287282600001516001600160801b031661092f83604001518560200151600a6120529190615a7c565b875188906128819083906157d4565b9052505050505b600191821c9101612501565b50604051638e8f294b60e01b81526001600160a01b038a81166004830152831690638e8f294b9060240160a060405180830381865afa1580156128db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ff9190615906565b505050506001600160801b03166020840152604051638e8f294b60e01b81526001600160a01b038981166004830152831690638e8f294b9060240160a060405180830381865afa158015612957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297b9190615906565b505050506001600160801b031660408481019190915251638e8f294b60e01b81526001600160a01b038a8116600483015260009190841690638e8f294b9060240160a060405180830381865afa1580156129d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fd9190615906565b945050505050612aed8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a68919061597d565b612a7390600a615a7c565b604051631710760b60e31b81526001600160a01b03848116600483015286169063b883b05890602401602060405180830381865afa158015612ab9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612add9190615759565b60408701518751611bac91612bd2565b8452861580612afc5750835187105b80612b495750670de0b6b3a7640000612b47612b31886107838860400151610b3f8a602001518e612bd290919063ffffffff16565b612b3b908a615792565b8651610783908b615792565b105b15612b8857612b7d612b6c85604001518660200151612bd290919063ffffffff16565b612b769088615792565b8790613186565b945050505050610360565b612bc4612bae876107838760400151610b3f89602001518d612bd290919063ffffffff16565b612bb89089615792565b8551610783908a615792565b9a9950505050505050505050565b6000612be78383670de0b6b3a7640000614e74565b90505b92915050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7591906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce19190615906565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6b91906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612db3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd79190615906565b945050505050610792856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e42919061597d565b612e4d90600a615a7c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ecf91906157b0565b604051631710760b60e31b81526001600160a01b038581166004830152919091169063b883b05890602401602060405180830381865afa158015612f17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3b9190615759565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc091906157b0565b604051631710760b60e31b81526001600160a01b038881166004830152919091169063b883b05890602401602060405180830381865afa158015613008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061302c9190615759565b8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561306a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308e919061597d565b61309990600a615a7c565b899190614e74565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa1580156130ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131109190615813565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561315a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317e9190615759565b949350505050565b6000612be783670de0b6b3a764000084614e74565b6000806000846131ac8989896116f9565b6131b69190615aaf565b925060008313156132545760405163ce96cb7760e01b81526001600160a01b03878116600483015261323e9185918891908c169063ce96cb7790602401602060405180830381865afa158015613210573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132349190615759565b61092f9190615aaf565b915061324d88888886886123df565b9050613265565b6132628888886000886123df565b90505b955095509592505050565b6000612be783670de0b6b3a764000084614e93565b606061328f614f83565b826001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132f191906157b0565b6001600160a01b03168082521561426857826001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336491906157b0565b604051638e8f294b60e01b81526001600160a01b0385811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156133ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d09190615906565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015613444573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261346c9190810190615ad7565b6101408201819052516001600160401b0381111561348c5761348c615366565b6040519080825280602002602001820160405280156134c557816020015b6134b2614ed7565b8152602001906001900390816134aa5790505b5060006101a083015291505b80610140015151816101a0015110156142685780600001516001600160a01b031663f2426f9a84836101400151846101a0015181518110613514576135146157fd565b60200260200101516040518363ffffffff1660e01b815260040161354e9291906001600160a01b0392831681529116602082015260400190565b6101c060405180830381865afa15801561356c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135909190615ba2565b81610120018190525080600001516001600160a01b03166344e250f884836101400151846101a00151815181106135c9576135c96157fd565b60200260200101516040518363ffffffff1660e01b81526004016136039291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa158015613620573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136449190615813565b506040830152606082015280516101408201516101a083015181516001600160a01b039093169263fc19606892879290918110613683576136836157fd565b60200260200101518461012001516060015163ffffffff1642116136a85760006136af565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613701573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137259190615813565b50608083015260a082015280516101408201516101a083015181516001600160a01b0390931692635684aa4692879290918110613764576137646157fd565b60200260200101516040518363ffffffff1660e01b815260040161379e9291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa1580156137bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137df9190615c96565b505063ffffffff166101c082018190526224ea00906137ff908290615cef565b826101c0015161380f9190615792565b61381991906157d4565b81610240018181525050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613861573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613885919061597d565b6138959060ff166224ea00615d03565b6138a26224ea0042615cef565b6138ac9042615792565b6138b691906157d4565b61022082018190526102408201516224ea00916138d39190615792565b6138dd9190615d1a565b6138e89060016157d4565b6001600160401b038111156138ff576138ff615366565b604051908082528060200260200182016040528015613928578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e0015111613a30576101e0810151604051630156d37d60e31b81526000916001600160a01b03861691630ab69be89161398b9160040190815260200190565b6040805180830381865afa1580156139a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139cb9190615a8b565b5090508082610200018181516139e191906157d4565b9052506101e082015160e08301516101c084015181518110613a0557613a056157fd565b6020908102919091010152506101e0810180516224ea000190526101c0810180516001019052613943565b6040518060a00160405280826101400151836101a0015181518110613a5757613a576157fd565b60200260200101516001600160a01b03168152602001826101400151836101a0015181518110613a8957613a896157fd565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015613ace573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613af69190810190615d2e565b8152602001826101400151836101a0015181518110613b1757613b176157fd565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015613b5c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613b849190810190615d2e565b81526020016000836102000151866001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bf39190615759565b613bfd91906157d4565b11613c09576000613f3c565b613f3c6301e13380846101800151611bac8660c00151613d668a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613c60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c8491906157b0565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cf49190615759565b8961020001518c6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d5c9190615759565b610b3f91906157d4565b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613da7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dcb91906157b0565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613e1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e409190615759565b610b3f8d6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b8152600401613e7691815260200190565b602060405180830381865afa158015613e93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eb79190615759565b8e6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ef5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f199190615759565b613f2391906157d4565b8c60c001518d606001518e60a00151611bac9190615792565b81526020016000856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613f81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fa59190615759565b11613fb1576000614232565b6142326301e13380846101800151611bac8660c001516140da8a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061402c91906157b0565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015614078573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061409c9190615759565b8b6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1b573d6000803e3d6000fd5b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561411b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061413f91906157b0565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015614190573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141b49190615759565b610b3f8d6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156141f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142199190615759565b8c60c001518d604001518e60800151611bac9190615792565b81525082826101a001518151811061424c5761424c6157fd565b60209081029190910101526101a08101805160010190526134d1565b50919050565b60608351855161427e91906157d4565b6001600160401b0381111561429557614295615366565b6040519080825280602002602001820160405280156142ce57816020015b6142bb614ed7565b8152602001906001900390816142b35790505b50905060005b85518110156144695761430d838783815181106142f3576142f36157fd565b602002602001015160800151612bd290919063ffffffff16565b82828151811061431f5761431f6157fd565b6020026020010151608001818152505083156143995761437661434a670de0b6b3a764000085615792565b87838151811061435c5761435c6157fd565b602002602001015160600151612bd290919063ffffffff16565b828281518110614388576143886157fd565b602002602001015160600181815250505b8581815181106143ab576143ab6157fd565b6020026020010151600001518282815181106143c9576143c96157fd565b60209081029190910101516001600160a01b03909116905285518690829081106143f5576143f56157fd565b602002602001015160200151828281518110614413576144136157fd565b602002602001015160200181905250858181518110614434576144346157fd565b602002602001015160400151828281518110614452576144526157fd565b6020908102919091010151604001526001016142d4565b836145c4575060005b84518110156145c4576144a2614490670de0b6b3a764000085615792565b86838151811061435c5761435c6157fd565b828751836144b091906157d4565b815181106144c0576144c06157fd565b602002602001015160600181815250508481815181106144e2576144e26157fd565b602002602001015160000151828751836144fc91906157d4565b8151811061450c5761450c6157fd565b60209081029190910101516001600160a01b0390911690528451859082908110614538576145386157fd565b6020026020010151602001518287518361455291906157d4565b81518110614562576145626157fd565b602002602001015160200181905250848181518110614583576145836157fd565b6020026020010151604001518287518361459d91906157d4565b815181106145ad576145ad6157fd565b602090810291909101015160400152600101614472565b50949350505050565b604080516080810182526000808252602082018190529181018290526060810182905260007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614650573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061467491906157b0565b604051638e8f294b60e01b81526001600160a01b03898116600483015291925090821690638e8f294b9060240160a060405180830381865afa1580156146be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e29190615906565b6001600160a01b039081166040888101919091526001600160801b039590951687529351638e8f294b60e01b81528a8516600482015293851693638e8f294b9350602401915061472f9050565b60a060405180830381865afa15801561474c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147709190615906565b6001600160a01b0390811660608801526001600160801b039094166020808801919091526040805163313ce56760e01b81529051611683968e16955063313ce56794506004808301945090918290030181865afa1580156147d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147f9919061597d565b61480490600a615a7c565b6040848101519051631710760b60e31b81526001600160a01b0391821660048201529084169063b883b05890602401602060405180830381865afa158015614850573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148749190615759565b8451602086015161497d916148899190612bd2565b6060870151604051631710760b60e31b81526001600160a01b0391821660048201526107839188169063b883b05890602401602060405180830381865afa1580156148d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148fc9190615759565b8c6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561493a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061495e919061597d565b61496990600a615a7c565b611bac6149768f8f6130a1565b8d90612bd2565b9190614e93565b600081602001516001600160a01b031682600001516001600160a01b0316106149af576149af6157e7565b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6bffffffffffffffffffffffff191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ad2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614af691906157b0565b6001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015614b33573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052614b5b9190810190615db8565b519050806001600160401b03811115614b7657614b76615366565b604051908082528060200260200182016040528015614bbb57816020015b6040805180820190915260008082526020820152815260200190600190039081614b945790505b50915060005b81811015614e5a5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4d91906157b0565b6001600160a01b031663232b956c836040518263ffffffff1660e01b8152600401614c7a91815260200190565b602060405180830381865afa158015614c97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614cbb91906157b0565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d1c91906157b0565b90506040518060400160405280826001600160a01b03168152602001826001600160a01b03166370a082317f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663158274a56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dc991906157b0565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015614e0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e319190615759565b815250848381518110614e4657614e466157fd565b602090810291909101015250600101614bc1565b505090565b6000612be78383670de0b6b3a7640000614e93565b828202811515841585830485141716614e8c57600080fd5b0492915050565b828202811515841585830485141716614eab57600080fd5b6001826001830304018115150290509392505050565b6000818310614ed05781612be7565b5090919050565b6040518060a0016040528060006001600160a01b03168152602001606081526020016060815260200160008152602001600081525090565b60405180610140016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001614f6f604080516060810182526000808252602082018190529181019190915290565b815260200160008152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b031681526020016150a3604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03811681146150fd57600080fd5b50565b803562ffffff8116811461511357600080fd5b919050565b6000806000806080858703121561512e57600080fd5b8435615139816150e8565b93506020850135615149816150e8565b92506040850135915061515e60608601615100565b905092959194509250565b60008060008060008060c0878903121561518257600080fd5b863561518d816150e8565b9550602087013561519d816150e8565b945060408701356151ad816150e8565b959894975094956060810135955060808101359460a0909101359350915050565b600080600080600080600060e0888a0312156151e957600080fd5b87356151f4816150e8565b96506020880135615204816150e8565b95506040880135615214816150e8565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b60005b8381101561525757818101518382015260200161523f565b50506000910152565b6000815180845261527881602086016020860161523c565b601f01601f19169290920160200192915050565b6000602080835260a0808401855183860152828601516040818188015280880151915060608281890152808901519250608080818a015284845180875260c08b01915060c08160051b8c01019650888601955060005b81811015615355578b880360bf19018352865180516001600160a01b031689528a8101518b8a018b90526153188b8b0182615260565b9050878201518a8203898c015261532f8282615260565b838901518c8a0152928701519a87019a909a5250975095890195918901916001016152e2565b50959b9a5050505050505050505050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b038111828210171561539e5761539e615366565b60405290565b6040516101c081016001600160401b038111828210171561539e5761539e615366565b604051601f8201601f191681016001600160401b03811182821017156153ef576153ef615366565b604052919050565b60006001600160401b0382111561541057615410615366565b5060051b60200190565b600082601f83011261542b57600080fd5b8135602061544061543b836153f7565b6153c7565b82815260059290921b8401810191818101908684111561545f57600080fd5b8286015b848110156154815761547481615100565b8352918301918301615463565b509695505050505050565b60008060408084860312156154a057600080fd5b83356001600160401b03808211156154b757600080fd5b818601915086601f8301126154cb57600080fd5b813560206154db61543b836153f7565b82815260069290921b8401810191818101908a8411156154fa57600080fd5b948201945b8386101561554c5786868c0312156155175760008081fd5b61551f61537c565b863561552a816150e8565b815286840135615539816150e8565b81850152825294860194908201906154ff565b9750508701359350508083111561556257600080fd5b50506155708582860161541a565b9150509250929050565b6000806000806080858703121561559057600080fd5b843561559b816150e8565b935060208501356155ab816150e8565b925060408501356155bb816150e8565b9396929550929360600135925050565b600081518084526020808501945080840160005b8381101561560f57815180516001600160a01b0316885283015183880152604090960195908201906001016155df565b509495945050505050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e0820152600060e083015161010061569e8185018380516001600160a01b0390811683526020808301519091169083015260409081015162ffffff16910152565b840151610160840152506101208301516101808084015261317e6101a08401826155cb565b600080604083850312156156d657600080fd5b82356156e1816150e8565b915060208301356156f1816150e8565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03828116828216039080821115615732576157326156fc565b5092915050565b6001600160a01b03818116838216019080821115615732576157326156fc565b60006020828403121561576b57600080fd5b5051919050565b8181036000831280158383131683831282161715615732576157326156fc565b81810381811115612bea57612bea6156fc565b8051615113816150e8565b6000602082840312156157c257600080fd5b81516157cd816150e8565b9392505050565b80820180821115612bea57612bea6156fc565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008060006060848603121561582857600080fd5b8351925060208401519150604084015190509250925092565b805161ffff8116811461511357600080fd5b805160ff8116811461511357600080fd5b8051801515811461511357600080fd5b600080600080600080600060e0888a03121561588f57600080fd5b875161589a816150e8565b8097505060208801518060020b81146158b257600080fd5b95506158c060408901615841565b94506158ce60608901615841565b93506158dc60808901615841565b92506158ea60a08901615853565b91506158f860c08901615864565b905092959891949750929550565b600080600080600060a0868803121561591e57600080fd5b85516001600160801b038116811461593557600080fd5b945061594360208701615853565b935061595160408701615853565b925061595f60608701615864565b9150608086015161596f816150e8565b809150509295509295909350565b60006020828403121561598f57600080fd5b612be782615853565b600181815b808511156159d35781600019048211156159b9576159b96156fc565b808516156159c657918102915b93841c939080029061599d565b509250929050565b6000826159ea57506001612bea565b816159f757506000612bea565b8160018114615a0d5760028114615a1757615a33565b6001915050612bea565b60ff841115615a2857615a286156fc565b50506001821b612bea565b5060208310610133831016604e8410600b8410161715615a56575081810a612bea565b615a608383615998565b8060001904821115615a7457615a746156fc565b029392505050565b6000612be760ff8416836159db565b60008060408385031215615a9e57600080fd5b505080516020909101519092909150565b8082018281126000831280158216821582161715615acf57615acf6156fc565b505092915050565b60006020808385031215615aea57600080fd5b82516001600160401b03811115615b0057600080fd5b8301601f81018513615b1157600080fd5b8051615b1f61543b826153f7565b81815260059190911b82018301908381019087831115615b3e57600080fd5b928401925b82841015611683578351615b56816150e8565b82529284019290840190615b43565b805163ffffffff8116811461511357600080fd5b8051600f81900b811461511357600080fd5b80516001600160401b038116811461511357600080fd5b60006101c08284031215615bb557600080fd5b615bbd6153a4565b615bc6836157a5565b8152615bd4602084016157a5565b6020820152615be5604084016157a5565b6040820152615bf660608401615b65565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615c31818501615b79565b90820152610120615c43848201615b8b565b90820152610140615c55848201615b8b565b90820152610160615c67848201615b8b565b90820152610180615c79848201615b8b565b908201526101a0615c8b848201615b8b565b908201529392505050565b600080600060608486031215615cab57600080fd5b615cb484615b65565b9250615cc260208501615b65565b9150615cd060408501615b65565b90509250925092565b634e487b7160e01b600052601260045260246000fd5b600082615cfe57615cfe615cd9565b500690565b8082028115828204841417612bea57612bea6156fc565b600082615d2957615d29615cd9565b500490565b600060208284031215615d4057600080fd5b81516001600160401b0380821115615d5757600080fd5b818401915084601f830112615d6b57600080fd5b815181811115615d7d57615d7d615366565b615d90601f8201601f19166020016153c7565b9150808252856020828501011115615da757600080fd5b6145c481602084016020860161523c565b60006020808385031215615dcb57600080fd5b82516001600160401b03811115615de157600080fd5b8301601f81018513615df257600080fd5b8051615e0061543b826153f7565b81815260059190911b82018301908381019087831115615e1f57600080fd5b928401925b82841015611683578351615e37816150e8565b82529284019290840190615e2456fea2646970667358221220a158b43fa62c2fe56cbeeabd92d9dc0d913e14f5fb4a89bf76dedefbb16d3c9664736f6c63430008110033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80639241c920116100665780639241c920146101ae578063926da1b4146101c3578063a9563e4f146101e3578063ecd0cca014610227578063fcc5815b1461023a57600080fd5b8063372f554f146100a357806337ad93f1146100c95780634d20d0f8146101285780635ce3d8331461016757806360b3a03314610187575b600080fd5b6100b66100b1366004615118565b61024d565b6040519081526020015b60405180910390f35b6100dc6100d7366004615169565b610369565b6040516100c09190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c0565b61017a6101753660046151ce565b61079c565b6040516100c0919061528c565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6101c16101bc36600461548c565b610bfa565b005b6101d66101d136600461557a565b610d7c565b6040516100c0919061561a565b6102136101f13660046156c3565b600160209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff90911681526020016100c0565b6100dc610235366004615169565b61113c565b6100b6610248366004615118565b611496565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f7729d438686858761028d8b8b8a61168e565b516001600160a01b038c81169116146102c4576102bf600173fffd8963efd1fc6a506488495d951d5263988d26615712565b6102d4565b6102d46401000276a36001615739565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561033c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103609190615759565b95945050505050565b6103a26040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006103af8888886116f9565b6060830181905212156103d5576040516342a7200160e11b815260040160405180910390fd5b60006103e2888888611c27565b9050816060015185116104235784826060018181516104019190615772565b915081815250506104198888888560600151876123df565b608083015261047a565b808511610461576104348582615792565b6060830181905260001261045057670de0b6b3a7640000610419565b6104198888888560600151876123df565b6040516342a7200160e11b815260040160405180910390fd5b8160800151841161048b5783610491565b81608001515b8083526000906104c6908a908a906104c1906104b690670de0b6b3a764000090615792565b606088015190612bd2565b612bf0565b6104d089896130a1565b6104da9190615792565b905060006105ac8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054391906157b0565b8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a591906157b0565b600061168e565b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528190205462ffffff16908201529050816105f08a8a6130a1565b6105fa9190615792565b60208501526001600160a01b03808a16908b16036106af5760405163ce96cb7760e01b81526001600160a01b038981166004830152839189918d169063ce96cb7790602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106809190615759565b61068a9190615792565b6106949190615792565b60408501525050670de0b6b3a764000060a083015250610792565b6106bf8a8a848460400151611496565b60405163ce96cb7760e01b81526001600160a01b038a811660048301528991908d169063ce96cb7790602401602060405180830381865afa158015610708573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072c9190615759565b6107369190615792565b6107409190615792565b604085015260006107528a8c85612bf0565b1161076557670de0b6b3a7640000610789565b6107896107738a8c85612bf0565b6107838c8c868660400151611496565b90613186565b60a08501525050505b9695505050505050565b6107c76040518060800160405280600081526020016000815260200160008152602001606081525090565b6000806107df8a8a8a8a670de0b6b3a764000061319b565b509150915060008213610805576040516342a7200160e11b815260040160405180910390fd5b60008187101561093d57600061082561081e8985615792565b8590612bd2565b90506109358b6001600160a01b03168d6001600160a01b03161461084a57600061084c565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561088a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ae9190615759565b6108b89190615792565b6108c38e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109259190615759565b61092f9190615792565b90613270565b915050610a5a565b600061094c61081e848a615792565b9050610a568b6001600160a01b03168d6001600160a01b031614610971576000610973565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d59190615759565b6109df91906157d4565b6109ea8e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4c9190615759565b61092f91906157d4565b9150505b610b45610a6f670de0b6b3a764000089615792565b8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad191906157b0565b6001600160a01b03166384a87466846040518263ffffffff1660e01b8152600401610afe91815260200190565b602060405180830381865afa158015610b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3f9190615759565b90612bd2565b6020850152610b548688612bd2565b6040850152610b638588612bd2565b8452610be6610b718c613285565b8b6001600160a01b03168d6001600160a01b031614610b9857610b938c613285565b610bcb565b6040805160008082526020820190925290610bc9565b610bb6614ed7565b815260200190600190039081610bae5790505b505b8c6001600160a01b03168e6001600160a01b0316148a61426e565b606085015250919998505050505050505050565b600054610100900460ff1615808015610c1a5750600054600160ff909116105b80610c345750303b158015610c34575060005460ff166001145b610c3d57600080fd5b6000805460ff191660011790558015610c60576000805461ff0019166101001790555b8151835114610c7157610c716157e7565b60005b8351811015610d30576000610cdd858381518110610c9457610c946157fd565b602002602001015160000151868481518110610cb257610cb26157fd565b602002602001015160200151868581518110610cd057610cd06157fd565b602002602001015161168e565b60408181015182516001600160a01b039081166000908152600160208181528583209681015190931682529490915291909120805462ffffff191662ffffff909216919091179055919091019050610c74565b508015610d77576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b610d84614f0f565b604051632f2e037160e11b81526001600160a01b03848116600483015260009190861690635e5c06e290602401606060405180830381865afa158015610dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df29190615813565b60405163ce96cb7760e01b81526001600160a01b03888116600483015291945060009350908916915063ce96cb7790602401602060405180830381865afa158015610e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e659190615759565b90506000610e75888888886145cd565b90506000610e848989896116f9565b90506000610ec98a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b80516001600160a01b03908116600090815260016020908152604080832082860151851684529091528082205462ffffff16908401529192508b8116908b161461100d57610f987f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635b5491826040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9291906157b0565b83614984565b6001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015610fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff99190615874565b50506001600160a01b039094169450505050505b60405180610140016040528060008513611028576000611032565b6110328786613186565b81526020018b6001600160a01b03166347dffde0896040518263ffffffff1660e01b815260040161106591815260200190565b602060405180830381865afa158015611082573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a69190615759565b81526020018681526020018481526020016110d48d8d8d600089136110cc5760006110ce565b885b8e6123df565b8152602001858710156110f0576110eb8787615792565b6110f3565b60005b815260200160008513611107576000611112565b6111128d8d8d611c27565b815260200183815260200182815260200161112b614a70565b90529b9a5050505050505050505050565b6111756040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000611184888888888761319b565b608085015260608401919091529050808410806111a45750816080015184115b6111ae57836111b0565b805b826000018181525050600061125e896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122091906157b0565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528181205462ffffff1691830191909152606085015191925012611338576112af88886130a1565b602084015260405163ce96cb7760e01b81526001600160a01b0388811660048301528791908b169063ce96cb7790602401602060405180830381865afa1580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113219190615759565b61132b91906157d4565b6040840152506107929050565b8251606084015161134891614e5f565b60408401526001600160a01b03808916908a160361139e5782516113849061137990670de0b6b3a764000090615792565b606085015190612bd2565b60208401525050670de0b6b3a764000060a0820152610792565b60405163ce96cb7760e01b81526001600160a01b03888116600483015260009188918c169063ce96cb7790602401602060405180830381865afa1580156113e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140d9190615759565b856040015161141c9190615792565b6114269190615792565b9050611438898b838560400151611496565b6114428a8a6130a1565b61144c91906157d4565b6020850152801580159061146a575060006114688b8b84612bf0565b115b61147c57670de0b6b3a7640000610789565b61078961148a8b8b84612bf0565b6107838b8d8587604001515b600080856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fb91906157b0565b90506000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561153d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156191906157b0565b905060008511611572576000611683565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166330d07f21838387896115b088888c61168e565b516001600160a01b038981169116146115e7576115e2600173fffd8963efd1fc6a506488495d951d5263988d26615712565b6115f7565b6115f76401000276a36001615739565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561165f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116839190615759565b979650505050505050565b6040805160608101825260008082526020820181905291810191909152826001600160a01b0316846001600160a01b031611156116c9579192915b50604080516060810182526001600160a01b03948516815292909316602083015262ffffff169181019190915290565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156117c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ea9190615906565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611850573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187491906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156118bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e09190615906565b945050505050611bb3866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194b919061597d565b61195690600a615a7c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119d891906157b0565b604051631710760b60e31b81526001600160a01b038681166004830152919091169063b883b05890602401602060405180830381865afa158015611a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a449190615759565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac991906157b0565b604051631710760b60e31b81526001600160a01b038781166004830152919091169063b883b05890602401602060405180830381865afa158015611b11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b359190615759565b896001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b97919061597d565b611ba290600a615a7c565b611bac8b8b6130a1565b9190614e74565b60405163ce96cb7760e01b81526001600160a01b03868116600483015288169063ce96cb7790602401602060405180830381865afa158015611bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1d9190615759565b6107929190615772565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cac91906157b0565b9050611d1d604051806101600160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b60405160016263e28d60e11b031981526001600160a01b03858116600483015283169063ff383ae690602401602060405180830381865afa158015611d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8a9190615759565b60c082015260006101208201525b60c08101511561222a5760c08101516001161561220b576040805160a081018252600080825260208083018290528284018290526060808401839052608084018390528451908101855282815290810182905292830152906101208301516040516308cae55b60e21b815260048101919091526001600160a01b0385169063232b956c90602401602060405180830381865afa158015611e3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6091906157b0565b6001600160a01b039081166101408501819052604051638e8f294b60e01b8152600481019190915290851690638e8f294b9060240160a060405180830381865afa158015611eb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed69190615906565b6001600160a01b03908116608088015260ff93909316602087015250506001600160801b0391909116835261014084015160405163014a296f60e01b8152888316600482015291169063014a296f906024016040805180830381865afa158015611f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f689190615a8b565b602083015281526080820151604051631710760b60e31b81526001600160a01b0391821660048201529085169063b883b05890602401602060405180830381865afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fdf9190615759565b6040820181905282516020840151612015926001600160801b0390921691610b3f9161200c90600a615a7c565b85519190614e74565b8360600181815161202691906157d4565b90525081516040820151602084015161205e926001600160801b03169161092f9161205290600a615a7c565b60208601519190614e93565b8351849061206d9083906157d4565b905250600061207c88886130a1565b9050876001600160a01b03168461014001516001600160a01b0316036120d4576120ce83600001516001600160801b031661092f84604001518660200151600a6120c69190615a7c565b859190614e93565b60208501525b886001600160a01b03168461014001516001600160a01b0316036122075761215683600001516001600160801b0316610b3f84604001518660200151600a61211c9190615a7c565b60008611801561213e57508d6001600160a01b03168d6001600160a01b031614155b6121485785611bac565b611bac8e8e886101f4611496565b608085018190528351604084015160208601516121f7926001600160801b031691610b3f9161218690600a615a7c565b6101408a015160405163ce96cb7760e01b81526001600160a01b038f811660048301529091169063ce96cb7790602401602060405180830381865afa1580156121d3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bac9190615759565b6122019190615792565b60408501525b5050505b61012081018051600190810190915260c08201805190911c9052611d98565b604051638e8f294b60e01b81526001600160a01b038781166004830152831690638e8f294b9060240160a060405180830381865afa158015612270573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122949190615906565b6001600160a01b0390811660a08701526001600160801b0390941660e086018190526040805163313ce56760e01b81529051610792969295506107839450918c16925063313ce5679160048083019260209291908290030181865afa158015612301573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612325919061597d565b61233090600a615a7c565b60a0850151604051631710760b60e31b81526001600160a01b0391821660048201529087169063b883b05890602401602060405180830381865afa15801561237c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a09190615759565b611bac86608001518760000151886020015189606001516123c191906157d4565b6123cb9190615792565b6123d59190615792565b8760400151614ec1565b600061240560405180606001604052806000815260200160008152602001600081525090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612465573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248991906157b0565b60405160016263e28d60e11b031981526001600160a01b03888116600483015291925060009183169063ff383ae690602401602060405180830381865afa1580156124d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fc9190615759565b905060005b8115612894576001821615612888576040516308cae55b60e21b8152600481018290526000906001600160a01b0385169063232b956c90602401602060405180830381865afa158015612558573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257c91906157b0565b90506125af6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6125d360405180606001604052806000815260200160008152602001600081525090565b604051638e8f294b60e01b81526001600160a01b038481166004830152871690638e8f294b9060240160a060405180830381865afa158015612619573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263d9190615906565b6001600160a01b039081166080880181905260ff9490941660208801526001600160801b039490941686525050604051631710760b60e31b815260048101919091529087169063b883b05890602401602060405180830381865afa1580156126a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126cd9190615759565b6040828101919091525163014a296f60e01b81526001600160a01b038c8116600483015284169063014a296f906024016040805180830381865afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273d9190615a8b565b6020830152506001600160a01b03808d169084160361284857604051632f2e037160e11b81526001600160a01b038c8116600483015260009190851690635e5c06e290602401606060405180830381865afa1580156127a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c49190615813565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561280e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128329190615759565b826020018181516128439190615792565b905250505b61287282600001516001600160801b031661092f83604001518560200151600a6120529190615a7c565b875188906128819083906157d4565b9052505050505b600191821c9101612501565b50604051638e8f294b60e01b81526001600160a01b038a81166004830152831690638e8f294b9060240160a060405180830381865afa1580156128db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ff9190615906565b505050506001600160801b03166020840152604051638e8f294b60e01b81526001600160a01b038981166004830152831690638e8f294b9060240160a060405180830381865afa158015612957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297b9190615906565b505050506001600160801b031660408481019190915251638e8f294b60e01b81526001600160a01b038a8116600483015260009190841690638e8f294b9060240160a060405180830381865afa1580156129d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fd9190615906565b945050505050612aed8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a68919061597d565b612a7390600a615a7c565b604051631710760b60e31b81526001600160a01b03848116600483015286169063b883b05890602401602060405180830381865afa158015612ab9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612add9190615759565b60408701518751611bac91612bd2565b8452861580612afc5750835187105b80612b495750670de0b6b3a7640000612b47612b31886107838860400151610b3f8a602001518e612bd290919063ffffffff16565b612b3b908a615792565b8651610783908b615792565b105b15612b8857612b7d612b6c85604001518660200151612bd290919063ffffffff16565b612b769088615792565b8790613186565b945050505050610360565b612bc4612bae876107838760400151610b3f89602001518d612bd290919063ffffffff16565b612bb89089615792565b8551610783908a615792565b9a9950505050505050505050565b6000612be78383670de0b6b3a7640000614e74565b90505b92915050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7591906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce19190615906565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6b91906157b0565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612db3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd79190615906565b945050505050610792856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e42919061597d565b612e4d90600a615a7c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ecf91906157b0565b604051631710760b60e31b81526001600160a01b038581166004830152919091169063b883b05890602401602060405180830381865afa158015612f17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3b9190615759565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc091906157b0565b604051631710760b60e31b81526001600160a01b038881166004830152919091169063b883b05890602401602060405180830381865afa158015613008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061302c9190615759565b8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561306a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308e919061597d565b61309990600a615a7c565b899190614e74565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa1580156130ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131109190615813565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561315a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317e9190615759565b949350505050565b6000612be783670de0b6b3a764000084614e74565b6000806000846131ac8989896116f9565b6131b69190615aaf565b925060008313156132545760405163ce96cb7760e01b81526001600160a01b03878116600483015261323e9185918891908c169063ce96cb7790602401602060405180830381865afa158015613210573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132349190615759565b61092f9190615aaf565b915061324d88888886886123df565b9050613265565b6132628888886000886123df565b90505b955095509592505050565b6000612be783670de0b6b3a764000084614e93565b606061328f614f83565b826001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132f191906157b0565b6001600160a01b03168082521561426857826001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336491906157b0565b604051638e8f294b60e01b81526001600160a01b0385811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156133ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d09190615906565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015613444573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261346c9190810190615ad7565b6101408201819052516001600160401b0381111561348c5761348c615366565b6040519080825280602002602001820160405280156134c557816020015b6134b2614ed7565b8152602001906001900390816134aa5790505b5060006101a083015291505b80610140015151816101a0015110156142685780600001516001600160a01b031663f2426f9a84836101400151846101a0015181518110613514576135146157fd565b60200260200101516040518363ffffffff1660e01b815260040161354e9291906001600160a01b0392831681529116602082015260400190565b6101c060405180830381865afa15801561356c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135909190615ba2565b81610120018190525080600001516001600160a01b03166344e250f884836101400151846101a00151815181106135c9576135c96157fd565b60200260200101516040518363ffffffff1660e01b81526004016136039291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa158015613620573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136449190615813565b506040830152606082015280516101408201516101a083015181516001600160a01b039093169263fc19606892879290918110613683576136836157fd565b60200260200101518461012001516060015163ffffffff1642116136a85760006136af565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613701573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137259190615813565b50608083015260a082015280516101408201516101a083015181516001600160a01b0390931692635684aa4692879290918110613764576137646157fd565b60200260200101516040518363ffffffff1660e01b815260040161379e9291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa1580156137bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137df9190615c96565b505063ffffffff166101c082018190526224ea00906137ff908290615cef565b826101c0015161380f9190615792565b61381991906157d4565b81610240018181525050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613861573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613885919061597d565b6138959060ff166224ea00615d03565b6138a26224ea0042615cef565b6138ac9042615792565b6138b691906157d4565b61022082018190526102408201516224ea00916138d39190615792565b6138dd9190615d1a565b6138e89060016157d4565b6001600160401b038111156138ff576138ff615366565b604051908082528060200260200182016040528015613928578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e0015111613a30576101e0810151604051630156d37d60e31b81526000916001600160a01b03861691630ab69be89161398b9160040190815260200190565b6040805180830381865afa1580156139a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139cb9190615a8b565b5090508082610200018181516139e191906157d4565b9052506101e082015160e08301516101c084015181518110613a0557613a056157fd565b6020908102919091010152506101e0810180516224ea000190526101c0810180516001019052613943565b6040518060a00160405280826101400151836101a0015181518110613a5757613a576157fd565b60200260200101516001600160a01b03168152602001826101400151836101a0015181518110613a8957613a896157fd565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015613ace573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613af69190810190615d2e565b8152602001826101400151836101a0015181518110613b1757613b176157fd565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015613b5c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613b849190810190615d2e565b81526020016000836102000151866001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bf39190615759565b613bfd91906157d4565b11613c09576000613f3c565b613f3c6301e13380846101800151611bac8660c00151613d668a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613c60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c8491906157b0565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cf49190615759565b8961020001518c6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d5c9190615759565b610b3f91906157d4565b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613da7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dcb91906157b0565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613e1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e409190615759565b610b3f8d6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b8152600401613e7691815260200190565b602060405180830381865afa158015613e93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eb79190615759565b8e6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ef5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f199190615759565b613f2391906157d4565b8c60c001518d606001518e60a00151611bac9190615792565b81526020016000856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613f81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fa59190615759565b11613fb1576000614232565b6142326301e13380846101800151611bac8660c001516140da8a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061402c91906157b0565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015614078573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061409c9190615759565b8b6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1b573d6000803e3d6000fd5b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561411b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061413f91906157b0565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015614190573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141b49190615759565b610b3f8d6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156141f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142199190615759565b8c60c001518d604001518e60800151611bac9190615792565b81525082826101a001518151811061424c5761424c6157fd565b60209081029190910101526101a08101805160010190526134d1565b50919050565b60608351855161427e91906157d4565b6001600160401b0381111561429557614295615366565b6040519080825280602002602001820160405280156142ce57816020015b6142bb614ed7565b8152602001906001900390816142b35790505b50905060005b85518110156144695761430d838783815181106142f3576142f36157fd565b602002602001015160800151612bd290919063ffffffff16565b82828151811061431f5761431f6157fd565b6020026020010151608001818152505083156143995761437661434a670de0b6b3a764000085615792565b87838151811061435c5761435c6157fd565b602002602001015160600151612bd290919063ffffffff16565b828281518110614388576143886157fd565b602002602001015160600181815250505b8581815181106143ab576143ab6157fd565b6020026020010151600001518282815181106143c9576143c96157fd565b60209081029190910101516001600160a01b03909116905285518690829081106143f5576143f56157fd565b602002602001015160200151828281518110614413576144136157fd565b602002602001015160200181905250858181518110614434576144346157fd565b602002602001015160400151828281518110614452576144526157fd565b6020908102919091010151604001526001016142d4565b836145c4575060005b84518110156145c4576144a2614490670de0b6b3a764000085615792565b86838151811061435c5761435c6157fd565b828751836144b091906157d4565b815181106144c0576144c06157fd565b602002602001015160600181815250508481815181106144e2576144e26157fd565b602002602001015160000151828751836144fc91906157d4565b8151811061450c5761450c6157fd565b60209081029190910101516001600160a01b0390911690528451859082908110614538576145386157fd565b6020026020010151602001518287518361455291906157d4565b81518110614562576145626157fd565b602002602001015160200181905250848181518110614583576145836157fd565b6020026020010151604001518287518361459d91906157d4565b815181106145ad576145ad6157fd565b602090810291909101015160400152600101614472565b50949350505050565b604080516080810182526000808252602082018190529181018290526060810182905260007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614650573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061467491906157b0565b604051638e8f294b60e01b81526001600160a01b03898116600483015291925090821690638e8f294b9060240160a060405180830381865afa1580156146be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e29190615906565b6001600160a01b039081166040888101919091526001600160801b039590951687529351638e8f294b60e01b81528a8516600482015293851693638e8f294b9350602401915061472f9050565b60a060405180830381865afa15801561474c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147709190615906565b6001600160a01b0390811660608801526001600160801b039094166020808801919091526040805163313ce56760e01b81529051611683968e16955063313ce56794506004808301945090918290030181865afa1580156147d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147f9919061597d565b61480490600a615a7c565b6040848101519051631710760b60e31b81526001600160a01b0391821660048201529084169063b883b05890602401602060405180830381865afa158015614850573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148749190615759565b8451602086015161497d916148899190612bd2565b6060870151604051631710760b60e31b81526001600160a01b0391821660048201526107839188169063b883b05890602401602060405180830381865afa1580156148d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148fc9190615759565b8c6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561493a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061495e919061597d565b61496990600a615a7c565b611bac6149768f8f6130a1565b8d90612bd2565b9190614e93565b600081602001516001600160a01b031682600001516001600160a01b0316106149af576149af6157e7565b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6bffffffffffffffffffffffff191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ad2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614af691906157b0565b6001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015614b33573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052614b5b9190810190615db8565b519050806001600160401b03811115614b7657614b76615366565b604051908082528060200260200182016040528015614bbb57816020015b6040805180820190915260008082526020820152815260200190600190039081614b945790505b50915060005b81811015614e5a5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4d91906157b0565b6001600160a01b031663232b956c836040518263ffffffff1660e01b8152600401614c7a91815260200190565b602060405180830381865afa158015614c97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614cbb91906157b0565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d1c91906157b0565b90506040518060400160405280826001600160a01b03168152602001826001600160a01b03166370a082317f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663158274a56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dc991906157b0565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015614e0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e319190615759565b815250848381518110614e4657614e466157fd565b602090810291909101015250600101614bc1565b505090565b6000612be78383670de0b6b3a7640000614e93565b828202811515841585830485141716614e8c57600080fd5b0492915050565b828202811515841585830485141716614eab57600080fd5b6001826001830304018115150290509392505050565b6000818310614ed05781612be7565b5090919050565b6040518060a0016040528060006001600160a01b03168152602001606081526020016060815260200160008152602001600081525090565b60405180610140016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001614f6f604080516060810182526000808252602082018190529181019190915290565b815260200160008152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b031681526020016150a3604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03811681146150fd57600080fd5b50565b803562ffffff8116811461511357600080fd5b919050565b6000806000806080858703121561512e57600080fd5b8435615139816150e8565b93506020850135615149816150e8565b92506040850135915061515e60608601615100565b905092959194509250565b60008060008060008060c0878903121561518257600080fd5b863561518d816150e8565b9550602087013561519d816150e8565b945060408701356151ad816150e8565b959894975094956060810135955060808101359460a0909101359350915050565b600080600080600080600060e0888a0312156151e957600080fd5b87356151f4816150e8565b96506020880135615204816150e8565b95506040880135615214816150e8565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b60005b8381101561525757818101518382015260200161523f565b50506000910152565b6000815180845261527881602086016020860161523c565b601f01601f19169290920160200192915050565b6000602080835260a0808401855183860152828601516040818188015280880151915060608281890152808901519250608080818a015284845180875260c08b01915060c08160051b8c01019650888601955060005b81811015615355578b880360bf19018352865180516001600160a01b031689528a8101518b8a018b90526153188b8b0182615260565b9050878201518a8203898c015261532f8282615260565b838901518c8a0152928701519a87019a909a5250975095890195918901916001016152e2565b50959b9a5050505050505050505050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b038111828210171561539e5761539e615366565b60405290565b6040516101c081016001600160401b038111828210171561539e5761539e615366565b604051601f8201601f191681016001600160401b03811182821017156153ef576153ef615366565b604052919050565b60006001600160401b0382111561541057615410615366565b5060051b60200190565b600082601f83011261542b57600080fd5b8135602061544061543b836153f7565b6153c7565b82815260059290921b8401810191818101908684111561545f57600080fd5b8286015b848110156154815761547481615100565b8352918301918301615463565b509695505050505050565b60008060408084860312156154a057600080fd5b83356001600160401b03808211156154b757600080fd5b818601915086601f8301126154cb57600080fd5b813560206154db61543b836153f7565b82815260069290921b8401810191818101908a8411156154fa57600080fd5b948201945b8386101561554c5786868c0312156155175760008081fd5b61551f61537c565b863561552a816150e8565b815286840135615539816150e8565b81850152825294860194908201906154ff565b9750508701359350508083111561556257600080fd5b50506155708582860161541a565b9150509250929050565b6000806000806080858703121561559057600080fd5b843561559b816150e8565b935060208501356155ab816150e8565b925060408501356155bb816150e8565b9396929550929360600135925050565b600081518084526020808501945080840160005b8381101561560f57815180516001600160a01b0316885283015183880152604090960195908201906001016155df565b509495945050505050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e0820152600060e083015161010061569e8185018380516001600160a01b0390811683526020808301519091169083015260409081015162ffffff16910152565b840151610160840152506101208301516101808084015261317e6101a08401826155cb565b600080604083850312156156d657600080fd5b82356156e1816150e8565b915060208301356156f1816150e8565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03828116828216039080821115615732576157326156fc565b5092915050565b6001600160a01b03818116838216019080821115615732576157326156fc565b60006020828403121561576b57600080fd5b5051919050565b8181036000831280158383131683831282161715615732576157326156fc565b81810381811115612bea57612bea6156fc565b8051615113816150e8565b6000602082840312156157c257600080fd5b81516157cd816150e8565b9392505050565b80820180821115612bea57612bea6156fc565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008060006060848603121561582857600080fd5b8351925060208401519150604084015190509250925092565b805161ffff8116811461511357600080fd5b805160ff8116811461511357600080fd5b8051801515811461511357600080fd5b600080600080600080600060e0888a03121561588f57600080fd5b875161589a816150e8565b8097505060208801518060020b81146158b257600080fd5b95506158c060408901615841565b94506158ce60608901615841565b93506158dc60808901615841565b92506158ea60a08901615853565b91506158f860c08901615864565b905092959891949750929550565b600080600080600060a0868803121561591e57600080fd5b85516001600160801b038116811461593557600080fd5b945061594360208701615853565b935061595160408701615853565b925061595f60608701615864565b9150608086015161596f816150e8565b809150509295509295909350565b60006020828403121561598f57600080fd5b612be782615853565b600181815b808511156159d35781600019048211156159b9576159b96156fc565b808516156159c657918102915b93841c939080029061599d565b509250929050565b6000826159ea57506001612bea565b816159f757506000612bea565b8160018114615a0d5760028114615a1757615a33565b6001915050612bea565b60ff841115615a2857615a286156fc565b50506001821b612bea565b5060208310610133831016604e8410600b8410161715615a56575081810a612bea565b615a608383615998565b8060001904821115615a7457615a746156fc565b029392505050565b6000612be760ff8416836159db565b60008060408385031215615a9e57600080fd5b505080516020909101519092909150565b8082018281126000831280158216821582161715615acf57615acf6156fc565b505092915050565b60006020808385031215615aea57600080fd5b82516001600160401b03811115615b0057600080fd5b8301601f81018513615b1157600080fd5b8051615b1f61543b826153f7565b81815260059190911b82018301908381019087831115615b3e57600080fd5b928401925b82841015611683578351615b56816150e8565b82529284019290840190615b43565b805163ffffffff8116811461511357600080fd5b8051600f81900b811461511357600080fd5b80516001600160401b038116811461511357600080fd5b60006101c08284031215615bb557600080fd5b615bbd6153a4565b615bc6836157a5565b8152615bd4602084016157a5565b6020820152615be5604084016157a5565b6040820152615bf660608401615b65565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615c31818501615b79565b90820152610120615c43848201615b8b565b90820152610140615c55848201615b8b565b90820152610160615c67848201615b8b565b90820152610180615c79848201615b8b565b908201526101a0615c8b848201615b8b565b908201529392505050565b600080600060608486031215615cab57600080fd5b615cb484615b65565b9250615cc260208501615b65565b9150615cd060408501615b65565b90509250925092565b634e487b7160e01b600052601260045260246000fd5b600082615cfe57615cfe615cd9565b500690565b8082028115828204841417612bea57612bea6156fc565b600082615d2957615d29615cd9565b500490565b600060208284031215615d4057600080fd5b81516001600160401b0380821115615d5757600080fd5b818401915084601f830112615d6b57600080fd5b815181811115615d7d57615d7d615366565b615d90601f8201601f19166020016153c7565b9150808252856020828501011115615da757600080fd5b6145c481602084016020860161523c565b60006020808385031215615dcb57600080fd5b82516001600160401b03811115615de157600080fd5b8301601f81018513615df257600080fd5b8051615e0061543b826153f7565b81815260059190911b82018301908381019087831115615e1f57600080fd5b928401925b82841015611683578351615e37816150e8565b82529284019290840190615e2456fea2646970667358221220a158b43fa62c2fe56cbeeabd92d9dc0d913e14f5fb4a89bf76dedefbb16d3c9664736f6c63430008110033", + "numDeployments": 3, + "solcInputHash": "0f3d5a71c203a330ccec578b8f3450f8", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract DebtManager\",\"name\":\"debtManager_\",\"type\":\"address\"},{\"internalType\":\"contract IUniswapQuoter\",\"name\":\"uniswapV3Quoter_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidPreview\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"debtManager\",\"outputs\":[{\"internalType\":\"contract DebtManager\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tokenB\",\"type\":\"address\"}],\"internalType\":\"struct Pool[]\",\"name\":\"pools\",\"type\":\"tuple[]\"},{\"internalType\":\"uint24[]\",\"name\":\"fees\",\"type\":\"uint24[]\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"minHealthFactor\",\"type\":\"uint256\"}],\"name\":\"leverage\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"principal\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"maxRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minDeposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxWithdraw\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"token0\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"token1\",\"type\":\"address\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"}],\"internalType\":\"struct PoolKey\",\"name\":\"pool\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"sqrtPriceX96\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"contract ERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"liquidity\",\"type\":\"uint256\"}],\"internalType\":\"struct AvailableAsset[]\",\"name\":\"availableAssets\",\"type\":\"tuple[]\"}],\"internalType\":\"struct Leverage\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"int256\",\"name\":\"assets\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"targetRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"depositRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nativeRate\",\"type\":\"uint256\"}],\"name\":\"leverageRates\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"native\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"contract ERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"}],\"internalType\":\"struct RewardRate[]\",\"name\":\"rewards\",\"type\":\"tuple[]\"}],\"internalType\":\"struct Rates\",\"name\":\"rates\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"poolFees\",\"outputs\":[{\"internalType\":\"uint24\",\"name\":\"\",\"type\":\"uint24\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"withdraw\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minHealthFactor\",\"type\":\"uint256\"}],\"name\":\"previewDeleverage\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"principal\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"maxRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapRatio\",\"type\":\"uint256\"}],\"internalType\":\"struct Limit\",\"name\":\"limit\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"assetIn\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"assetOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountIn\",\"type\":\"uint256\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"}],\"name\":\"previewInputSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketDeposit\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketBorrow\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minHealthFactor\",\"type\":\"uint256\"}],\"name\":\"previewLeverage\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"ratio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deposit\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"principal\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"maxRatio\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"swapRatio\",\"type\":\"uint256\"}],\"internalType\":\"struct Limit\",\"name\":\"limit\",\"type\":\"tuple\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"marketIn\",\"type\":\"address\"},{\"internalType\":\"contract Market\",\"name\":\"marketOut\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountOut\",\"type\":\"uint256\"},{\"internalType\":\"uint24\",\"name\":\"fee\",\"type\":\"uint24\"}],\"name\":\"previewOutputSwap\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"uniswapV3Quoter\",\"outputs\":[{\"internalType\":\"contract IUniswapQuoter\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"initialize((address,address)[],uint24[])\":{\"details\":\"can only be called once.\"},\"leverage(address,address,address,uint256)\":{\"params\":{\"account\":\"The account operating with the `DebtManager`.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"minHealthFactor\":\"The minimum health factor that the account must have after the leverage.\"},\"returns\":{\"_0\":\"extended leverage data.\"}},\"leverageRates(address,address,address,int256,uint256,uint256,uint256)\":{\"params\":{\"account\":\"The account to preview.\",\"assets\":\"The amount of assets that should be added or substracted to the principal.\",\"depositRate\":\"The current deposit rate of the deposit market.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"nativeRate\":\"The current native rate of the deposit market.\",\"targetRatio\":\"The target ratio to preview.\"}},\"previewDeleverage(address,address,address,uint256,uint256,uint256)\":{\"params\":{\"account\":\"The account that will be deleveraged.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"minHealthFactor\":\"The minimum health factor that the account must have after the leverage.\",\"ratio\":\"The ratio to be previewed.\",\"withdraw\":\"The amount of assets that will be withdrawn from the principal.\"}},\"previewInputSwap(address,address,uint256,uint24)\":{\"params\":{\"amountIn\":\"The exact amount of `assetIn` to be swapped.\",\"assetIn\":\"The address of the token to be swapped.\",\"assetOut\":\"The address of the token to receive.\",\"fee\":\"The fee of the pool that will be used to swap the assets.\"},\"returns\":{\"_0\":\"amountOut The amount of `assetOut` received.\"}},\"previewLeverage(address,address,address,uint256,uint256,uint256)\":{\"params\":{\"account\":\"The account that will be leveraged.\",\"deposit\":\"The amount of assets that will be added to the principal.\",\"marketBorrow\":\"The borrow Market.\",\"marketDeposit\":\"The deposit Market.\",\"minHealthFactor\":\"The minimum health factor that the account must have after the leverage.\",\"ratio\":\"The ratio to be previewed.\"}},\"previewOutputSwap(address,address,uint256,uint24)\":{\"params\":{\"amountOut\":\"The exact amount of `amountOut` to be swapped.\",\"fee\":\"The fee of the pool that will be used to swap the assets.\",\"marketIn\":\"The Market of the underlying asset to be swapped.\",\"marketOut\":\"The Market of the underlying asset to receive.\"},\"returns\":{\"_0\":\"amountIn The amount of `amountIn` received.\"}}},\"stateVariables\":{\"MAX_SQRT_RATIO\":{\"details\":\"The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\"},\"MIN_SQRT_RATIO\":{\"details\":\"The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\"},\"debtManager\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"uniswapV3Quoter\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"DebtPreviewer\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"debtManager()\":{\"notice\":\"DebtManager contract to be used to get Auditor, BalancerVault and UniswapV3Factory addresses.\"},\"initialize((address,address)[],uint24[])\":{\"notice\":\"Initializes the contract.\"},\"leverage(address,address,address,uint256)\":{\"notice\":\"Returns extended data useful to leverage or deleverage an account principal position.\"},\"leverageRates(address,address,address,int256,uint256,uint256,uint256)\":{\"notice\":\"returns rates based on inputs and leverage ratio impact on the borrow market\"},\"poolFees(address,address)\":{\"notice\":\"Mapping of Uniswap pools to their respective pool fee.\"},\"previewDeleverage(address,address,address,uint256,uint256,uint256)\":{\"notice\":\"Returns the maximum ratio that an account can deleverage its principal minus `assets` amount.\"},\"previewInputSwap(address,address,uint256,uint24)\":{\"notice\":\"Returns the output received for a given exact amount of a single pool swap.\"},\"previewLeverage(address,address,address,uint256,uint256,uint256)\":{\"notice\":\"Returns the maximum ratio that an account can leverage its principal plus `assets` amount.\"},\"previewOutputSwap(address,address,uint256,uint24)\":{\"notice\":\"Returns the input for an exact amount out of a single pool swap.\"},\"uniswapV3Quoter()\":{\"notice\":\"Quoter contract to be used to preview the amount of assets to be swapped.\"}},\"notice\":\"Contract to be consumed by Exactly's front-end dApp as a helper for `DebtManager`.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/DebtPreviewer.sol\":\"DebtPreviewer\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControlUpgradeable.sol\\\";\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../utils/StringsUpgradeable.sol\\\";\\nimport \\\"../utils/introspection/ERC165Upgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```solidity\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```solidity\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\\n * to enforce additional security measures for this role.\\n */\\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\\n function __AccessControl_init() internal onlyInitializing {\\n }\\n\\n function __AccessControl_init_unchained() internal onlyInitializing {\\n }\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n StringsUpgradeable.toHexString(account),\\n \\\" is missing role \\\",\\n StringsUpgradeable.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xfeefb24d068524440e1ba885efdf105d91f83504af3c2d745ffacc4595396831\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControlUpgradeable {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0xb8f5302f12138c5561362e88a78d061573e6298b7a1a5afe84a1e2c8d4d5aeaa\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n _requireNotPaused();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n _requirePaused();\\n _;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x40c636b4572ff5f1dc50cf22097e93c0723ee14eff87e99ac2b02636eeca1250\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20Upgradeable {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\\n}\\n\",\"keccak256\":\"0x0e1f0f5f62f67a881cd1a9597acbc0a5e4071f3c2c10449a183b922ae7272e3f\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20PermitUpgradeable {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xd60f939a3ca0199014d079b4dd66aa757954334947d81eb5c1d35d7a83061ab3\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20Upgradeable.sol\\\";\\nimport \\\"../extensions/IERC20PermitUpgradeable.sol\\\";\\nimport \\\"../../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20Upgradeable {\\n using AddressUpgradeable for address;\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to\\n * 0 before setting it to a non-zero value.\\n */\\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\\n * Revert on invalid signature.\\n */\\n function safePermit(\\n IERC20PermitUpgradeable token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return\\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));\\n }\\n}\\n\",\"keccak256\":\"0x4dae161227d332808312ee2caf6384929321b83c16cc89b5642985fbec6b814c\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\nimport \\\"./math/SignedMathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\\n */\\n function toString(int256 value) internal pure returns (string memory) {\\n return string(abi.encodePacked(value < 0 ? \\\"-\\\" : \\\"\\\", toString(SignedMathUpgradeable.abs(value))));\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n\\n /**\\n * @dev Returns true if the two strings are equal.\\n */\\n function equal(string memory a, string memory b) internal pure returns (bool) {\\n return keccak256(bytes(a)) == keccak256(bytes(b));\\n }\\n}\\n\",\"keccak256\":\"0xb96dc79b65b7c37937919dcdb356a969ce0aa2e8338322bf4dc027a3c9c9a7eb\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\\n function __ERC165_init() internal onlyInitializing {\\n }\\n\\n function __ERC165_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165Upgradeable).interfaceId;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x9a3b990bd56d139df3e454a9edf1c64668530b5a77fc32eb063bc206f958274a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1, \\\"Math: mulDiv overflow\\\");\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2bc0007987c229ae7624eb29be6a9b84f6a6a5872f76248b15208b131ea41c4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMathUpgradeable {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two signed numbers.\\n */\\n function min(int256 a, int256 b) internal pure returns (int256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two signed numbers without overflow.\\n * The result is rounded towards zero.\\n */\\n function average(int256 a, int256 b) internal pure returns (int256) {\\n // Formula from the book \\\"Hacker's Delight\\\"\\n int256 x = (a & b) + ((a ^ b) >> 1);\\n return x + (int256(uint256(x) >> 255) & (a ^ b));\\n }\\n\\n /**\\n * @dev Returns the absolute unsigned value of a signed value.\\n */\\n function abs(int256 n) internal pure returns (uint256) {\\n unchecked {\\n // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x88f6b7bba3ee33eeb741f9a0f5bc98b6e6e352d0fe4905377bb328590f84095a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1, \\\"Math: mulDiv overflow\\\");\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe4455ac1eb7fc497bb7402579e7b4d64d928b846fce7d2b6fde06d366f21c2b3\",\"license\":\"MIT\"},\"contracts/Auditor.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract Auditor is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n\\n /// @notice Address that a market should have as price feed to consider as base price and avoid external price call.\\n address public constant BASE_FEED = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\\n /// @notice Target health factor that the account should have after it's liquidated to prevent cascade liquidations.\\n uint256 public constant TARGET_HEALTH = 1.25e18;\\n /// @notice Maximum value the liquidator can send and still have granular control of max assets.\\n /// Above this threshold, they should send `type(uint256).max`.\\n uint256 public constant ASSETS_THRESHOLD = type(uint256).max / 1e18;\\n\\n /// @notice Decimals that the answer of all price feeds should have.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable priceDecimals;\\n /// @notice Base factor to scale the price returned by the feed to 18 decimals.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable baseFactor;\\n /// @notice Base price used if the feed to fetch the price from is `BASE_FEED`.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable basePrice;\\n\\n /// @notice Tracks the markets' indexes that an account has entered as collateral.\\n mapping(address => uint256) public accountMarkets;\\n /// @notice Stores market parameters per each enabled market.\\n mapping(Market => MarketData) public markets;\\n /// @notice Array of all enabled markets.\\n Market[] public marketList;\\n\\n /// @notice Liquidation incentive factors for the liquidator and the lenders of the market where the debt is repaid.\\n LiquidationIncentive public liquidationIncentive;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(uint256 priceDecimals_) {\\n priceDecimals = priceDecimals_;\\n baseFactor = 10 ** (18 - priceDecimals_);\\n basePrice = 10 ** priceDecimals_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(LiquidationIncentive memory liquidationIncentive_) external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setLiquidationIncentive(liquidationIncentive_);\\n }\\n\\n /// @notice Allows assets of a certain market to be used as collateral for borrowing other assets.\\n /// @param market market to enabled as collateral.\\n function enterMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) != 0) return;\\n accountMarkets[msg.sender] = marketMap | marketMask;\\n\\n emit MarketEntered(market, msg.sender);\\n }\\n\\n /// @notice Removes market from sender's account liquidity calculation.\\n /// @dev Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral\\n /// for an outstanding borrow.\\n /// @param market market to be disabled as collateral.\\n function exitMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n (uint256 assets, uint256 debt) = market.accountSnapshot(msg.sender);\\n\\n // fail if the sender has a borrow balance\\n if (debt != 0) revert RemainingDebt();\\n\\n // fail if the sender is not permitted to redeem all of their assets\\n checkShortfall(market, msg.sender, assets);\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) == 0) return;\\n accountMarkets[msg.sender] = marketMap & ~marketMask;\\n\\n emit MarketExited(market, msg.sender);\\n }\\n\\n /// @notice Returns account's liquidity calculation.\\n /// @param account account in which the liquidity will be calculated.\\n /// @param marketToSimulate market in which to simulate withdraw operation.\\n /// @param withdrawAmount amount to simulate as withdraw.\\n /// @return sumCollateral sum of all collateral, already multiplied by each adjust factor (denominated in base).\\n /// @return sumDebtPlusEffects sum of all debt divided by adjust factor considering withdrawal (denominated in base).\\n function accountLiquidity(\\n address account,\\n Market marketToSimulate,\\n uint256 withdrawAmount\\n ) public view returns (uint256 sumCollateral, uint256 sumDebtPlusEffects) {\\n AccountLiquidity memory vars; // holds all our calculation results\\n\\n // for each asset the account is in\\n uint256 marketMap = accountMarkets[account];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 baseUnit = 10 ** m.decimals;\\n uint256 adjustFactor = m.adjustFactor;\\n\\n // read the balances\\n (vars.balance, vars.borrowBalance) = market.accountSnapshot(account);\\n\\n // get the normalized price of the asset (18 decimals)\\n vars.price = assetPrice(m.priceFeed);\\n\\n // sum all the collateral prices\\n sumCollateral += vars.balance.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n\\n // sum all the debt\\n sumDebtPlusEffects += vars.borrowBalance.mulDivUp(vars.price, baseUnit).divWadUp(adjustFactor);\\n\\n // simulate the effects of withdrawing from a pool\\n if (market == marketToSimulate) {\\n // calculate the effects of redeeming markets\\n // (having less collateral is the same as having more debt for this calculation)\\n if (withdrawAmount != 0) {\\n sumDebtPlusEffects += withdrawAmount.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n }\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Validates that the current state of the position and system are valid.\\n /// @dev To be called after adding the borrowed debt to the account position.\\n /// @param market address of the market where the borrow is made.\\n /// @param borrower address of the account that will repay the debt.\\n function checkBorrow(Market market, address borrower) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[borrower];\\n uint256 marketMask = 1 << m.index;\\n\\n // validate borrow state\\n if ((marketMap & marketMask) == 0) {\\n // only markets may call checkBorrow if borrower not in market\\n if (msg.sender != address(market)) revert NotMarket();\\n\\n accountMarkets[borrower] = marketMap | marketMask;\\n emit MarketEntered(market, borrower);\\n }\\n\\n // verify that current liquidity is not short\\n (uint256 collateral, uint256 debt) = accountLiquidity(borrower, Market(address(0)), 0);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Checks if the account has liquidity shortfall.\\n /// @param market address of the market where the operation will happen.\\n /// @param account address of the account to check for possible shortfall.\\n /// @param amount amount that the account wants to withdraw or transfer.\\n function checkShortfall(Market market, address account, uint256 amount) public view {\\n // if the account is not 'in' the market, bypass the liquidity check\\n if ((accountMarkets[account] & (1 << markets[market].index)) == 0) return;\\n\\n // otherwise, perform a hypothetical liquidity check to guard against shortfall\\n (uint256 collateral, uint256 debt) = accountLiquidity(account, market, amount);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Allows/rejects liquidation of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt is being repaid.\\n /// @param seizeMarket market from where the liquidator will seize assets.\\n /// @param borrower address in which the assets are being liquidated.\\n /// @param maxLiquidatorAssets maximum amount of debt the liquidator is willing to accept.\\n /// @return maxRepayAssets capped amount of debt the liquidator is allowed to repay.\\n function checkLiquidation(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 maxLiquidatorAssets\\n ) external view returns (uint256 maxRepayAssets) {\\n // if markets are listed, they have the same auditor\\n if (!markets[repayMarket].isListed || !markets[seizeMarket].isListed) revert MarketNotListed();\\n\\n MarketVars memory repay;\\n LiquidityVars memory base;\\n uint256 marketMap = accountMarkets[borrower];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage marketData = markets[market];\\n MarketVars memory m = MarketVars({\\n price: assetPrice(marketData.priceFeed),\\n adjustFactor: marketData.adjustFactor,\\n baseUnit: 10 ** marketData.decimals\\n });\\n\\n if (market == repayMarket) repay = m;\\n\\n (uint256 collateral, uint256 debt) = market.accountSnapshot(borrower);\\n\\n uint256 value = debt.mulDivUp(m.price, m.baseUnit);\\n base.totalDebt += value;\\n base.adjustedDebt += value.divWadUp(m.adjustFactor);\\n\\n value = collateral.mulDivDown(m.price, m.baseUnit);\\n base.totalCollateral += value;\\n base.adjustedCollateral += value.mulWadDown(m.adjustFactor);\\n if (market == seizeMarket) base.seizeAvailable = value;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n if (base.adjustedCollateral >= base.adjustedDebt) revert InsufficientShortfall();\\n\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n uint256 adjustFactor = base.adjustedCollateral.mulWadDown(base.totalDebt).divWadUp(\\n base.adjustedDebt.mulWadUp(base.totalCollateral)\\n );\\n uint256 closeFactor = (TARGET_HEALTH - base.adjustedCollateral.divWadUp(base.adjustedDebt)).divWadUp(\\n TARGET_HEALTH - adjustFactor.mulWadDown(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n );\\n maxRepayAssets = Math.min(\\n Math\\n .min(\\n base.totalDebt.mulWadUp(Math.min(1e18, closeFactor)),\\n base.seizeAvailable.divWadUp(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n )\\n .mulDivUp(repay.baseUnit, repay.price),\\n maxLiquidatorAssets < ASSETS_THRESHOLD\\n ? maxLiquidatorAssets.divWadDown(1e18 + memIncentive.lenders)\\n : maxLiquidatorAssets\\n );\\n }\\n\\n /// @notice Allow/rejects seizing of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market where the assets will be seized.\\n function checkSeize(Market repayMarket, Market seizeMarket) external view {\\n // if markets are listed, they also point to the same Auditor\\n if (!markets[seizeMarket].isListed || !markets[repayMarket].isListed) revert MarketNotListed();\\n }\\n\\n /// @notice Calculates the amount of collateral to be seized when a position is undercollateralized.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market from where the assets will be seized by the liquidator.\\n /// @param borrower account in which assets are being seized.\\n /// @param actualRepayAssets amount being repaid.\\n /// @return lendersAssets amount to be added for other lenders as a compensation of bad debt clearing.\\n /// @return seizeAssets amount that can be seized by the liquidator.\\n function calculateSeize(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 actualRepayAssets\\n ) external view returns (uint256 lendersAssets, uint256 seizeAssets) {\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n lendersAssets = actualRepayAssets.mulWadDown(memIncentive.lenders);\\n\\n // read prices for borrowed and collateral markets\\n uint256 priceBorrowed = assetPrice(markets[repayMarket].priceFeed);\\n uint256 priceCollateral = assetPrice(markets[seizeMarket].priceFeed);\\n uint256 baseAmount = actualRepayAssets.mulDivUp(priceBorrowed, 10 ** markets[repayMarket].decimals);\\n\\n seizeAssets = Math.min(\\n baseAmount.mulDivUp(10 ** markets[seizeMarket].decimals, priceCollateral).mulWadUp(\\n 1e18 + memIncentive.liquidator + memIncentive.lenders\\n ),\\n seizeMarket.maxWithdraw(borrower)\\n );\\n }\\n\\n /// @notice Checks if account has debt with no collateral, if so then call `clearBadDebt` from each market.\\n /// @dev Collateral is multiplied by price and adjust factor to be accurately evaluated as positive collateral asset.\\n /// @param account account in which debt is being checked.\\n function handleBadDebt(address account) external {\\n uint256 memMarketMap = accountMarkets[account];\\n uint256 marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 assets = market.maxWithdraw(account);\\n if (assets.mulDivDown(assetPrice(m.priceFeed), 10 ** m.decimals).mulWadDown(m.adjustFactor) > 0) return;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) marketList[i].clearBadDebt(account);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the asset price of a price feed.\\n /// @dev If Chainlink's asset price is <= 0 the call is reverted.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price.\\n /// @return The price of the asset scaled to 18-digit decimals.\\n function assetPrice(IPriceFeed priceFeed) public view returns (uint256) {\\n if (address(priceFeed) == BASE_FEED) return basePrice;\\n\\n int256 price = priceFeed.latestAnswer();\\n if (price <= 0) revert InvalidPrice();\\n return uint256(price) * baseFactor;\\n }\\n\\n /// @notice Retrieves all markets.\\n function allMarkets() external view returns (Market[] memory) {\\n return marketList;\\n }\\n\\n /// @notice Enables a certain market.\\n /// @dev Enabling more than 256 markets will cause an overflow when casting market index to uint8.\\n /// @param market market to add to the protocol.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n /// @param adjustFactor market's adjust factor for the underlying asset.\\n function enableMarket(\\n Market market,\\n IPriceFeed priceFeed,\\n uint128 adjustFactor\\n ) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (market.auditor() != this) revert AuditorMismatch();\\n if (markets[market].isListed) revert MarketAlreadyListed();\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n\\n uint8 decimals = market.decimals();\\n markets[market] = MarketData({\\n isListed: true,\\n adjustFactor: adjustFactor,\\n decimals: decimals,\\n index: uint8(marketList.length),\\n priceFeed: priceFeed\\n });\\n\\n marketList.push(market);\\n\\n emit MarketListed(market, decimals);\\n emit PriceFeedSet(market, priceFeed);\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the adjust factor for a certain market.\\n /// @param market address of the market to change adjust factor for.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n function setAdjustFactor(Market market, uint128 adjustFactor) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (!markets[market].isListed) revert MarketNotListed();\\n\\n markets[market].adjustFactor = adjustFactor;\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the Chainlink Price Feed Aggregator source for a market.\\n /// @param market market address of the asset.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n function setPriceFeed(Market market, IPriceFeed priceFeed) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n markets[market].priceFeed = priceFeed;\\n emit PriceFeedSet(market, priceFeed);\\n }\\n\\n /// @notice Sets liquidation incentive (liquidator and lenders) for the whole ecosystem.\\n /// @param liquidationIncentive_ new liquidation incentive.\\n function setLiquidationIncentive(\\n LiquidationIncentive memory liquidationIncentive_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n liquidationIncentive = liquidationIncentive_;\\n emit LiquidationIncentiveSet(liquidationIncentive_);\\n }\\n\\n /// @notice Emitted when a new market is listed for borrow/lending.\\n /// @param market address of the market that was listed.\\n /// @param decimals decimals of the market's underlying asset.\\n event MarketListed(Market indexed market, uint8 decimals);\\n\\n /// @notice Emitted when an account enters a market to use his deposit as collateral for a loan.\\n /// @param market address of the market that the account entered.\\n /// @param account address of the account that just entered a market.\\n event MarketEntered(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when an account leaves a market.\\n /// Means that they would stop using their deposit as collateral and won't ask for any loans in this market.\\n /// @param market address of the market that the account just left.\\n /// @param account address of the account that just left a market.\\n event MarketExited(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when a adjust factor is changed by admin.\\n /// @param market address of the market that has a new adjust factor.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n event AdjustFactorSet(Market indexed market, uint256 adjustFactor);\\n\\n /// @notice Emitted when a new liquidationIncentive has been set.\\n /// @param liquidationIncentive represented with 18 decimals.\\n event LiquidationIncentiveSet(LiquidationIncentive liquidationIncentive);\\n\\n /// @notice Emitted when a market and prie feed is changed by admin.\\n /// @param market address of the asset used to get the price.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n event PriceFeedSet(Market indexed market, IPriceFeed indexed priceFeed);\\n\\n /// @notice Stores the market parameters used for liquidity calculations.\\n /// @param adjustFactor used to asses the lending power of the market's underlying asset.\\n /// @param decimals number of decimals of the market's underlying asset.\\n /// @param index index of the market in the `marketList`.\\n /// @param isListed true if the market is enabled.\\n /// @param priceFeed address of the price feed used to query the asset's price.\\n struct MarketData {\\n uint128 adjustFactor;\\n uint8 decimals;\\n uint8 index;\\n bool isListed;\\n IPriceFeed priceFeed;\\n }\\n\\n /// @notice Stores the liquidator and lenders factors used in liquidations to calculate the amount to seize.\\n /// @param liquidator factor used to calculate the extra bonus a liquidator can seize.\\n /// @param lenders factor used to calculate the bonus that the pool lenders receive.\\n struct LiquidationIncentive {\\n uint128 liquidator;\\n uint128 lenders;\\n }\\n\\n /// @notice Used as memory access to temporary store account liquidity data.\\n /// @param balance collateral balance of the account.\\n /// @param borrowBalance borrow balance of the account.\\n /// @param price asset price returned by the price feed with 18 decimals.\\n struct AccountLiquidity {\\n uint256 balance;\\n uint256 borrowBalance;\\n uint256 price;\\n }\\n}\\n\\nerror AuditorMismatch();\\nerror InsufficientAccountLiquidity();\\nerror InsufficientShortfall();\\nerror InvalidPrice();\\nerror InvalidPriceFeed();\\nerror MarketAlreadyListed();\\nerror MarketNotListed();\\nerror NotMarket();\\nerror RemainingDebt();\\n\\nstruct MarketVars {\\n uint256 price;\\n uint256 baseUnit;\\n uint128 adjustFactor;\\n}\\n\\nstruct LiquidityVars {\\n uint256 totalDebt;\\n uint256 totalCollateral;\\n uint256 adjustedDebt;\\n uint256 adjustedCollateral;\\n uint256 seizeAvailable;\\n}\\n\",\"keccak256\":\"0x93d487fdf861e8f58edca8058bffec88f31d280846420faec8e3e7049d3068fd\",\"license\":\"BUSL-1.1\"},\"contracts/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\ncontract InterestRateModel {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n\\n /// @notice Threshold to define which method should be used to calculate the interest rates.\\n /// @dev When `eta` (`delta / alpha`) is lower than this value, use simpson's rule for approximation.\\n uint256 internal constant PRECISION_THRESHOLD = 7.5e14;\\n\\n /// @notice Scale factor of the fixed curve.\\n uint256 public immutable fixedCurveA;\\n /// @notice Origin intercept of the fixed curve.\\n int256 public immutable fixedCurveB;\\n /// @notice Asymptote of the fixed curve.\\n uint256 public immutable fixedMaxUtilization;\\n\\n /// @notice Scale factor of the floating curve.\\n uint256 public immutable floatingCurveA;\\n /// @notice Origin intercept of the floating curve.\\n int256 public immutable floatingCurveB;\\n /// @notice Asymptote of the floating curve.\\n uint256 public immutable floatingMaxUtilization;\\n\\n constructor(\\n uint256 fixedCurveA_,\\n int256 fixedCurveB_,\\n uint256 fixedMaxUtilization_,\\n uint256 floatingCurveA_,\\n int256 floatingCurveB_,\\n uint256 floatingMaxUtilization_\\n ) {\\n assert(fixedMaxUtilization_ > 1e18);\\n assert(floatingMaxUtilization_ > 1e18);\\n\\n fixedCurveA = fixedCurveA_;\\n fixedCurveB = fixedCurveB_;\\n fixedMaxUtilization = fixedMaxUtilization_;\\n\\n floatingCurveA = floatingCurveA_;\\n floatingCurveB = floatingCurveB_;\\n floatingMaxUtilization = floatingMaxUtilization_;\\n\\n // reverts if it's an invalid curve (such as one yielding a negative interest rate).\\n fixedRate(0, 0);\\n floatingRate(0);\\n }\\n\\n /// @notice Gets the rate to borrow a certain amount at a certain maturity with supply/demand values in the fixed rate\\n /// pool and assets from the backup supplier.\\n /// @param maturity maturity date for calculating days left to maturity.\\n /// @param amount the current borrow's amount.\\n /// @param borrowed ex-ante amount borrowed from this fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay (represented with 18 decimals).\\n function fixedBorrowRate(\\n uint256 maturity,\\n uint256 amount,\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256) {\\n if (block.timestamp >= maturity) revert AlreadyMatured();\\n\\n uint256 potentialAssets = supplied + backupAssets;\\n uint256 utilizationAfter = (borrowed + amount).divWadUp(potentialAssets);\\n\\n if (utilizationAfter > 1e18) revert UtilizationExceeded();\\n\\n uint256 utilizationBefore = borrowed.divWadDown(potentialAssets);\\n\\n return fixedRate(utilizationBefore, utilizationAfter).mulDivDown(maturity - block.timestamp, 365 days);\\n }\\n\\n /// @notice Returns the current annualized fixed rate to borrow with supply/demand values in the fixed rate pool and\\n /// assets from the backup supplier.\\n /// @param borrowed amount borrowed from the fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay, with 18 decimals precision.\\n /// @return utilization current utilization rate, with 18 decimals precision.\\n function minFixedRate(\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256 rate, uint256 utilization) {\\n utilization = borrowed.divWadUp(supplied + backupAssets);\\n rate = fixedRate(utilization, utilization);\\n }\\n\\n /// @notice Returns the interest rate integral from `u0` to `u1`, using the analytical solution (ln).\\n /// @dev Uses the fixed rate curve parameters.\\n /// Handles special case where delta utilization tends to zero, using simpson's rule.\\n /// @param utilizationBefore ex-ante utilization rate, with 18 decimals precision.\\n /// @param utilizationAfter ex-post utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function fixedRate(uint256 utilizationBefore, uint256 utilizationAfter) internal view returns (uint256) {\\n uint256 alpha = fixedMaxUtilization - utilizationBefore;\\n uint256 delta = utilizationAfter - utilizationBefore;\\n int256 r = int256(\\n delta.divWadDown(alpha) < PRECISION_THRESHOLD\\n ? (fixedCurveA.divWadDown(alpha) +\\n fixedCurveA.mulDivDown(4e18, fixedMaxUtilization - ((utilizationAfter + utilizationBefore) / 2)) +\\n fixedCurveA.divWadDown(fixedMaxUtilization - utilizationAfter)) / 6\\n : fixedCurveA.mulDivDown(\\n uint256(int256(alpha.divWadDown(fixedMaxUtilization - utilizationAfter)).lnWad()),\\n delta\\n )\\n ) + fixedCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n\\n /// @notice Returns the interest rate for an utilization rate.\\n /// @dev Uses the floating rate curve parameters.\\n /// @param utilization utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function floatingRate(uint256 utilization) public view returns (uint256) {\\n int256 r = int256(floatingCurveA.divWadDown(floatingMaxUtilization - utilization)) + floatingCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n}\\n\\nerror AlreadyMatured();\\nerror UtilizationExceeded();\\n\",\"keccak256\":\"0xfb1d32f03bb869906ce577bb0e4cbc3e141006c7087f4e826ce513a9c4582f57\",\"license\":\"BUSL-1.1\"},\"contracts/Market.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { ERC4626, ERC20, SafeTransferLib } from \\\"solmate/src/mixins/ERC4626.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"./RewardsController.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\n\\ncontract Market is Initializable, AccessControlUpgradeable, PausableUpgradeable, ERC4626 {\\n using FixedPointMathLib for int256;\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint128;\\n using SafeTransferLib for ERC20;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for uint256;\\n\\n bytes32 public constant PAUSER_ROLE = keccak256(\\\"PAUSER_ROLE\\\");\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n\\n /// @notice Tracks account's fixed deposit positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedDepositPositions;\\n /// @notice Tracks account's fixed borrow positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedBorrowPositions;\\n /// @notice Tracks fixed pools state by maturity.\\n mapping(uint256 => FixedLib.Pool) public fixedPools;\\n\\n /// @notice Tracks fixed deposit and borrow map and floating borrow shares of an account.\\n mapping(address => Account) public accounts;\\n\\n /// @notice Amount of assets lent by the floating pool to the fixed pools.\\n uint256 public floatingBackupBorrowed;\\n /// @notice Amount of assets lent by the floating pool to accounts.\\n uint256 public floatingDebt;\\n\\n /// @notice Accumulated earnings from extraordinary sources to be gradually distributed.\\n uint256 public earningsAccumulator;\\n /// @notice Rate per second to be charged to delayed fixed pools borrowers after maturity.\\n uint256 public penaltyRate;\\n /// @notice Rate charged to the fixed pool to be retained by the floating pool for initially providing liquidity.\\n uint256 public backupFeeRate;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is higher.\\n uint256 public dampSpeedUp;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is lower.\\n uint256 public dampSpeedDown;\\n\\n /// @notice Number of fixed pools to be active at the same time.\\n uint8 public maxFuturePools;\\n /// @notice Last time the accumulator distributed earnings.\\n uint32 public lastAccumulatorAccrual;\\n /// @notice Last time the floating debt was updated.\\n uint32 public lastFloatingDebtUpdate;\\n /// @notice Last time the floating assets average was updated.\\n uint32 public lastAverageUpdate;\\n\\n /// @notice Interest rate model contract used to get the borrow rates.\\n InterestRateModel public interestRateModel;\\n\\n /// @notice Factor used for gradual accrual of earnings to the floating pool.\\n uint128 public earningsAccumulatorSmoothFactor;\\n /// @notice Percentage factor that represents the liquidity reserves that can't be borrowed.\\n uint128 public reserveFactor;\\n\\n /// @notice Amount of floating assets deposited to the pool.\\n uint256 public floatingAssets;\\n /// @notice Average of the floating assets to get fixed borrow rates and prevent rate manipulation.\\n uint256 public floatingAssetsAverage;\\n\\n /// @notice Total amount of floating borrow shares assigned to floating borrow accounts.\\n uint256 public totalFloatingBorrowShares;\\n\\n /// @dev gap from deprecated state.\\n /// @custom:oz-renamed-from floatingUtilization\\n uint256 private __gap;\\n\\n /// @notice Address of the treasury that will receive the allocated earnings.\\n address public treasury;\\n /// @notice Rate to be charged by the treasury to floating and fixed borrows.\\n uint256 public treasuryFeeRate;\\n\\n /// @notice Address of the rewards controller that will accrue rewards for accounts operating with the Market.\\n RewardsController public rewardsController;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(ERC20 asset_, Auditor auditor_) ERC4626(asset_, \\\"\\\", \\\"\\\") {\\n auditor = auditor_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(\\n uint8 maxFuturePools_,\\n uint128 earningsAccumulatorSmoothFactor_,\\n InterestRateModel interestRateModel_,\\n uint256 penaltyRate_,\\n uint256 backupFeeRate_,\\n uint128 reserveFactor_,\\n uint256 dampSpeedUp_,\\n uint256 dampSpeedDown_\\n ) external initializer {\\n __AccessControl_init();\\n __Pausable_init();\\n\\n string memory assetSymbol = asset.symbol();\\n name = string.concat(\\\"exactly \\\", assetSymbol);\\n symbol = string.concat(\\\"exa\\\", assetSymbol);\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n lastAverageUpdate = uint32(block.timestamp);\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setMaxFuturePools(maxFuturePools_);\\n setEarningsAccumulatorSmoothFactor(earningsAccumulatorSmoothFactor_);\\n setInterestRateModel(interestRateModel_);\\n setPenaltyRate(penaltyRate_);\\n setBackupFeeRate(backupFeeRate_);\\n setReserveFactor(reserveFactor_);\\n setDampSpeed(dampSpeedUp_, dampSpeedDown_);\\n }\\n\\n /// @notice Borrows a certain amount from the floating pool.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return borrowShares shares corresponding to the borrowed assets.\\n function borrow(\\n uint256 assets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 borrowShares) {\\n spendAllowance(borrower, assets);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n\\n borrowShares = previewBorrow(assets);\\n\\n uint256 newFloatingDebt = floatingDebt + assets;\\n floatingDebt = newFloatingDebt;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed, also considering the reserves\\n if (floatingBackupBorrowed + newFloatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n\\n totalFloatingBorrowShares += borrowShares;\\n accounts[borrower].floatingBorrowShares += borrowShares;\\n\\n emit Borrow(msg.sender, receiver, borrower, assets, borrowShares);\\n emitMarketUpdate();\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Repays a certain amount of assets to the floating pool.\\n /// @param assets assets to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepay the actual amount that should be transferred into the protocol.\\n /// @return borrowShares subtracted shares from the borrower's accountability.\\n function repay(\\n uint256 assets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepay, uint256 borrowShares) {\\n (actualRepay, borrowShares) = noTransferRefund(previewRepay(assets), borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), actualRepay);\\n }\\n\\n /// @notice Repays a certain amount of shares to the floating pool.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return assets subtracted assets from the borrower's accountability.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function refund(\\n uint256 borrowShares,\\n address borrower\\n ) external whenNotPaused returns (uint256 assets, uint256 actualShares) {\\n (assets, actualShares) = noTransferRefund(borrowShares, borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Allows to (partially) repay a floating borrow. It does not transfer assets.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower the address of the account that has the debt.\\n /// @return assets the actual amount that should be transferred into the protocol.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function noTransferRefund(\\n uint256 borrowShares,\\n address borrower\\n ) internal returns (uint256 assets, uint256 actualShares) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n Account storage account = accounts[borrower];\\n uint256 accountBorrowShares = account.floatingBorrowShares;\\n actualShares = Math.min(borrowShares, accountBorrowShares);\\n assets = previewRefund(actualShares);\\n\\n if (assets == 0) revert ZeroRepay();\\n\\n floatingDebt -= assets;\\n account.floatingBorrowShares = accountBorrowShares - actualShares;\\n totalFloatingBorrowShares -= actualShares;\\n\\n emit Repay(msg.sender, borrower, assets, actualShares);\\n }\\n\\n /// @notice Deposits a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be deposited.\\n /// @param assets amount to receive from the msg.sender.\\n /// @param minAssetsRequired minimum amount of assets required by the depositor for the transaction to be accepted.\\n /// @param receiver address that will be able to withdraw the deposited assets.\\n /// @return positionAssets total amount of assets (principal + fee) to be withdrawn at maturity.\\n function depositAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 minAssetsRequired,\\n address receiver\\n ) external whenNotPaused returns (uint256 positionAssets) {\\n if (assets == 0) revert ZeroDeposit();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n (uint256 fee, uint256 backupFee) = pool.calculateDeposit(assets, backupFeeRate);\\n positionAssets = assets + fee;\\n if (positionAssets < minAssetsRequired) revert Disagreement();\\n\\n floatingBackupBorrowed -= pool.deposit(assets);\\n pool.unassignedEarnings -= fee + backupFee;\\n earningsAccumulator += backupFee;\\n\\n // update account's position\\n FixedLib.Position storage position = fixedDepositPositions[maturity][receiver];\\n\\n // if account doesn't have a current position, add it to the list\\n if (position.principal == 0) {\\n Account storage account = accounts[receiver];\\n account.fixedDeposits = account.fixedDeposits.setMaturity(maturity);\\n }\\n\\n position.principal += assets;\\n position.fee += fee;\\n\\n floatingAssets += backupEarnings;\\n\\n emit DepositAtMaturity(maturity, msg.sender, receiver, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Borrows a certain amount from a maturity.\\n /// @param maturity maturity date for repayment.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return assetsOwed total amount of assets (principal + fee) to be repaid at maturity.\\n function borrowAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 maxAssets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 assetsOwed) {\\n if (assets == 0) revert ZeroBorrow();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n uint256 fee = assets.mulWadDown(\\n interestRateModel.fixedBorrowRate(maturity, assets, pool.borrowed, pool.supplied, previewFloatingAssetsAverage())\\n );\\n assetsOwed = assets + fee;\\n\\n // validate that the account is not taking arbitrary fees\\n if (assetsOwed > maxAssets) revert Disagreement();\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n spendAllowance(borrower, assetsOwed);\\n\\n {\\n uint256 backupDebtAddition = pool.borrow(assets);\\n if (backupDebtAddition > 0) {\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed + backupDebtAddition;\\n depositToTreasury(updateFloatingDebt());\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n }\\n\\n {\\n // if account doesn't have a current position, add it to the list\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n if (position.principal == 0) {\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.setMaturity(maturity);\\n }\\n\\n // calculate what portion of the fees are to be accrued and what portion goes to earnings accumulator\\n (uint256 newUnassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(fee),\\n assets\\n );\\n if (newUnassignedEarnings > 0) pool.unassignedEarnings += newUnassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n fixedBorrowPositions[maturity][borrower] = FixedLib.Position(position.principal + assets, position.fee + fee);\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit BorrowAtMaturity(maturity, msg.sender, receiver, borrower, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Withdraws a certain amount from a maturity.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param maturity maturity date where the assets will be withdrawn.\\n /// @param positionAssets position size to be reduced.\\n /// @param minAssetsRequired minimum amount required by the account (if discount included for early withdrawal).\\n /// @param receiver address that will receive the withdrawn assets.\\n /// @param owner address that previously deposited the assets.\\n /// @return assetsDiscounted amount of assets withdrawn (can include a discount for early withdraw).\\n function withdrawAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 minAssetsRequired,\\n address receiver,\\n address owner\\n ) external returns (uint256 assetsDiscounted) {\\n if (positionAssets == 0) revert ZeroWithdraw();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedDepositPositions[maturity][owner];\\n\\n if (positionAssets > position.principal + position.fee) positionAssets = position.principal + position.fee;\\n\\n // verify if there are any penalties/fee for the account because of early withdrawal, if so discount\\n if (block.timestamp < maturity) {\\n assetsDiscounted = positionAssets.divWadDown(\\n 1e18 +\\n interestRateModel.fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n previewFloatingAssetsAverage()\\n )\\n );\\n } else {\\n assetsDiscounted = positionAssets;\\n }\\n\\n if (assetsDiscounted < minAssetsRequired) revert Disagreement();\\n\\n spendAllowance(owner, assetsDiscounted);\\n\\n {\\n // remove the supply from the fixed rate pool\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed +\\n pool.withdraw(\\n FixedLib.Position(position.principal, position.fee).scaleProportionally(positionAssets).principal\\n );\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets) revert InsufficientProtocolLiquidity();\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n\\n // all the fees go to unassigned or to the floating pool\\n (uint256 unassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(positionAssets - assetsDiscounted),\\n assetsDiscounted\\n );\\n pool.unassignedEarnings += unassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n // the account gets discounted the full amount\\n position.reduceProportionally(positionAssets);\\n if (position.principal | position.fee == 0) {\\n delete fixedDepositPositions[maturity][owner];\\n Account storage account = accounts[owner];\\n account.fixedDeposits = account.fixedDeposits.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedDepositPositions[maturity][owner] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit WithdrawAtMaturity(maturity, msg.sender, receiver, owner, positionAssets, assetsDiscounted);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransfer(receiver, assetsDiscounted);\\n }\\n\\n /// @notice Repays a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be repaid.\\n /// @param positionAssets amount to be paid for the borrower's debt.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepayAssets the actual amount that was transferred into the protocol.\\n function repayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepayAssets) {\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n actualRepayAssets = noTransferRepayAtMaturity(maturity, positionAssets, maxAssets, borrower, true);\\n emitMarketUpdate();\\n\\n asset.safeTransferFrom(msg.sender, address(this), actualRepayAssets);\\n }\\n\\n /// @notice Allows to (partially) repay a fixed rate position. It does not transfer assets.\\n /// @param maturity the maturity to access the pool.\\n /// @param positionAssets the amount of debt of the pool that should be paid.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower the address of the account that has the debt.\\n /// @param canDiscount should early repay discounts be applied.\\n /// @return actualRepayAssets the actual amount that should be transferred into the protocol.\\n function noTransferRepayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower,\\n bool canDiscount\\n ) internal returns (uint256 actualRepayAssets) {\\n if (positionAssets == 0) revert ZeroRepay();\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedBorrowPositions[maturity][borrower];\\n\\n uint256 debtCovered = Math.min(positionAssets, position.principal + position.fee);\\n\\n uint256 principalCovered = FixedLib\\n .Position(position.principal, position.fee)\\n .scaleProportionally(debtCovered)\\n .principal;\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n // early repayment allows a discount from the unassigned earnings\\n if (block.timestamp < maturity) {\\n if (canDiscount) {\\n // calculate the deposit fee considering the amount of debt the account'll pay\\n (uint256 discountFee, uint256 backupFee) = pool.calculateDeposit(principalCovered, backupFeeRate);\\n\\n // remove the fee from unassigned earnings\\n pool.unassignedEarnings -= discountFee + backupFee;\\n\\n // the fee charged to the fixed pool supplier goes to the earnings accumulator\\n earningsAccumulator += backupFee;\\n\\n // the fee gets discounted from the account through `actualRepayAssets`\\n actualRepayAssets = debtCovered - discountFee;\\n } else {\\n actualRepayAssets = debtCovered;\\n }\\n } else {\\n actualRepayAssets = debtCovered + debtCovered.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n\\n // all penalties go to the earnings accumulator\\n earningsAccumulator += actualRepayAssets - debtCovered;\\n }\\n\\n // verify that the account agrees to this discount or penalty\\n if (actualRepayAssets > maxAssets) revert Disagreement();\\n\\n // reduce the borrowed from the pool and might decrease the floating backup borrowed\\n floatingBackupBorrowed -= pool.repay(principalCovered);\\n\\n // update the account position\\n position.reduceProportionally(debtCovered);\\n if (position.principal | position.fee == 0) {\\n delete fixedBorrowPositions[maturity][borrower];\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedBorrowPositions[maturity][borrower] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, actualRepayAssets, debtCovered);\\n emitFixedEarningsUpdate(maturity);\\n }\\n\\n /// @notice Liquidates undercollateralized fixed/floating (or both) position(s).\\n /// @dev Msg.sender liquidates borrower's position(s) and repays a certain amount of debt for the floating pool,\\n /// or/and for multiple fixed pools, seizing a portion of borrower's collateral.\\n /// @param borrower account that has an outstanding debt across floating or fixed pools.\\n /// @param maxAssets maximum amount of debt that the liquidator is willing to accept. (it can be less)\\n /// @param seizeMarket market from which the collateral will be seized to give to the liquidator.\\n /// @return repaidAssets actual amount repaid.\\n function liquidate(\\n address borrower,\\n uint256 maxAssets,\\n Market seizeMarket\\n ) external whenNotPaused returns (uint256 repaidAssets) {\\n if (msg.sender == borrower) revert SelfLiquidation();\\n\\n maxAssets = auditor.checkLiquidation(this, seizeMarket, borrower, maxAssets);\\n if (maxAssets == 0) revert ZeroRepay();\\n\\n Account storage account = accounts[borrower];\\n\\n {\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0 && maxAssets != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 actualRepay;\\n if (block.timestamp < maturity) {\\n actualRepay = noTransferRepayAtMaturity(maturity, maxAssets, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n } else {\\n uint256 position;\\n {\\n FixedLib.Position storage p = fixedBorrowPositions[maturity][borrower];\\n position = p.principal + p.fee;\\n }\\n uint256 debt = position + position.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n actualRepay = debt > maxAssets ? maxAssets.mulDivDown(position, debt) : maxAssets;\\n\\n if (actualRepay == 0) maxAssets = 0;\\n else {\\n actualRepay = noTransferRepayAtMaturity(maturity, actualRepay, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n }\\n }\\n repaidAssets += actualRepay;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n if (maxAssets > 0 && account.floatingBorrowShares > 0) {\\n uint256 borrowShares = previewRepay(maxAssets);\\n if (borrowShares > 0) {\\n (uint256 actualRepayAssets, ) = noTransferRefund(borrowShares, borrower);\\n repaidAssets += actualRepayAssets;\\n }\\n }\\n\\n // reverts on failure\\n (uint256 lendersAssets, uint256 seizeAssets) = auditor.calculateSeize(this, seizeMarket, borrower, repaidAssets);\\n earningsAccumulator += lendersAssets;\\n\\n if (address(seizeMarket) == address(this)) {\\n internalSeize(this, msg.sender, borrower, seizeAssets);\\n } else {\\n seizeMarket.seize(msg.sender, borrower, seizeAssets);\\n\\n emitMarketUpdate();\\n }\\n\\n emit Liquidate(msg.sender, borrower, repaidAssets, lendersAssets, seizeMarket, seizeAssets);\\n\\n auditor.handleBadDebt(borrower);\\n\\n asset.safeTransferFrom(msg.sender, address(this), repaidAssets + lendersAssets);\\n }\\n\\n /// @notice Clears floating and fixed debt for an account spreading the losses to the `earningsAccumulator`.\\n /// @dev Can only be called from the auditor.\\n /// @param borrower account with insufficient collateral to be cleared the debt.\\n function clearBadDebt(address borrower) external {\\n if (msg.sender != address(auditor)) revert NotAuditor();\\n\\n floatingAssets += accrueAccumulatedEarnings();\\n Account storage account = accounts[borrower];\\n uint256 accumulator = earningsAccumulator;\\n uint256 totalBadDebt = 0;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 badDebt = position.principal + position.fee;\\n if (accumulator >= badDebt) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n accumulator -= badDebt;\\n totalBadDebt += badDebt;\\n floatingBackupBorrowed -= fixedPools[maturity].repay(position.principal);\\n delete fixedBorrowPositions[maturity][borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, badDebt, badDebt);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n if (account.floatingBorrowShares > 0 && (accumulator = previewRepay(accumulator)) > 0) {\\n (uint256 badDebt, ) = noTransferRefund(accumulator, borrower);\\n totalBadDebt += badDebt;\\n }\\n if (totalBadDebt > 0) {\\n earningsAccumulator -= totalBadDebt;\\n emit SpreadBadDebt(borrower, totalBadDebt);\\n }\\n emitMarketUpdate();\\n }\\n\\n /// @notice Public function to seize a certain amount of assets.\\n /// @dev Public function for liquidator to seize borrowers assets in the floating pool.\\n /// This function will only be called from another Market, on `liquidation` calls.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function seize(address liquidator, address borrower, uint256 assets) external whenNotPaused {\\n internalSeize(Market(msg.sender), liquidator, borrower, assets);\\n }\\n\\n /// @notice Internal function to seize a certain amount of assets.\\n /// @dev Internal function for liquidator to seize borrowers assets in the floating pool.\\n /// Will only be called from this Market on `liquidation` or through `seize` calls from another Market.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param seizeMarket address which is calling the seize function (see `seize` public function).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function internalSeize(Market seizeMarket, address liquidator, address borrower, uint256 assets) internal {\\n if (assets == 0) revert ZeroWithdraw();\\n\\n // reverts on failure\\n auditor.checkSeize(seizeMarket, this);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(borrower);\\n uint256 shares = previewWithdraw(assets);\\n beforeWithdraw(assets, shares);\\n _burn(borrower, shares);\\n emit Withdraw(msg.sender, liquidator, borrower, assets, shares);\\n emit Seize(liquidator, borrower, assets);\\n emitMarketUpdate();\\n\\n asset.safeTransfer(liquidator, assets);\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param assets amount of assets to be withdrawn from the floating pool.\\n function beforeWithdraw(uint256 assets, uint256) internal override {\\n updateFloatingAssetsAverage();\\n depositToTreasury(updateFloatingDebt());\\n uint256 earnings = accrueAccumulatedEarnings();\\n uint256 newFloatingAssets = floatingAssets + earnings - assets;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed\\n if (floatingBackupBorrowed + floatingDebt > newFloatingAssets) revert InsufficientProtocolLiquidity();\\n floatingAssets = newFloatingAssets;\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @param assets amount of assets to be deposited to the floating pool.\\n function afterDeposit(uint256 assets, uint256) internal override whenNotPaused {\\n updateFloatingAssetsAverage();\\n uint256 treasuryFee = updateFloatingDebt();\\n uint256 earnings = accrueAccumulatedEarnings();\\n floatingAssets += earnings + assets;\\n depositToTreasury(treasuryFee);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Withdraws the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param assets amount of underlying to be withdrawn.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return shares amount of shares redeemed for underlying asset.\\n function withdraw(uint256 assets, address receiver, address owner) public override returns (uint256 shares) {\\n auditor.checkShortfall(this, owner, assets);\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n shares = super.withdraw(assets, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Redeems the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param shares amount of shares to be redeemed for underlying asset.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return assets amount of underlying asset that was withdrawn.\\n function redeem(uint256 shares, address receiver, address owner) public override returns (uint256 assets) {\\n auditor.checkShortfall(this, owner, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n assets = super.redeem(shares, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n function _mint(address to, uint256 amount) internal override {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(to);\\n super._mint(to, amount);\\n }\\n\\n /// @notice Moves amount of shares from the caller's account to `to`.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that the caller doesn't have shortfall after transferring.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transfer(address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, msg.sender, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(msg.sender);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transfer(to, shares);\\n }\\n\\n /// @notice Moves amount of shares from `from` to `to` using the allowance mechanism.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that `from` address doesn't have shortfall after transferring.\\n /// @param from address from which the assets will be transferred.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transferFrom(address from, address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, from, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(from);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transferFrom(from, to, shares);\\n }\\n\\n /// @notice Gets current snapshot for an account across all maturities.\\n /// @param account account to return status snapshot in the specified maturity date.\\n /// @return the amount deposited to the floating pool and the amount owed to floating and fixed pools.\\n function accountSnapshot(address account) external view returns (uint256, uint256) {\\n return (convertToAssets(balanceOf[account]), previewDebt(account));\\n }\\n\\n /// @notice Gets all borrows and penalties for an account.\\n /// @param borrower account to return status snapshot for fixed and floating borrows.\\n /// @return debt the total debt, denominated in number of assets.\\n function previewDebt(address borrower) public view returns (uint256 debt) {\\n Account storage account = accounts[borrower];\\n uint256 memPenaltyRate = penaltyRate;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n // calculate all maturities using the base maturity and the following bits representing the following intervals\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 positionAssets = position.principal + position.fee;\\n\\n debt += positionAssets;\\n\\n if (block.timestamp > maturity) {\\n debt += positionAssets.mulWadDown((block.timestamp - maturity) * memPenaltyRate);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n // calculate floating borrowed debt\\n uint256 shares = account.floatingBorrowShares;\\n if (shares > 0) debt += previewRefund(shares);\\n }\\n\\n /// @notice Charges treasury fee to certain amount of earnings.\\n /// @param earnings amount of earnings.\\n /// @return earnings minus the fees charged by the treasury.\\n function chargeTreasuryFee(uint256 earnings) internal returns (uint256) {\\n uint256 fee = earnings.mulWadDown(treasuryFeeRate);\\n depositToTreasury(fee);\\n return earnings - fee;\\n }\\n\\n /// @notice Collects all earnings that are charged to borrowers that make use of fixed pool deposits' assets.\\n /// @param earnings amount of earnings.\\n function collectFreeLunch(uint256 earnings) internal {\\n if (earnings == 0) return;\\n\\n if (treasuryFeeRate > 0) {\\n depositToTreasury(earnings);\\n } else {\\n earningsAccumulator += earnings;\\n }\\n }\\n\\n /// @notice Deposits amount of assets on behalf of the treasury address.\\n /// @param fee amount of assets to be deposited.\\n function depositToTreasury(uint256 fee) internal {\\n if (fee > 0) {\\n _mint(treasury, previewDeposit(fee));\\n floatingAssets += fee;\\n }\\n }\\n\\n /// @notice Calculates the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings to be distributed from the accumulator.\\n function accumulatedEarnings() internal view returns (uint256 earnings) {\\n uint256 elapsed = block.timestamp - lastAccumulatorAccrual;\\n if (elapsed == 0) return 0;\\n return\\n earningsAccumulator.mulDivDown(\\n elapsed,\\n elapsed + earningsAccumulatorSmoothFactor.mulWadDown(maxFuturePools * FixedLib.INTERVAL)\\n );\\n }\\n\\n /// @notice Accrues the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings distributed from the accumulator.\\n function accrueAccumulatedEarnings() internal returns (uint256 earnings) {\\n earnings = accumulatedEarnings();\\n\\n earningsAccumulator -= earnings;\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n emit AccumulatorAccrual(block.timestamp);\\n }\\n\\n /// @notice Updates the `floatingAssetsAverage`.\\n function updateFloatingAssetsAverage() internal {\\n floatingAssetsAverage = previewFloatingAssetsAverage();\\n lastAverageUpdate = uint32(block.timestamp);\\n }\\n\\n /// @notice Returns the current `floatingAssetsAverage` without updating the storage variable.\\n /// @return projected `floatingAssetsAverage`.\\n function previewFloatingAssetsAverage() public view returns (uint256) {\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 memFloatingAssetsAverage = floatingAssetsAverage;\\n uint256 dampSpeedFactor = memFloatingAssets < memFloatingAssetsAverage ? dampSpeedDown : dampSpeedUp;\\n uint256 averageFactor = uint256(1e18 - (-int256(dampSpeedFactor * (block.timestamp - lastAverageUpdate))).expWad());\\n return memFloatingAssetsAverage.mulWadDown(1e18 - averageFactor) + averageFactor.mulWadDown(memFloatingAssets);\\n }\\n\\n /// @notice Updates the floating pool borrows' variables.\\n /// @return treasuryFee amount of fees charged by the treasury to the new calculated floating debt.\\n function updateFloatingDebt() internal returns (uint256 treasuryFee) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n\\n memFloatingDebt += newDebt;\\n treasuryFee = newDebt.mulWadDown(treasuryFeeRate);\\n floatingAssets = memFloatingAssets + newDebt - treasuryFee;\\n floatingDebt = memFloatingDebt;\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n emit FloatingDebtUpdate(block.timestamp, floatingUtilization);\\n }\\n\\n /// @notice Calculates the total floating debt, considering elapsed time since last update and current interest rate.\\n /// @return actual floating debt plus projected interest.\\n function totalFloatingBorrowAssets() public view returns (uint256) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n return memFloatingDebt + newDebt;\\n }\\n\\n /// @notice Calculates the floating pool balance plus earnings to be accrued at current timestamp\\n /// from maturities and accumulator.\\n /// @return actual floatingAssets plus earnings to be accrued at current timestamp.\\n function totalAssets() public view override returns (uint256) {\\n unchecked {\\n uint256 memMaxFuturePools = maxFuturePools;\\n uint256 backupEarnings = 0;\\n\\n uint256 latestMaturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL);\\n uint256 maxMaturity = latestMaturity + memMaxFuturePools * FixedLib.INTERVAL;\\n\\n for (uint256 maturity = latestMaturity; maturity <= maxMaturity; maturity += FixedLib.INTERVAL) {\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (maturity > lastAccrual) {\\n backupEarnings += block.timestamp < maturity\\n ? pool.unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual)\\n : pool.unassignedEarnings;\\n }\\n }\\n\\n return\\n floatingAssets +\\n backupEarnings +\\n accumulatedEarnings() +\\n (totalFloatingBorrowAssets() - floatingDebt).mulWadDown(1e18 - treasuryFeeRate);\\n }\\n }\\n\\n /// @notice Simulates the effects of a borrow at the current time, given current contract conditions.\\n /// @param assets amount of assets to borrow.\\n /// @return amount of shares that will be asigned to the account after the borrow.\\n function previewBorrow(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a repay at the current time, given current contract conditions.\\n /// @param assets amount of assets to repay.\\n /// @return amount of shares that will be subtracted from the account after the repay.\\n function previewRepay(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a refund at the current time, given current contract conditions.\\n /// @param shares amount of shares to subtract from caller's accountability.\\n /// @return amount of assets that will be repaid.\\n function previewRefund(uint256 shares) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalFloatingBorrowAssets(), supply);\\n }\\n\\n /// @notice Checks msg.sender's allowance over account's assets.\\n /// @param account account in which the allowance will be checked.\\n /// @param assets assets from account that msg.sender wants to operate on.\\n function spendAllowance(address account, uint256 assets) internal {\\n if (msg.sender != account) {\\n uint256 allowed = allowance[account][msg.sender]; // saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[account][msg.sender] = allowed - previewWithdraw(assets);\\n }\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed amount of the fixed pool.\\n function fixedPoolBorrowed(uint256 maturity) external view returns (uint256) {\\n return fixedPools[maturity].borrowed;\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed and supplied amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed and supplied amount of the fixed pool.\\n function fixedPoolBalance(uint256 maturity) external view returns (uint256, uint256) {\\n return (fixedPools[maturity].borrowed, fixedPools[maturity].supplied);\\n }\\n\\n /// @notice Emits MarketUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitMarketUpdate() internal {\\n emit MarketUpdate(\\n block.timestamp,\\n totalSupply,\\n floatingAssets,\\n totalFloatingBorrowShares,\\n floatingDebt,\\n earningsAccumulator\\n );\\n }\\n\\n /// @notice Emits FixedEarningsUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitFixedEarningsUpdate(uint256 maturity) internal {\\n emit FixedEarningsUpdate(block.timestamp, maturity, fixedPools[maturity].unassignedEarnings);\\n }\\n\\n /// @notice Sets the rate charged to the fixed depositors that the floating pool suppliers will retain for initially\\n /// providing liquidity.\\n /// @param backupFeeRate_ percentage amount represented with 18 decimals.\\n function setBackupFeeRate(uint256 backupFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n backupFeeRate = backupFeeRate_;\\n emit BackupFeeRateSet(backupFeeRate_);\\n }\\n\\n /// @notice Sets the damp speed used to update the floatingAssetsAverage.\\n /// @param up damp speed up, represented with 18 decimals.\\n /// @param down damp speed down, represented with 18 decimals.\\n function setDampSpeed(uint256 up, uint256 down) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n updateFloatingAssetsAverage();\\n dampSpeedUp = up;\\n dampSpeedDown = down;\\n emit DampSpeedSet(up, down);\\n }\\n\\n /// @notice Sets the factor used when smoothly accruing earnings to the floating pool.\\n /// @param earningsAccumulatorSmoothFactor_ represented with 18 decimals.\\n function setEarningsAccumulatorSmoothFactor(\\n uint128 earningsAccumulatorSmoothFactor_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n floatingAssets += accrueAccumulatedEarnings();\\n emitMarketUpdate();\\n earningsAccumulatorSmoothFactor = earningsAccumulatorSmoothFactor_;\\n emit EarningsAccumulatorSmoothFactorSet(earningsAccumulatorSmoothFactor_);\\n }\\n\\n /// @notice Sets the interest rate model to be used to calculate rates.\\n /// @param interestRateModel_ new interest rate model.\\n function setInterestRateModel(InterestRateModel interestRateModel_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(interestRateModel) != address(0)) depositToTreasury(updateFloatingDebt());\\n\\n interestRateModel = interestRateModel_;\\n emitMarketUpdate();\\n emit InterestRateModelSet(interestRateModel_);\\n }\\n\\n /// @notice Sets the rewards controller to update account rewards when operating with the Market.\\n /// @param rewardsController_ new rewards controller.\\n function setRewardsController(RewardsController rewardsController_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n rewardsController = rewardsController_;\\n emit RewardsControllerSet(rewardsController_);\\n }\\n\\n /// @notice Sets the protocol's max future pools for fixed borrowing and lending.\\n /// @dev If value is decreased, VALID maturities will become NOT_READY.\\n /// @param futurePools number of pools to be active at the same time.\\n function setMaxFuturePools(uint8 futurePools) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n maxFuturePools = futurePools;\\n emit MaxFuturePoolsSet(futurePools);\\n }\\n\\n /// @notice Sets the penalty rate per second.\\n /// @param penaltyRate_ percentage represented with 18 decimals.\\n function setPenaltyRate(uint256 penaltyRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n penaltyRate = penaltyRate_;\\n emit PenaltyRateSet(penaltyRate_);\\n }\\n\\n /// @notice Sets the percentage that represents the liquidity reserves that can't be borrowed.\\n /// @param reserveFactor_ parameter represented with 18 decimals.\\n function setReserveFactor(uint128 reserveFactor_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n reserveFactor = reserveFactor_;\\n emit ReserveFactorSet(reserveFactor_);\\n }\\n\\n /// @notice Sets the treasury variables.\\n /// @param treasury_ address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate_ represented with 18 decimals.\\n function setTreasury(address treasury_, uint256 treasuryFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n depositToTreasury(updateFloatingDebt());\\n treasury = treasury_;\\n treasuryFeeRate = treasuryFeeRate_;\\n emit TreasurySet(treasury_, treasuryFeeRate_);\\n }\\n\\n /// @notice Sets the pause state to true in case of emergency, triggered by an authorized account.\\n function pause() external onlyRole(PAUSER_ROLE) {\\n _pause();\\n }\\n\\n /// @notice Sets the pause state to false when threat is gone, triggered by an authorized account.\\n function unpause() external onlyRole(PAUSER_ROLE) {\\n _unpause();\\n }\\n\\n /// @notice Event emitted when an account borrows amount of assets from a floating pool.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of assets that were borrowed.\\n /// @param shares amount of borrow shares assigned to the account.\\n event Borrow(\\n address indexed caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /// @notice Emitted when an account repays amount of assets to a floating pool.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of assets that was repaid.\\n /// @param shares amount of borrow shares that were subtracted from the account's accountability.\\n event Repay(address indexed caller, address indexed borrower, uint256 assets, uint256 shares);\\n\\n /// @notice Emitted when an account deposits an amount of an asset to a certain fixed rate pool,\\n /// collecting fees at the end of the period.\\n /// @param maturity maturity at which the account will be able to collect his deposit + his fee.\\n /// @param caller address which deposited the assets.\\n /// @param owner address that will be able to withdraw the deposited assets.\\n /// @param assets amount of the asset that were deposited.\\n /// @param fee is the extra amount that it will be collected at maturity.\\n event DepositAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed owner,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account withdraws from a fixed rate pool.\\n /// @param maturity maturity where the account withdraw its deposits.\\n /// @param caller address which withdraw the asset.\\n /// @param receiver address which will be collecting the assets.\\n /// @param owner address which had the assets withdrawn.\\n /// @param positionAssets position size reduced.\\n /// @param assets amount of assets withdrawn (can include a discount for early withdraw).\\n event WithdrawAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 positionAssets,\\n uint256 assets\\n );\\n\\n /// @notice Emitted when an account borrows amount of an asset from a certain maturity date.\\n /// @param maturity maturity in which the account will have to repay the loan.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of the asset that were borrowed.\\n /// @param fee extra amount that will need to be paid at maturity.\\n event BorrowAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account repays its borrows after maturity.\\n /// @param maturity maturity where the account repaid its borrowed amounts.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount that was repaid.\\n /// @param positionAssets amount of the debt that was covered in this repayment (penalties could have been repaid).\\n event RepayAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed borrower,\\n uint256 assets,\\n uint256 positionAssets\\n );\\n\\n /// @notice Emitted when an account's position had a liquidation.\\n /// @param receiver address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of the asset that were repaid.\\n /// @param lendersAssets incentive paid to lenders.\\n /// @param seizeMarket address of the asset that were seized by the liquidator.\\n /// @param seizedAssets amount seized of the collateral.\\n event Liquidate(\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 lendersAssets,\\n Market indexed seizeMarket,\\n uint256 seizedAssets\\n );\\n\\n /// @notice Emitted when an account's collateral has been seized.\\n /// @param liquidator address which seized this collateral.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount seized of the collateral.\\n event Seize(address indexed liquidator, address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when an account is cleared from bad debt.\\n /// @param borrower address which was cleared from bad debt.\\n /// @param assets amount that was subtracted from the borrower's debt and spread to the `earningsAccumulator`.\\n event SpreadBadDebt(address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when the backupFeeRate parameter is changed by admin.\\n /// @param backupFeeRate rate charged to the fixed pools to be accrued by the floating depositors.\\n event BackupFeeRateSet(uint256 backupFeeRate);\\n\\n /// @notice Emitted when the damp speeds are changed by admin.\\n /// @param dampSpeedUp represented with 18 decimals.\\n /// @param dampSpeedDown represented with 18 decimals.\\n event DampSpeedSet(uint256 dampSpeedUp, uint256 dampSpeedDown);\\n\\n /// @notice Emitted when the earningsAccumulatorSmoothFactor is changed by admin.\\n /// @param earningsAccumulatorSmoothFactor factor represented with 18 decimals.\\n event EarningsAccumulatorSmoothFactorSet(uint256 earningsAccumulatorSmoothFactor);\\n\\n /// @notice Emitted when the interestRateModel is changed by admin.\\n /// @param interestRateModel new interest rate model to be used to calculate rates.\\n event InterestRateModelSet(InterestRateModel indexed interestRateModel);\\n\\n /// @notice Emitted when the maxFuturePools is changed by admin.\\n /// @param maxFuturePools represented with 0 decimals.\\n event MaxFuturePoolsSet(uint256 maxFuturePools);\\n\\n /// @notice Emitted when the penaltyRate is changed by admin.\\n /// @param penaltyRate penaltyRate percentage per second represented with 18 decimals.\\n event PenaltyRateSet(uint256 penaltyRate);\\n\\n /// @notice Emitted when the reserveFactor is changed by admin.\\n /// @param reserveFactor reserveFactor percentage.\\n event ReserveFactorSet(uint256 reserveFactor);\\n\\n /// @notice Emitted when the treasury variables are changed by admin.\\n /// @param treasury address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate represented with 18 decimals.\\n event TreasurySet(address indexed treasury, uint256 treasuryFeeRate);\\n\\n /// @notice Emitted when the rewardsController is changed by admin.\\n /// @param rewardsController new rewards controller to update account rewards when operating with the Market.\\n event RewardsControllerSet(RewardsController indexed rewardsController);\\n\\n /// @notice Emitted when market state is updated.\\n /// @param timestamp current timestamp.\\n /// @param floatingDepositShares total floating supply shares.\\n /// @param floatingAssets total floating supply assets.\\n /// @param floatingBorrowShares total floating borrow shares.\\n /// @param floatingDebt total floating borrow assets.\\n /// @param earningsAccumulator earnings accumulator.\\n event MarketUpdate(\\n uint256 timestamp,\\n uint256 floatingDepositShares,\\n uint256 floatingAssets,\\n uint256 floatingBorrowShares,\\n uint256 floatingDebt,\\n uint256 earningsAccumulator\\n );\\n\\n /// @notice Emitted when the earnings of a maturity are updated.\\n /// @param timestamp current timestamp.\\n /// @param maturity maturity date where the earnings were updated.\\n /// @param unassignedEarnings pending unassigned earnings.\\n event FixedEarningsUpdate(uint256 timestamp, uint256 indexed maturity, uint256 unassignedEarnings);\\n\\n /// @notice Emitted when accumulator distributes earnings.\\n /// @param timestamp current timestamp.\\n event AccumulatorAccrual(uint256 timestamp);\\n\\n /// @notice Emitted when the floating debt is updated.\\n /// @param timestamp current timestamp.\\n /// @param utilization new floating utilization.\\n event FloatingDebtUpdate(uint256 timestamp, uint256 utilization);\\n\\n /// @notice Stores fixed deposits and fixed borrows map and floating borrow shares of an account.\\n /// @param fixedDeposits encoded map maturity dates where the account supplied to.\\n /// @param fixedBorrows encoded map maturity dates where the account borrowed from.\\n /// @param floatingBorrowShares number of floating borrow shares assigned to the account.\\n struct Account {\\n uint256 fixedDeposits;\\n uint256 fixedBorrows;\\n uint256 floatingBorrowShares;\\n }\\n}\\n\\nerror Disagreement();\\nerror InsufficientProtocolLiquidity();\\nerror NotAuditor();\\nerror SelfLiquidation();\\nerror ZeroBorrow();\\nerror ZeroDeposit();\\nerror ZeroRepay();\\nerror ZeroWithdraw();\\n\",\"keccak256\":\"0x94894ef0aeac99df31979475878d006fb676a9d795d9cfc3b3b1ed321ed672d8\",\"license\":\"BUSL-1.1\"},\"contracts/RewardsController.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/src/utils/SafeTransferLib.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract RewardsController is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint64;\\n using FixedPointMathLib for int256;\\n using SafeTransferLib for ERC20;\\n\\n /// @notice Max utilization supported by the sigmoid function not to cause a division by zero (1e18 = WAD).\\n uint256 public constant UTILIZATION_CAP = 1e18 - 1;\\n /// @notice Tracks the reward distribution data for a given market.\\n mapping(Market => Distribution) public distribution;\\n /// @notice Tracks enabled asset rewards.\\n mapping(ERC20 => bool) public rewardEnabled;\\n /// @notice Stores registered asset rewards.\\n ERC20[] public rewardList;\\n /// @notice Stores Markets with distributions set.\\n Market[] public marketList;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev Can only be called once.\\n function initialize() external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded deposit.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleDeposit(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n ops[0] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n update(account, market, dist.availableRewards[r], ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded borrow.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleBorrow(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n (, , uint256 accountFloatingBorrowShares) = market.accounts(account);\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n ERC20 reward = dist.availableRewards[r];\\n ops[0] = AccountOperation({\\n operation: true,\\n balance: accountFloatingBorrowShares + accountFixedBorrowShares(market, account, dist.rewards[reward].start)\\n });\\n update(account, Market(msg.sender), reward, ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Claims all `msg.sender` rewards to the given account.\\n /// @param to The address to send the rewards to.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claimAll(address to) external returns (ERC20[] memory rewardsList, uint256[] memory claimedAmounts) {\\n return claim(allMarketsOperations(), to, rewardList);\\n }\\n\\n /// @notice Claims `msg.sender` rewards for the given operations and reward assets to the given account.\\n /// @param marketOps The operations to claim rewards for.\\n /// @param to The address to send the rewards to.\\n /// @param rewardsList The list of rewards assets to claim.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claim(\\n MarketOperation[] memory marketOps,\\n address to,\\n ERC20[] memory rewardsList\\n ) public returns (ERC20[] memory, uint256[] memory claimedAmounts) {\\n uint256 rewardsCount = rewardsList.length;\\n claimedAmounts = new uint256[](rewardsCount);\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n uint256 availableRewards = dist.availableRewardsCount;\\n for (uint128 r = 0; r < availableRewards; ) {\\n update(\\n msg.sender,\\n marketOperation.market,\\n dist.availableRewards[r],\\n accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n msg.sender,\\n dist.rewards[dist.availableRewards[r]].start\\n )\\n );\\n unchecked {\\n ++r;\\n }\\n }\\n for (uint256 r = 0; r < rewardsCount; ) {\\n RewardData storage rewardData = dist.rewards[rewardsList[r]];\\n for (uint256 o = 0; o < marketOperation.operations.length; ) {\\n uint256 rewardAmount = rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued;\\n if (rewardAmount != 0) {\\n claimedAmounts[r] += rewardAmount;\\n rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued = 0;\\n }\\n unchecked {\\n ++o;\\n }\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n for (uint256 r = 0; r < rewardsList.length; ) {\\n uint256 claimedAmount = claimedAmounts[r];\\n if (claimedAmount > 0) {\\n rewardsList[r].safeTransfer(to, claimedAmount);\\n emit Claim(msg.sender, rewardsList[r], to, claimedAmount);\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n return (rewardsList, claimedAmounts);\\n }\\n\\n /// @notice Gets the configuration of a given distribution.\\n /// @param market The market to get the distribution configuration for.\\n /// @param reward The reward asset.\\n /// @return The distribution configuration.\\n function rewardConfig(Market market, ERC20 reward) external view returns (Config memory) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return\\n Config({\\n market: market,\\n reward: reward,\\n priceFeed: rewardData.priceFeed,\\n start: rewardData.start,\\n distributionPeriod: rewardData.end - rewardData.start,\\n targetDebt: rewardData.targetDebt,\\n totalDistribution: rewardData.totalDistribution,\\n undistributedFactor: rewardData.undistributedFactor,\\n flipSpeed: rewardData.flipSpeed,\\n compensationFactor: rewardData.compensationFactor,\\n transitionFactor: rewardData.transitionFactor,\\n borrowAllocationWeightFactor: rewardData.borrowAllocationWeightFactor,\\n depositAllocationWeightAddend: rewardData.depositAllocationWeightAddend,\\n depositAllocationWeightFactor: rewardData.depositAllocationWeightFactor\\n });\\n }\\n\\n /// @notice Gets the amount of reward assets that are being distributed for a Market.\\n /// @param market Market to get the number of available rewards to distribute.\\n /// @return The amount reward assets set to a Market.\\n function availableRewardsCount(Market market) external view returns (uint256) {\\n return distribution[market].availableRewardsCount;\\n }\\n\\n /// @notice Gets the account data of a given account, Market, operation and reward asset.\\n /// @param account The account to get the operation data from.\\n /// @param market The market in which the operation was made.\\n /// @param operation True if the operation was a borrow, false if it was a deposit.\\n /// @param reward The reward asset.\\n /// @return accrued The accrued amount.\\n /// @return index The account index.\\n function accountOperation(\\n address account,\\n Market market,\\n bool operation,\\n ERC20 reward\\n ) external view returns (uint256, uint256) {\\n Account storage operationAccount = distribution[market].rewards[reward].accounts[account][operation];\\n return (operationAccount.accrued, operationAccount.index);\\n }\\n\\n /// @notice Gets the distribution `start`, `end` and `lastUpdate` value of a given market and reward.\\n /// @param market The market to get the distribution times.\\n /// @param reward The reward asset.\\n /// @return The distribution `start`, `end` and `lastUpdate` time.\\n function distributionTime(Market market, ERC20 reward) external view returns (uint32, uint32, uint32) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.start, rewardData.end, rewardData.lastUpdate);\\n }\\n\\n /// @notice Retrieves all rewards addresses.\\n function allRewards() external view returns (ERC20[] memory) {\\n return rewardList;\\n }\\n\\n /// @notice Gets all market and operations.\\n /// @return marketOps The list of market operations.\\n function allMarketsOperations() public view returns (MarketOperation[] memory marketOps) {\\n Market[] memory markets = marketList;\\n marketOps = new MarketOperation[](markets.length);\\n for (uint256 m = 0; m < markets.length; ) {\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[m] = MarketOperation({ market: markets[m], operations: ops });\\n unchecked {\\n ++m;\\n }\\n }\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account and reward asset.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function allClaimable(address account, ERC20 reward) external view returns (uint256 unclaimedRewards) {\\n return claimable(allMarketsOperations(), account, reward);\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account, Market operations and reward asset.\\n /// @param marketOps The list of Market operations to get the accrued and pending rewards from.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function claimable(\\n MarketOperation[] memory marketOps,\\n address account,\\n ERC20 reward\\n ) public view returns (uint256 unclaimedRewards) {\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n RewardData storage rewardData = dist.rewards[reward];\\n if (dist.availableRewardsCount == 0) {\\n unchecked {\\n ++i;\\n }\\n continue;\\n }\\n\\n AccountOperation[] memory ops = accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n account,\\n rewardData.start\\n );\\n uint256 balance;\\n for (uint256 o = 0; o < ops.length; ) {\\n unclaimedRewards += rewardData.accounts[account][ops[o].operation].accrued;\\n balance += ops[o].balance;\\n unchecked {\\n ++o;\\n }\\n }\\n if (balance > 0) {\\n unclaimedRewards += pendingRewards(\\n account,\\n reward,\\n AccountMarketOperation({ market: marketOperation.market, accountOperations: ops })\\n );\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Iterates and accrues all rewards for the operations of the given account in the given market.\\n /// @param account The account to accrue the rewards for.\\n /// @param market The Market in which the operations where made.\\n /// @param reward The reward asset.\\n /// @param ops The operations to accrue the rewards for.\\n function update(address account, Market market, ERC20 reward, AccountOperation[] memory ops) internal {\\n uint256 baseUnit = distribution[market].baseUnit;\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n {\\n uint256 lastUpdate = rewardData.lastUpdate;\\n // `lastUpdate` can be greater than `block.timestamp` if distribution is set to start on a future date\\n if (block.timestamp > lastUpdate) {\\n (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) = previewAllocation(\\n rewardData,\\n market,\\n block.timestamp - lastUpdate\\n );\\n if (borrowIndex > type(uint128).max || depositIndex > type(uint128).max) revert IndexOverflow();\\n rewardData.borrowIndex = uint128(borrowIndex);\\n rewardData.depositIndex = uint128(depositIndex);\\n rewardData.lastUpdate = uint32(block.timestamp);\\n rewardData.lastUndistributed = newUndistributed;\\n emit IndexUpdate(market, reward, borrowIndex, depositIndex, newUndistributed, block.timestamp);\\n }\\n }\\n\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 i = 0; i < ops.length; ) {\\n AccountOperation memory op = ops[i];\\n Account storage accountData = operationAccount[op.operation];\\n uint256 accountIndex = accountData.index;\\n uint256 newAccountIndex;\\n if (op.operation) {\\n newAccountIndex = rewardData.borrowIndex;\\n } else {\\n newAccountIndex = rewardData.depositIndex;\\n }\\n if (accountIndex != newAccountIndex) {\\n accountData.index = uint128(newAccountIndex);\\n if (op.balance != 0) {\\n uint256 rewardsAccrued = accountRewards(op.balance, newAccountIndex, accountIndex, baseUnit);\\n accountData.accrued += uint128(rewardsAccrued);\\n emit Accrue(market, reward, account, op.operation, accountIndex, newAccountIndex, rewardsAccrued);\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the equivalent of borrow shares from fixed pool principal borrows of an account.\\n /// @param market The Market to get the fixed borrows from.\\n /// @param account The account that borrowed from fixed pools.\\n /// @return fixedDebt The fixed borrow shares.\\n function accountFixedBorrowShares(\\n Market market,\\n address account,\\n uint32 start\\n ) internal view returns (uint256 fixedDebt) {\\n uint256 firstMaturity = start - (start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 principal, ) = market.fixedBorrowPositions(maturity, account);\\n fixedDebt += principal;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n fixedDebt = market.previewRepay(fixedDebt);\\n }\\n\\n /// @notice Gets the reward indexes and last amount of undistributed rewards for a given market and reward asset.\\n /// @param market The market to get the reward indexes for.\\n /// @param reward The reward asset to get the reward indexes for.\\n /// @return borrowIndex The index for the floating and fixed borrow operation.\\n /// @return depositIndex The index for the floating deposit operation.\\n /// @return lastUndistributed The last amount of undistributed rewards.\\n function rewardIndexes(Market market, ERC20 reward) external view returns (uint256, uint256, uint256) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.borrowIndex, rewardData.depositIndex, rewardData.lastUndistributed);\\n }\\n\\n /// @notice Calculates the rewards not accrued yet for the given operations of a given account and reward asset.\\n /// @param account The account to get the pending rewards for.\\n /// @param reward The reward asset to get the pending rewards for.\\n /// @param ops The operations to get the pending rewards for.\\n /// @return rewards The pending rewards for the given operations.\\n function pendingRewards(\\n address account,\\n ERC20 reward,\\n AccountMarketOperation memory ops\\n ) internal view returns (uint256 rewards) {\\n RewardData storage rewardData = distribution[ops.market].rewards[reward];\\n uint256 baseUnit = distribution[ops.market].baseUnit;\\n uint256 lastUpdate = rewardData.lastUpdate;\\n (uint256 borrowIndex, uint256 depositIndex, ) = previewAllocation(\\n rewardData,\\n ops.market,\\n block.timestamp > lastUpdate ? block.timestamp - lastUpdate : 0\\n );\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 o = 0; o < ops.accountOperations.length; ) {\\n uint256 nextIndex;\\n if (ops.accountOperations[o].operation) {\\n nextIndex = borrowIndex;\\n } else {\\n nextIndex = depositIndex;\\n }\\n\\n rewards += accountRewards(\\n ops.accountOperations[o].balance,\\n nextIndex,\\n operationAccount[ops.accountOperations[o].operation].index,\\n baseUnit\\n );\\n unchecked {\\n ++o;\\n }\\n }\\n }\\n\\n /// @notice Calculates and returns the new amount of rewards given by the difference between the `accountIndex` and\\n /// the `globalIndex`.\\n /// @param balance The account's balance in the operation's pool.\\n /// @param globalIndex Current index of the distribution.\\n /// @param accountIndex Last index stored for the account.\\n /// @param baseUnit One unit of the Market's asset (10**decimals).\\n /// @return The amount of new rewards to be accrued by the account.\\n function accountRewards(\\n uint256 balance,\\n uint256 globalIndex,\\n uint256 accountIndex,\\n uint256 baseUnit\\n ) internal pure returns (uint256) {\\n return balance.mulDivDown(globalIndex - accountIndex, baseUnit);\\n }\\n\\n /// @notice Retrieves projected distribution indexes and new undistributed amount for a given `deltaTime`.\\n /// @param market The market to calculate the indexes for.\\n /// @param reward The reward asset to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n Market market,\\n ERC20 reward,\\n uint256 deltaTime\\n ) external view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n return previewAllocation(distribution[market].rewards[reward], market, deltaTime);\\n }\\n\\n /// @notice Calculates and returns the distribution indexes and new undistributed tokens for a given `rewardData`.\\n /// @param rewardData The distribution's data.\\n /// @param market The market to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n RewardData storage rewardData,\\n Market market,\\n uint256 deltaTime\\n ) internal view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n TotalMarketBalance memory m;\\n m.debt = market.totalFloatingBorrowAssets();\\n m.supply = market.totalAssets();\\n TimeVars memory t;\\n t.start = rewardData.start;\\n t.end = rewardData.end;\\n {\\n uint256 firstMaturity = t.start - (t.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n uint256 fixedDebt;\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 borrowed, uint256 supplied) = market.fixedPoolBalance(maturity);\\n fixedDebt += borrowed;\\n m.supply += supplied;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n m.debt += fixedDebt;\\n m.fixedBorrowShares = market.previewRepay(fixedDebt);\\n }\\n uint256 target;\\n {\\n uint256 targetDebt = rewardData.targetDebt;\\n target = m.debt < targetDebt ? m.debt.divWadDown(targetDebt) : 1e18;\\n }\\n uint256 rewards;\\n {\\n uint256 releaseRate = rewardData.releaseRate;\\n uint256 lastUndistributed = rewardData.lastUndistributed;\\n t.period = t.end - t.start;\\n uint256 distributionFactor = t.period > 0\\n ? rewardData.undistributedFactor.mulDivDown(target, t.period * 1e18)\\n : 0;\\n if (block.timestamp <= t.end) {\\n if (distributionFactor > 0) {\\n uint256 exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n } else if (rewardData.lastUpdate > t.end) {\\n newUndistributed =\\n lastUndistributed -\\n lastUndistributed.mulWadUp(1e18 - uint256((-int256(distributionFactor * deltaTime)).expWad()));\\n rewards = uint256(-(int256(newUndistributed) - int256(lastUndistributed)));\\n } else {\\n uint256 exponential;\\n deltaTime = t.end - rewardData.lastUpdate;\\n if (distributionFactor > 0) {\\n exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n exponential = uint256((-int256(distributionFactor * (block.timestamp - t.end))).expWad());\\n newUndistributed = newUndistributed - newUndistributed.mulWadUp(1e18 - exponential);\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n }\\n if (rewards == 0) return (rewardData.borrowIndex, rewardData.depositIndex, newUndistributed);\\n }\\n {\\n AllocationVars memory v;\\n v.utilization = m.supply > 0 ? Math.min(m.debt.divWadDown(m.supply), UTILIZATION_CAP) : 0;\\n v.transitionFactor = rewardData.transitionFactor;\\n v.flipSpeed = rewardData.flipSpeed;\\n v.borrowAllocationWeightFactor = rewardData.borrowAllocationWeightFactor;\\n v.sigmoid = v.utilization > 0\\n ? uint256(1e18).divWadDown(\\n 1e18 +\\n uint256(\\n (-(v.flipSpeed *\\n (int256(v.utilization.divWadDown(1e18 - v.utilization)).lnWad() -\\n int256(v.transitionFactor.divWadDown(1e18 - v.transitionFactor)).lnWad())) / 1e18).expWad()\\n )\\n )\\n : 0;\\n v.borrowRewardRule = rewardData\\n .compensationFactor\\n .mulWadDown(\\n market.interestRateModel().floatingRate(v.utilization).mulWadDown(\\n 1e18 - v.utilization.mulWadUp(1e18 - market.treasuryFeeRate())\\n ) + v.borrowAllocationWeightFactor\\n )\\n .mulWadDown(1e18 - v.sigmoid);\\n v.depositRewardRule =\\n rewardData.depositAllocationWeightAddend.mulWadDown(1e18 - v.sigmoid) +\\n rewardData.depositAllocationWeightFactor.mulWadDown(v.sigmoid);\\n v.borrowAllocation = v.borrowRewardRule.divWadDown(v.borrowRewardRule + v.depositRewardRule);\\n v.depositAllocation = 1e18 - v.borrowAllocation;\\n {\\n uint256 totalDepositSupply = market.totalSupply();\\n uint256 totalBorrowSupply = market.totalFloatingBorrowShares() + m.fixedBorrowShares;\\n uint256 baseUnit = distribution[market].baseUnit;\\n borrowIndex =\\n rewardData.borrowIndex +\\n (totalBorrowSupply > 0 ? rewards.mulWadDown(v.borrowAllocation).mulDivDown(baseUnit, totalBorrowSupply) : 0);\\n depositIndex =\\n rewardData.depositIndex +\\n (\\n totalDepositSupply > 0\\n ? rewards.mulWadDown(v.depositAllocation).mulDivDown(baseUnit, totalDepositSupply)\\n : 0\\n );\\n }\\n }\\n }\\n\\n /// @notice Get account balances of the given Market operations.\\n /// @param market The address of the Market.\\n /// @param ops List of operations to retrieve account balance.\\n /// @param account Account to get the balance from.\\n /// @param distributionStart Timestamp of the start of the distribution to correctly get the rewarded fixed pools.\\n /// @return accountBalanceOps contains a list with account balance per each operation.\\n function accountBalanceOperations(\\n Market market,\\n bool[] memory ops,\\n address account,\\n uint32 distributionStart\\n ) internal view returns (AccountOperation[] memory accountBalanceOps) {\\n accountBalanceOps = new AccountOperation[](ops.length);\\n for (uint256 i = 0; i < ops.length; ) {\\n if (ops[i]) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n accountBalanceOps[i] = AccountOperation({\\n operation: true,\\n balance: floatingBorrowShares + accountFixedBorrowShares(market, account, distributionStart)\\n });\\n } else {\\n accountBalanceOps[i] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Withdraws the contract's balance of the given asset to the given address.\\n /// @param asset The asset to withdraw.\\n /// @param to The address to withdraw the asset to.\\n function withdraw(ERC20 asset, address to) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n asset.safeTransfer(to, asset.balanceOf(address(this)));\\n }\\n\\n /// @notice Enables or updates the reward distribution for the given markets and rewards.\\n /// @param configs The configurations to update each RewardData with.\\n function config(Config[] memory configs) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n for (uint256 i = 0; i < configs.length; ) {\\n // transitionFactor cannot be eq or higher than 1e18 to avoid division by zero or underflow\\n if (configs[i].transitionFactor >= 1e18) revert InvalidConfig();\\n // depositAllocationWeightFactor cannot be zero to avoid division by zero when sigmoid equals 1e18\\n if (configs[i].depositAllocationWeightFactor == 0) revert InvalidConfig();\\n\\n Distribution storage dist = distribution[configs[i].market];\\n RewardData storage rewardData = dist.rewards[configs[i].reward];\\n\\n if (dist.baseUnit == 0) {\\n // never initialized before, adding to the list of markets\\n marketList.push(configs[i].market);\\n }\\n if (!rewardEnabled[configs[i].reward]) {\\n // add reward address to global rewards list if still not enabled\\n rewardEnabled[configs[i].reward] = true;\\n rewardList.push(configs[i].reward);\\n }\\n if (rewardData.lastUpdate == 0) {\\n // add reward address to distribution data's available rewards if distribution is new\\n dist.availableRewards[dist.availableRewardsCount++] = configs[i].reward;\\n dist.baseUnit = 10 ** configs[i].market.decimals();\\n // set initial parameters if distribution is new\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n } else {\\n uint32 start = rewardData.start;\\n uint32 end = rewardData.end;\\n // update global indexes before updating distribution values\\n bool[] memory ops = new bool[](1);\\n ops[0] = true;\\n update(\\n address(0),\\n configs[i].market,\\n configs[i].reward,\\n accountBalanceOperations(configs[i].market, ops, address(0), start)\\n );\\n // properly update release rate\\n if (block.timestamp < end) {\\n uint256 released = 0;\\n uint256 elapsed = 0;\\n if (block.timestamp > start) {\\n released =\\n rewardData.lastConfigReleased +\\n rewardData.releaseRate *\\n (block.timestamp - rewardData.lastConfig);\\n elapsed = block.timestamp - start;\\n if (configs[i].totalDistribution <= released || configs[i].distributionPeriod <= elapsed) {\\n revert InvalidConfig();\\n }\\n rewardData.lastConfigReleased = released;\\n }\\n\\n rewardData.releaseRate =\\n (configs[i].totalDistribution - released) /\\n (configs[i].distributionPeriod - elapsed);\\n } else if (rewardData.start != configs[i].start) {\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n rewardData.lastConfigReleased = 0;\\n }\\n }\\n rewardData.lastConfig = uint32(block.timestamp);\\n rewardData.end = rewardData.start + uint32(configs[i].distributionPeriod);\\n rewardData.priceFeed = configs[i].priceFeed;\\n // set emission and distribution parameters\\n rewardData.totalDistribution = configs[i].totalDistribution;\\n rewardData.targetDebt = configs[i].targetDebt;\\n rewardData.undistributedFactor = configs[i].undistributedFactor;\\n rewardData.flipSpeed = configs[i].flipSpeed;\\n rewardData.compensationFactor = configs[i].compensationFactor;\\n rewardData.borrowAllocationWeightFactor = configs[i].borrowAllocationWeightFactor;\\n rewardData.depositAllocationWeightAddend = configs[i].depositAllocationWeightAddend;\\n rewardData.transitionFactor = configs[i].transitionFactor;\\n rewardData.depositAllocationWeightFactor = configs[i].depositAllocationWeightFactor;\\n\\n emit DistributionSet(configs[i].market, configs[i].reward, configs[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n struct TotalMarketBalance {\\n uint256 debt;\\n uint256 supply;\\n uint256 fixedBorrowShares;\\n }\\n\\n struct TimeVars {\\n uint256 start;\\n uint256 end;\\n uint256 period;\\n }\\n\\n struct AllocationVars {\\n uint256 utilization;\\n uint256 sigmoid;\\n uint256 borrowRewardRule;\\n uint256 depositRewardRule;\\n uint256 borrowAllocation;\\n uint256 depositAllocation;\\n uint256 transitionFactor;\\n int256 flipSpeed;\\n uint256 borrowAllocationWeightFactor;\\n }\\n\\n struct AccountOperation {\\n bool operation;\\n uint256 balance;\\n }\\n\\n struct MarketOperation {\\n Market market;\\n bool[] operations;\\n }\\n\\n struct AccountMarketOperation {\\n Market market;\\n AccountOperation[] accountOperations;\\n }\\n\\n struct Account {\\n // liquidity index of the reward distribution for the account\\n uint128 index;\\n // amount of accrued rewards for the account since last account index update\\n uint128 accrued;\\n }\\n\\n struct Config {\\n Market market;\\n ERC20 reward;\\n IPriceFeed priceFeed;\\n uint32 start;\\n uint256 distributionPeriod;\\n uint256 targetDebt;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n }\\n\\n struct RewardData {\\n // distribution model\\n uint256 targetDebt;\\n uint256 releaseRate;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n uint256 lastUndistributed;\\n // allocation model\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n // liquidity indexes of the reward distribution\\n uint128 borrowIndex;\\n uint128 depositIndex;\\n // distribution timestamps\\n uint32 start;\\n uint32 end;\\n uint32 lastUpdate;\\n // config helpers\\n uint32 lastConfig;\\n uint256 lastConfigReleased;\\n // price feed\\n IPriceFeed priceFeed;\\n // account addresses and their rewards data (index & accrued)\\n mapping(address => mapping(bool => Account)) accounts;\\n }\\n\\n struct Distribution {\\n // reward assets and their data\\n mapping(ERC20 => RewardData) rewards;\\n // list of reward asset addresses for the market\\n mapping(uint128 => ERC20) availableRewards;\\n // count of reward tokens for the market\\n uint8 availableRewardsCount;\\n // base unit of the market\\n uint256 baseUnit;\\n }\\n\\n /// @notice Emitted when rewards are accrued by an account.\\n /// @param market Market where the operation was made.\\n /// @param reward reward asset.\\n /// @param account account that accrued the rewards.\\n /// @param operation true if the operation was a borrow, false if it was a deposit.\\n /// @param accountIndex previous account index.\\n /// @param operationIndex new operation index that is assigned to the `accountIndex`.\\n /// @param rewardsAccrued amount of rewards accrued.\\n event Accrue(\\n Market indexed market,\\n ERC20 indexed reward,\\n address indexed account,\\n bool operation,\\n uint256 accountIndex,\\n uint256 operationIndex,\\n uint256 rewardsAccrued\\n );\\n\\n /// @notice Emitted when rewards are claimed by an account.\\n /// @param account account that claimed the rewards.\\n /// @param reward reward asset.\\n /// @param to account that received the rewards.\\n /// @param amount amount of rewards claimed.\\n event Claim(address indexed account, ERC20 indexed reward, address indexed to, uint256 amount);\\n\\n /// @notice Emitted when a distribution is set.\\n /// @param market Market whose distribution was set.\\n /// @param reward reward asset to be distributed when operating with the Market.\\n /// @param config configuration struct containing the distribution parameters.\\n event DistributionSet(Market indexed market, ERC20 indexed reward, Config config);\\n\\n /// @notice Emitted when the distribution indexes are updated.\\n /// @param market Market of the distribution.\\n /// @param reward reward asset.\\n /// @param borrowIndex index of the borrow operations of a distribution.\\n /// @param depositIndex index of the deposit operations of a distribution.\\n /// @param newUndistributed amount of undistributed rewards.\\n /// @param lastUpdate current timestamp.\\n event IndexUpdate(\\n Market indexed market,\\n ERC20 indexed reward,\\n uint256 borrowIndex,\\n uint256 depositIndex,\\n uint256 newUndistributed,\\n uint256 lastUpdate\\n );\\n}\\n\\nerror IndexOverflow();\\nerror InvalidConfig();\\n\",\"keccak256\":\"0x1542122ea5dfca16000fa7e476201de82eef8ff8d7f44601274e1ed12c60344f\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/DebtManager.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { SafeTransferLib } from \\\"solmate/src/utils/SafeTransferLib.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { AddressUpgradeable as Address } from \\\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\\\";\\nimport {\\n SafeERC20Upgradeable as SafeERC20,\\n IERC20PermitUpgradeable\\n} from \\\"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\\\";\\nimport { Market, ERC20, FixedLib, Disagreement } from \\\"../Market.sol\\\";\\nimport { Auditor, IPriceFeed, MarketNotListed } from \\\"../Auditor.sol\\\";\\n\\n/// @title DebtManager\\n/// @notice Contract for efficient debt management of accounts interacting with Exactly Protocol.\\ncontract DebtManager is Initializable {\\n using FixedPointMathLib for uint256;\\n using SafeTransferLib for ERC20;\\n using SafeERC20 for IERC20PermitUpgradeable;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for FixedLib.Pool;\\n using Address for address;\\n\\n /// @notice Auditor contract that lists the markets that can be leveraged.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n /// @notice Permit2 contract to be used to transfer assets from accounts.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IPermit2 public immutable permit2;\\n /// @notice Balancer's vault contract that is used to take flash loans.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IBalancerVault public immutable balancerVault;\\n /// @notice Factory contract to be used to compute the address of the Uniswap V3 pool.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n address public immutable uniswapV3Factory;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IPermit2 permit2_, IBalancerVault balancerVault_, address uniswapV3Factory_) {\\n auditor = auditor_;\\n permit2 = permit2_;\\n balancerVault = balancerVault_;\\n uniswapV3Factory = uniswapV3Factory_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize() external initializer {\\n Market[] memory markets = auditor.allMarkets();\\n for (uint256 i = 0; i < markets.length; ++i) approve(markets[i]);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n function leverage(Market market, uint256 deposit, uint256 ratio) public msgSender {\\n transferIn(market, deposit);\\n noTransferLeverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `market` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function leverage(\\n Market market,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit2 calldata assetPermit\\n ) external permit(market, borrowAssets, marketPermit) permitTransfer(market.asset(), deposit, assetPermit) msgSender {\\n noTransferLeverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `market` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function leverage(\\n Market market,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit calldata assetPermit\\n ) external permit(market, borrowAssets, marketPermit) permit(market.asset(), deposit, assetPermit) {\\n leverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `market` on behalf of `_msgSender`.\\n /// Permit `value` should be `borrowAssets`.\\n function leverage(\\n Market market,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 borrowAssets,\\n Permit calldata marketPermit\\n ) external permit(market, borrowAssets, marketPermit) msgSender {\\n market.asset().safeTransferFrom(msg.sender, address(this), deposit);\\n noTransferLeverage(market, deposit, ratio);\\n }\\n\\n /// @notice Leverages the floating position of `_msgSender` a certain `ratio` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param deposit The amount of assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n function noTransferLeverage(Market market, uint256 deposit, uint256 ratio) internal {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n uint256 loopCount;\\n {\\n uint256 collateral = market.maxWithdraw(sender);\\n uint256 targetDeposit = (collateral + deposit - floatingBorrowAssets(market)).mulWadDown(ratio);\\n int256 amount = int256(targetDeposit) - int256(collateral + deposit);\\n if (amount <= 0) {\\n market.deposit(deposit, sender);\\n return;\\n }\\n loopCount = uint256(amount).mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n amounts[0] = uint256(amount).mulDivUp(1, loopCount);\\n }\\n bytes[] memory calls = new bytes[](2 * loopCount);\\n uint256 callIndex = 0;\\n for (uint256 i = 0; i < loopCount; ) {\\n calls[callIndex++] = abi.encodeCall(market.deposit, (i == 0 ? amounts[0] + deposit : amounts[0], sender));\\n calls[callIndex++] = abi.encodeCall(\\n market.borrow,\\n (amounts[0], i + 1 == loopCount ? address(balancerVault) : address(this), sender)\\n );\\n unchecked {\\n ++i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, call(abi.encode(market, calls)));\\n }\\n\\n /// @notice Deleverages `_msgSender`'s position to a `ratio` via flash loan from Balancer's vault.\\n /// @param market The Market to deleverage the position out.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The ratio of the borrow that will be repaid, represented with 18 decimals.\\n /// @param permitAssets The amount of assets to allow this contract to withdraw on behalf of `_msgSender`.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `permitAssets`.\\n function deleverage(\\n Market market,\\n uint256 withdraw,\\n uint256 ratio,\\n uint256 permitAssets,\\n Permit calldata p\\n ) external permit(market, permitAssets, p) {\\n deleverage(market, withdraw, ratio);\\n }\\n\\n /// @notice Deleverages `_msgSender`'s position to a `ratio` via flash loan from Balancer's vault.\\n /// @param market The Market to deleverage the position out.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n function deleverage(Market market, uint256 withdraw, uint256 ratio) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n uint256 collateral = market.maxWithdraw(sender) - withdraw;\\n uint256 amount = collateral - (collateral - floatingBorrowAssets(market)).mulWadDown(ratio);\\n\\n r.loopCount = amount.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n r.amounts[0] = amount.mulDivUp(1, r.loopCount);\\n r.calls = new bytes[](2 * r.loopCount + (withdraw == 0 ? 0 : 1));\\n uint256 callIndex = 0;\\n for (uint256 i = 0; i < r.loopCount; ) {\\n r.calls[callIndex++] = abi.encodeCall(market.repay, (r.amounts[0], sender));\\n r.calls[callIndex++] = abi.encodeCall(\\n market.withdraw,\\n (r.amounts[0], i + 1 == r.loopCount ? address(balancerVault) : address(this), sender)\\n );\\n unchecked {\\n ++i;\\n }\\n }\\n if (withdraw != 0) r.calls[callIndex] = abi.encodeCall(market.withdraw, (withdraw, sender, sender));\\n\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n function crossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96\\n ) external msgSender {\\n transferIn(marketIn, deposit);\\n noTransferCrossLeverage(marketIn, marketOut, fee, deposit, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `marketOut` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function crossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit2 calldata assetPermit\\n )\\n external\\n permit(marketOut, borrowAssets, marketPermit)\\n permitTransfer(marketIn.asset(), deposit, assetPermit)\\n msgSender\\n {\\n noTransferCrossLeverage(marketIn, marketOut, fee, deposit, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n /// @param borrowAssets The amount of assets to allow this contract to borrow on behalf of `_msgSender`.\\n /// @param marketPermit Arguments for the permit call to `marketOut` on behalf of `_msgSender`.\\n /// @param assetPermit Arguments for the permit2 asset call.\\n /// Permit `value` should be `borrowAssets`.\\n function crossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96,\\n uint256 borrowAssets,\\n Permit calldata marketPermit,\\n Permit calldata assetPermit\\n ) external permit(marketOut, borrowAssets, marketPermit) permit(marketIn.asset(), deposit, assetPermit) msgSender {\\n transferIn(marketIn, deposit);\\n noTransferCrossLeverage(marketIn, marketOut, fee, deposit, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Cross-leverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to deposit the leveraged position.\\n /// @param marketOut The Market to borrow the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param ratio The number of times that the current principal will be leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n function noTransferCrossLeverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 deposit,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96\\n ) internal {\\n LeverageVars memory v;\\n v.assetIn = address(marketIn.asset());\\n v.assetOut = address(marketOut.asset());\\n v.sender = _msgSender;\\n\\n v.amount =\\n crossPrincipal(marketIn, marketOut, deposit, v.sender).mulWadDown(ratio) -\\n marketIn.maxWithdraw(v.sender) -\\n deposit;\\n if (v.amount > 0) {\\n PoolKey memory poolKey = PoolAddress.getPoolKey(v.assetIn, v.assetOut, fee);\\n IUniswapV3Pool(PoolAddress.computeAddress(uniswapV3Factory, poolKey)).swap(\\n address(this),\\n v.assetOut == poolKey.token0,\\n -int256(v.amount),\\n sqrtPriceLimitX96,\\n abi.encode(\\n SwapCallbackData({\\n marketIn: marketIn,\\n marketOut: marketOut,\\n assetIn: v.assetIn,\\n assetOut: v.assetOut,\\n principal: deposit,\\n account: v.sender,\\n fee: fee,\\n leverage: true\\n })\\n )\\n );\\n } else {\\n marketIn.deposit(deposit, v.sender);\\n }\\n }\\n\\n /// @notice Cross-deleverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to withdraw the leveraged position.\\n /// @param marketOut The Market to repay the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The number of times that the current principal will end up leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n function crossDeleverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 withdraw,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96\\n ) public msgSender {\\n LeverageVars memory v;\\n v.assetIn = address(marketIn.asset());\\n v.assetOut = address(marketOut.asset());\\n v.sender = _msgSender;\\n\\n v.amount =\\n floatingBorrowAssets(marketOut) -\\n (\\n ratio > 1e18\\n ? previewAssetsOut(\\n marketIn,\\n marketOut,\\n (crossPrincipal(marketIn, marketOut, 0, v.sender) - withdraw).mulWadDown(ratio - 1e18)\\n )\\n : 0\\n );\\n\\n PoolKey memory poolKey = PoolAddress.getPoolKey(v.assetIn, v.assetOut, fee);\\n IUniswapV3Pool(PoolAddress.computeAddress(uniswapV3Factory, poolKey)).swap(\\n address(this),\\n v.assetIn == poolKey.token0,\\n -int256(v.amount),\\n sqrtPriceLimitX96,\\n abi.encode(\\n SwapCallbackData({\\n marketIn: marketIn,\\n marketOut: marketOut,\\n assetIn: v.assetIn,\\n assetOut: v.assetOut,\\n principal: withdraw,\\n account: v.sender,\\n fee: fee,\\n leverage: false\\n })\\n )\\n );\\n }\\n\\n /// @notice Cross-deleverages `_msgSender`'s position to a `ratio` via flash swap from Uniswap's pool.\\n /// @param marketIn The Market to withdraw the leveraged position.\\n /// @param marketOut The Market to repay the leveraged position.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @param withdraw The amount of assets that will be withdrawn to `_msgSender`.\\n /// @param ratio The number of times that the current principal will end up leveraged, represented with 18 decimals.\\n /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this.\\n /// @param permitAssets The amount of assets to allow.\\n /// @param p Arguments for the permit call to `marketIn` on behalf of `_msgSender`.\\n /// Permit `value` should be `permitAssets`.\\n function crossDeleverage(\\n Market marketIn,\\n Market marketOut,\\n uint24 fee,\\n uint256 withdraw,\\n uint256 ratio,\\n uint160 sqrtPriceLimitX96,\\n uint256 permitAssets,\\n Permit calldata p\\n ) external permit(marketIn, permitAssets, p) {\\n crossDeleverage(marketIn, marketOut, fee, withdraw, ratio, sqrtPriceLimitX96);\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to another fixed pool.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n function rollFixed(\\n Market market,\\n uint256 repayMaturity,\\n uint256 borrowMaturity,\\n uint256 maxRepayAssets,\\n uint256 maxBorrowAssets,\\n uint256 percentage\\n ) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n (r.repayAssets, r.positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n\\n r.loopCount = r.repayAssets.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n if (r.loopCount > 1 && repayMaturity == borrowMaturity) revert InvalidOperation();\\n\\n r.amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n r.positionAssets = r.positionAssets / r.loopCount;\\n r.calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.repayAtMaturity,\\n (repayMaturity, r.positionAssets, type(uint256).max, sender)\\n );\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n r.amounts[0],\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n if (\\n newPrincipal + newFee >\\n (\\n maxBorrowAssets < type(uint256).max - r.principal - r.fee\\n ? maxBorrowAssets + r.principal + r.fee\\n : type(uint256).max\\n ) ||\\n newPrincipal >\\n (maxRepayAssets < type(uint256).max - r.principal ? maxRepayAssets + r.principal : type(uint256).max)\\n ) {\\n revert Disagreement();\\n }\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to another fixed pool\\n /// after calling `market.permit`.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `maxBorrowAssets`.\\n function rollFixed(\\n Market market,\\n uint256 repayMaturity,\\n uint256 borrowMaturity,\\n uint256 maxRepayAssets,\\n uint256 maxBorrowAssets,\\n uint256 percentage,\\n Permit calldata p\\n ) external permit(market, maxBorrowAssets, p) {\\n rollFixed(market, repayMaturity, borrowMaturity, maxRepayAssets, maxBorrowAssets, percentage);\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to a floating position.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n function rollFixedToFloating(\\n Market market,\\n uint256 repayMaturity,\\n uint256 maxRepayAssets,\\n uint256 percentage\\n ) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n r.principal = floatingBorrowAssets(market);\\n (uint256 repayAssets, uint256 positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n r.loopCount = repayAssets.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n positionAssets = positionAssets / r.loopCount;\\n\\n r.amounts[0] = repayAssets.mulDivUp(1, r.loopCount);\\n r.calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.repayAtMaturity,\\n (repayMaturity, positionAssets, type(uint256).max, sender)\\n );\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.borrow,\\n (r.amounts[0], r.i + 1 == r.loopCount ? address(balancerVault) : address(this), sender)\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n if (maxRepayAssets < floatingBorrowAssets(market) - r.principal) revert Disagreement();\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `_msgSender` to a floating position\\n /// after calling `market.permit`.\\n /// @param market The Market to roll the position in.\\n /// @param repayMaturity The maturity of the fixed pool that the position is being rolled from.\\n /// @param maxRepayAssets Max amount of debt that the account is willing to accept to be repaid.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `maxRepayAssets`.\\n function rollFixedToFloating(\\n Market market,\\n uint256 repayMaturity,\\n uint256 maxRepayAssets,\\n uint256 percentage,\\n Permit calldata p\\n ) external permit(market, maxRepayAssets, p) {\\n rollFixedToFloating(market, repayMaturity, maxRepayAssets, percentage);\\n }\\n\\n /// @notice Rolls a percentage of the floating position of `_msgSender` to a fixed position.\\n /// @param market The Market to roll the position in.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n function rollFloatingToFixed(\\n Market market,\\n uint256 borrowMaturity,\\n uint256 maxBorrowAssets,\\n uint256 percentage\\n ) public msgSender {\\n RollVars memory r;\\n r.amounts = new uint256[](1);\\n r.tokens = new ERC20[](1);\\n r.tokens[0] = market.asset();\\n address sender = _msgSender;\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n r.repayAssets = floatingBorrowAssets(market);\\n if (percentage < 1e18) r.repayAssets = r.repayAssets.mulWadDown(percentage);\\n r.loopCount = r.repayAssets.mulDivUp(1, r.tokens[0].balanceOf(address(balancerVault)));\\n\\n r.amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n r.calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n r.calls[r.callIndex++] = abi.encodeCall(market.repay, (r.amounts[0], sender));\\n r.calls[r.callIndex++] = abi.encodeCall(\\n market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n r.amounts[0],\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), r.tokens, r.amounts, call(abi.encode(market, r.calls)));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, sender);\\n if (maxBorrowAssets < newPrincipal + newFee - r.principal - r.fee) revert Disagreement();\\n }\\n\\n /// @notice Rolls a percentage of the floating position of `_msgSender` to a fixed position\\n /// after calling `market.permit`.\\n /// @param market The Market to roll the position in.\\n /// @param borrowMaturity The maturity of the fixed pool that the position is being rolled to.\\n /// @param maxBorrowAssets Max amount of debt that the sender is willing to accept to be borrowed.\\n /// @param percentage The percentage of the position that will be rolled, represented with 18 decimals.\\n /// @param p Arguments for the permit call to `market` on behalf of `permit.account`.\\n /// Permit `value` should be `maxBorrowAssets`.\\n function rollFloatingToFixed(\\n Market market,\\n uint256 borrowMaturity,\\n uint256 maxBorrowAssets,\\n uint256 percentage,\\n Permit calldata p\\n ) external permit(market, maxBorrowAssets, p) {\\n rollFloatingToFixed(market, borrowMaturity, maxBorrowAssets, percentage);\\n }\\n\\n /// @notice Calculates the actual repay and position assets of a repay operation at maturity.\\n /// @param market The Market to calculate the actual repay and position assets.\\n /// @param maturity The maturity of the fixed pool in which the position is being repaid.\\n /// @param percentage The percentage of the position that will be repaid, represented with 18 decimals.\\n /// @return actualRepay The actual amount of assets that will be repaid.\\n /// @return positionAssets The amount of principal and fee to be covered.\\n function repayAtMaturityAssets(\\n Market market,\\n uint256 maturity,\\n uint256 percentage\\n ) internal view returns (uint256 actualRepay, uint256 positionAssets) {\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedBorrowPositions(maturity, _msgSender);\\n positionAssets = percentage < 1e18\\n ? percentage.mulWadDown(position.principal + position.fee)\\n : position.principal + position.fee;\\n if (block.timestamp < maturity) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(maturity);\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n maturity - pool.lastAccrual\\n );\\n (uint256 yield, ) = pool.calculateDeposit(\\n position.scaleProportionally(positionAssets).principal,\\n market.backupFeeRate()\\n );\\n actualRepay = positionAssets - yield;\\n } else {\\n actualRepay = positionAssets + positionAssets.mulWadDown((block.timestamp - maturity) * market.penaltyRate());\\n }\\n }\\n\\n /// @notice Hash of the call data that will be used to verify that the flash loan is originated from `this`.\\n bytes32 private callHash;\\n\\n /// @notice Hashes the data and stores its value in `callHash`.\\n /// @param data The calldata to be hashed.\\n /// @return Same calldata that was passed as an argument.\\n function call(bytes memory data) internal returns (bytes memory) {\\n callHash = keccak256(data);\\n return data;\\n }\\n\\n /// @notice Calculates the crossed principal amount for a given `sender` in the input and output markets.\\n /// @param marketIn The Market to withdraw the leveraged position.\\n /// @param marketOut The Market to repay the leveraged position.\\n /// @param deposit The amount of `marketIn` underlying assets to deposit.\\n /// @param sender The account that will be deleveraged.\\n function crossPrincipal(\\n Market marketIn,\\n Market marketOut,\\n uint256 deposit,\\n address sender\\n ) internal view returns (uint256) {\\n (, , , , IPriceFeed priceFeedIn) = auditor.markets(marketIn);\\n (, , , , IPriceFeed priceFeedOut) = auditor.markets(marketOut);\\n\\n return\\n marketIn.maxWithdraw(sender) +\\n deposit -\\n floatingBorrowAssets(marketOut)\\n .mulDivDown(auditor.assetPrice(priceFeedOut), 10 ** marketOut.decimals())\\n .mulDivDown(10 ** marketIn.decimals(), auditor.assetPrice(priceFeedIn));\\n }\\n\\n /// @notice Returns the amount of `marketOut` underlying assets considering `amountIn` and both assets oracle prices.\\n /// @param marketIn The market of the assets accounted as `amountIn`.\\n /// @param marketOut The market of the assets that will be returned.\\n /// @param amountIn The amount of `marketIn` underlying assets.\\n function previewAssetsOut(Market marketIn, Market marketOut, uint256 amountIn) internal view returns (uint256) {\\n (, , , , IPriceFeed priceFeedIn) = auditor.markets(marketIn);\\n (, , , , IPriceFeed priceFeedOut) = auditor.markets(marketOut);\\n\\n return\\n amountIn.mulDivDown(auditor.assetPrice(priceFeedIn), 10 ** marketIn.decimals()).mulDivDown(\\n 10 ** marketOut.decimals(),\\n auditor.assetPrice(priceFeedOut)\\n );\\n }\\n\\n /// @notice Callback function called by the Balancer Vault contract when a flash loan is initiated.\\n /// @dev Only the Balancer Vault contract is allowed to call this function.\\n /// @param userData Additional data provided by the borrower for the flash loan.\\n function receiveFlashLoan(ERC20[] memory, uint256[] memory, uint256[] memory, bytes memory userData) external {\\n bytes32 memCallHash = callHash;\\n assert(msg.sender == address(balancerVault) && memCallHash != bytes32(0) && memCallHash == keccak256(userData));\\n callHash = bytes32(0);\\n\\n (Market market, bytes[] memory calls) = abi.decode(userData, (Market, bytes[]));\\n for (uint256 i = 0; i < calls.length; ) {\\n address(market).functionCall(calls[i], \\\"\\\");\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Callback function called by the Uniswap V3 pool contract when a swap is initiated.\\n /// @dev Only the Uniswap V3 pool contract is allowed to call this function.\\n /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by\\n /// the end of the swap. If positive, the callback must send that amount of token0 to the pool.\\n /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by\\n /// the end of the swap. If positive, the callback must send that amount of token1 to the pool.\\n /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call\\n function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {\\n SwapCallbackData memory s = abi.decode(data, (SwapCallbackData));\\n PoolKey memory poolKey = PoolAddress.getPoolKey(s.assetIn, s.assetOut, s.fee);\\n assert(msg.sender == PoolAddress.computeAddress(uniswapV3Factory, poolKey));\\n\\n if (s.leverage) {\\n s.marketIn.deposit(\\n s.principal + uint256(-(s.assetIn == poolKey.token0 ? amount0Delta : amount1Delta)),\\n s.account\\n );\\n s.marketOut.borrow(uint256(s.assetIn == poolKey.token1 ? amount0Delta : amount1Delta), msg.sender, s.account);\\n } else {\\n s.marketOut.repay(uint256(-(s.assetIn == poolKey.token1 ? amount0Delta : amount1Delta)), s.account);\\n s.marketIn.withdraw(uint256(s.assetIn == poolKey.token1 ? amount1Delta : amount0Delta), msg.sender, s.account);\\n s.marketIn.withdraw(s.principal, s.account, s.account);\\n }\\n }\\n\\n address private _msgSender;\\n\\n modifier msgSender() {\\n if (_msgSender == address(0)) _msgSender = msg.sender;\\n _;\\n delete _msgSender;\\n }\\n\\n /// @notice Calls `token.permit` on behalf of `permit.account`.\\n /// @param token The `ERC20` to call `permit`.\\n /// @param assets The amount of assets to allow.\\n /// @param p Arguments for the permit call.\\n modifier permit(\\n ERC20 token,\\n uint256 assets,\\n Permit calldata p\\n ) {\\n IERC20PermitUpgradeable(address(token)).safePermit(p.account, address(this), assets, p.deadline, p.v, p.r, p.s);\\n {\\n address sender = _msgSender;\\n if (sender == address(0)) _msgSender = p.account;\\n else assert(p.account == sender);\\n }\\n _;\\n assert(_msgSender == address(0));\\n }\\n\\n /// @notice Calls `permit2.permitTransferFrom` to transfer `_msgSender` assets.\\n /// @param token The `ERC20` to transfer from `_msgSender` to this contract.\\n /// @param assets The amount of assets to transfer from `_msgSender`.\\n /// @param p2 Arguments for the permit2 call.\\n modifier permitTransfer(\\n ERC20 token,\\n uint256 assets,\\n Permit2 calldata p2\\n ) {\\n {\\n address sender = _msgSender;\\n permit2.permitTransferFrom(\\n IPermit2.PermitTransferFrom(\\n IPermit2.TokenPermissions(address(token), assets),\\n uint256(keccak256(abi.encode(sender, token, assets, p2.deadline))),\\n p2.deadline\\n ),\\n IPermit2.SignatureTransferDetails(address(this), assets),\\n sender,\\n p2.signature\\n );\\n }\\n _;\\n }\\n\\n /// @notice Approves the Market to spend the contract's balance of the underlying asset.\\n /// @dev The Market must be listed by the Auditor in order to be valid for approval.\\n /// @param market The Market to spend the contract's balance.\\n function approve(Market market) public {\\n (, , , bool isListed, ) = auditor.markets(market);\\n if (!isListed) revert MarketNotListed();\\n\\n market.asset().safeApprove(address(market), type(uint256).max);\\n }\\n\\n function transferIn(Market market, uint256 assets) internal {\\n if (assets != 0) market.asset().safeTransferFrom(_msgSender, address(this), assets);\\n }\\n\\n function floatingBorrowAssets(Market market) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(_msgSender);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n}\\n\\nerror InvalidOperation();\\n\\nstruct Permit {\\n address account;\\n uint256 deadline;\\n uint8 v;\\n bytes32 r;\\n bytes32 s;\\n}\\n\\nstruct Permit2 {\\n uint256 deadline;\\n bytes signature;\\n}\\n\\nstruct SwapCallbackData {\\n Market marketIn;\\n Market marketOut;\\n address assetIn;\\n address assetOut;\\n address account;\\n uint256 principal;\\n uint24 fee;\\n bool leverage;\\n}\\n\\nstruct RollVars {\\n uint256[] amounts;\\n ERC20[] tokens;\\n bytes[] calls;\\n uint256 positionAssets;\\n uint256 repayAssets;\\n uint256 callIndex;\\n uint256 loopCount;\\n uint256 principal;\\n uint256 fee;\\n uint256 i;\\n}\\n\\nstruct LeverageVars {\\n address sender;\\n address assetIn;\\n address assetOut;\\n uint256 amount;\\n}\\n\\ninterface IBalancerVault {\\n function flashLoan(\\n address recipient,\\n ERC20[] memory tokens,\\n uint256[] memory amounts,\\n bytes memory userData\\n ) external;\\n}\\n\\ninterface IPermit2 {\\n struct TokenPermissions {\\n address token;\\n uint256 amount;\\n }\\n\\n struct PermitTransferFrom {\\n TokenPermissions permitted;\\n uint256 nonce;\\n uint256 deadline;\\n }\\n\\n struct SignatureTransferDetails {\\n address to;\\n uint256 requestedAmount;\\n }\\n\\n function permitTransferFrom(\\n PermitTransferFrom memory permit,\\n SignatureTransferDetails calldata transferDetails,\\n address owner,\\n bytes calldata signature\\n ) external;\\n\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\\ninterface IUniswapV3Pool {\\n function swap(\\n address recipient,\\n bool zeroForOne,\\n int256 amountSpecified,\\n uint160 sqrtPriceLimitX96,\\n bytes calldata data\\n ) external returns (int256 amount0, int256 amount1);\\n\\n function slot0()\\n external\\n view\\n returns (\\n uint160 sqrtPriceX96,\\n int24 tick,\\n uint16 observationIndex,\\n uint16 observationCardinality,\\n uint16 observationCardinalityNext,\\n uint8 feeProtocol,\\n bool unlocked\\n );\\n}\\n\\n// https://github.com/Uniswap/v3-periphery/pull/271\\nlibrary PoolAddress {\\n bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;\\n\\n function getPoolKey(address tokenA, address tokenB, uint24 fee) internal pure returns (PoolKey memory) {\\n if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);\\n return PoolKey({ token0: tokenA, token1: tokenB, fee: fee });\\n }\\n\\n function computeAddress(address uniswapV3Factory, PoolKey memory key) internal pure returns (address pool) {\\n assert(key.token0 < key.token1);\\n pool = address(\\n uint160(\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n hex\\\"ff\\\",\\n uniswapV3Factory,\\n keccak256(abi.encode(key.token0, key.token1, key.fee)),\\n POOL_INIT_CODE_HASH\\n )\\n )\\n )\\n )\\n );\\n }\\n}\\n\\nstruct PoolKey {\\n address token0;\\n address token1;\\n uint24 fee;\\n}\\n\",\"keccak256\":\"0x3d0573ed373ae09bc255004e48ed74343437c3e36ec679fdd80557d61d9bb456\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/DebtPreviewer.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { Previewer, FixedLib } from \\\"./Previewer.sol\\\";\\nimport {\\n ERC20,\\n Market,\\n Auditor,\\n IPriceFeed,\\n DebtManager,\\n IUniswapV3Pool,\\n PoolAddress,\\n PoolKey\\n} from \\\"./DebtManager.sol\\\";\\n\\n/// @title DebtPreviewer\\n/// @notice Contract to be consumed by Exactly's front-end dApp as a helper for `DebtManager`.\\ncontract DebtPreviewer is Initializable {\\n using FixedPointMathLib for uint256;\\n\\n /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)\\n uint160 internal constant MIN_SQRT_RATIO = 4295128739;\\n /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)\\n uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;\\n\\n /// @notice DebtManager contract to be used to get Auditor, BalancerVault and UniswapV3Factory addresses.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n DebtManager public immutable debtManager;\\n /// @notice Quoter contract to be used to preview the amount of assets to be swapped.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IUniswapQuoter public immutable uniswapV3Quoter;\\n /// @notice Mapping of Uniswap pools to their respective pool fee.\\n mapping(address => mapping(address => uint24)) public poolFees;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(DebtManager debtManager_, IUniswapQuoter uniswapV3Quoter_) {\\n debtManager = debtManager_;\\n uniswapV3Quoter = uniswapV3Quoter_;\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(Pool[] memory pools, uint24[] memory fees) external initializer {\\n assert(pools.length == fees.length);\\n for (uint256 i = 0; i < pools.length; ) {\\n PoolKey memory poolKey = PoolAddress.getPoolKey(pools[i].tokenA, pools[i].tokenB, fees[i]);\\n poolFees[poolKey.token0][poolKey.token1] = poolKey.fee;\\n\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Returns the output received for a given exact amount of a single pool swap.\\n /// @param assetIn The address of the token to be swapped.\\n /// @param assetOut The address of the token to receive.\\n /// @param amountIn The exact amount of `assetIn` to be swapped.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @return amountOut The amount of `assetOut` received.\\n function previewInputSwap(\\n address assetIn,\\n address assetOut,\\n uint256 amountIn,\\n uint24 fee\\n ) external returns (uint256) {\\n return\\n uniswapV3Quoter.quoteExactInputSingle(\\n assetIn,\\n assetOut,\\n fee,\\n amountIn,\\n assetIn == PoolAddress.getPoolKey(assetIn, assetOut, fee).token0 ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1\\n );\\n }\\n\\n /// @notice Returns the input for an exact amount out of a single pool swap.\\n /// @param marketIn The Market of the underlying asset to be swapped.\\n /// @param marketOut The Market of the underlying asset to receive.\\n /// @param amountOut The exact amount of `amountOut` to be swapped.\\n /// @param fee The fee of the pool that will be used to swap the assets.\\n /// @return amountIn The amount of `amountIn` received.\\n function previewOutputSwap(\\n Market marketIn,\\n Market marketOut,\\n uint256 amountOut,\\n uint24 fee\\n ) public returns (uint256) {\\n address assetIn = address(marketIn.asset());\\n address assetOut = address(marketOut.asset());\\n return\\n amountOut > 0\\n ? uniswapV3Quoter.quoteExactOutputSingle(\\n assetIn,\\n assetOut,\\n fee,\\n amountOut,\\n assetIn == PoolAddress.getPoolKey(assetIn, assetOut, fee).token0 ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1\\n )\\n : 0;\\n }\\n\\n /// @notice Returns extended data useful to leverage or deleverage an account principal position.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account operating with the `DebtManager`.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n /// @return extended leverage data.\\n function leverage(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 minHealthFactor\\n ) external returns (Leverage memory) {\\n (, , uint256 floatingBorrowShares) = marketBorrow.accounts(account);\\n uint256 deposit = marketDeposit.maxWithdraw(account);\\n uint256 memMinDeposit = minDeposit(marketDeposit, marketBorrow, account, minHealthFactor);\\n int256 principal = crossPrincipal(marketDeposit, marketBorrow, account);\\n PoolKey memory poolKey = PoolAddress.getPoolKey(address(marketDeposit.asset()), address(marketBorrow.asset()), 0);\\n poolKey.fee = poolFees[poolKey.token0][poolKey.token1];\\n uint256 sqrtPriceX96;\\n if (marketDeposit != marketBorrow) {\\n (sqrtPriceX96, , , , , , ) = IUniswapV3Pool(PoolAddress.computeAddress(debtManager.uniswapV3Factory(), poolKey))\\n .slot0();\\n }\\n\\n return\\n Leverage({\\n borrow: marketBorrow.previewRefund(floatingBorrowShares),\\n deposit: deposit,\\n principal: principal,\\n ratio: principal > 0 ? deposit.divWadDown(uint256(principal)) : 0,\\n maxRatio: maxRatio(\\n marketDeposit,\\n marketBorrow,\\n account,\\n principal > 0 ? uint256(principal) : 0,\\n minHealthFactor\\n ),\\n minDeposit: deposit >= memMinDeposit ? 0 : memMinDeposit - deposit,\\n maxWithdraw: principal > 0 ? maxWithdraw(marketDeposit, marketBorrow, account) : 0,\\n pool: poolKey,\\n sqrtPriceX96: sqrtPriceX96,\\n availableAssets: balancerAvailableLiquidity()\\n });\\n }\\n\\n /// @notice Returns minimum deposit based on account's current debt and a given health factor.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account operating with the markets.\\n /// @param minHealthFactor The health factor that the account must have with the minimum deposit, isolated.\\n function minDeposit(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 minHealthFactor\\n ) internal view returns (uint256) {\\n MinDepositVars memory vars;\\n Auditor auditor = debtManager.auditor();\\n (vars.adjustFactorIn, , , , vars.priceFeedIn) = auditor.markets(marketDeposit);\\n (vars.adjustFactorOut, , , , vars.priceFeedOut) = auditor.markets(marketBorrow);\\n\\n return\\n minHealthFactor\\n .mulWadDown(floatingBorrowAssets(marketBorrow, account))\\n .mulDivDown(auditor.assetPrice(vars.priceFeedOut), 10 ** marketBorrow.decimals())\\n .divWadDown(vars.adjustFactorOut.mulWadDown(vars.adjustFactorIn))\\n .mulDivUp(10 ** marketDeposit.decimals(), auditor.assetPrice(vars.priceFeedIn));\\n }\\n\\n /// @notice Returns the maximum ratio that an account can leverage its principal plus `assets` amount.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account that will be leveraged.\\n /// @param deposit The amount of assets that will be added to the principal.\\n /// @param ratio The ratio to be previewed.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n function previewLeverage(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 deposit,\\n uint256 ratio,\\n uint256 minHealthFactor\\n ) external returns (Limit memory limit) {\\n uint256 currentRatio;\\n (limit.principal, currentRatio, limit.maxRatio) = previewRatio(\\n marketDeposit,\\n marketBorrow,\\n account,\\n int256(deposit),\\n minHealthFactor\\n );\\n\\n limit.ratio = (ratio < currentRatio || ratio > limit.maxRatio) ? currentRatio : ratio;\\n PoolKey memory poolKey = PoolAddress.getPoolKey(address(marketDeposit.asset()), address(marketBorrow.asset()), 0);\\n poolKey.fee = poolFees[poolKey.token0][poolKey.token1];\\n if (limit.principal <= 0) {\\n limit.borrow = floatingBorrowAssets(marketBorrow, account);\\n limit.deposit = marketDeposit.maxWithdraw(account) + deposit;\\n return limit;\\n }\\n limit.deposit = uint256(limit.principal).mulWadUp(limit.ratio);\\n if (marketDeposit == marketBorrow) {\\n limit.borrow = uint256(limit.principal).mulWadDown(limit.ratio - 1e18);\\n limit.swapRatio = 1e18;\\n return limit;\\n }\\n uint256 assetsSwap = limit.deposit - marketDeposit.maxWithdraw(account) - deposit;\\n limit.borrow =\\n floatingBorrowAssets(marketBorrow, account) +\\n previewOutputSwap(marketBorrow, marketDeposit, assetsSwap, poolKey.fee);\\n limit.swapRatio = assetsSwap > 0 && previewAssetsOut(marketDeposit, marketBorrow, assetsSwap) > 0\\n ? previewOutputSwap(marketBorrow, marketDeposit, assetsSwap, poolKey.fee).divWadDown(\\n previewAssetsOut(marketDeposit, marketBorrow, assetsSwap)\\n )\\n : 1e18;\\n }\\n\\n /// @notice Returns the maximum ratio that an account can deleverage its principal minus `assets` amount.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account that will be deleveraged.\\n /// @param withdraw The amount of assets that will be withdrawn from the principal.\\n /// @param ratio The ratio to be previewed.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n function previewDeleverage(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 withdraw,\\n uint256 ratio,\\n uint256 minHealthFactor\\n ) external returns (Limit memory limit) {\\n if ((limit.principal = crossPrincipal(marketDeposit, marketBorrow, account)) < 0) revert InvalidPreview();\\n uint256 memMaxWithdraw = maxWithdraw(marketDeposit, marketBorrow, account);\\n if (withdraw <= uint256(limit.principal)) {\\n limit.principal -= int256(withdraw);\\n limit.maxRatio = maxRatio(marketDeposit, marketBorrow, account, uint256(limit.principal), minHealthFactor);\\n } else if (withdraw <= memMaxWithdraw) {\\n limit.principal = int256(memMaxWithdraw - withdraw);\\n limit.maxRatio = limit.principal > 0\\n ? maxRatio(marketDeposit, marketBorrow, account, uint256(limit.principal), minHealthFactor)\\n : 1e18;\\n } else revert InvalidPreview();\\n\\n limit.ratio = ratio > limit.maxRatio ? limit.maxRatio : ratio;\\n\\n uint256 borrowRepay = floatingBorrowAssets(marketBorrow, account) -\\n previewAssetsOut(marketDeposit, marketBorrow, uint256(limit.principal).mulWadDown(limit.ratio - 1e18));\\n\\n PoolKey memory poolKey = PoolAddress.getPoolKey(address(marketDeposit.asset()), address(marketBorrow.asset()), 0);\\n poolKey.fee = poolFees[poolKey.token0][poolKey.token1];\\n limit.borrow = floatingBorrowAssets(marketBorrow, account) - borrowRepay;\\n if (marketDeposit == marketBorrow) {\\n limit.deposit = marketDeposit.maxWithdraw(account) - withdraw - borrowRepay;\\n limit.swapRatio = 1e18;\\n return limit;\\n }\\n\\n limit.deposit =\\n marketDeposit.maxWithdraw(account) -\\n withdraw -\\n previewOutputSwap(marketDeposit, marketBorrow, borrowRepay, poolKey.fee);\\n limit.swapRatio = previewAssetsOut(marketBorrow, marketDeposit, borrowRepay) > 0\\n ? previewOutputSwap(marketDeposit, marketBorrow, borrowRepay, poolKey.fee).divWadDown(\\n previewAssetsOut(marketBorrow, marketDeposit, borrowRepay)\\n )\\n : 1e18;\\n }\\n\\n /// @notice Returns principal, current ratio and max ratio, considering assets to add or substract.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account to preview the ratio.\\n /// @param assets The amount of assets that will be added or subtracted to the principal.\\n /// @param minHealthFactor The minimum health factor that the account should have with the max ratio.\\n function previewRatio(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n int256 assets,\\n uint256 minHealthFactor\\n ) internal view returns (int256 principal, uint256 current, uint256 max) {\\n principal = crossPrincipal(marketDeposit, marketBorrow, account) + assets;\\n if (principal > 0) {\\n current = uint256(int256(marketDeposit.maxWithdraw(account)) + assets).divWadUp(uint256(principal));\\n max = maxRatio(marketDeposit, marketBorrow, account, uint256(principal), minHealthFactor);\\n } else {\\n max = maxRatio(marketDeposit, marketBorrow, account, 0, minHealthFactor);\\n }\\n }\\n\\n /// @notice Returns the amount of `marketBorrow` underlying assets considering `amountIn` and assets oracle prices.\\n /// @param marketDeposit The market of the assets accounted as `amountIn`.\\n /// @param marketBorrow The market of the assets that will be returned.\\n /// @param amountIn The amount of `marketDeposit` underlying assets.\\n function previewAssetsOut(\\n Market marketDeposit,\\n Market marketBorrow,\\n uint256 amountIn\\n ) internal view returns (uint256) {\\n (, , , , IPriceFeed priceFeedIn) = debtManager.auditor().markets(marketDeposit);\\n (, , , , IPriceFeed priceFeedOut) = debtManager.auditor().markets(marketBorrow);\\n return\\n amountIn.mulDivDown(debtManager.auditor().assetPrice(priceFeedIn), 10 ** marketDeposit.decimals()).mulDivDown(\\n 10 ** marketBorrow.decimals(),\\n debtManager.auditor().assetPrice(priceFeedOut)\\n );\\n }\\n\\n /// @notice Returns the maximum ratio that an account can leverage its principal position.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account that will be leveraged.\\n /// @param principal The principal amount that will be leveraged.\\n /// @param minHealthFactor The minimum health factor that the account must have after the leverage.\\n function maxRatio(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n uint256 principal,\\n uint256 minHealthFactor\\n ) internal view returns (uint256) {\\n RatioVars memory r;\\n Auditor auditor = debtManager.auditor();\\n\\n uint256 marketMap = auditor.accountMarkets(account);\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = auditor.marketList(i);\\n Auditor.MarketData memory m;\\n Auditor.AccountLiquidity memory vars;\\n (m.adjustFactor, m.decimals, , , m.priceFeed) = auditor.markets(market);\\n vars.price = auditor.assetPrice(m.priceFeed);\\n (, vars.borrowBalance) = market.accountSnapshot(account);\\n\\n if (market == marketBorrow) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n vars.borrowBalance -= market.previewRefund(floatingBorrowShares);\\n }\\n r.adjustedDebt += vars.borrowBalance.mulDivUp(vars.price, 10 ** m.decimals).divWadUp(m.adjustFactor);\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n (r.adjustFactorIn, , , , ) = auditor.markets(marketDeposit);\\n (r.adjustFactorOut, , , , ) = auditor.markets(marketBorrow);\\n (, , , , IPriceFeed priceFeedIn) = auditor.markets(marketDeposit);\\n r.adjustedDebt = r.adjustedDebt.mulWadDown(r.adjustFactorOut).mulDivDown(\\n 10 ** marketDeposit.decimals(),\\n auditor.assetPrice(priceFeedIn)\\n );\\n if (\\n principal == 0 ||\\n r.adjustedDebt > principal ||\\n (principal - r.adjustedDebt).divWadDown(\\n principal - principal.mulWadDown(r.adjustFactorIn).mulWadDown(r.adjustFactorOut).divWadDown(minHealthFactor)\\n ) <\\n 1e18\\n ) {\\n return minHealthFactor.divWadDown(minHealthFactor - r.adjustFactorIn.mulWadDown(r.adjustFactorOut));\\n }\\n return\\n (principal - r.adjustedDebt).divWadDown(\\n principal - principal.mulWadDown(r.adjustFactorIn).mulWadDown(r.adjustFactorOut).divWadDown(minHealthFactor)\\n );\\n }\\n\\n function floatingBorrowAssets(Market market, address account) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n\\n /// @notice Returns the maximum amount that an account can withdraw when leveraged, repaying the full borrow.\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account to preview.\\n function maxWithdraw(Market marketDeposit, Market marketBorrow, address account) internal returns (uint256) {\\n Auditor auditor = debtManager.auditor();\\n\\n MaxWithdrawVars memory mw;\\n mw.marketMap = auditor.accountMarkets(account);\\n for (mw.i = 0; mw.marketMap != 0; mw.marketMap >>= 1) {\\n if (mw.marketMap & 1 != 0) {\\n Auditor.MarketData memory md;\\n Auditor.AccountLiquidity memory vars;\\n\\n mw.market = auditor.marketList(mw.i);\\n (md.adjustFactor, md.decimals, , , md.priceFeed) = auditor.markets(mw.market);\\n (vars.balance, vars.borrowBalance) = mw.market.accountSnapshot(account);\\n vars.price = auditor.assetPrice(md.priceFeed);\\n\\n mw.adjustedCollateral += vars.balance.mulDivDown(vars.price, 10 ** md.decimals).mulWadDown(md.adjustFactor);\\n mw.adjustedDebt += vars.borrowBalance.mulDivUp(vars.price, 10 ** md.decimals).divWadUp(md.adjustFactor);\\n\\n uint256 borrowAssets = floatingBorrowAssets(marketBorrow, account);\\n\\n if (mw.market == marketBorrow) {\\n mw.adjustedRepay = borrowAssets.mulDivUp(vars.price, 10 ** md.decimals).divWadUp(md.adjustFactor);\\n }\\n if (mw.market == marketDeposit) {\\n mw.adjustedPrincipalToRepayDebt = (\\n borrowAssets > 0 && marketBorrow != marketDeposit\\n ? previewOutputSwap(marketDeposit, marketBorrow, borrowAssets, 500)\\n : borrowAssets\\n ).mulDivDown(vars.price, 10 ** md.decimals).mulWadDown(md.adjustFactor);\\n mw.adjustedPrincipal =\\n (mw.market.maxWithdraw(account)).mulDivDown(vars.price, 10 ** md.decimals).mulWadDown(md.adjustFactor) -\\n mw.adjustedPrincipalToRepayDebt;\\n }\\n }\\n unchecked {\\n ++mw.i;\\n }\\n }\\n (mw.adjustFactorIn, , , , mw.priceFeedIn) = auditor.markets(marketDeposit);\\n\\n return\\n Math\\n .min(\\n mw.adjustedCollateral + mw.adjustedRepay - mw.adjustedDebt - mw.adjustedPrincipalToRepayDebt,\\n mw.adjustedPrincipal\\n )\\n .mulDivDown(10 ** marketDeposit.decimals(), auditor.assetPrice(mw.priceFeedIn))\\n .divWadDown(mw.adjustFactorIn);\\n }\\n\\n /// @notice Calculates the crossed principal amount for a given `account` in the input and output markets.\\n /// @param marketDeposit The Market to withdraw the leveraged position.\\n /// @param marketBorrow The Market to repay the leveraged position.\\n /// @param account The account that will be deleveraged.\\n function crossPrincipal(Market marketDeposit, Market marketBorrow, address account) internal view returns (int256) {\\n (, , , , IPriceFeed priceFeedIn) = debtManager.auditor().markets(marketDeposit);\\n (, , , , IPriceFeed priceFeedOut) = debtManager.auditor().markets(marketBorrow);\\n\\n return\\n int256(marketDeposit.maxWithdraw(account)) -\\n int256(\\n floatingBorrowAssets(marketBorrow, account)\\n .mulDivDown(debtManager.auditor().assetPrice(priceFeedOut), 10 ** marketBorrow.decimals())\\n .mulDivDown(10 ** marketDeposit.decimals(), debtManager.auditor().assetPrice(priceFeedIn))\\n );\\n }\\n\\n /// @notice Returns Balancer Vault's available liquidity of each enabled underlying asset.\\n function balancerAvailableLiquidity() internal view returns (AvailableAsset[] memory availableAssets) {\\n uint256 marketsCount = debtManager.auditor().allMarkets().length;\\n availableAssets = new AvailableAsset[](marketsCount);\\n\\n for (uint256 i = 0; i < marketsCount; ) {\\n ERC20 asset = debtManager.auditor().marketList(i).asset();\\n availableAssets[i] = AvailableAsset({\\n asset: asset,\\n liquidity: asset.balanceOf(address(debtManager.balancerVault()))\\n });\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice returns rates based on inputs and leverage ratio impact on the borrow market\\n /// @param marketDeposit The deposit Market.\\n /// @param marketBorrow The borrow Market.\\n /// @param account The account to preview.\\n /// @param assets The amount of assets that should be added or substracted to the principal.\\n /// @param targetRatio The target ratio to preview.\\n /// @param depositRate The current deposit rate of the deposit market.\\n /// @param nativeRate The current native rate of the deposit market.\\n function leverageRates(\\n Market marketDeposit,\\n Market marketBorrow,\\n address account,\\n int256 assets,\\n uint256 targetRatio,\\n uint256 depositRate,\\n uint256 nativeRate\\n ) external view returns (Rates memory rates) {\\n (int256 principal, uint256 currentRatio, ) = previewRatio(marketDeposit, marketBorrow, account, assets, 1e18);\\n if (principal <= 0) revert InvalidPreview();\\n\\n uint256 utilization;\\n if (targetRatio < currentRatio) {\\n uint256 depositDecrease = uint256(principal).mulWadDown(currentRatio - targetRatio);\\n utilization = (marketBorrow.totalFloatingBorrowAssets() -\\n previewAssetsOut(marketDeposit, marketBorrow, depositDecrease)).divWadUp(\\n marketBorrow.totalAssets() - (marketDeposit == marketBorrow ? depositDecrease : 0)\\n );\\n } else {\\n uint256 depositIncrease = uint256(principal).mulWadDown(targetRatio - currentRatio);\\n utilization = (marketBorrow.totalFloatingBorrowAssets() +\\n previewAssetsOut(marketDeposit, marketBorrow, depositIncrease)).divWadUp(\\n marketBorrow.totalAssets() + (marketDeposit == marketBorrow ? depositIncrease : 0)\\n );\\n }\\n rates.borrow = marketBorrow.interestRateModel().floatingRate(utilization).mulWadDown(targetRatio - 1e18);\\n rates.deposit = depositRate.mulWadDown(targetRatio);\\n rates.native = nativeRate.mulWadDown(targetRatio);\\n rates.rewards = calculateRewards(\\n rewardRates(marketDeposit),\\n marketDeposit == marketBorrow ? new RewardRate[](0) : rewardRates(marketBorrow),\\n marketDeposit == marketBorrow,\\n targetRatio\\n );\\n }\\n\\n function calculateRewards(\\n RewardRate[] memory depositRewards,\\n RewardRate[] memory borrowRewards,\\n bool sameMarket,\\n uint256 targetRatio\\n ) internal pure returns (RewardRate[] memory result) {\\n result = new RewardRate[](depositRewards.length + borrowRewards.length);\\n uint256 i;\\n for (; i < depositRewards.length; ) {\\n result[i].deposit = depositRewards[i].deposit.mulWadDown(targetRatio);\\n if (sameMarket) {\\n result[i].borrow = depositRewards[i].borrow.mulWadDown(targetRatio - 1e18);\\n }\\n result[i].asset = depositRewards[i].asset;\\n result[i].assetName = depositRewards[i].assetName;\\n result[i].assetSymbol = depositRewards[i].assetSymbol;\\n unchecked {\\n ++i;\\n }\\n }\\n if (!sameMarket) {\\n for (i = 0; i < borrowRewards.length; ) {\\n result[i + depositRewards.length].borrow = borrowRewards[i].borrow.mulWadDown(targetRatio - 1e18);\\n result[i + depositRewards.length].asset = borrowRewards[i].asset;\\n result[i + depositRewards.length].assetName = borrowRewards[i].assetName;\\n result[i + depositRewards.length].assetSymbol = borrowRewards[i].assetSymbol;\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n }\\n\\n function rewardRates(Market market) internal view returns (RewardRate[] memory rewards) {\\n Previewer.RewardsVars memory r;\\n r.controller = market.rewardsController();\\n if (address(r.controller) != address(0)) {\\n (, r.underlyingDecimals, , , r.underlyingPriceFeed) = market.auditor().markets(market);\\n unchecked {\\n r.underlyingBaseUnit = 10 ** r.underlyingDecimals;\\n }\\n r.deltaTime = 1 hours;\\n r.rewardList = r.controller.allRewards();\\n rewards = new RewardRate[](r.rewardList.length);\\n {\\n uint256 index;\\n for (r.i = 0; r.i < r.rewardList.length; ++r.i) {\\n (r.start, , ) = r.controller.distributionTime(market, r.rewardList[r.i]);\\n if (r.start == 0) continue;\\n rewards[index++].asset = r.rewardList[r.i];\\n }\\n RewardRate[] memory rewardList = rewards;\\n rewards = new RewardRate[](index);\\n for (r.i = 0; r.i < rewards.length; ++r.i) rewards[r.i] = rewardList[r.i];\\n }\\n for (r.i = 0; r.i < rewards.length; ) {\\n r.config = r.controller.rewardConfig(market, rewards[r.i].asset);\\n (r.borrowIndex, r.depositIndex, ) = r.controller.rewardIndexes(market, rewards[r.i].asset);\\n (r.projectedBorrowIndex, r.projectedDepositIndex, ) = r.controller.previewAllocation(\\n market,\\n rewards[r.i].asset,\\n block.timestamp > r.config.start ? r.deltaTime : 0\\n );\\n r.firstMaturity = r.start - (r.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n r.maxMaturity =\\n block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n r.maturities = new uint256[]((r.maxMaturity - r.firstMaturity) / FixedLib.INTERVAL + 1);\\n r.start = 0;\\n for (r.maturity = r.firstMaturity; r.maturity <= r.maxMaturity; ) {\\n (uint256 borrowed, ) = market.fixedPoolBalance(r.maturity);\\n r.fixedDebt += borrowed;\\n r.maturities[r.start] = r.maturity;\\n unchecked {\\n r.maturity += FixedLib.INTERVAL;\\n ++r.start;\\n }\\n }\\n rewards[r.i] = RewardRate({\\n asset: rewards[r.i].asset,\\n assetName: rewards[r.i].asset.name(),\\n assetSymbol: rewards[r.i].asset.symbol(),\\n borrow: (market.totalFloatingBorrowAssets() + r.fixedDebt) > 0\\n ? (r.projectedBorrowIndex - r.borrowIndex)\\n .mulDivDown(market.totalFloatingBorrowShares() + market.previewRepay(r.fixedDebt), r.underlyingBaseUnit)\\n .mulWadDown(market.auditor().assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n (market.totalFloatingBorrowAssets() + r.fixedDebt).mulWadDown(\\n market.auditor().assetPrice(r.underlyingPriceFeed)\\n )\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n deposit: market.totalAssets() > 0\\n ? (r.projectedDepositIndex - r.depositIndex)\\n .mulDivDown(market.totalSupply(), r.underlyingBaseUnit)\\n .mulWadDown(market.auditor().assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n market.totalAssets().mulWadDown(market.auditor().assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0\\n });\\n unchecked {\\n ++r.i;\\n }\\n }\\n }\\n }\\n}\\n\\nerror InvalidPreview();\\n\\nstruct Leverage {\\n uint256 ratio;\\n uint256 borrow;\\n uint256 deposit;\\n int256 principal;\\n uint256 maxRatio;\\n uint256 minDeposit;\\n uint256 maxWithdraw;\\n PoolKey pool;\\n uint256 sqrtPriceX96;\\n AvailableAsset[] availableAssets;\\n}\\n\\nstruct AvailableAsset {\\n ERC20 asset;\\n uint256 liquidity;\\n}\\n\\nstruct Pool {\\n address tokenA;\\n address tokenB;\\n}\\n\\nstruct Limit {\\n uint256 ratio;\\n uint256 borrow;\\n uint256 deposit;\\n int256 principal;\\n uint256 maxRatio;\\n uint256 swapRatio;\\n}\\n\\nstruct RatioVars {\\n uint256 adjustedDebt;\\n uint256 adjustFactorIn;\\n uint256 adjustFactorOut;\\n}\\n\\nstruct MaxWithdrawVars {\\n uint256 adjustedDebt;\\n uint256 adjustedRepay;\\n uint256 adjustedPrincipal;\\n uint256 adjustedCollateral;\\n uint256 adjustedPrincipalToRepayDebt;\\n IPriceFeed priceFeedIn;\\n uint256 marketMap;\\n uint256 adjustFactorIn;\\n uint256 adjustFactorOut;\\n uint256 i;\\n Market market;\\n}\\n\\nstruct MinDepositVars {\\n uint256 adjustFactorIn;\\n uint256 adjustFactorOut;\\n IPriceFeed priceFeedIn;\\n IPriceFeed priceFeedOut;\\n}\\n\\nstruct Rates {\\n uint256 native;\\n uint256 borrow;\\n uint256 deposit;\\n RewardRate[] rewards;\\n}\\n\\nstruct RewardRate {\\n ERC20 asset;\\n string assetName;\\n string assetSymbol;\\n uint256 borrow;\\n uint256 deposit;\\n}\\n\\ninterface IUniswapQuoter {\\n function quoteExactInputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountIn,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountOut);\\n\\n function quoteExactOutputSingle(\\n address tokenIn,\\n address tokenOut,\\n uint24 fee,\\n uint256 amountOut,\\n uint160 sqrtPriceLimitX96\\n ) external returns (uint256 amountIn);\\n}\\n\",\"keccak256\":\"0xaf28219d1c93caac444088caf955f1f02afaf1b882a46385d2f262d16cd4410c\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/Previewer.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { InterestRateModel as IRM, AlreadyMatured } from \\\"../InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"../RewardsController.sol\\\";\\nimport { FixedLib } from \\\"../utils/FixedLib.sol\\\";\\nimport { Auditor, IPriceFeed } from \\\"../Auditor.sol\\\";\\nimport { Market } from \\\"../Market.sol\\\";\\n\\n/// @title Previewer\\n/// @notice Contract to be consumed by Exactly's front-end dApp.\\ncontract Previewer {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for uint256;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IPriceFeed public immutable basePriceFeed;\\n\\n struct MarketAccount {\\n // market\\n Market market;\\n string symbol;\\n uint8 decimals;\\n address asset;\\n string assetName;\\n string assetSymbol;\\n InterestRateModel interestRateModel;\\n uint256 usdPrice;\\n uint256 penaltyRate;\\n uint256 adjustFactor;\\n uint8 maxFuturePools;\\n FixedPool[] fixedPools;\\n RewardRate[] rewardRates;\\n uint256 floatingBorrowRate;\\n uint256 floatingUtilization;\\n uint256 floatingBackupBorrowed;\\n uint256 floatingAvailableAssets;\\n uint256 totalFloatingBorrowAssets;\\n uint256 totalFloatingDepositAssets;\\n uint256 totalFloatingBorrowShares;\\n uint256 totalFloatingDepositShares;\\n // account\\n bool isCollateral;\\n uint256 maxBorrowAssets;\\n uint256 floatingBorrowShares;\\n uint256 floatingBorrowAssets;\\n uint256 floatingDepositShares;\\n uint256 floatingDepositAssets;\\n FixedPosition[] fixedDepositPositions;\\n FixedPosition[] fixedBorrowPositions;\\n ClaimableReward[] claimableRewards;\\n }\\n\\n struct RewardRate {\\n ERC20 asset;\\n string assetName;\\n string assetSymbol;\\n uint256 usdPrice;\\n uint256 borrow;\\n uint256 floatingDeposit;\\n uint256[] maturities;\\n }\\n\\n struct ClaimableReward {\\n address asset;\\n string assetName;\\n string assetSymbol;\\n uint256 amount;\\n }\\n\\n struct InterestRateModel {\\n address id;\\n uint256 fixedCurveA;\\n int256 fixedCurveB;\\n uint256 fixedMaxUtilization;\\n uint256 floatingCurveA;\\n int256 floatingCurveB;\\n uint256 floatingMaxUtilization;\\n }\\n\\n struct FixedPosition {\\n uint256 maturity;\\n uint256 previewValue;\\n FixedLib.Position position;\\n }\\n\\n struct FixedPreview {\\n uint256 maturity;\\n uint256 assets;\\n uint256 utilization;\\n }\\n\\n struct FixedPool {\\n uint256 maturity;\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 available;\\n uint256 utilization;\\n uint256 depositRate;\\n uint256 minBorrowRate;\\n uint256 optimalDeposit;\\n }\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IPriceFeed basePriceFeed_) {\\n auditor = auditor_;\\n basePriceFeed = basePriceFeed_;\\n }\\n\\n /// @notice Function to get a certain account extended data.\\n /// @param account address which the extended data will be calculated.\\n /// @return data extended accountability of all markets for the account.\\n function exactly(address account) external view returns (MarketAccount[] memory data) {\\n uint256 markets = auditor.accountMarkets(account);\\n uint256 maxValue = auditor.allMarkets().length;\\n (uint256 adjustedCollateral, uint256 adjustedDebt) = auditor.accountLiquidity(account, Market(address(0)), 0);\\n uint256 basePrice = address(basePriceFeed) != address(0)\\n ? uint256(basePriceFeed.latestAnswer()) * 10 ** (18 - basePriceFeed.decimals())\\n : 1e18;\\n data = new MarketAccount[](maxValue);\\n for (uint256 i = 0; i < maxValue; ++i) {\\n Market market = auditor.marketList(i);\\n Market.Account memory a;\\n Auditor.MarketData memory m;\\n (a.fixedDeposits, a.fixedBorrows, a.floatingBorrowShares) = market.accounts(account);\\n (m.adjustFactor, m.decimals, m.index, m.isListed, m.priceFeed) = auditor.markets(market);\\n IRM irm = market.interestRateModel();\\n data[i] = MarketAccount({\\n // market\\n market: market,\\n symbol: market.symbol(),\\n decimals: m.decimals,\\n asset: address(market.asset()),\\n assetName: market.asset().name(),\\n assetSymbol: market.asset().symbol(),\\n interestRateModel: InterestRateModel({\\n id: address(irm),\\n fixedCurveA: irm.fixedCurveA(),\\n fixedCurveB: irm.fixedCurveB(),\\n fixedMaxUtilization: irm.fixedMaxUtilization(),\\n floatingCurveA: irm.floatingCurveA(),\\n floatingCurveB: irm.floatingCurveB(),\\n floatingMaxUtilization: irm.floatingMaxUtilization()\\n }),\\n usdPrice: auditor.assetPrice(m.priceFeed).mulWadDown(basePrice),\\n penaltyRate: market.penaltyRate(),\\n adjustFactor: m.adjustFactor,\\n maxFuturePools: market.maxFuturePools(),\\n fixedPools: fixedPools(market),\\n rewardRates: rewardRates(market, basePrice),\\n floatingBorrowRate: irm.floatingRate(\\n market.floatingAssets() > 0 ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18) : 0\\n ),\\n floatingUtilization: market.floatingAssets() > 0\\n ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18)\\n : 0,\\n floatingBackupBorrowed: market.floatingBackupBorrowed(),\\n floatingAvailableAssets: floatingAvailableAssets(market),\\n totalFloatingBorrowAssets: market.totalFloatingBorrowAssets(),\\n totalFloatingDepositAssets: market.totalAssets(),\\n totalFloatingBorrowShares: market.totalFloatingBorrowShares(),\\n totalFloatingDepositShares: market.totalSupply(),\\n // account\\n isCollateral: markets & (1 << i) != 0 ? true : false,\\n maxBorrowAssets: adjustedCollateral >= adjustedDebt\\n ? (adjustedCollateral - adjustedDebt).mulDivUp(10 ** m.decimals, auditor.assetPrice(m.priceFeed)).mulWadUp(\\n m.adjustFactor\\n )\\n : 0,\\n floatingBorrowShares: a.floatingBorrowShares,\\n floatingBorrowAssets: maxRepay(market, account),\\n floatingDepositShares: market.balanceOf(account),\\n floatingDepositAssets: market.maxWithdraw(account),\\n fixedDepositPositions: fixedPositions(\\n market,\\n account,\\n a.fixedDeposits,\\n market.fixedDepositPositions,\\n this.previewWithdrawAtMaturity\\n ),\\n fixedBorrowPositions: fixedPositions(\\n market,\\n account,\\n a.fixedBorrows,\\n market.fixedBorrowPositions,\\n this.previewRepayAtMaturity\\n ),\\n claimableRewards: claimableRewards(market, account)\\n });\\n }\\n }\\n\\n /// @notice Gets the assets plus yield offered by a maturity when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be deposited.\\n /// @param assets amount of assets that will be deposited.\\n /// @return amount plus yield that the depositor will receive after maturity.\\n function previewDepositAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n if (block.timestamp > maturity) revert AlreadyMatured();\\n (uint256 borrowed, uint256 supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fixedDepositYield(market, maturity, assets),\\n utilization: memFloatingAssetsAverage > 0 ? borrowed.divWadUp(supplied + assets + memFloatingAssetsAverage) : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus yield offered by all VALID maturities when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be deposited.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewDepositAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n previews[i] = previewDepositAtMaturity(market, maturity, assets);\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount plus fees to be repaid at maturity when borrowing certain amount of assets.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be borrowed.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return positionAssets amount plus fees that the depositor will repay at maturity.\\n function previewBorrowAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n uint256 fees = assets.mulWadDown(\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n assets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n );\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fees,\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed + assets).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus fees offered by all VALID maturities when borrowing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewBorrowAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n try this.previewBorrowAtMaturity(market, maturity, assets) returns (FixedPreview memory preview) {\\n previews[i] = preview;\\n } catch {\\n previews[i] = FixedPreview({ maturity: maturity, assets: type(uint256).max, utilization: type(uint256).max });\\n }\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount to be withdrawn for a certain positionAmount of assets at maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be withdrawn.\\n /// @param positionAssets amount of assets that will be tried to withdraw.\\n /// @return withdrawAssets amount that will be withdrawn.\\n function previewWithdrawAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address owner\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedDepositPositions(maturity, owner);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets.divWadDown(\\n 1e18 +\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n )\\n : positionAssets,\\n utilization: memFloatingAssetsAverage > 0\\n ? pool.borrowed.divWadUp(pool.supplied + memFloatingAssetsAverage - principal)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets that will be repaid when repaying a certain amount at the current maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be repaid.\\n /// @param positionAssets amount of assets that will be subtracted from the position.\\n /// @param borrower address of the borrower.\\n /// @return repayAssets amount of assets that will be repaid.\\n function previewRepayAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address borrower\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedBorrowPositions(maturity, borrower);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets - fixedDepositYield(market, maturity, principal)\\n : positionAssets + positionAssets.mulWadDown((block.timestamp - maturity) * market.penaltyRate()),\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed - principal).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n function fixedPools(Market market) internal view returns (FixedPool[] memory pools) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n pools = new FixedPool[](market.maxFuturePools());\\n for (uint256 i = 0; i < market.maxFuturePools(); i++) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)\\n );\\n (uint256 minBorrowRate, uint256 utilization) = (market.previewFloatingAssetsAverage() + pool.supplied) > 0\\n ? market.interestRateModel().minFixedRate(pool.borrowed, pool.supplied, market.previewFloatingAssetsAverage())\\n : (0, 0);\\n\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n (block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)) - pool.lastAccrual\\n );\\n pools[i] = FixedPool({\\n maturity: block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1),\\n borrowed: pool.borrowed,\\n supplied: pool.supplied,\\n available: Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()) -\\n Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()),\\n market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt\\n ),\\n market.previewFloatingAssetsAverage()\\n ) +\\n pool.supplied -\\n Math.min(pool.supplied, pool.borrowed),\\n utilization: utilization,\\n optimalDeposit: pool.borrowed - Math.min(pool.borrowed, pool.supplied),\\n depositRate: uint256(365 days).mulDivDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied) > 0\\n ? (pool.unassignedEarnings.mulWadDown(1e18 - market.backupFeeRate())).divWadDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied)\\n )\\n : 0,\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1) - block.timestamp\\n ),\\n minBorrowRate: minBorrowRate\\n });\\n }\\n }\\n\\n function rewardRates(Market market, uint256 basePrice) internal view returns (RewardRate[] memory rewards) {\\n RewardsVars memory r;\\n r.controller = market.rewardsController();\\n if (address(r.controller) != address(0)) {\\n (, r.underlyingDecimals, , , r.underlyingPriceFeed) = auditor.markets(market);\\n unchecked {\\n r.underlyingBaseUnit = 10 ** r.underlyingDecimals;\\n }\\n r.deltaTime = 1 hours;\\n r.rewardList = r.controller.allRewards();\\n rewards = new RewardRate[](r.rewardList.length);\\n {\\n uint256 index;\\n for (r.i = 0; r.i < r.rewardList.length; ++r.i) {\\n (r.start, , ) = r.controller.distributionTime(market, r.rewardList[r.i]);\\n if (r.start == 0) continue;\\n rewards[index++].asset = r.rewardList[r.i];\\n }\\n RewardRate[] memory rewardList = rewards;\\n rewards = new RewardRate[](index);\\n for (r.i = 0; r.i < rewards.length; ++r.i) rewards[r.i] = rewardList[r.i];\\n }\\n for (r.i = 0; r.i < rewards.length; ++r.i) {\\n r.config = r.controller.rewardConfig(market, rewards[r.i].asset);\\n (r.borrowIndex, r.depositIndex, ) = r.controller.rewardIndexes(market, rewards[r.i].asset);\\n (r.projectedBorrowIndex, r.projectedDepositIndex, ) = r.controller.previewAllocation(\\n market,\\n rewards[r.i].asset,\\n block.timestamp > r.config.start ? r.deltaTime : 0\\n );\\n r.firstMaturity = r.start - (r.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n r.maxMaturity =\\n block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n r.maturities = new uint256[]((r.maxMaturity - r.firstMaturity) / FixedLib.INTERVAL + 1);\\n r.start = 0;\\n for (r.maturity = r.firstMaturity; r.maturity <= r.maxMaturity; ) {\\n (uint256 borrowed, ) = market.fixedPoolBalance(r.maturity);\\n r.fixedDebt += borrowed;\\n r.maturities[r.start] = r.maturity;\\n unchecked {\\n r.maturity += FixedLib.INTERVAL;\\n ++r.start;\\n }\\n }\\n rewards[r.i] = RewardRate({\\n asset: rewards[r.i].asset,\\n assetName: rewards[r.i].asset.name(),\\n assetSymbol: rewards[r.i].asset.symbol(),\\n usdPrice: auditor.assetPrice(r.config.priceFeed).mulWadDown(basePrice),\\n borrow: (market.totalFloatingBorrowAssets() + r.fixedDebt) > 0\\n ? (r.projectedBorrowIndex - r.borrowIndex)\\n .mulDivDown(market.totalFloatingBorrowShares() + market.previewRepay(r.fixedDebt), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n (market.totalFloatingBorrowAssets() + r.fixedDebt).mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n floatingDeposit: market.totalAssets() > 0\\n ? (r.projectedDepositIndex - r.depositIndex)\\n .mulDivDown(market.totalSupply(), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n market.totalAssets().mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n maturities: r.maturities\\n });\\n }\\n }\\n }\\n\\n function claimableRewards(Market market, address account) internal view returns (ClaimableReward[] memory rewards) {\\n RewardsController rewardsController = market.rewardsController();\\n if (address(rewardsController) != address(0)) {\\n ERC20[] memory rewardList = rewardsController.allRewards();\\n\\n rewards = new ClaimableReward[](rewardList.length);\\n RewardsController.MarketOperation[] memory marketOps = new RewardsController.MarketOperation[](1);\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[0] = RewardsController.MarketOperation({ market: market, operations: ops });\\n\\n for (uint256 i = 0; i < rewardList.length; ++i) {\\n rewards[i] = ClaimableReward({\\n asset: address(rewardList[i]),\\n assetName: rewardList[i].name(),\\n assetSymbol: rewardList[i].symbol(),\\n amount: rewardsController.claimable(marketOps, account, rewardList[i])\\n });\\n }\\n }\\n }\\n\\n function floatingAvailableAssets(Market market) internal view returns (uint256) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n uint256 maxAssets = (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor());\\n return maxAssets - Math.min(maxAssets, market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt);\\n }\\n\\n function fixedPositions(\\n Market market,\\n address account,\\n uint256 packedMaturities,\\n function(uint256, address) external view returns (uint256, uint256) getPosition,\\n function(Market, uint256, uint256, address) external view returns (FixedPreview memory) previewValue\\n ) internal view returns (FixedPosition[] memory userMaturityPositions) {\\n uint256 userMaturityCount = 0;\\n FixedPosition[] memory allMaturityPositions = new FixedPosition[](224);\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 positionAssets;\\n {\\n (uint256 principal, uint256 fee) = getPosition(maturity, account);\\n positionAssets = principal + fee;\\n allMaturityPositions[userMaturityCount].position = FixedLib.Position(principal, fee);\\n }\\n try previewValue(market, maturity, positionAssets, account) returns (FixedPreview memory fixedPreview) {\\n allMaturityPositions[userMaturityCount].previewValue = fixedPreview.assets;\\n } catch {\\n allMaturityPositions[userMaturityCount].previewValue = positionAssets;\\n }\\n allMaturityPositions[userMaturityCount].maturity = maturity;\\n ++userMaturityCount;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n\\n userMaturityPositions = new FixedPosition[](userMaturityCount);\\n for (uint256 i = 0; i < userMaturityCount; ++i) userMaturityPositions[i] = allMaturityPositions[i];\\n }\\n\\n function fixedDepositYield(Market market, uint256 maturity, uint256 assets) internal view returns (uint256 yield) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(maturity);\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n maturity - pool.lastAccrual\\n );\\n (yield, ) = pool.calculateDeposit(assets, market.backupFeeRate());\\n }\\n\\n function maxRepay(Market market, address borrower) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(borrower);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n\\n function newFloatingDebt(Market market) internal view returns (uint256) {\\n uint256 memFloatingDebt = market.floatingDebt();\\n uint256 memFloatingAssets = market.floatingAssets();\\n uint256 floatingUtilization = memFloatingAssets > 0\\n ? Math.min(memFloatingDebt.divWadUp(memFloatingAssets), 1e18)\\n : 0;\\n return\\n memFloatingDebt.mulWadDown(\\n market.interestRateModel().floatingRate(floatingUtilization).mulDivDown(\\n block.timestamp - market.lastFloatingDebtUpdate(),\\n 365 days\\n )\\n );\\n }\\n\\n struct RewardsVars {\\n RewardsController controller;\\n uint256 lastUpdate;\\n uint256 depositIndex;\\n uint256 borrowIndex;\\n uint256 projectedDepositIndex;\\n uint256 projectedBorrowIndex;\\n uint256 underlyingBaseUnit;\\n uint256[] maturities;\\n IPriceFeed underlyingPriceFeed;\\n RewardsController.Config config;\\n ERC20[] rewardList;\\n uint256 underlyingDecimals;\\n uint256 deltaTime;\\n uint256 i;\\n uint256 start;\\n uint256 maturity;\\n uint256 fixedDebt;\\n uint256 maxMaturity;\\n uint256 firstMaturity;\\n }\\n}\\n\\nerror InvalidRewardsLength();\\n\",\"keccak256\":\"0x49580c383ef1adee2e988a4590f68315ad85e14dbb2bfa1f5d3becf0d9eff940\",\"license\":\"BUSL-1.1\"},\"contracts/utils/FixedLib.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\nlibrary FixedLib {\\n using FixedPointMathLib for uint256;\\n\\n uint256 internal constant INTERVAL = 4 weeks;\\n\\n /// @notice Gets the amount of revenue sharing between the backup supplier and the new fixed pool supplier.\\n /// @param pool fixed rate pool.\\n /// @param amount amount being provided by the fixed pool supplier.\\n /// @param backupFeeRate rate charged to the fixed pool supplier to be accrued by the backup supplier.\\n /// @return yield amount to be offered to the fixed pool supplier.\\n /// @return backupFee yield to be accrued by the backup supplier for initially providing the liquidity.\\n function calculateDeposit(\\n Pool memory pool,\\n uint256 amount,\\n uint256 backupFeeRate\\n ) internal pure returns (uint256 yield, uint256 backupFee) {\\n uint256 memBackupSupplied = backupSupplied(pool);\\n if (memBackupSupplied != 0) {\\n yield = pool.unassignedEarnings.mulDivDown(Math.min(amount, memBackupSupplied), memBackupSupplied);\\n backupFee = yield.mulWadDown(backupFeeRate);\\n yield -= backupFee;\\n }\\n }\\n\\n /// @notice Registers an operation to add supply to a fixed rate pool and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be added to the supply.\\n /// @param amount amount to be added to the supply.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function deposit(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.supplied = supplied + amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to reduce borrowed amount from a fixed rate pool\\n /// and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be repaid.\\n /// @param amount amount to be added to the fixed rate pool.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function repay(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.borrowed = borrowed - amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to increase borrowed amount of a fixed rate pool\\n /// and potentially increase backup debt.\\n /// @param pool fixed rate pool where an amount will be borrowed.\\n /// @param amount amount to be borrowed from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function borrow(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 newBorrowed = borrowed + amount;\\n\\n backupDebtAddition = newBorrowed - Math.min(Math.max(borrowed, pool.supplied), newBorrowed);\\n pool.borrowed = newBorrowed;\\n }\\n\\n /// @notice Registers an operation to reduce supply from a fixed rate pool and potentially increase backup debt.\\n /// @param pool fixed rate pool where amount will be withdrawn.\\n /// @param amountToDiscount amount to be withdrawn from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function withdraw(Pool storage pool, uint256 amountToDiscount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n uint256 newSupply = supplied - amountToDiscount;\\n\\n backupDebtAddition = Math.min(supplied, borrowed) - Math.min(newSupply, borrowed);\\n pool.supplied = newSupply;\\n }\\n\\n /// @notice Accrues backup earnings from `unassignedEarnings` based on the `lastAccrual` time.\\n /// @param pool fixed rate pool where earnings will be accrued.\\n /// @param maturity maturity date of the pool.\\n /// @return backupEarnings amount of earnings to be distributed to the backup supplier.\\n function accrueEarnings(Pool storage pool, uint256 maturity) internal returns (uint256 backupEarnings) {\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (block.timestamp < maturity) {\\n uint256 unassignedEarnings = pool.unassignedEarnings;\\n pool.lastAccrual = block.timestamp;\\n backupEarnings = unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual);\\n pool.unassignedEarnings = unassignedEarnings - backupEarnings;\\n } else if (lastAccrual == maturity) {\\n backupEarnings = 0;\\n } else {\\n pool.lastAccrual = maturity;\\n backupEarnings = pool.unassignedEarnings;\\n pool.unassignedEarnings = 0;\\n }\\n }\\n\\n /// @notice Calculates the amount that a fixed rate pool borrowed from the backup supplier.\\n /// @param pool fixed rate pool.\\n /// @return amount borrowed from the fixed rate pool.\\n function backupSupplied(Pool memory pool) internal pure returns (uint256) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n return borrowed - Math.min(borrowed, supplied);\\n }\\n\\n /// @notice Modify positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it. Needs for the amount to be less than the principal and the fee\\n /// @param position original position to be scaled.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return scaled position.\\n function scaleProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 principal = amount.mulDivDown(position.principal, position.principal + position.fee);\\n position.principal = principal;\\n position.fee = amount - principal;\\n return position;\\n }\\n\\n /// @notice Reduce positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it.\\n /// @param position original position to be reduced.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return reduced position.\\n function reduceProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 positionAssets = position.principal + position.fee;\\n uint256 newPositionAssets = positionAssets - amount;\\n position.principal = newPositionAssets.mulDivDown(position.principal, positionAssets);\\n position.fee = newPositionAssets - position.principal;\\n return position;\\n }\\n\\n /// @notice Calculates what proportion of earnings would `borrowAmount` represent considering `backupSupplied`.\\n /// @param earnings amount to be distributed.\\n /// @param borrowAmount amount that will be checked if came from the backup supplier or fixed rate pool.\\n /// @return unassignedEarnings earnings to be added to `unassignedEarnings`.\\n /// @return backupEarnings earnings to be distributed to the backup supplier.\\n function distributeEarnings(\\n Pool memory pool,\\n uint256 earnings,\\n uint256 borrowAmount\\n ) internal pure returns (uint256 unassignedEarnings, uint256 backupEarnings) {\\n backupEarnings = borrowAmount == 0\\n ? 0\\n : earnings.mulDivDown(borrowAmount - Math.min(backupSupplied(pool), borrowAmount), borrowAmount);\\n unassignedEarnings = earnings - backupEarnings;\\n }\\n\\n /// @notice Adds a maturity date to the borrow or supply positions of the account.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity the new maturity where the account will borrow or supply to.\\n /// @return updated encoded maturity dates.\\n function setMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n // initialize the maturity with also the 1st bit on the 33th position set\\n if (encoded == 0) return maturity | (1 << 32);\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n if (maturity < baseMaturity) {\\n // if the new maturity is lower than the base, set it as the new base\\n // wipe clean the last 32 bits, shift the amount of `INTERVAL` and set the new value with the 33rd bit set\\n uint256 range = (baseMaturity - maturity) / INTERVAL;\\n if (encoded >> (256 - range) != 0) revert MaturityOverflow();\\n encoded = ((encoded >> 32) << (32 + range));\\n return maturity | encoded | (1 << 32);\\n } else {\\n uint256 range = (maturity - baseMaturity) / INTERVAL;\\n if (range > 223) revert MaturityOverflow();\\n return encoded | (1 << (32 + range));\\n }\\n }\\n\\n /// @notice Remove maturity from account's borrow or supplied positions.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity maturity date to be removed.\\n /// @return updated encoded maturity dates.\\n function clearMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n if (encoded == 0 || encoded == maturity | (1 << 32)) return 0;\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n // if the baseMaturity is the one being cleaned\\n if (maturity == baseMaturity) {\\n // wipe 32 bytes + 1 for the old base flag\\n uint256 packed = encoded >> 33;\\n uint256 range = 1;\\n while ((packed & 1) == 0 && packed != 0) {\\n unchecked {\\n ++range;\\n }\\n packed >>= 1;\\n }\\n encoded = ((encoded >> (32 + range)) << 32);\\n return (maturity + (range * INTERVAL)) | encoded;\\n } else {\\n // otherwise just clear the bit\\n return encoded & ~(1 << (32 + ((maturity - baseMaturity) / INTERVAL)));\\n }\\n }\\n\\n /// @notice Verifies that a maturity is `VALID`, `MATURED`, `NOT_READY` or `INVALID`.\\n /// @dev if expected state doesn't match the calculated one, it reverts with a custom error `UnmatchedPoolState`.\\n /// @param maturity timestamp of the maturity date to be verified.\\n /// @param maxPools number of pools available in the time horizon.\\n /// @param requiredState state required by the caller to be verified (see `State` for description).\\n /// @param alternativeState state required by the caller to be verified (see `State` for description).\\n function checkPoolState(uint256 maturity, uint8 maxPools, State requiredState, State alternativeState) internal view {\\n State state;\\n if (maturity % INTERVAL != 0) {\\n state = State.INVALID;\\n } else if (maturity <= block.timestamp) {\\n state = State.MATURED;\\n } else if (maturity > block.timestamp - (block.timestamp % INTERVAL) + (INTERVAL * maxPools)) {\\n state = State.NOT_READY;\\n } else {\\n state = State.VALID;\\n }\\n\\n if (state != requiredState && state != alternativeState) {\\n if (alternativeState == State.NONE) revert UnmatchedPoolState(uint8(state), uint8(requiredState));\\n\\n revert UnmatchedPoolStates(uint8(state), uint8(requiredState), uint8(alternativeState));\\n }\\n }\\n\\n /// @notice Stores the accountability of a fixed interest rate pool.\\n /// @param borrowed total amount borrowed from the pool.\\n /// @param supplied total amount supplied to the pool.\\n /// @param unassignedEarnings total amount of earnings not yet distributed and accrued.\\n /// @param lastAccrual timestamp for the last time that some earnings have been distributed to the backup supplier.\\n struct Pool {\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 unassignedEarnings;\\n uint256 lastAccrual;\\n }\\n\\n /// @notice Stores principal and fee of a borrow or a supply position of a account in a fixed rate pool.\\n /// @param principal amount borrowed or supplied to the fixed rate pool.\\n /// @param fee amount of fees to be repaid or earned at the maturity of the fixed rate pool.\\n struct Position {\\n uint256 principal;\\n uint256 fee;\\n }\\n\\n enum State {\\n NONE,\\n INVALID,\\n MATURED,\\n VALID,\\n NOT_READY\\n }\\n}\\n\\nerror MaturityOverflow();\\nerror UnmatchedPoolState(uint8 state, uint8 requiredState);\\nerror UnmatchedPoolStates(uint8 state, uint8 requiredState, uint8 alternativeState);\\n\",\"keccak256\":\"0x34f461426e416de7b4d38263269571d0274dda55df2e580e920196096b166c01\",\"license\":\"BUSL-1.1\"},\"contracts/utils/IPriceFeed.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\ninterface IPriceFeed {\\n function decimals() external view returns (uint8);\\n\\n function latestAnswer() external view returns (int256);\\n}\\n\",\"keccak256\":\"0xce1b3c2ebe700449e2e3c7637ffaf85e574eed3f79925feee22426b2c43fc667\",\"license\":\"BUSL-1.1\"},\"solmate/src/mixins/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\nimport {SafeTransferLib} from \\\"../utils/SafeTransferLib.sol\\\";\\nimport {FixedPointMathLib} from \\\"../utils/FixedPointMathLib.sol\\\";\\n\\n/// @notice Minimal ERC4626 tokenized Vault implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol)\\nabstract contract ERC4626 is ERC20 {\\n using SafeTransferLib for ERC20;\\n using FixedPointMathLib for uint256;\\n\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /*//////////////////////////////////////////////////////////////\\n IMMUTABLES\\n //////////////////////////////////////////////////////////////*/\\n\\n ERC20 public immutable asset;\\n\\n constructor(\\n ERC20 _asset,\\n string memory _name,\\n string memory _symbol\\n ) ERC20(_name, _symbol, _asset.decimals()) {\\n asset = _asset;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {\\n // Check for rounding error since we round down in previewDeposit.\\n require((shares = previewDeposit(assets)) != 0, \\\"ZERO_SHARES\\\");\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {\\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function withdraw(\\n uint256 assets,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 shares) {\\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\\n\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n function redeem(\\n uint256 shares,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 assets) {\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n // Check for rounding error since we round down in previewRedeem.\\n require((assets = previewRedeem(shares)) != 0, \\\"ZERO_ASSETS\\\");\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ACCOUNTING LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function totalAssets() public view virtual returns (uint256);\\n\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\\n }\\n\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);\\n }\\n\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return convertToShares(assets);\\n }\\n\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);\\n }\\n\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());\\n }\\n\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return convertToAssets(shares);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LIMIT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return convertToAssets(balanceOf[owner]);\\n }\\n\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf[owner];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL HOOKS LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}\\n\\n function afterDeposit(uint256 assets, uint256 shares) internal virtual {}\\n}\\n\",\"keccak256\":\"0xa0e0c28a727524fa94e7e6c1f4c793a6bd1e6d1bc652b7b02b343ebaf4cd774b\",\"license\":\"MIT\"},\"solmate/src/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0x43aa1509bb753f053143530705d9c4eee415691d26a4779769bf028a74e6ac69\",\"license\":\"MIT\"},\"solmate/src/utils/FixedPointMathLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Arithmetic library with operations for fixed-point numbers.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)\\nlibrary FixedPointMathLib {\\n /*//////////////////////////////////////////////////////////////\\n SIMPLIFIED FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\\n\\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\\n }\\n\\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\\n }\\n\\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\\n }\\n\\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\\n }\\n\\n function powWad(int256 x, int256 y) internal pure returns (int256) {\\n // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)\\n return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.\\n }\\n\\n function expWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n // When the result is < 0.5 we return zero. This happens when\\n // x <= floor(log(0.5e18) * 1e18) ~ -42e18\\n if (x <= -42139678854452767551) return 0;\\n\\n // When the result is > (2**255 - 1) / 1e18 we can not represent it as an\\n // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.\\n if (x >= 135305999368893231589) revert(\\\"EXP_OVERFLOW\\\");\\n\\n // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96\\n // for more intermediate precision and a binary basis. This base conversion\\n // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.\\n x = (x << 78) / 5**18;\\n\\n // Reduce range of x to (-\\u00bd ln 2, \\u00bd ln 2) * 2**96 by factoring out powers\\n // of two such that exp(x) = exp(x') * 2**k, where k is an integer.\\n // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).\\n int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;\\n x = x - k * 54916777467707473351141471128;\\n\\n // k is in the range [-61, 195].\\n\\n // Evaluate using a (6, 7)-term rational approximation.\\n // p is made monic, we'll multiply by a scale factor later.\\n int256 y = x + 1346386616545796478920950773328;\\n y = ((y * x) >> 96) + 57155421227552351082224309758442;\\n int256 p = y + x - 94201549194550492254356042504812;\\n p = ((p * y) >> 96) + 28719021644029726153956944680412240;\\n p = p * x + (4385272521454847904659076985693276 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n int256 q = x - 2855989394907223263936484059900;\\n q = ((q * x) >> 96) + 50020603652535783019961831881945;\\n q = ((q * x) >> 96) - 533845033583426703283633433725380;\\n q = ((q * x) >> 96) + 3604857256930695427073651918091429;\\n q = ((q * x) >> 96) - 14423608567350463180887372962807573;\\n q = ((q * x) >> 96) + 26449188498355588339934803723976023;\\n\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial won't have zeros in the domain as all its roots are complex.\\n // No scaling is necessary because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r should be in the range (0.09, 0.25) * 2**96.\\n\\n // We now need to multiply r by:\\n // * the scale factor s = ~6.031367120.\\n // * the 2**k factor from the range reduction.\\n // * the 1e18 / 2**96 factor for base conversion.\\n // We do this all at once, with an intermediate result in 2**213\\n // basis, so the final right shift is always by a positive amount.\\n r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));\\n }\\n }\\n\\n function lnWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n // We want to convert x from 10**18 fixed point to 2**96 fixed point.\\n // We do this by multiplying by 2**96 / 10**18. But since\\n // ln(x * C) = ln(x) + ln(C), we can simply do nothing here\\n // and add ln(2**96 / 10**18) at the end.\\n\\n // Reduce range of x to (1, 2) * 2**96\\n // ln(2^k * x) = k * ln(2) + ln(x)\\n int256 k = int256(log2(uint256(x))) - 96;\\n x <<= uint256(159 - k);\\n x = int256(uint256(x) >> 159);\\n\\n // Evaluate using a (8, 8)-term rational approximation.\\n // p is made monic, we will multiply by a scale factor later.\\n int256 p = x + 3273285459638523848632254066296;\\n p = ((p * x) >> 96) + 24828157081833163892658089445524;\\n p = ((p * x) >> 96) + 43456485725739037958740375743393;\\n p = ((p * x) >> 96) - 11111509109440967052023855526967;\\n p = ((p * x) >> 96) - 45023709667254063763336534515857;\\n p = ((p * x) >> 96) - 14706773417378608786704636184526;\\n p = p * x - (795164235651350426258249787498 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n // q is monic by convention.\\n int256 q = x + 5573035233440673466300451813936;\\n q = ((q * x) >> 96) + 71694874799317883764090561454958;\\n q = ((q * x) >> 96) + 283447036172924575727196451306956;\\n q = ((q * x) >> 96) + 401686690394027663651624208769553;\\n q = ((q * x) >> 96) + 204048457590392012362485061816622;\\n q = ((q * x) >> 96) + 31853899698501571402653359427138;\\n q = ((q * x) >> 96) + 909429971244387300277376558375;\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial is known not to have zeros in the domain.\\n // No scaling required because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r is in the range (0, 0.125) * 2**96\\n\\n // Finalization, we need to:\\n // * multiply by the scale factor s = 5.549\\u2026\\n // * add ln(2**96 / 10**18)\\n // * add k * ln(2)\\n // * multiply by 10**18 / 2**96 = 5**18 >> 78\\n\\n // mul s * 5e18 * 2**96, base is now 5**18 * 2**192\\n r *= 1677202110996718588342820967067443963516166;\\n // add ln(2) * k * 5e18 * 2**192\\n r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;\\n // add ln(2**96 / 10**18) * 5e18 * 2**192\\n r += 600920179829731861736702779321621459595472258049074101567377883020018308;\\n // base conversion: mul 2**18 / 2**192\\n r >>= 174;\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n LOW LEVEL FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function mulDivDown(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // Divide z by the denominator.\\n z := div(z, denominator)\\n }\\n }\\n\\n function mulDivUp(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // First, divide z - 1 by the denominator and add 1.\\n // We allow z - 1 to underflow if z is 0, because we multiply the\\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\\n }\\n }\\n\\n function rpow(\\n uint256 x,\\n uint256 n,\\n uint256 scalar\\n ) internal pure returns (uint256 z) {\\n assembly {\\n switch x\\n case 0 {\\n switch n\\n case 0 {\\n // 0 ** 0 = 1\\n z := scalar\\n }\\n default {\\n // 0 ** n = 0\\n z := 0\\n }\\n }\\n default {\\n switch mod(n, 2)\\n case 0 {\\n // If n is even, store scalar in z for now.\\n z := scalar\\n }\\n default {\\n // If n is odd, store x in z for now.\\n z := x\\n }\\n\\n // Shifting right by 1 is like dividing by 2.\\n let half := shr(1, scalar)\\n\\n for {\\n // Shift n right by 1 before looping to halve it.\\n n := shr(1, n)\\n } n {\\n // Shift n right by 1 each iteration to halve it.\\n n := shr(1, n)\\n } {\\n // Revert immediately if x ** 2 would overflow.\\n // Equivalent to iszero(eq(div(xx, x), x)) here.\\n if shr(128, x) {\\n revert(0, 0)\\n }\\n\\n // Store x squared.\\n let xx := mul(x, x)\\n\\n // Round to the nearest number.\\n let xxRound := add(xx, half)\\n\\n // Revert if xx + half overflowed.\\n if lt(xxRound, xx) {\\n revert(0, 0)\\n }\\n\\n // Set x to scaled xxRound.\\n x := div(xxRound, scalar)\\n\\n // If n is even:\\n if mod(n, 2) {\\n // Compute z * x.\\n let zx := mul(z, x)\\n\\n // If z * x overflowed:\\n if iszero(eq(div(zx, x), z)) {\\n // Revert if x is non-zero.\\n if iszero(iszero(x)) {\\n revert(0, 0)\\n }\\n }\\n\\n // Round to the nearest number.\\n let zxRound := add(zx, half)\\n\\n // Revert if zx + half overflowed.\\n if lt(zxRound, zx) {\\n revert(0, 0)\\n }\\n\\n // Return properly scaled zxRound.\\n z := div(zxRound, scalar)\\n }\\n }\\n }\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n GENERAL NUMBER UTILITIES\\n //////////////////////////////////////////////////////////////*/\\n\\n function sqrt(uint256 x) internal pure returns (uint256 z) {\\n assembly {\\n let y := x // We start y at x, which will help us make our initial estimate.\\n\\n z := 181 // The \\\"correct\\\" value is 1, but this saves a multiplication later.\\n\\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\\n\\n // We check y >= 2^(k + 8) but shift right by k bits\\n // each branch to ensure that if x >= 256, then y >= 256.\\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\\n y := shr(128, y)\\n z := shl(64, z)\\n }\\n if iszero(lt(y, 0x1000000000000000000)) {\\n y := shr(64, y)\\n z := shl(32, z)\\n }\\n if iszero(lt(y, 0x10000000000)) {\\n y := shr(32, y)\\n z := shl(16, z)\\n }\\n if iszero(lt(y, 0x1000000)) {\\n y := shr(16, y)\\n z := shl(8, z)\\n }\\n\\n // Goal was to get z*z*y within a small factor of x. More iterations could\\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\\n\\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\\n\\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\\n\\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\\n\\n // There is no overflow risk here since y < 2^136 after the first branch above.\\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\\n\\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n\\n // If x+1 is a perfect square, the Babylonian method cycles between\\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\\n z := sub(z, lt(div(x, z), z))\\n }\\n }\\n\\n function log2(uint256 x) internal pure returns (uint256 r) {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n assembly {\\n r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))\\n r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))\\n r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\\n r := or(r, shl(4, lt(0xffff, shr(r, x))))\\n r := or(r, shl(3, lt(0xff, shr(r, x))))\\n r := or(r, shl(2, lt(0xf, shr(r, x))))\\n r := or(r, shl(1, lt(0x3, shr(r, x))))\\n r := or(r, lt(0x1, shr(r, x)))\\n }\\n }\\n\\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := mod(x, y)\\n }\\n }\\n\\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := div(x, y)\\n }\\n }\\n\\n /// @dev Will return 0 instead of reverting if y is zero.\\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // Add 1 to x * y if x % y > 0.\\n z := add(gt(mod(x, y), 0), div(x, y))\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0bf1d4f3999a4471e0fded0a2f67e7fe328e2a27385348571b1fc0a8d9c9f62e\",\"license\":\"MIT\"},\"solmate/src/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Caution! This library won't check that a token has code, responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(4, from) // Append the \\\"from\\\" argument.\\n mstore(36, to) // Append the \\\"to\\\" argument.\\n mstore(68, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because that's the total length of our calldata (4 + 32 * 3)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 100, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x5f2e1158c68c1f3d15b80e8a7dd92b6849f873066969562ad33c0abb80e536ff\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b506040516200612138038062006121833981016040819052620000349162000065565b6001600160a01b039182166080521660a052620000a4565b6001600160a01b03811681146200006257600080fd5b50565b600080604083850312156200007957600080fd5b825162000086816200004c565b602084015190925062000099816200004c565b809150509250929050565b60805160a051615fe0620001416000396000818161012d01528181610251015261157401526000818161018c01528181610f12015281816116fe015281816117f40152818161195801528181611a4901528181611c2c0152818161240901528181612bf501528181612ceb01528181612e4f01528181612f400152818161473f01528181614bc101528181614d180152614e940152615fe06000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c80639241c920116100665780639241c920146101ae578063926da1b4146101c3578063a9563e4f146101e3578063ecd0cca014610227578063fcc5815b1461023a57600080fd5b8063372f554f146100a357806337ad93f1146100c95780634d20d0f8146101285780635ce3d8331461016757806360b3a03314610187575b600080fd5b6100b66100b1366004615263565b61024d565b6040519081526020015b60405180910390f35b6100dc6100d73660046152b4565b610369565b6040516100c09190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c0565b61017a610175366004615319565b61079c565b6040516100c091906153d7565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6101c16101bc3660046155d7565b610bfa565b005b6101d66101d13660046156c5565b610d7c565b6040516100c09190615765565b6102136101f136600461580e565b600160209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff90911681526020016100c0565b6100dc6102353660046152b4565b61113c565b6100b6610248366004615263565b611496565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f7729d438686858761028d8b8b8a61168e565b516001600160a01b038c81169116146102c4576102bf600173fffd8963efd1fc6a506488495d951d5263988d2661585d565b6102d4565b6102d46401000276a36001615884565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561033c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036091906158a4565b95945050505050565b6103a26040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006103af8888886116f9565b6060830181905212156103d5576040516342a7200160e11b815260040160405180910390fd5b60006103e2888888611c27565b90508160600151851161042357848260600181815161040191906158bd565b915081815250506104198888888560600151876123df565b608083015261047a565b8085116104615761043485826158dd565b6060830181905260001261045057670de0b6b3a7640000610419565b6104198888888560600151876123df565b6040516342a7200160e11b815260040160405180910390fd5b8160800151841161048b5783610491565b81608001515b8083526000906104c6908a908a906104c1906104b690670de0b6b3a7640000906158dd565b606088015190612bd2565b612bf0565b6104d089896130a1565b6104da91906158dd565b905060006105ac8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054391906158fb565b8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a591906158fb565b600061168e565b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528190205462ffffff16908201529050816105f08a8a6130a1565b6105fa91906158dd565b60208501526001600160a01b03808a16908b16036106af5760405163ce96cb7760e01b81526001600160a01b038981166004830152839189918d169063ce96cb7790602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068091906158a4565b61068a91906158dd565b61069491906158dd565b60408501525050670de0b6b3a764000060a083015250610792565b6106bf8a8a848460400151611496565b60405163ce96cb7760e01b81526001600160a01b038a811660048301528991908d169063ce96cb7790602401602060405180830381865afa158015610708573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072c91906158a4565b61073691906158dd565b61074091906158dd565b604085015260006107528a8c85612bf0565b1161076557670de0b6b3a7640000610789565b6107896107738a8c85612bf0565b6107838c8c868660400151611496565b90613186565b60a08501525050505b9695505050505050565b6107c76040518060800160405280600081526020016000815260200160008152602001606081525090565b6000806107df8a8a8a8a670de0b6b3a764000061319b565b509150915060008213610805576040516342a7200160e11b815260040160405180910390fd5b60008187101561093d57600061082561081e89856158dd565b8590612bd2565b90506109358b6001600160a01b03168d6001600160a01b03161461084a57600061084c565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561088a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ae91906158a4565b6108b891906158dd565b6108c38e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092591906158a4565b61092f91906158dd565b90613270565b915050610a5a565b600061094c61081e848a6158dd565b9050610a568b6001600160a01b03168d6001600160a01b031614610971576000610973565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d591906158a4565b6109df919061591f565b6109ea8e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4c91906158a4565b61092f919061591f565b9150505b610b45610a6f670de0b6b3a7640000896158dd565b8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad191906158fb565b6001600160a01b03166384a87466846040518263ffffffff1660e01b8152600401610afe91815260200190565b602060405180830381865afa158015610b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3f91906158a4565b90612bd2565b6020850152610b548688612bd2565b6040850152610b638588612bd2565b8452610be6610b718c613285565b8b6001600160a01b03168d6001600160a01b031614610b9857610b938c613285565b610bcb565b6040805160008082526020820190925290610bc9565b610bb6615022565b815260200190600190039081610bae5790505b505b8c6001600160a01b03168e6001600160a01b0316148a6143b9565b606085015250919998505050505050505050565b600054610100900460ff1615808015610c1a5750600054600160ff909116105b80610c345750303b158015610c34575060005460ff166001145b610c3d57600080fd5b6000805460ff191660011790558015610c60576000805461ff0019166101001790555b8151835114610c7157610c71615932565b60005b8351811015610d30576000610cdd858381518110610c9457610c94615948565b602002602001015160000151868481518110610cb257610cb2615948565b602002602001015160200151868581518110610cd057610cd0615948565b602002602001015161168e565b60408181015182516001600160a01b039081166000908152600160208181528583209681015190931682529490915291909120805462ffffff191662ffffff909216919091179055919091019050610c74565b508015610d77576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b610d8461505a565b604051632f2e037160e11b81526001600160a01b03848116600483015260009190861690635e5c06e290602401606060405180830381865afa158015610dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df2919061595e565b60405163ce96cb7760e01b81526001600160a01b03888116600483015291945060009350908916915063ce96cb7790602401602060405180830381865afa158015610e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6591906158a4565b90506000610e7588888888614718565b90506000610e848989896116f9565b90506000610ec98a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b80516001600160a01b03908116600090815260016020908152604080832082860151851684529091528082205462ffffff16908401529192508b8116908b161461100d57610f987f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635b5491826040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9291906158fb565b83614acf565b6001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015610fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff991906159bf565b50506001600160a01b039094169450505050505b60405180610140016040528060008513611028576000611032565b6110328786613186565b81526020018b6001600160a01b03166347dffde0896040518263ffffffff1660e01b815260040161106591815260200190565b602060405180830381865afa158015611082573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a691906158a4565b81526020018681526020018481526020016110d48d8d8d600089136110cc5760006110ce565b885b8e6123df565b8152602001858710156110f0576110eb87876158dd565b6110f3565b60005b815260200160008513611107576000611112565b6111128d8d8d611c27565b815260200183815260200182815260200161112b614bbb565b90529b9a5050505050505050505050565b6111756040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000611184888888888761319b565b608085015260608401919091529050808410806111a45750816080015184115b6111ae57836111b0565b805b826000018181525050600061125e896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122091906158fb565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528181205462ffffff1691830191909152606085015191925012611338576112af88886130a1565b602084015260405163ce96cb7760e01b81526001600160a01b0388811660048301528791908b169063ce96cb7790602401602060405180830381865afa1580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132191906158a4565b61132b919061591f565b6040840152506107929050565b8251606084015161134891614faa565b60408401526001600160a01b03808916908a160361139e5782516113849061137990670de0b6b3a7640000906158dd565b606085015190612bd2565b60208401525050670de0b6b3a764000060a0820152610792565b60405163ce96cb7760e01b81526001600160a01b03888116600483015260009188918c169063ce96cb7790602401602060405180830381865afa1580156113e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140d91906158a4565b856040015161141c91906158dd565b61142691906158dd565b9050611438898b838560400151611496565b6114428a8a6130a1565b61144c919061591f565b6020850152801580159061146a575060006114688b8b84612bf0565b115b61147c57670de0b6b3a7640000610789565b61078961148a8b8b84612bf0565b6107838b8d8587604001515b600080856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fb91906158fb565b90506000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561153d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156191906158fb565b905060008511611572576000611683565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166330d07f21838387896115b088888c61168e565b516001600160a01b038981169116146115e7576115e2600173fffd8963efd1fc6a506488495d951d5263988d2661585d565b6115f7565b6115f76401000276a36001615884565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561165f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168391906158a4565b979650505050505050565b6040805160608101825260008082526020820181905291810191909152826001600160a01b0316846001600160a01b031611156116c9579192915b50604080516060810182526001600160a01b03948516815292909316602083015262ffffff169181019190915290565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156117c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ea9190615a51565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611850573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187491906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156118bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e09190615a51565b945050505050611bb3866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194b9190615ac8565b61195690600a615bc7565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119d891906158fb565b604051631710760b60e31b81526001600160a01b038681166004830152919091169063b883b05890602401602060405180830381865afa158015611a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4491906158a4565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac991906158fb565b604051631710760b60e31b81526001600160a01b038781166004830152919091169063b883b05890602401602060405180830381865afa158015611b11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3591906158a4565b896001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b979190615ac8565b611ba290600a615bc7565b611bac8b8b6130a1565b9190614fbf565b60405163ce96cb7760e01b81526001600160a01b03868116600483015288169063ce96cb7790602401602060405180830381865afa158015611bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1d91906158a4565b61079291906158bd565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cac91906158fb565b9050611d1d604051806101600160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b60405160016263e28d60e11b031981526001600160a01b03858116600483015283169063ff383ae690602401602060405180830381865afa158015611d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8a91906158a4565b60c082015260006101208201525b60c08101511561222a5760c08101516001161561220b576040805160a081018252600080825260208083018290528284018290526060808401839052608084018390528451908101855282815290810182905292830152906101208301516040516308cae55b60e21b815260048101919091526001600160a01b0385169063232b956c90602401602060405180830381865afa158015611e3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6091906158fb565b6001600160a01b039081166101408501819052604051638e8f294b60e01b8152600481019190915290851690638e8f294b9060240160a060405180830381865afa158015611eb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed69190615a51565b6001600160a01b03908116608088015260ff93909316602087015250506001600160801b0391909116835261014084015160405163014a296f60e01b8152888316600482015291169063014a296f906024016040805180830381865afa158015611f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f689190615bd6565b602083015281526080820151604051631710760b60e31b81526001600160a01b0391821660048201529085169063b883b05890602401602060405180830381865afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fdf91906158a4565b6040820181905282516020840151612015926001600160801b0390921691610b3f9161200c90600a615bc7565b85519190614fbf565b83606001818151612026919061591f565b90525081516040820151602084015161205e926001600160801b03169161092f9161205290600a615bc7565b60208601519190614fde565b8351849061206d90839061591f565b905250600061207c88886130a1565b9050876001600160a01b03168461014001516001600160a01b0316036120d4576120ce83600001516001600160801b031661092f84604001518660200151600a6120c69190615bc7565b859190614fde565b60208501525b886001600160a01b03168461014001516001600160a01b0316036122075761215683600001516001600160801b0316610b3f84604001518660200151600a61211c9190615bc7565b60008611801561213e57508d6001600160a01b03168d6001600160a01b031614155b6121485785611bac565b611bac8e8e886101f4611496565b608085018190528351604084015160208601516121f7926001600160801b031691610b3f9161218690600a615bc7565b6101408a015160405163ce96cb7760e01b81526001600160a01b038f811660048301529091169063ce96cb7790602401602060405180830381865afa1580156121d3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bac91906158a4565b61220191906158dd565b60408501525b5050505b61012081018051600190810190915260c08201805190911c9052611d98565b604051638e8f294b60e01b81526001600160a01b038781166004830152831690638e8f294b9060240160a060405180830381865afa158015612270573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122949190615a51565b6001600160a01b0390811660a08701526001600160801b0390941660e086018190526040805163313ce56760e01b81529051610792969295506107839450918c16925063313ce5679160048083019260209291908290030181865afa158015612301573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123259190615ac8565b61233090600a615bc7565b60a0850151604051631710760b60e31b81526001600160a01b0391821660048201529087169063b883b05890602401602060405180830381865afa15801561237c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a091906158a4565b611bac86608001518760000151886020015189606001516123c1919061591f565b6123cb91906158dd565b6123d591906158dd565b876040015161500c565b600061240560405180606001604052806000815260200160008152602001600081525090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612465573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248991906158fb565b60405160016263e28d60e11b031981526001600160a01b03888116600483015291925060009183169063ff383ae690602401602060405180830381865afa1580156124d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fc91906158a4565b905060005b8115612894576001821615612888576040516308cae55b60e21b8152600481018290526000906001600160a01b0385169063232b956c90602401602060405180830381865afa158015612558573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257c91906158fb565b90506125af6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6125d360405180606001604052806000815260200160008152602001600081525090565b604051638e8f294b60e01b81526001600160a01b038481166004830152871690638e8f294b9060240160a060405180830381865afa158015612619573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263d9190615a51565b6001600160a01b039081166080880181905260ff9490941660208801526001600160801b039490941686525050604051631710760b60e31b815260048101919091529087169063b883b05890602401602060405180830381865afa1580156126a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126cd91906158a4565b6040828101919091525163014a296f60e01b81526001600160a01b038c8116600483015284169063014a296f906024016040805180830381865afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273d9190615bd6565b6020830152506001600160a01b03808d169084160361284857604051632f2e037160e11b81526001600160a01b038c8116600483015260009190851690635e5c06e290602401606060405180830381865afa1580156127a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c4919061595e565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561280e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061283291906158a4565b8260200181815161284391906158dd565b905250505b61287282600001516001600160801b031661092f83604001518560200151600a6120529190615bc7565b8751889061288190839061591f565b9052505050505b600191821c9101612501565b50604051638e8f294b60e01b81526001600160a01b038a81166004830152831690638e8f294b9060240160a060405180830381865afa1580156128db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ff9190615a51565b505050506001600160801b03166020840152604051638e8f294b60e01b81526001600160a01b038981166004830152831690638e8f294b9060240160a060405180830381865afa158015612957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297b9190615a51565b505050506001600160801b031660408481019190915251638e8f294b60e01b81526001600160a01b038a8116600483015260009190841690638e8f294b9060240160a060405180830381865afa1580156129d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fd9190615a51565b945050505050612aed8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a689190615ac8565b612a7390600a615bc7565b604051631710760b60e31b81526001600160a01b03848116600483015286169063b883b05890602401602060405180830381865afa158015612ab9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612add91906158a4565b60408701518751611bac91612bd2565b8452861580612afc5750835187105b80612b495750670de0b6b3a7640000612b47612b31886107838860400151610b3f8a602001518e612bd290919063ffffffff16565b612b3b908a6158dd565b8651610783908b6158dd565b105b15612b8857612b7d612b6c85604001518660200151612bd290919063ffffffff16565b612b7690886158dd565b8790613186565b945050505050610360565b612bc4612bae876107838760400151610b3f89602001518d612bd290919063ffffffff16565b612bb890896158dd565b8551610783908a6158dd565b9a9950505050505050505050565b6000612be78383670de0b6b3a7640000614fbf565b90505b92915050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7591906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce19190615a51565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6b91906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612db3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd79190615a51565b945050505050610792856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e429190615ac8565b612e4d90600a615bc7565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ecf91906158fb565b604051631710760b60e31b81526001600160a01b038581166004830152919091169063b883b05890602401602060405180830381865afa158015612f17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3b91906158a4565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc091906158fb565b604051631710760b60e31b81526001600160a01b038881166004830152919091169063b883b05890602401602060405180830381865afa158015613008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061302c91906158a4565b8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561306a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308e9190615ac8565b61309990600a615bc7565b899190614fbf565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa1580156130ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613110919061595e565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561315a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317e91906158a4565b949350505050565b6000612be783670de0b6b3a764000084614fbf565b6000806000846131ac8989896116f9565b6131b69190615bfa565b925060008313156132545760405163ce96cb7760e01b81526001600160a01b03878116600483015261323e9185918891908c169063ce96cb7790602401602060405180830381865afa158015613210573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061323491906158a4565b61092f9190615bfa565b915061324d88888886886123df565b9050613265565b6132628888886000886123df565b90505b955095509592505050565b6000612be783670de0b6b3a764000084614fde565b606061328f6150ce565b826001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132f191906158fb565b6001600160a01b0316808252156143b357826001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336491906158fb565b604051638e8f294b60e01b81526001600160a01b0385811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156133ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d09190615a51565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015613444573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261346c9190810190615c22565b6101408201819052516001600160401b0381111561348c5761348c6154b1565b6040519080825280602002602001820160405280156134c557816020015b6134b2615022565b8152602001906001900390816134aa5790505b5060006101a083018190529092505b81610140015151826101a0015110156136195781600001516001600160a01b0316635684aa4685846101400151856101a001518151811061351757613517615948565b60200260200101516040518363ffffffff1660e01b81526004016135519291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa15801561356e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135929190615cc4565b505063ffffffff166101c083018190521561360257816101400151826101a00151815181106135c3576135c3615948565b60200260200101518382806135d790615d07565b9350815181106135e9576135e9615948565b60209081029190910101516001600160a01b0390911690525b816101a001805161361290615d07565b90526134d4565b82816001600160401b03811115613632576136326154b1565b60405190808252806020026020018201604052801561366b57816020015b613658615022565b8152602001906001900390816136505790505b5060006101a085015293505b8351836101a0015110156136dd5780836101a001518151811061369c5761369c615948565b602002602001015184846101a00151815181106136bb576136bb615948565b6020026020010181905250826101a00180516136d690615d07565b9052613677565b505060006101a08201525b8151816101a0015110156143b35780600001516001600160a01b031663f2426f9a8484846101a001518151811061372157613721615948565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016101c060405180830381865afa158015613779573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379d9190615d49565b81610120018190525080600001516001600160a01b03166344e250f88484846101a00151815181106137d1576137d1615948565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401606060405180830381865afa158015613828573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061384c919061595e565b506040830152606082015280516101a082015183516001600160a01b039092169163fc196068918691869190811061388657613886615948565b6020026020010151600001518461012001516060015163ffffffff1642116138af5760006138b6565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613908573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061392c919061595e565b50608083015260a08201526101c08101516224ea009061394d908290615e53565b826101c0015161395d91906158dd565b613967919061591f565b81610240018181525050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156139af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139d39190615ac8565b6139e39060ff166224ea00615e67565b6139f06224ea0042615e53565b6139fa90426158dd565b613a04919061591f565b61022082018190526102408201516224ea0091613a2191906158dd565b613a2b9190615e7e565b613a3690600161591f565b6001600160401b03811115613a4d57613a4d6154b1565b604051908082528060200260200182016040528015613a76578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e0015111613b7e576101e0810151604051630156d37d60e31b81526000916001600160a01b03861691630ab69be891613ad99160040190815260200190565b6040805180830381865afa158015613af5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b199190615bd6565b509050808261020001818151613b2f919061591f565b9052506101e082015160e08301516101c084015181518110613b5357613b53615948565b6020908102919091010152506101e0810180516224ea000190526101c0810180516001019052613a91565b6040518060a0016040528083836101a0015181518110613ba057613ba0615948565b6020026020010151600001516001600160a01b0316815260200183836101a0015181518110613bd157613bd1615948565b6020026020010151600001516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015613c1a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613c429190810190615e92565b815260200183836101a0015181518110613c5e57613c5e615948565b6020026020010151600001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015613ca7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613ccf9190810190615e92565b81526020016000836102000151866001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d3e91906158a4565b613d48919061591f565b11613d54576000614087565b6140876301e13380846101800151611bac8660c00151613eb18a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dcf91906158fb565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e3f91906158a4565b8961020001518c6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ea791906158a4565b610b3f919061591f565b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ef2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f1691906158fb565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f8b91906158a4565b610b3f8d6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b8152600401613fc191815260200190565b602060405180830381865afa158015613fde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061400291906158a4565b8e6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015614040573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061406491906158a4565b61406e919061591f565b8c60c001518d606001518e60a00151611bac91906158dd565b81526020016000856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140f091906158a4565b116140fc57600061437d565b61437d6301e13380846101800151611bac8660c001516142258a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614153573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061417791906158fb565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa1580156141c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141e791906158a4565b8b6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1b573d6000803e3d6000fd5b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061428a91906158fb565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa1580156142db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142ff91906158a4565b610b3f8d6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061436491906158a4565b8c60c001518d604001518e60800151611bac91906158dd565b81525082826101a001518151811061439757614397615948565b60209081029190910101526101a08101805160010190526136e8565b50919050565b6060835185516143c9919061591f565b6001600160401b038111156143e0576143e06154b1565b60405190808252806020026020018201604052801561441957816020015b614406615022565b8152602001906001900390816143fe5790505b50905060005b85518110156145b4576144588387838151811061443e5761443e615948565b602002602001015160800151612bd290919063ffffffff16565b82828151811061446a5761446a615948565b6020026020010151608001818152505083156144e4576144c1614495670de0b6b3a7640000856158dd565b8783815181106144a7576144a7615948565b602002602001015160600151612bd290919063ffffffff16565b8282815181106144d3576144d3615948565b602002602001015160600181815250505b8581815181106144f6576144f6615948565b60200260200101516000015182828151811061451457614514615948565b60209081029190910101516001600160a01b039091169052855186908290811061454057614540615948565b60200260200101516020015182828151811061455e5761455e615948565b60200260200101516020018190525085818151811061457f5761457f615948565b60200260200101516040015182828151811061459d5761459d615948565b60209081029190910101516040015260010161441f565b8361470f575060005b845181101561470f576145ed6145db670de0b6b3a7640000856158dd565b8683815181106144a7576144a7615948565b828751836145fb919061591f565b8151811061460b5761460b615948565b6020026020010151606001818152505084818151811061462d5761462d615948565b60200260200101516000015182875183614647919061591f565b8151811061465757614657615948565b60209081029190910101516001600160a01b039091169052845185908290811061468357614683615948565b6020026020010151602001518287518361469d919061591f565b815181106146ad576146ad615948565b6020026020010151602001819052508481815181106146ce576146ce615948565b602002602001015160400151828751836146e8919061591f565b815181106146f8576146f8615948565b6020908102919091010151604001526001016145bd565b50949350505050565b604080516080810182526000808252602082018190529181018290526060810182905260007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561479b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147bf91906158fb565b604051638e8f294b60e01b81526001600160a01b03898116600483015291925090821690638e8f294b9060240160a060405180830381865afa158015614809573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482d9190615a51565b6001600160a01b039081166040888101919091526001600160801b039590951687529351638e8f294b60e01b81528a8516600482015293851693638e8f294b9350602401915061487a9050565b60a060405180830381865afa158015614897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148bb9190615a51565b6001600160a01b0390811660608801526001600160801b039094166020808801919091526040805163313ce56760e01b81529051611683968e16955063313ce56794506004808301945090918290030181865afa158015614920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149449190615ac8565b61494f90600a615bc7565b6040848101519051631710760b60e31b81526001600160a01b0391821660048201529084169063b883b05890602401602060405180830381865afa15801561499b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149bf91906158a4565b84516020860151614ac8916149d49190612bd2565b6060870151604051631710760b60e31b81526001600160a01b0391821660048201526107839188169063b883b05890602401602060405180830381865afa158015614a23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a4791906158a4565b8c6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614aa99190615ac8565b614ab490600a615bc7565b611bac614ac18f8f6130a1565b8d90612bd2565b9190614fde565b600081602001516001600160a01b031682600001516001600160a01b031610614afa57614afa615932565b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6bffffffffffffffffffffffff191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4191906158fb565b6001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015614c7e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052614ca69190810190615f1c565b519050806001600160401b03811115614cc157614cc16154b1565b604051908082528060200260200182016040528015614d0657816020015b6040805180820190915260008082526020820152815260200190600190039081614cdf5790505b50915060005b81811015614fa55760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d9891906158fb565b6001600160a01b031663232b956c836040518263ffffffff1660e01b8152600401614dc591815260200190565b602060405180830381865afa158015614de2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e0691906158fb565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614e43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e6791906158fb565b90506040518060400160405280826001600160a01b03168152602001826001600160a01b03166370a082317f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663158274a56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f1491906158fb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015614f58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f7c91906158a4565b815250848381518110614f9157614f91615948565b602090810291909101015250600101614d0c565b505090565b6000612be78383670de0b6b3a7640000614fde565b828202811515841585830485141716614fd757600080fd5b0492915050565b828202811515841585830485141716614ff657600080fd5b6001826001830304018115150290509392505050565b600081831061501b5781612be7565b5090919050565b6040518060a0016040528060006001600160a01b03168152602001606081526020016060815260200160008152602001600081525090565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016150ba604080516060810182526000808252602082018190529181019190915290565b815260200160008152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b031681526020016151ee604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038116811461524857600080fd5b50565b803562ffffff8116811461525e57600080fd5b919050565b6000806000806080858703121561527957600080fd5b843561528481615233565b9350602085013561529481615233565b9250604085013591506152a96060860161524b565b905092959194509250565b60008060008060008060c087890312156152cd57600080fd5b86356152d881615233565b955060208701356152e881615233565b945060408701356152f881615233565b959894975094956060810135955060808101359460a0909101359350915050565b600080600080600080600060e0888a03121561533457600080fd5b873561533f81615233565b9650602088013561534f81615233565b9550604088013561535f81615233565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b60005b838110156153a257818101518382015260200161538a565b50506000910152565b600081518084526153c3816020860160208601615387565b601f01601f19169290920160200192915050565b6000602080835260a0808401855183860152828601516040818188015280880151915060608281890152808901519250608080818a015284845180875260c08b01915060c08160051b8c01019650888601955060005b818110156154a0578b880360bf19018352865180516001600160a01b031689528a8101518b8a018b90526154638b8b01826153ab565b9050878201518a8203898c015261547a82826153ab565b838901518c8a0152928701519a87019a909a52509750958901959189019160010161542d565b50959b9a5050505050505050505050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156154e9576154e96154b1565b60405290565b6040516101c081016001600160401b03811182821017156154e9576154e96154b1565b604051601f8201601f191681016001600160401b038111828210171561553a5761553a6154b1565b604052919050565b60006001600160401b0382111561555b5761555b6154b1565b5060051b60200190565b600082601f83011261557657600080fd5b8135602061558b61558683615542565b615512565b82815260059290921b840181019181810190868411156155aa57600080fd5b8286015b848110156155cc576155bf8161524b565b83529183019183016155ae565b509695505050505050565b60008060408084860312156155eb57600080fd5b83356001600160401b038082111561560257600080fd5b818601915086601f83011261561657600080fd5b8135602061562661558683615542565b82815260069290921b8401810191818101908a84111561564557600080fd5b948201945b838610156156975786868c0312156156625760008081fd5b61566a6154c7565b863561567581615233565b81528684013561568481615233565b818501528252948601949082019061564a565b975050870135935050808311156156ad57600080fd5b50506156bb85828601615565565b9150509250929050565b600080600080608085870312156156db57600080fd5b84356156e681615233565b935060208501356156f681615233565b9250604085013561570681615233565b9396929550929360600135925050565b600081518084526020808501945080840160005b8381101561575a57815180516001600160a01b03168852830151838801526040909601959082019060010161572a565b509495945050505050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e0820152600060e08301516101006157e98185018380516001600160a01b0390811683526020808301519091169083015260409081015162ffffff16910152565b840151610160840152506101208301516101808084015261317e6101a0840182615716565b6000806040838503121561582157600080fd5b823561582c81615233565b9150602083013561583c81615233565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0382811682821603908082111561587d5761587d615847565b5092915050565b6001600160a01b0381811683821601908082111561587d5761587d615847565b6000602082840312156158b657600080fd5b5051919050565b818103600083128015838313168383128216171561587d5761587d615847565b81810381811115612bea57612bea615847565b805161525e81615233565b60006020828403121561590d57600080fd5b815161591881615233565b9392505050565b80820180821115612bea57612bea615847565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008060006060848603121561597357600080fd5b8351925060208401519150604084015190509250925092565b805161ffff8116811461525e57600080fd5b805160ff8116811461525e57600080fd5b8051801515811461525e57600080fd5b600080600080600080600060e0888a0312156159da57600080fd5b87516159e581615233565b8097505060208801518060020b81146159fd57600080fd5b9550615a0b6040890161598c565b9450615a196060890161598c565b9350615a276080890161598c565b9250615a3560a0890161599e565b9150615a4360c089016159af565b905092959891949750929550565b600080600080600060a08688031215615a6957600080fd5b85516001600160801b0381168114615a8057600080fd5b9450615a8e6020870161599e565b9350615a9c6040870161599e565b9250615aaa606087016159af565b91506080860151615aba81615233565b809150509295509295909350565b600060208284031215615ada57600080fd5b612be78261599e565b600181815b80851115615b1e578160001904821115615b0457615b04615847565b80851615615b1157918102915b93841c9390800290615ae8565b509250929050565b600082615b3557506001612bea565b81615b4257506000612bea565b8160018114615b585760028114615b6257615b7e565b6001915050612bea565b60ff841115615b7357615b73615847565b50506001821b612bea565b5060208310610133831016604e8410600b8410161715615ba1575081810a612bea565b615bab8383615ae3565b8060001904821115615bbf57615bbf615847565b029392505050565b6000612be760ff841683615b26565b60008060408385031215615be957600080fd5b505080516020909101519092909150565b8082018281126000831280158216821582161715615c1a57615c1a615847565b505092915050565b60006020808385031215615c3557600080fd5b82516001600160401b03811115615c4b57600080fd5b8301601f81018513615c5c57600080fd5b8051615c6a61558682615542565b81815260059190911b82018301908381019087831115615c8957600080fd5b928401925b82841015611683578351615ca181615233565b82529284019290840190615c8e565b805163ffffffff8116811461525e57600080fd5b600080600060608486031215615cd957600080fd5b615ce284615cb0565b9250615cf060208501615cb0565b9150615cfe60408501615cb0565b90509250925092565b600060018201615d1957615d19615847565b5060010190565b8051600f81900b811461525e57600080fd5b80516001600160401b038116811461525e57600080fd5b60006101c08284031215615d5c57600080fd5b615d646154ef565b615d6d836158f0565b8152615d7b602084016158f0565b6020820152615d8c604084016158f0565b6040820152615d9d60608401615cb0565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615dd8818501615d20565b90820152610120615dea848201615d32565b90820152610140615dfc848201615d32565b90820152610160615e0e848201615d32565b90820152610180615e20848201615d32565b908201526101a0615e32848201615d32565b908201529392505050565b634e487b7160e01b600052601260045260246000fd5b600082615e6257615e62615e3d565b500690565b8082028115828204841417612bea57612bea615847565b600082615e8d57615e8d615e3d565b500490565b600060208284031215615ea457600080fd5b81516001600160401b0380821115615ebb57600080fd5b818401915084601f830112615ecf57600080fd5b815181811115615ee157615ee16154b1565b615ef4601f8201601f1916602001615512565b9150808252856020828501011115615f0b57600080fd5b61470f816020840160208601615387565b60006020808385031215615f2f57600080fd5b82516001600160401b03811115615f4557600080fd5b8301601f81018513615f5657600080fd5b8051615f6461558682615542565b81815260059190911b82018301908381019087831115615f8357600080fd5b928401925b82841015611683578351615f9b81615233565b82529284019290840190615f8856fea26469706673582212207f788112a3f9d9e88d0ff809d0ded9dcfeceac00215af7a435358746ade369b464736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80639241c920116100665780639241c920146101ae578063926da1b4146101c3578063a9563e4f146101e3578063ecd0cca014610227578063fcc5815b1461023a57600080fd5b8063372f554f146100a357806337ad93f1146100c95780634d20d0f8146101285780635ce3d8331461016757806360b3a03314610187575b600080fd5b6100b66100b1366004615263565b61024d565b6040519081526020015b60405180910390f35b6100dc6100d73660046152b4565b610369565b6040516100c09190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c0565b61017a610175366004615319565b61079c565b6040516100c091906153d7565b61014f7f000000000000000000000000000000000000000000000000000000000000000081565b6101c16101bc3660046155d7565b610bfa565b005b6101d66101d13660046156c5565b610d7c565b6040516100c09190615765565b6102136101f136600461580e565b600160209081526000928352604080842090915290825290205462ffffff1681565b60405162ffffff90911681526020016100c0565b6100dc6102353660046152b4565b61113c565b6100b6610248366004615263565b611496565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f7729d438686858761028d8b8b8a61168e565b516001600160a01b038c81169116146102c4576102bf600173fffd8963efd1fc6a506488495d951d5263988d2661585d565b6102d4565b6102d46401000276a36001615884565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561033c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036091906158a4565b95945050505050565b6103a26040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006103af8888886116f9565b6060830181905212156103d5576040516342a7200160e11b815260040160405180910390fd5b60006103e2888888611c27565b90508160600151851161042357848260600181815161040191906158bd565b915081815250506104198888888560600151876123df565b608083015261047a565b8085116104615761043485826158dd565b6060830181905260001261045057670de0b6b3a7640000610419565b6104198888888560600151876123df565b6040516342a7200160e11b815260040160405180910390fd5b8160800151841161048b5783610491565b81608001515b8083526000906104c6908a908a906104c1906104b690670de0b6b3a7640000906158dd565b606088015190612bd2565b612bf0565b6104d089896130a1565b6104da91906158dd565b905060006105ac8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054391906158fb565b8a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a591906158fb565b600061168e565b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528190205462ffffff16908201529050816105f08a8a6130a1565b6105fa91906158dd565b60208501526001600160a01b03808a16908b16036106af5760405163ce96cb7760e01b81526001600160a01b038981166004830152839189918d169063ce96cb7790602401602060405180830381865afa15801561065c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068091906158a4565b61068a91906158dd565b61069491906158dd565b60408501525050670de0b6b3a764000060a083015250610792565b6106bf8a8a848460400151611496565b60405163ce96cb7760e01b81526001600160a01b038a811660048301528991908d169063ce96cb7790602401602060405180830381865afa158015610708573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072c91906158a4565b61073691906158dd565b61074091906158dd565b604085015260006107528a8c85612bf0565b1161076557670de0b6b3a7640000610789565b6107896107738a8c85612bf0565b6107838c8c868660400151611496565b90613186565b60a08501525050505b9695505050505050565b6107c76040518060800160405280600081526020016000815260200160008152602001606081525090565b6000806107df8a8a8a8a670de0b6b3a764000061319b565b509150915060008213610805576040516342a7200160e11b815260040160405180910390fd5b60008187101561093d57600061082561081e89856158dd565b8590612bd2565b90506109358b6001600160a01b03168d6001600160a01b03161461084a57600061084c565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561088a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ae91906158a4565b6108b891906158dd565b6108c38e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092591906158a4565b61092f91906158dd565b90613270565b915050610a5a565b600061094c61081e848a6158dd565b9050610a568b6001600160a01b03168d6001600160a01b031614610971576000610973565b815b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d591906158a4565b6109df919061591f565b6109ea8e8e85612bf0565b8d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4c91906158a4565b61092f919061591f565b9150505b610b45610a6f670de0b6b3a7640000896158dd565b8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad191906158fb565b6001600160a01b03166384a87466846040518263ffffffff1660e01b8152600401610afe91815260200190565b602060405180830381865afa158015610b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3f91906158a4565b90612bd2565b6020850152610b548688612bd2565b6040850152610b638588612bd2565b8452610be6610b718c613285565b8b6001600160a01b03168d6001600160a01b031614610b9857610b938c613285565b610bcb565b6040805160008082526020820190925290610bc9565b610bb6615022565b815260200190600190039081610bae5790505b505b8c6001600160a01b03168e6001600160a01b0316148a6143b9565b606085015250919998505050505050505050565b600054610100900460ff1615808015610c1a5750600054600160ff909116105b80610c345750303b158015610c34575060005460ff166001145b610c3d57600080fd5b6000805460ff191660011790558015610c60576000805461ff0019166101001790555b8151835114610c7157610c71615932565b60005b8351811015610d30576000610cdd858381518110610c9457610c94615948565b602002602001015160000151868481518110610cb257610cb2615948565b602002602001015160200151868581518110610cd057610cd0615948565b602002602001015161168e565b60408181015182516001600160a01b039081166000908152600160208181528583209681015190931682529490915291909120805462ffffff191662ffffff909216919091179055919091019050610c74565b508015610d77576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b610d8461505a565b604051632f2e037160e11b81526001600160a01b03848116600483015260009190861690635e5c06e290602401606060405180830381865afa158015610dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df2919061595e565b60405163ce96cb7760e01b81526001600160a01b03888116600483015291945060009350908916915063ce96cb7790602401602060405180830381865afa158015610e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6591906158a4565b90506000610e7588888888614718565b90506000610e848989896116f9565b90506000610ec98a6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051f573d6000803e3d6000fd5b80516001600160a01b03908116600090815260016020908152604080832082860151851684529091528082205462ffffff16908401529192508b8116908b161461100d57610f987f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635b5491826040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9291906158fb565b83614acf565b6001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015610fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff991906159bf565b50506001600160a01b039094169450505050505b60405180610140016040528060008513611028576000611032565b6110328786613186565b81526020018b6001600160a01b03166347dffde0896040518263ffffffff1660e01b815260040161106591815260200190565b602060405180830381865afa158015611082573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a691906158a4565b81526020018681526020018481526020016110d48d8d8d600089136110cc5760006110ce565b885b8e6123df565b8152602001858710156110f0576110eb87876158dd565b6110f3565b60005b815260200160008513611107576000611112565b6111128d8d8d611c27565b815260200183815260200182815260200161112b614bbb565b90529b9a5050505050505050505050565b6111756040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000611184888888888761319b565b608085015260608401919091529050808410806111a45750816080015184115b6111ae57836111b0565b805b826000018181525050600061125e896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122091906158fb565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610581573d6000803e3d6000fd5b80516001600160a01b0390811660009081526001602090815260408083208286015190941683529290528181205462ffffff1691830191909152606085015191925012611338576112af88886130a1565b602084015260405163ce96cb7760e01b81526001600160a01b0388811660048301528791908b169063ce96cb7790602401602060405180830381865afa1580156112fd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132191906158a4565b61132b919061591f565b6040840152506107929050565b8251606084015161134891614faa565b60408401526001600160a01b03808916908a160361139e5782516113849061137990670de0b6b3a7640000906158dd565b606085015190612bd2565b60208401525050670de0b6b3a764000060a0820152610792565b60405163ce96cb7760e01b81526001600160a01b03888116600483015260009188918c169063ce96cb7790602401602060405180830381865afa1580156113e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140d91906158a4565b856040015161141c91906158dd565b61142691906158dd565b9050611438898b838560400151611496565b6114428a8a6130a1565b61144c919061591f565b6020850152801580159061146a575060006114688b8b84612bf0565b115b61147c57670de0b6b3a7640000610789565b61078961148a8b8b84612bf0565b6107838b8d8587604001515b600080856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fb91906158fb565b90506000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561153d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156191906158fb565b905060008511611572576000611683565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166330d07f21838387896115b088888c61168e565b516001600160a01b038981169116146115e7576115e2600173fffd8963efd1fc6a506488495d951d5263988d2661585d565b6115f7565b6115f76401000276a36001615884565b6040516001600160e01b031960e088901b1681526001600160a01b039586166004820152938516602485015262ffffff9092166044840152606483015291909116608482015260a4016020604051808303816000875af115801561165f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168391906158a4565b979650505050505050565b6040805160608101825260008082526020820181905291810191909152826001600160a01b0316846001600160a01b031611156116c9579192915b50604080516060810182526001600160a01b03948516815292909316602083015262ffffff169181019190915290565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177e91906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156117c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ea9190615a51565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611850573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187491906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156118bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e09190615a51565b945050505050611bb3866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061194b9190615ac8565b61195690600a615bc7565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119d891906158fb565b604051631710760b60e31b81526001600160a01b038681166004830152919091169063b883b05890602401602060405180830381865afa158015611a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4491906158a4565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aa5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac991906158fb565b604051631710760b60e31b81526001600160a01b038781166004830152919091169063b883b05890602401602060405180830381865afa158015611b11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b3591906158a4565b896001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b979190615ac8565b611ba290600a615bc7565b611bac8b8b6130a1565b9190614fbf565b60405163ce96cb7760e01b81526001600160a01b03868116600483015288169063ce96cb7790602401602060405180830381865afa158015611bf9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1d91906158a4565b61079291906158bd565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cac91906158fb565b9050611d1d604051806101600160405280600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160006001600160a01b031681525090565b60405160016263e28d60e11b031981526001600160a01b03858116600483015283169063ff383ae690602401602060405180830381865afa158015611d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8a91906158a4565b60c082015260006101208201525b60c08101511561222a5760c08101516001161561220b576040805160a081018252600080825260208083018290528284018290526060808401839052608084018390528451908101855282815290810182905292830152906101208301516040516308cae55b60e21b815260048101919091526001600160a01b0385169063232b956c90602401602060405180830381865afa158015611e3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6091906158fb565b6001600160a01b039081166101408501819052604051638e8f294b60e01b8152600481019190915290851690638e8f294b9060240160a060405180830381865afa158015611eb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ed69190615a51565b6001600160a01b03908116608088015260ff93909316602087015250506001600160801b0391909116835261014084015160405163014a296f60e01b8152888316600482015291169063014a296f906024016040805180830381865afa158015611f44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f689190615bd6565b602083015281526080820151604051631710760b60e31b81526001600160a01b0391821660048201529085169063b883b05890602401602060405180830381865afa158015611fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fdf91906158a4565b6040820181905282516020840151612015926001600160801b0390921691610b3f9161200c90600a615bc7565b85519190614fbf565b83606001818151612026919061591f565b90525081516040820151602084015161205e926001600160801b03169161092f9161205290600a615bc7565b60208601519190614fde565b8351849061206d90839061591f565b905250600061207c88886130a1565b9050876001600160a01b03168461014001516001600160a01b0316036120d4576120ce83600001516001600160801b031661092f84604001518660200151600a6120c69190615bc7565b859190614fde565b60208501525b886001600160a01b03168461014001516001600160a01b0316036122075761215683600001516001600160801b0316610b3f84604001518660200151600a61211c9190615bc7565b60008611801561213e57508d6001600160a01b03168d6001600160a01b031614155b6121485785611bac565b611bac8e8e886101f4611496565b608085018190528351604084015160208601516121f7926001600160801b031691610b3f9161218690600a615bc7565b6101408a015160405163ce96cb7760e01b81526001600160a01b038f811660048301529091169063ce96cb7790602401602060405180830381865afa1580156121d3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bac91906158a4565b61220191906158dd565b60408501525b5050505b61012081018051600190810190915260c08201805190911c9052611d98565b604051638e8f294b60e01b81526001600160a01b038781166004830152831690638e8f294b9060240160a060405180830381865afa158015612270573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122949190615a51565b6001600160a01b0390811660a08701526001600160801b0390941660e086018190526040805163313ce56760e01b81529051610792969295506107839450918c16925063313ce5679160048083019260209291908290030181865afa158015612301573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123259190615ac8565b61233090600a615bc7565b60a0850151604051631710760b60e31b81526001600160a01b0391821660048201529087169063b883b05890602401602060405180830381865afa15801561237c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a091906158a4565b611bac86608001518760000151886020015189606001516123c1919061591f565b6123cb91906158dd565b6123d591906158dd565b876040015161500c565b600061240560405180606001604052806000815260200160008152602001600081525090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612465573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248991906158fb565b60405160016263e28d60e11b031981526001600160a01b03888116600483015291925060009183169063ff383ae690602401602060405180830381865afa1580156124d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fc91906158a4565b905060005b8115612894576001821615612888576040516308cae55b60e21b8152600481018290526000906001600160a01b0385169063232b956c90602401602060405180830381865afa158015612558573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257c91906158fb565b90506125af6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6125d360405180606001604052806000815260200160008152602001600081525090565b604051638e8f294b60e01b81526001600160a01b038481166004830152871690638e8f294b9060240160a060405180830381865afa158015612619573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263d9190615a51565b6001600160a01b039081166080880181905260ff9490941660208801526001600160801b039490941686525050604051631710760b60e31b815260048101919091529087169063b883b05890602401602060405180830381865afa1580156126a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126cd91906158a4565b6040828101919091525163014a296f60e01b81526001600160a01b038c8116600483015284169063014a296f906024016040805180830381865afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061273d9190615bd6565b6020830152506001600160a01b03808d169084160361284857604051632f2e037160e11b81526001600160a01b038c8116600483015260009190851690635e5c06e290602401606060405180830381865afa1580156127a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c4919061595e565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561280e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061283291906158a4565b8260200181815161284391906158dd565b905250505b61287282600001516001600160801b031661092f83604001518560200151600a6120529190615bc7565b8751889061288190839061591f565b9052505050505b600191821c9101612501565b50604051638e8f294b60e01b81526001600160a01b038a81166004830152831690638e8f294b9060240160a060405180830381865afa1580156128db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ff9190615a51565b505050506001600160801b03166020840152604051638e8f294b60e01b81526001600160a01b038981166004830152831690638e8f294b9060240160a060405180830381865afa158015612957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297b9190615a51565b505050506001600160801b031660408481019190915251638e8f294b60e01b81526001600160a01b038a8116600483015260009190841690638e8f294b9060240160a060405180830381865afa1580156129d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129fd9190615a51565b945050505050612aed8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a689190615ac8565b612a7390600a615bc7565b604051631710760b60e31b81526001600160a01b03848116600483015286169063b883b05890602401602060405180830381865afa158015612ab9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612add91906158a4565b60408701518751611bac91612bd2565b8452861580612afc5750835187105b80612b495750670de0b6b3a7640000612b47612b31886107838860400151610b3f8a602001518e612bd290919063ffffffff16565b612b3b908a6158dd565b8651610783908b6158dd565b105b15612b8857612b7d612b6c85604001518660200151612bd290919063ffffffff16565b612b7690886158dd565b8790613186565b945050505050610360565b612bc4612bae876107838760400151610b3f89602001518d612bd290919063ffffffff16565b612bb890896158dd565b8551610783908a6158dd565b9a9950505050505050505050565b6000612be78383670de0b6b3a7640000614fbf565b90505b92915050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7591906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ce19190615a51565b94505050505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6b91906158fb565b604051638e8f294b60e01b81526001600160a01b0387811660048301529190911690638e8f294b9060240160a060405180830381865afa158015612db3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd79190615a51565b945050505050610792856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e429190615ac8565b612e4d90600a615bc7565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ecf91906158fb565b604051631710760b60e31b81526001600160a01b038581166004830152919091169063b883b05890602401602060405180830381865afa158015612f17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3b91906158a4565b611bac7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc091906158fb565b604051631710760b60e31b81526001600160a01b038881166004830152919091169063b883b05890602401602060405180830381865afa158015613008573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061302c91906158a4565b8a6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561306a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308e9190615ac8565b61309990600a615bc7565b899190614fbf565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa1580156130ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613110919061595e565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa15801561315a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061317e91906158a4565b949350505050565b6000612be783670de0b6b3a764000084614fbf565b6000806000846131ac8989896116f9565b6131b69190615bfa565b925060008313156132545760405163ce96cb7760e01b81526001600160a01b03878116600483015261323e9185918891908c169063ce96cb7790602401602060405180830381865afa158015613210573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061323491906158a4565b61092f9190615bfa565b915061324d88888886886123df565b9050613265565b6132628888886000886123df565b90505b955095509592505050565b6000612be783670de0b6b3a764000084614fde565b606061328f6150ce565b826001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132f191906158fb565b6001600160a01b0316808252156143b357826001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061336491906158fb565b604051638e8f294b60e01b81526001600160a01b0385811660048301529190911690638e8f294b9060240160a060405180830381865afa1580156133ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133d09190615a51565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015613444573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261346c9190810190615c22565b6101408201819052516001600160401b0381111561348c5761348c6154b1565b6040519080825280602002602001820160405280156134c557816020015b6134b2615022565b8152602001906001900390816134aa5790505b5060006101a083018190529092505b81610140015151826101a0015110156136195781600001516001600160a01b0316635684aa4685846101400151856101a001518151811061351757613517615948565b60200260200101516040518363ffffffff1660e01b81526004016135519291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa15801561356e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135929190615cc4565b505063ffffffff166101c083018190521561360257816101400151826101a00151815181106135c3576135c3615948565b60200260200101518382806135d790615d07565b9350815181106135e9576135e9615948565b60209081029190910101516001600160a01b0390911690525b816101a001805161361290615d07565b90526134d4565b82816001600160401b03811115613632576136326154b1565b60405190808252806020026020018201604052801561366b57816020015b613658615022565b8152602001906001900390816136505790505b5060006101a085015293505b8351836101a0015110156136dd5780836101a001518151811061369c5761369c615948565b602002602001015184846101a00151815181106136bb576136bb615948565b6020026020010181905250826101a00180516136d690615d07565b9052613677565b505060006101a08201525b8151816101a0015110156143b35780600001516001600160a01b031663f2426f9a8484846101a001518151811061372157613721615948565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016101c060405180830381865afa158015613779573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379d9190615d49565b81610120018190525080600001516001600160a01b03166344e250f88484846101a00151815181106137d1576137d1615948565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401606060405180830381865afa158015613828573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061384c919061595e565b506040830152606082015280516101a082015183516001600160a01b039092169163fc196068918691869190811061388657613886615948565b6020026020010151600001518461012001516060015163ffffffff1642116138af5760006138b6565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613908573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061392c919061595e565b50608083015260a08201526101c08101516224ea009061394d908290615e53565b826101c0015161395d91906158dd565b613967919061591f565b81610240018181525050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156139af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139d39190615ac8565b6139e39060ff166224ea00615e67565b6139f06224ea0042615e53565b6139fa90426158dd565b613a04919061591f565b61022082018190526102408201516224ea0091613a2191906158dd565b613a2b9190615e7e565b613a3690600161591f565b6001600160401b03811115613a4d57613a4d6154b1565b604051908082528060200260200182016040528015613a76578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e0015111613b7e576101e0810151604051630156d37d60e31b81526000916001600160a01b03861691630ab69be891613ad99160040190815260200190565b6040805180830381865afa158015613af5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b199190615bd6565b509050808261020001818151613b2f919061591f565b9052506101e082015160e08301516101c084015181518110613b5357613b53615948565b6020908102919091010152506101e0810180516224ea000190526101c0810180516001019052613a91565b6040518060a0016040528083836101a0015181518110613ba057613ba0615948565b6020026020010151600001516001600160a01b0316815260200183836101a0015181518110613bd157613bd1615948565b6020026020010151600001516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015613c1a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613c429190810190615e92565b815260200183836101a0015181518110613c5e57613c5e615948565b6020026020010151600001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015613ca7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613ccf9190810190615e92565b81526020016000836102000151866001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d3e91906158a4565b613d48919061591f565b11613d54576000614087565b6140876301e13380846101800151611bac8660c00151613eb18a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dcf91906158fb565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613e1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e3f91906158a4565b8961020001518c6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ea791906158a4565b610b3f919061591f565b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ef2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f1691906158fb565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa158015613f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f8b91906158a4565b610b3f8d6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b8152600401613fc191815260200190565b602060405180830381865afa158015613fde573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061400291906158a4565b8e6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015614040573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061406491906158a4565b61406e919061591f565b8c60c001518d606001518e60a00151611bac91906158dd565b81526020016000856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156140cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140f091906158a4565b116140fc57600061437d565b61437d6301e13380846101800151611bac8660c001516142258a6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614153573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061417791906158fb565b6101008a0151604051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa1580156141c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141e791906158a4565b8b6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1b573d6000803e3d6000fd5b611bac8b6001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061428a91906158fb565b6101208b01516040908101519051631710760b60e31b81526001600160a01b03918216600482015291169063b883b05890602401602060405180830381865afa1580156142db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906142ff91906158a4565b610b3f8d6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614340573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061436491906158a4565b8c60c001518d604001518e60800151611bac91906158dd565b81525082826101a001518151811061439757614397615948565b60209081029190910101526101a08101805160010190526136e8565b50919050565b6060835185516143c9919061591f565b6001600160401b038111156143e0576143e06154b1565b60405190808252806020026020018201604052801561441957816020015b614406615022565b8152602001906001900390816143fe5790505b50905060005b85518110156145b4576144588387838151811061443e5761443e615948565b602002602001015160800151612bd290919063ffffffff16565b82828151811061446a5761446a615948565b6020026020010151608001818152505083156144e4576144c1614495670de0b6b3a7640000856158dd565b8783815181106144a7576144a7615948565b602002602001015160600151612bd290919063ffffffff16565b8282815181106144d3576144d3615948565b602002602001015160600181815250505b8581815181106144f6576144f6615948565b60200260200101516000015182828151811061451457614514615948565b60209081029190910101516001600160a01b039091169052855186908290811061454057614540615948565b60200260200101516020015182828151811061455e5761455e615948565b60200260200101516020018190525085818151811061457f5761457f615948565b60200260200101516040015182828151811061459d5761459d615948565b60209081029190910101516040015260010161441f565b8361470f575060005b845181101561470f576145ed6145db670de0b6b3a7640000856158dd565b8683815181106144a7576144a7615948565b828751836145fb919061591f565b8151811061460b5761460b615948565b6020026020010151606001818152505084818151811061462d5761462d615948565b60200260200101516000015182875183614647919061591f565b8151811061465757614657615948565b60209081029190910101516001600160a01b039091169052845185908290811061468357614683615948565b6020026020010151602001518287518361469d919061591f565b815181106146ad576146ad615948565b6020026020010151602001819052508481815181106146ce576146ce615948565b602002602001015160400151828751836146e8919061591f565b815181106146f8576146f8615948565b6020908102919091010151604001526001016145bd565b50949350505050565b604080516080810182526000808252602082018190529181018290526060810182905260007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561479b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147bf91906158fb565b604051638e8f294b60e01b81526001600160a01b03898116600483015291925090821690638e8f294b9060240160a060405180830381865afa158015614809573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482d9190615a51565b6001600160a01b039081166040888101919091526001600160801b039590951687529351638e8f294b60e01b81528a8516600482015293851693638e8f294b9350602401915061487a9050565b60a060405180830381865afa158015614897573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148bb9190615a51565b6001600160a01b0390811660608801526001600160801b039094166020808801919091526040805163313ce56760e01b81529051611683968e16955063313ce56794506004808301945090918290030181865afa158015614920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149449190615ac8565b61494f90600a615bc7565b6040848101519051631710760b60e31b81526001600160a01b0391821660048201529084169063b883b05890602401602060405180830381865afa15801561499b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149bf91906158a4565b84516020860151614ac8916149d49190612bd2565b6060870151604051631710760b60e31b81526001600160a01b0391821660048201526107839188169063b883b05890602401602060405180830381865afa158015614a23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a4791906158a4565b8c6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015614a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614aa99190615ac8565b614ab490600a615bc7565b611bac614ac18f8f6130a1565b8d90612bd2565b9190614fde565b600081602001516001600160a01b031682600001516001600160a01b031610614afa57614afa615932565b815160208084015160408086015181516001600160a01b0395861681860152949092168482015262ffffff90911660608085019190915281518085038201815260808501909252815191909201206001600160f81b031960a08401529085901b6bffffffffffffffffffffffff191660a183015260b58201527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d582015260f50160408051601f1981840301815291905280516020909101209392505050565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614c1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4191906158fb565b6001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015614c7e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052614ca69190810190615f1c565b519050806001600160401b03811115614cc157614cc16154b1565b604051908082528060200260200182016040528015614d0657816020015b6040805180820190915260008082526020820152815260200190600190039081614cdf5790505b50915060005b81811015614fa55760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633ec045a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015614d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614d9891906158fb565b6001600160a01b031663232b956c836040518263ffffffff1660e01b8152600401614dc591815260200190565b602060405180830381865afa158015614de2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e0691906158fb565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614e43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e6791906158fb565b90506040518060400160405280826001600160a01b03168152602001826001600160a01b03166370a082317f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663158274a56040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f1491906158fb565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015614f58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f7c91906158a4565b815250848381518110614f9157614f91615948565b602090810291909101015250600101614d0c565b505090565b6000612be78383670de0b6b3a7640000614fde565b828202811515841585830485141716614fd757600080fd5b0492915050565b828202811515841585830485141716614ff657600080fd5b6001826001830304018115150290509392505050565b600081831061501b5781612be7565b5090919050565b6040518060a0016040528060006001600160a01b03168152602001606081526020016060815260200160008152602001600081525090565b604051806101400160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016150ba604080516060810182526000808252602082018190529181019190915290565b815260200160008152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b031681526020016151ee604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b038116811461524857600080fd5b50565b803562ffffff8116811461525e57600080fd5b919050565b6000806000806080858703121561527957600080fd5b843561528481615233565b9350602085013561529481615233565b9250604085013591506152a96060860161524b565b905092959194509250565b60008060008060008060c087890312156152cd57600080fd5b86356152d881615233565b955060208701356152e881615233565b945060408701356152f881615233565b959894975094956060810135955060808101359460a0909101359350915050565b600080600080600080600060e0888a03121561533457600080fd5b873561533f81615233565b9650602088013561534f81615233565b9550604088013561535f81615233565b969995985095966060810135965060808101359560a0820135955060c0909101359350915050565b60005b838110156153a257818101518382015260200161538a565b50506000910152565b600081518084526153c3816020860160208601615387565b601f01601f19169290920160200192915050565b6000602080835260a0808401855183860152828601516040818188015280880151915060608281890152808901519250608080818a015284845180875260c08b01915060c08160051b8c01019650888601955060005b818110156154a0578b880360bf19018352865180516001600160a01b031689528a8101518b8a018b90526154638b8b01826153ab565b9050878201518a8203898c015261547a82826153ab565b838901518c8a0152928701519a87019a909a52509750958901959189019160010161542d565b50959b9a5050505050505050505050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156154e9576154e96154b1565b60405290565b6040516101c081016001600160401b03811182821017156154e9576154e96154b1565b604051601f8201601f191681016001600160401b038111828210171561553a5761553a6154b1565b604052919050565b60006001600160401b0382111561555b5761555b6154b1565b5060051b60200190565b600082601f83011261557657600080fd5b8135602061558b61558683615542565b615512565b82815260059290921b840181019181810190868411156155aa57600080fd5b8286015b848110156155cc576155bf8161524b565b83529183019183016155ae565b509695505050505050565b60008060408084860312156155eb57600080fd5b83356001600160401b038082111561560257600080fd5b818601915086601f83011261561657600080fd5b8135602061562661558683615542565b82815260069290921b8401810191818101908a84111561564557600080fd5b948201945b838610156156975786868c0312156156625760008081fd5b61566a6154c7565b863561567581615233565b81528684013561568481615233565b818501528252948601949082019061564a565b975050870135935050808311156156ad57600080fd5b50506156bb85828601615565565b9150509250929050565b600080600080608085870312156156db57600080fd5b84356156e681615233565b935060208501356156f681615233565b9250604085013561570681615233565b9396929550929360600135925050565b600081518084526020808501945080840160005b8381101561575a57815180516001600160a01b03168852830151838801526040909601959082019060010161572a565b509495945050505050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015260a082015160c082015260c082015160e0820152600060e08301516101006157e98185018380516001600160a01b0390811683526020808301519091169083015260409081015162ffffff16910152565b840151610160840152506101208301516101808084015261317e6101a0840182615716565b6000806040838503121561582157600080fd5b823561582c81615233565b9150602083013561583c81615233565b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0382811682821603908082111561587d5761587d615847565b5092915050565b6001600160a01b0381811683821601908082111561587d5761587d615847565b6000602082840312156158b657600080fd5b5051919050565b818103600083128015838313168383128216171561587d5761587d615847565b81810381811115612bea57612bea615847565b805161525e81615233565b60006020828403121561590d57600080fd5b815161591881615233565b9392505050565b80820180821115612bea57612bea615847565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008060006060848603121561597357600080fd5b8351925060208401519150604084015190509250925092565b805161ffff8116811461525e57600080fd5b805160ff8116811461525e57600080fd5b8051801515811461525e57600080fd5b600080600080600080600060e0888a0312156159da57600080fd5b87516159e581615233565b8097505060208801518060020b81146159fd57600080fd5b9550615a0b6040890161598c565b9450615a196060890161598c565b9350615a276080890161598c565b9250615a3560a0890161599e565b9150615a4360c089016159af565b905092959891949750929550565b600080600080600060a08688031215615a6957600080fd5b85516001600160801b0381168114615a8057600080fd5b9450615a8e6020870161599e565b9350615a9c6040870161599e565b9250615aaa606087016159af565b91506080860151615aba81615233565b809150509295509295909350565b600060208284031215615ada57600080fd5b612be78261599e565b600181815b80851115615b1e578160001904821115615b0457615b04615847565b80851615615b1157918102915b93841c9390800290615ae8565b509250929050565b600082615b3557506001612bea565b81615b4257506000612bea565b8160018114615b585760028114615b6257615b7e565b6001915050612bea565b60ff841115615b7357615b73615847565b50506001821b612bea565b5060208310610133831016604e8410600b8410161715615ba1575081810a612bea565b615bab8383615ae3565b8060001904821115615bbf57615bbf615847565b029392505050565b6000612be760ff841683615b26565b60008060408385031215615be957600080fd5b505080516020909101519092909150565b8082018281126000831280158216821582161715615c1a57615c1a615847565b505092915050565b60006020808385031215615c3557600080fd5b82516001600160401b03811115615c4b57600080fd5b8301601f81018513615c5c57600080fd5b8051615c6a61558682615542565b81815260059190911b82018301908381019087831115615c8957600080fd5b928401925b82841015611683578351615ca181615233565b82529284019290840190615c8e565b805163ffffffff8116811461525e57600080fd5b600080600060608486031215615cd957600080fd5b615ce284615cb0565b9250615cf060208501615cb0565b9150615cfe60408501615cb0565b90509250925092565b600060018201615d1957615d19615847565b5060010190565b8051600f81900b811461525e57600080fd5b80516001600160401b038116811461525e57600080fd5b60006101c08284031215615d5c57600080fd5b615d646154ef565b615d6d836158f0565b8152615d7b602084016158f0565b6020820152615d8c604084016158f0565b6040820152615d9d60608401615cb0565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615dd8818501615d20565b90820152610120615dea848201615d32565b90820152610140615dfc848201615d32565b90820152610160615e0e848201615d32565b90820152610180615e20848201615d32565b908201526101a0615e32848201615d32565b908201529392505050565b634e487b7160e01b600052601260045260246000fd5b600082615e6257615e62615e3d565b500690565b8082028115828204841417612bea57612bea615847565b600082615e8d57615e8d615e3d565b500490565b600060208284031215615ea457600080fd5b81516001600160401b0380821115615ebb57600080fd5b818401915084601f830112615ecf57600080fd5b815181811115615ee157615ee16154b1565b615ef4601f8201601f1916602001615512565b9150808252856020828501011115615f0b57600080fd5b61470f816020840160208601615387565b60006020808385031215615f2f57600080fd5b82516001600160401b03811115615f4557600080fd5b8301601f81018513615f5657600080fd5b8051615f6461558682615542565b81815260059190911b82018301908381019087831115615f8357600080fd5b928401925b82841015611683578351615f9b81615233565b82529284019290840190615f8856fea26469706673582212207f788112a3f9d9e88d0ff809d0ded9dcfeceac00215af7a435358746ade369b464736f6c63430008110033", "devdoc": { "kind": "dev", "methods": { @@ -705,7 +705,7 @@ "storageLayout": { "storage": [ { - "astId": 415, + "astId": 542, "contract": "contracts/periphery/DebtPreviewer.sol:DebtPreviewer", "label": "_initialized", "offset": 0, @@ -713,7 +713,7 @@ "type": "t_uint8" }, { - "astId": 418, + "astId": 545, "contract": "contracts/periphery/DebtPreviewer.sol:DebtPreviewer", "label": "_initializing", "offset": 1, @@ -721,7 +721,7 @@ "type": "t_bool" }, { - "astId": 19450, + "astId": 24308, "contract": "contracts/periphery/DebtPreviewer.sol:DebtPreviewer", "label": "poolFees", "offset": 0, diff --git a/deployments/optimism/Previewer.json b/deployments/optimism/Previewer.json index d124a6cda..3c626d86b 100644 --- a/deployments/optimism/Previewer.json +++ b/deployments/optimism/Previewer.json @@ -309,7 +309,7 @@ { "components": [ { - "internalType": "address", + "internalType": "contract ERC20", "name": "asset", "type": "address" }, @@ -867,33 +867,18 @@ "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a", "0x" ], - "numDeployments": 2, - "solcInputHash": "7f84a745038d683ecec6e9910037248b", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"implementation_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"changeAdmin(address)\":{\"details\":\"Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n *\\n * @custom:oz-upgrades-unsafe-allow delegatecall\\n */\\nabstract contract ERC1967Upgrade {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(\\n address newImplementation,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Emitted when the beacon is upgraded.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(\\n address newBeacon,\\n bytes memory data,\\n bool forceCall\\n ) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xabf3f59bc0e5423eae45e459dbe92e7052c6983628d39008590edc852a62f94a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(\\n address _logic,\\n address admin_,\\n bytes memory _data\\n ) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address admin_) {\\n admin_ = _getAdmin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address implementation_) {\\n implementation_ = _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external virtual ifAdmin {\\n _changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeToAndCall(newImplementation, data, true);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _getAdmin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xa6a787e7a901af6511e19aa53e1a00352db215a011d2c7a438d0582dd5da76f9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf96f969e24029d43d0df89e59d365f277021dac62b48e1c1e3ebe0acdd7f1ca1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd5c50c54bf02740ebd122ff06832546cb5fa84486d52695a9ccfd11666e0c81d\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x608060405260405162000b5038038062000b5083398101604081905262000026916200038b565b828162000036828260006200004d565b50620000449050826200008a565b50505062000489565b6200005883620000e5565b600082511180620000665750805b1562000085576200008383836200012760201b6200022e1760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f620000b562000156565b604080516001600160a01b03928316815291841660208301520160405180910390a1620000e2816200018f565b50565b620000f081620001ed565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200014f838360405180606001604052806027815260200162000b296027913962000247565b9392505050565b60006200018060008051602062000b0983398151915260001b620002c660201b620001ea1760201c565b546001600160a01b0316919050565b6001600160a01b038116620001a357600080fd5b80620001cc60008051602062000b0983398151915260001b620002c660201b620001ea1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6200020381620002c960201b6200025a1760201c565b6200020d57600080fd5b80620001cc7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b620002c660201b620001ea1760201c565b6060600080856001600160a01b0316856040516200026691906200046b565b600060405180830381855af49150503d8060008114620002a3576040519150601f19603f3d011682016040523d82523d6000602084013e620002a8565b606091505b509092509050620002bc86838387620002d8565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200030857825160000362000300576001600160a01b0385163b6200030057600080fd5b508162000314565b6200031483836200031c565b949350505050565b8151156200032d5781518083602001fd5b600080fd5b80516001600160a01b03811681146200034a57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200038257818101518382015260200162000368565b50506000910152565b600080600060608486031215620003a157600080fd5b620003ac8462000332565b9250620003bc6020850162000332565b60408501519092506001600160401b0380821115620003da57600080fd5b818601915086601f830112620003ef57600080fd5b8151818111156200040457620004046200034f565b604051601f8201601f19908116603f011681019083821181831017156200042f576200042f6200034f565b816040528281528960208487010111156200044957600080fd5b6200045c83602083016020880162000365565b80955050505050509250925092565b600082516200047f81846020870162000365565b9190910192915050565b61067080620004996000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b610080366004610546565b610118565b61005b610093366004610561565b610155565b3480156100a457600080fd5b506100ad6101bc565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e4366004610546565b6101ed565b3480156100f557600080fd5b506100ad61020d565b610106610269565b610116610111610285565b61028f565b565b6101206102b3565b6001600160a01b0316330361014d5761014a816040518060200160405280600081525060006102e6565b50565b61014a6100fe565b61015d6102b3565b6001600160a01b031633036101b4576101af8383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506102e6915050565b505050565b6101af6100fe565b60006101c66102b3565b6001600160a01b031633036101e2576101dd610285565b905090565b6101ea6100fe565b90565b6101f56102b3565b6001600160a01b0316330361014d5761014a81610311565b60006102176102b3565b6001600160a01b031633036101e2576101dd6102b3565b6060610253838360405180606001604052806027815260200161061460279139610365565b9392505050565b6001600160a01b03163b151590565b6102716102b3565b6001600160a01b0316330361011657600080fd5b60006101dd6103dd565b3660008037600080366000845af43d6000803e8080156102ae573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b6102ef83610405565b6000825111806102fc5750805b156101af5761030b838361022e565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61033a6102b3565b604080516001600160a01b03928316815291841660208301520160405180910390a161014a81610445565b6060600080856001600160a01b03168560405161038291906105e4565b600060405180830381855af49150503d80600081146103bd576040519150601f19603f3d011682016040523d82523d6000602084013e6103c2565b606091505b50915091506103d38683838761049c565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6102d7565b61040e816104da565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045857600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b606083156104c85782516000036104c1576001600160a01b0385163b6104c157600080fd5b50816104d2565b6104d28383610515565b949350505050565b6001600160a01b0381163b6104ee57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61047b565b8151156105255781518083602001fd5b600080fd5b80356001600160a01b038116811461054157600080fd5b919050565b60006020828403121561055857600080fd5b6102538261052a565b60008060006040848603121561057657600080fd5b61057f8461052a565b9250602084013567ffffffffffffffff8082111561059c57600080fd5b818601915086601f8301126105b057600080fd5b8135818111156105bf57600080fd5b8760208285010111156105d157600080fd5b6020830194508093505050509250925092565b6000825160005b8181101561060557602081860181015185830152016105eb565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203011748945e626a6c7d6bd1969f4e5640e829c89504a5d4e52671d90f482851564736f6c63430008110033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", - "deployedBytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b610080366004610546565b610118565b61005b610093366004610561565b610155565b3480156100a457600080fd5b506100ad6101bc565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e4366004610546565b6101ed565b3480156100f557600080fd5b506100ad61020d565b610106610269565b610116610111610285565b61028f565b565b6101206102b3565b6001600160a01b0316330361014d5761014a816040518060200160405280600081525060006102e6565b50565b61014a6100fe565b61015d6102b3565b6001600160a01b031633036101b4576101af8383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506102e6915050565b505050565b6101af6100fe565b60006101c66102b3565b6001600160a01b031633036101e2576101dd610285565b905090565b6101ea6100fe565b90565b6101f56102b3565b6001600160a01b0316330361014d5761014a81610311565b60006102176102b3565b6001600160a01b031633036101e2576101dd6102b3565b6060610253838360405180606001604052806027815260200161061460279139610365565b9392505050565b6001600160a01b03163b151590565b6102716102b3565b6001600160a01b0316330361011657600080fd5b60006101dd6103dd565b3660008037600080366000845af43d6000803e8080156102ae573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b6102ef83610405565b6000825111806102fc5750805b156101af5761030b838361022e565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61033a6102b3565b604080516001600160a01b03928316815291841660208301520160405180910390a161014a81610445565b6060600080856001600160a01b03168560405161038291906105e4565b600060405180830381855af49150503d80600081146103bd576040519150601f19603f3d011682016040523d82523d6000602084013e6103c2565b606091505b50915091506103d38683838761049c565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6102d7565b61040e816104da565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045857600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b606083156104c85782516000036104c1576001600160a01b0385163b6104c157600080fd5b50816104d2565b6104d28383610515565b949350505050565b6001600160a01b0381163b6104ee57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61047b565b8151156105255781518083602001fd5b600080fd5b80356001600160a01b038116811461054157600080fd5b919050565b60006020828403121561055857600080fd5b6102538261052a565b60008060006040848603121561057657600080fd5b61057f8461052a565b9250602084013567ffffffffffffffff8082111561059c57600080fd5b818601915086601f8301126105b057600080fd5b8135818111156105bf57600080fd5b8760208285010111156105d157600080fd5b6020830194508093505050509250925092565b6000825160005b8181101561060557602081860181015185830152016105eb565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212203011748945e626a6c7d6bd1969f4e5640e829c89504a5d4e52671d90f482851564736f6c63430008110033", - "implementation": "0xFFf4fE4AF99Dd3A1C9Ac637c71aE2685A5358818", + "numDeployments": 4, + "solcInputHash": "0f3d5a71c203a330ccec578b8f3450f8", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_logic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"admin_\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"previousAdmin\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"AdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"beacon\",\"type\":\"address\"}],\"name\":\"BeaconUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to fully implement transparency without decoding reverts caused by selector clashes between the proxy and the implementation. WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.\",\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":\"TransparentUpgradeableProxy\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/interfaces/IERC1967.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\\n *\\n * _Available since v4.8.3._\\n */\\ninterface IERC1967 {\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Emitted when the beacon is changed.\\n */\\n event BeaconUpgraded(address indexed beacon);\\n}\\n\",\"keccak256\":\"0x3cbef5ebc24b415252e2f8c0c9254555d30d9f085603b4b80d9b5ed20ab87e90\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC1822.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\\n * proxy whose upgrades are fully controlled by the current implementation.\\n */\\ninterface IERC1822Proxiable {\\n /**\\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\\n * address.\\n *\\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\\n * function revert if invoked through a proxy.\\n */\\n function proxiableUUID() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x1d4afe6cb24200cc4545eed814ecf5847277dfe5d613a1707aad5fceecebcfff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Proxy.sol\\\";\\nimport \\\"./ERC1967Upgrade.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n */\\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n *\\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n _upgradeToAndCall(_logic, _data, false);\\n }\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal view virtual override returns (address impl) {\\n return ERC1967Upgrade._getImplementation();\\n }\\n}\\n\",\"keccak256\":\"0xa2b22da3032e50b55f95ec1d13336102d675f341167aa76db571ef7f8bb7975d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../beacon/IBeacon.sol\\\";\\nimport \\\"../../interfaces/IERC1967.sol\\\";\\nimport \\\"../../interfaces/draft-IERC1822.sol\\\";\\nimport \\\"../../utils/Address.sol\\\";\\nimport \\\"../../utils/StorageSlot.sol\\\";\\n\\n/**\\n * @dev This abstract contract provides getters and event emitting update functions for\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\\n *\\n * _Available since v4.1._\\n */\\nabstract contract ERC1967Upgrade is IERC1967 {\\n // This is the keccak-256 hash of \\\"eip1967.proxy.rollback\\\" subtracted by 1\\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _getImplementation() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n }\\n\\n /**\\n * @dev Perform implementation upgrade\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\\n _upgradeTo(newImplementation);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(newImplementation, data);\\n }\\n }\\n\\n /**\\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\\n *\\n * Emits an {Upgraded} event.\\n */\\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\\n // Upgrades from old implementations will perform a rollback test. This test requires the new\\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\\n // this special case will break upgrade paths from old UUPS implementation to new ones.\\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\\n _setImplementation(newImplementation);\\n } else {\\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\\n require(slot == _IMPLEMENTATION_SLOT, \\\"ERC1967Upgrade: unsupported proxiableUUID\\\");\\n } catch {\\n revert(\\\"ERC1967Upgrade: new implementation is not UUPS\\\");\\n }\\n _upgradeToAndCall(newImplementation, data, forceCall);\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _getAdmin() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n require(newAdmin != address(0), \\\"ERC1967: new admin is the zero address\\\");\\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _changeAdmin(address newAdmin) internal {\\n emit AdminChanged(_getAdmin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\\n * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\\n */\\n bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\\n\\n /**\\n * @dev Returns the current beacon.\\n */\\n function _getBeacon() internal view returns (address) {\\n return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\\n }\\n\\n /**\\n * @dev Stores a new beacon in the EIP1967 beacon slot.\\n */\\n function _setBeacon(address newBeacon) private {\\n require(Address.isContract(newBeacon), \\\"ERC1967: new beacon is not a contract\\\");\\n require(\\n Address.isContract(IBeacon(newBeacon).implementation()),\\n \\\"ERC1967: beacon implementation is not a contract\\\"\\n );\\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\\n }\\n\\n /**\\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\\n *\\n * Emits a {BeaconUpgraded} event.\\n */\\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\\n _setBeacon(newBeacon);\\n emit BeaconUpgraded(newBeacon);\\n if (data.length > 0 || forceCall) {\\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3b21ae06bf5957f73fa16754b0669c77b7abd8ba6c072d35c3281d446fdb86c2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n *\\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n *\\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal virtual {\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 {\\n revert(0, returndatasize())\\n }\\n default {\\n return(0, returndatasize())\\n }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal view virtual returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n *\\n * This function does not return to its internal call site, it will return directly to the external caller.\\n */\\n function _fallback() internal virtual {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive() external payable virtual {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n *\\n * If overridden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {}\\n}\\n\",\"keccak256\":\"0xc130fe33f1b2132158531a87734153293f6d07bc263ff4ac90e85da9c82c0e27\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\\n */\\ninterface IBeacon {\\n /**\\n * @dev Must return an address that can be used as a delegate call target.\\n *\\n * {BeaconProxy} will check that this address is a contract.\\n */\\n function implementation() external view returns (address);\\n}\\n\",\"keccak256\":\"0xd50a3421ac379ccb1be435fa646d66a65c986b4924f0849839f08692f39dde61\",\"license\":\"MIT\"},\"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../ERC1967/ERC1967Proxy.sol\\\";\\n\\n/**\\n * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}\\n * does not implement this interface directly, and some of its functions are implemented by an internal dispatch\\n * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not\\n * include them in the ABI so this interface must be used to interact with it.\\n */\\ninterface ITransparentUpgradeableProxy is IERC1967 {\\n function admin() external view returns (address);\\n\\n function implementation() external view returns (address);\\n\\n function changeAdmin(address) external;\\n\\n function upgradeTo(address) external;\\n\\n function upgradeToAndCall(address, bytes memory) external payable;\\n}\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\\n *\\n * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not\\n * inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch\\n * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to\\n * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the\\n * implementation.\\n *\\n * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler\\n * will not check that there are no selector conflicts, due to the note above. A selector clash between any new function\\n * and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could\\n * render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.\\n */\\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\\n */\\n constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {\\n _changeAdmin(admin_);\\n }\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n *\\n * CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the\\n * implementation provides a function with the same selector.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _getAdmin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior\\n */\\n function _fallback() internal virtual override {\\n if (msg.sender == _getAdmin()) {\\n bytes memory ret;\\n bytes4 selector = msg.sig;\\n if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {\\n ret = _dispatchUpgradeTo();\\n } else if (selector == ITransparentUpgradeableProxy.upgradeToAndCall.selector) {\\n ret = _dispatchUpgradeToAndCall();\\n } else if (selector == ITransparentUpgradeableProxy.changeAdmin.selector) {\\n ret = _dispatchChangeAdmin();\\n } else if (selector == ITransparentUpgradeableProxy.admin.selector) {\\n ret = _dispatchAdmin();\\n } else if (selector == ITransparentUpgradeableProxy.implementation.selector) {\\n ret = _dispatchImplementation();\\n } else {\\n revert(\\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n }\\n assembly {\\n return(add(ret, 0x20), mload(ret))\\n }\\n } else {\\n super._fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function _dispatchAdmin() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address admin = _getAdmin();\\n return abi.encode(admin);\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function _dispatchImplementation() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address implementation = _implementation();\\n return abi.encode(implementation);\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n *\\n * Emits an {AdminChanged} event.\\n */\\n function _dispatchChangeAdmin() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address newAdmin = abi.decode(msg.data[4:], (address));\\n _changeAdmin(newAdmin);\\n\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n */\\n function _dispatchUpgradeTo() private returns (bytes memory) {\\n _requireZeroValue();\\n\\n address newImplementation = abi.decode(msg.data[4:], (address));\\n _upgradeToAndCall(newImplementation, bytes(\\\"\\\"), false);\\n\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n */\\n function _dispatchUpgradeToAndCall() private returns (bytes memory) {\\n (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));\\n _upgradeToAndCall(newImplementation, data, true);\\n\\n return \\\"\\\";\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.\\n */\\n function _admin() internal view virtual returns (address) {\\n return _getAdmin();\\n }\\n\\n /**\\n * @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to\\n * emulate some proxy functions being non-payable while still allowing value to pass through.\\n */\\n function _requireZeroValue() private {\\n require(msg.value == 0);\\n }\\n}\\n\",\"keccak256\":\"0x168e36d7e616bd41f6abab4a83009da64513ae9e638aa6d5980066e2a92db689\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x006dd67219697fe68d7fbfdea512e7c4cb64a43565ed86171d67e844982da6fa\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/StorageSlot.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Library for reading and writing primitive types to specific storage slots.\\n *\\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\\n * This library helps with reading and writing to such slots without the need for inline assembly.\\n *\\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\\n *\\n * Example usage to set ERC1967 implementation slot:\\n * ```solidity\\n * contract ERC1967 {\\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n *\\n * function _getImplementation() internal view returns (address) {\\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\\n * }\\n *\\n * function _setImplementation(address newImplementation) internal {\\n * require(Address.isContract(newImplementation), \\\"ERC1967: new implementation is not a contract\\\");\\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\\n * }\\n * }\\n * ```\\n *\\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\\n * _Available since v4.9 for `string`, `bytes`._\\n */\\nlibrary StorageSlot {\\n struct AddressSlot {\\n address value;\\n }\\n\\n struct BooleanSlot {\\n bool value;\\n }\\n\\n struct Bytes32Slot {\\n bytes32 value;\\n }\\n\\n struct Uint256Slot {\\n uint256 value;\\n }\\n\\n struct StringSlot {\\n string value;\\n }\\n\\n struct BytesSlot {\\n bytes value;\\n }\\n\\n /**\\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\\n */\\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\\n */\\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\\n */\\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\\n */\\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\\n */\\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\\n */\\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := store.slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\\n */\\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := slot\\n }\\n }\\n\\n /**\\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\\n */\\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n r.slot := store.slot\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf09e68aa0dc6722a25bc46490e8d48ed864466d17313b8a0b254c36b54e49899\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405260405162000bb938038062000bb983398101604081905262000026916200038b565b828162000036828260006200004d565b50620000449050826200008a565b50505062000489565b6200005883620000e5565b600082511180620000665750805b1562000085576200008383836200012760201b620000f01760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f620000b562000156565b604080516001600160a01b03928316815291841660208301520160405180910390a1620000e2816200018f565b50565b620000f081620001ed565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606200014f838360405180606001604052806027815260200162000b926027913962000247565b9392505050565b60006200018060008051602062000b7283398151915260001b620002c660201b6200011c1760201c565b546001600160a01b0316919050565b6001600160a01b038116620001a357600080fd5b80620001cc60008051602062000b7283398151915260001b620002c660201b6200011c1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6200020381620002c960201b6200011f1760201c565b6200020d57600080fd5b80620001cc7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b620002c660201b6200011c1760201c565b6060600080856001600160a01b0316856040516200026691906200046b565b600060405180830381855af49150503d8060008114620002a3576040519150601f19603f3d011682016040523d82523d6000602084013e620002a8565b606091505b509092509050620002bc86838387620002d8565b9695505050505050565b90565b6001600160a01b03163b151590565b606083156200030857825160000362000300576001600160a01b0385163b6200030057600080fd5b508162000314565b6200031483836200031c565b949350505050565b8151156200032d5781518083602001fd5b600080fd5b80516001600160a01b03811681146200034a57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200038257818101518382015260200162000368565b50506000910152565b600080600060608486031215620003a157600080fd5b620003ac8462000332565b9250620003bc6020850162000332565b60408501519092506001600160401b0380821115620003da57600080fd5b818601915086601f830112620003ef57600080fd5b8151818111156200040457620004046200034f565b604051601f8201601f19908116603f011681019083821181831017156200042f576200042f6200034f565b816040528281528960208487010111156200044957600080fd5b6200045c83602083016020880162000365565b80955050505050509250925092565b600082516200047f81846020870162000365565b9190910192915050565b6106d980620004996000396000f3fe60806040523661001357610011610017565b005b6100115b61001f61012e565b6001600160a01b031633036100e65760606001600160e01b0319600035166364d3180d60e11b810161005a57610053610161565b91506100de565b63587086bd60e11b6001600160e01b031982160161007a576100536101b8565b63070d7c6960e41b6001600160e01b031982160161009a576100536101fe565b621eb96f60e61b6001600160e01b03198216016100b95761005361022f565b63a39f25e560e01b6001600160e01b03198216016100d95761005361026f565b600080fd5b815160208301f35b6100ee610283565b565b6060610115838360405180606001604052806027815260200161067d60279139610293565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b606061016b61030b565b600061017a3660048184610514565b810190610187919061055a565b90506101a481604051806020016040528060008152506000610316565b505060408051602081019091526000815290565b60606000806101ca3660048184610514565b8101906101d7919061058b565b915091506101e782826001610316565b604051806020016040528060008152509250505090565b606061020861030b565b60006102173660048184610514565b810190610224919061055a565b90506101a481610342565b606061023961030b565b600061024361012e565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b606061027961030b565b6000610243610399565b6100ee61028e610399565b6103a8565b6060600080856001600160a01b0316856040516102b0919061064d565b600060405180830381855af49150503d80600081146102eb576040519150601f19603f3d011682016040523d82523d6000602084013e6102f0565b606091505b5091509150610301868383876103cc565b9695505050505050565b34156100ee57600080fd5b61031f8361040a565b60008251118061032c5750805b1561033d5761033b83836100f0565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61036b61012e565b604080516001600160a01b03928316815291841660208301520160405180910390a16103968161044a565b50565b60006103a36104a1565b905090565b3660008037600080366000845af43d6000803e8080156103c7573d6000f35b3d6000fd5b606083156103f85782516000036103f1576001600160a01b0385163b6103f157600080fd5b5081610402565b61040283836104c9565b949350505050565b610413816104d9565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045d57600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610152565b8151156100d95781518083602001fd5b6001600160a01b0381163b6104ed57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610480565b6000808585111561052457600080fd5b8386111561053157600080fd5b5050820193919092039150565b80356001600160a01b038116811461055557600080fd5b919050565b60006020828403121561056c57600080fd5b6101158261053e565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059e57600080fd5b6105a78361053e565b9150602083013567ffffffffffffffff808211156105c457600080fd5b818501915085601f8301126105d857600080fd5b8135818111156105ea576105ea610575565b604051601f8201601f19908116603f0116810190838211818310171561061257610612610575565b8160405282815288602084870101111561062b57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b8181101561066e5760208186018101518583015201610654565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b01b6cfc5e4b180efda020a05b771d034ebbaca7fb66eb1a85ef640af48786fb64736f6c63430008110033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564", + "deployedBytecode": "0x60806040523661001357610011610017565b005b6100115b61001f61012e565b6001600160a01b031633036100e65760606001600160e01b0319600035166364d3180d60e11b810161005a57610053610161565b91506100de565b63587086bd60e11b6001600160e01b031982160161007a576100536101b8565b63070d7c6960e41b6001600160e01b031982160161009a576100536101fe565b621eb96f60e61b6001600160e01b03198216016100b95761005361022f565b63a39f25e560e01b6001600160e01b03198216016100d95761005361026f565b600080fd5b815160208301f35b6100ee610283565b565b6060610115838360405180606001604052806027815260200161067d60279139610293565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b606061016b61030b565b600061017a3660048184610514565b810190610187919061055a565b90506101a481604051806020016040528060008152506000610316565b505060408051602081019091526000815290565b60606000806101ca3660048184610514565b8101906101d7919061058b565b915091506101e782826001610316565b604051806020016040528060008152509250505090565b606061020861030b565b60006102173660048184610514565b810190610224919061055a565b90506101a481610342565b606061023961030b565b600061024361012e565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b606061027961030b565b6000610243610399565b6100ee61028e610399565b6103a8565b6060600080856001600160a01b0316856040516102b0919061064d565b600060405180830381855af49150503d80600081146102eb576040519150601f19603f3d011682016040523d82523d6000602084013e6102f0565b606091505b5091509150610301868383876103cc565b9695505050505050565b34156100ee57600080fd5b61031f8361040a565b60008251118061032c5750805b1561033d5761033b83836100f0565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61036b61012e565b604080516001600160a01b03928316815291841660208301520160405180910390a16103968161044a565b50565b60006103a36104a1565b905090565b3660008037600080366000845af43d6000803e8080156103c7573d6000f35b3d6000fd5b606083156103f85782516000036103f1576001600160a01b0385163b6103f157600080fd5b5081610402565b61040283836104c9565b949350505050565b610413816104d9565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b03811661045d57600080fd5b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610152565b8151156100d95781518083602001fd5b6001600160a01b0381163b6104ed57600080fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610480565b6000808585111561052457600080fd5b8386111561053157600080fd5b5050820193919092039150565b80356001600160a01b038116811461055557600080fd5b919050565b60006020828403121561056c57600080fd5b6101158261053e565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561059e57600080fd5b6105a78361053e565b9150602083013567ffffffffffffffff808211156105c457600080fd5b818501915085601f8301126105d857600080fd5b8135818111156105ea576105ea610575565b604051601f8201601f19908116603f0116810190838211818310171561061257610612610575565b8160405282815288602084870101111561062b57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000825160005b8181101561066e5760208186018101518583015201610654565b50600092019182525091905056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b01b6cfc5e4b180efda020a05b771d034ebbaca7fb66eb1a85ef640af48786fb64736f6c63430008110033", + "implementation": "0xa15566E9cF856F3780706715A1b1EfB2918304aF", "devdoc": { - "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.", + "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to fully implement transparency without decoding reverts caused by selector clashes between the proxy and the implementation. WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.", "kind": "dev", "methods": { - "admin()": { - "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" - }, - "changeAdmin(address)": { - "details": "Changes the admin of the proxy. Emits an {AdminChanged} event. NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}." - }, "constructor": { "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}." - }, - "implementation()": { - "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" - }, - "upgradeTo(address)": { - "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." - }, - "upgradeToAndCall(address,bytes)": { - "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." } }, "version": 1 diff --git a/deployments/optimism/Previewer_Implementation.json b/deployments/optimism/Previewer_Implementation.json index e2d654c10..292a680b0 100644 --- a/deployments/optimism/Previewer_Implementation.json +++ b/deployments/optimism/Previewer_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0xFFf4fE4AF99Dd3A1C9Ac637c71aE2685A5358818", + "address": "0xa15566E9cF856F3780706715A1b1EfB2918304aF", "abi": [ { "inputs": [ @@ -202,7 +202,7 @@ { "components": [ { - "internalType": "address", + "internalType": "contract ERC20", "name": "asset", "type": "address" }, @@ -692,19 +692,19 @@ "type": "function" } ], - "transactionHash": "0x6908dc50e1844ed5fa22b8afcc6547107934cdc2132fcde650c02a2f1cad7711", + "transactionHash": "0x71d046fbd157b4f09c4007279837acd73ff834605e3c9a2a614ffd5318f45953", "receipt": { "to": null, "from": "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a", - "contractAddress": "0xFFf4fE4AF99Dd3A1C9Ac637c71aE2685A5358818", - "transactionIndex": 0, - "gasUsed": "5222579", + "contractAddress": "0xa15566E9cF856F3780706715A1b1EfB2918304aF", + "transactionIndex": 7, + "gasUsed": "5295161", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x7a102d039bc9d98187155a9c29ea72cac8e98c0d46b43e370dc23781b6352a49", - "transactionHash": "0x6908dc50e1844ed5fa22b8afcc6547107934cdc2132fcde650c02a2f1cad7711", + "blockHash": "0x6b6a32ea1e74058854b44ece81680989af6a3bad9a3fbe40cd0dc64ac51a9456", + "transactionHash": "0x71d046fbd157b4f09c4007279837acd73ff834605e3c9a2a614ffd5318f45953", "logs": [], - "blockNumber": 99594882, - "cumulativeGasUsed": "5222579", + "blockNumber": 107320128, + "cumulativeGasUsed": "7033743", "status": 1, "byzantium": true }, @@ -712,11 +712,11 @@ "0xaEb62e6F27BC103702E7BC879AE98bceA56f027E", "0x0000000000000000000000000000000000000000" ], - "numDeployments": 2, - "solcInputHash": "7f84a745038d683ecec6e9910037248b", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"auditor_\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"basePriceFeed_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyMatured\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"auditor\",\"outputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"basePriceFeed\",\"outputs\":[{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"exactly\",\"outputs\":[{\"components\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"decimals\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"id\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fixedCurveA\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"fixedCurveB\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"fixedMaxUtilization\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingCurveA\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"floatingCurveB\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"floatingMaxUtilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.InterestRateModel\",\"name\":\"interestRateModel\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"usdPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"penaltyRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adjustFactor\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"maxFuturePools\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowed\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplied\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"available\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"depositRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minBorrowRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimalDeposit\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPool[]\",\"name\":\"fixedPools\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"usdPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingDeposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"maturities\",\"type\":\"uint256[]\"}],\"internalType\":\"struct Previewer.RewardRate[]\",\"name\":\"rewardRates\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"floatingBorrowRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingUtilization\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingBackupBorrowed\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingAvailableAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingDepositAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingBorrowShares\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingDepositShares\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isCollateral\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingBorrowShares\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingDepositShares\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingDepositAssets\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previewValue\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"internalType\":\"struct FixedLib.Position\",\"name\":\"position\",\"type\":\"tuple\"}],\"internalType\":\"struct Previewer.FixedPosition[]\",\"name\":\"fixedDepositPositions\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previewValue\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"internalType\":\"struct FixedLib.Position\",\"name\":\"position\",\"type\":\"tuple\"}],\"internalType\":\"struct Previewer.FixedPosition[]\",\"name\":\"fixedBorrowPositions\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.ClaimableReward[]\",\"name\":\"claimableRewards\",\"type\":\"tuple[]\"}],\"internalType\":\"struct Previewer.MarketAccount[]\",\"name\":\"data\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewBorrowAtAllMaturities\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview[]\",\"name\":\"previews\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewBorrowAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewDepositAtAllMaturities\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview[]\",\"name\":\"previews\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewDepositAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionAssets\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"previewRepayAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionAssets\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"previewWithdrawAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"exactly(address)\":{\"params\":{\"account\":\"address which the extended data will be calculated.\"},\"returns\":{\"data\":\"extended accountability of all markets for the account.\"}},\"previewBorrowAtAllMaturities(address,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be borrowed.\",\"market\":\"address of the market.\"},\"returns\":{\"previews\":\"array containing amount plus yield that account will receive after each maturity.\"}},\"previewBorrowAtMaturity(address,uint256,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be borrowed.\",\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be borrowed.\"},\"returns\":{\"_0\":\"positionAssets amount plus fees that the depositor will repay at maturity.\"}},\"previewDepositAtAllMaturities(address,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be deposited.\",\"market\":\"address of the market.\"},\"returns\":{\"previews\":\"array containing amount plus yield that account will receive after each maturity.\"}},\"previewDepositAtMaturity(address,uint256,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be deposited.\",\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be deposited.\"},\"returns\":{\"_0\":\"amount plus yield that the depositor will receive after maturity.\"}},\"previewRepayAtMaturity(address,uint256,uint256,address)\":{\"params\":{\"borrower\":\"address of the borrower.\",\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be repaid.\",\"positionAssets\":\"amount of assets that will be subtracted from the position.\"},\"returns\":{\"_0\":\"repayAssets amount of assets that will be repaid.\"}},\"previewWithdrawAtMaturity(address,uint256,uint256,address)\":{\"params\":{\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be withdrawn.\",\"positionAssets\":\"amount of assets that will be tried to withdraw.\"},\"returns\":{\"_0\":\"withdrawAssets amount that will be withdrawn.\"}}},\"stateVariables\":{\"auditor\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"basePriceFeed\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"Previewer\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"exactly(address)\":{\"notice\":\"Function to get a certain account extended data.\"},\"previewBorrowAtAllMaturities(address,uint256)\":{\"notice\":\"Gets the assets plus fees offered by all VALID maturities when borrowing a certain amount.\"},\"previewBorrowAtMaturity(address,uint256,uint256)\":{\"notice\":\"Gets the amount plus fees to be repaid at maturity when borrowing certain amount of assets.\"},\"previewDepositAtAllMaturities(address,uint256)\":{\"notice\":\"Gets the assets plus yield offered by all VALID maturities when depositing a certain amount.\"},\"previewDepositAtMaturity(address,uint256,uint256)\":{\"notice\":\"Gets the assets plus yield offered by a maturity when depositing a certain amount.\"},\"previewRepayAtMaturity(address,uint256,uint256,address)\":{\"notice\":\"Gets the assets that will be repaid when repaying a certain amount at the current maturity.\"},\"previewWithdrawAtMaturity(address,uint256,uint256,address)\":{\"notice\":\"Gets the amount to be withdrawn for a certain positionAmount of assets at maturity.\"}},\"notice\":\"Contract to be consumed by Exactly's front-end dApp.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/Previewer.sol\":\"Previewer\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControlUpgradeable.sol\\\";\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../utils/StringsUpgradeable.sol\\\";\\nimport \\\"../utils/introspection/ERC165Upgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it.\\n */\\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\\n function __AccessControl_init() internal onlyInitializing {\\n }\\n\\n function __AccessControl_init_unchained() internal onlyInitializing {\\n }\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n StringsUpgradeable.toHexString(account),\\n \\\" is missing role \\\",\\n StringsUpgradeable.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xe8f27a3e3e25067334e76799f03d4de6d8f8535c3fc4806468228a9ebd5de51a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControlUpgradeable {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0xb8f5302f12138c5561362e88a78d061573e6298b7a1a5afe84a1e2c8d4d5aeaa\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized < type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x037c334add4b033ad3493038c25be1682d78c00992e1acb0e2795caff3925271\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n _requireNotPaused();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n _requirePaused();\\n _;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x40c636b4572ff5f1dc50cf22097e93c0723ee14eff87e99ac2b02636eeca1250\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2edcb41c121abc510932e8d83ff8b82cf9cdde35e7c297622f5c29ef0af25183\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n}\\n\",\"keccak256\":\"0x6b9a5d35b744b25529a2856a8093e7c03fb35a34b1c4fb5499e560f8ade140da\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\\n function __ERC165_init() internal onlyInitializing {\\n }\\n\\n function __ERC165_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165Upgradeable).interfaceId;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x9a3b990bd56d139df3e454a9edf1c64668530b5a77fc32eb063bc206f958274a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc1bd5b53319c68f84e3becd75694d941e8f4be94049903232cd8bc7c535aaa5a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1);\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(\\n uint256 x,\\n uint256 y,\\n uint256 denominator,\\n Rounding rounding\\n ) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10**64) {\\n value /= 10**64;\\n result += 64;\\n }\\n if (value >= 10**32) {\\n value /= 10**32;\\n result += 32;\\n }\\n if (value >= 10**16) {\\n value /= 10**16;\\n result += 16;\\n }\\n if (value >= 10**8) {\\n value /= 10**8;\\n result += 8;\\n }\\n if (value >= 10**4) {\\n value /= 10**4;\\n result += 4;\\n }\\n if (value >= 10**2) {\\n value /= 10**2;\\n result += 2;\\n }\\n if (value >= 10**1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa1e8e83cd0087785df04ac79fb395d9f3684caeaf973d9e2c71caef723a3a5d6\",\"license\":\"MIT\"},\"contracts/Auditor.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract Auditor is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n\\n /// @notice Address that a market should have as price feed to consider as base price and avoid external price call.\\n address public constant BASE_FEED = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\\n /// @notice Target health factor that the account should have after it's liquidated to prevent cascade liquidations.\\n uint256 public constant TARGET_HEALTH = 1.25e18;\\n /// @notice Maximum value the liquidator can send and still have granular control of max assets.\\n /// Above this threshold, they should send `type(uint256).max`.\\n uint256 public constant ASSETS_THRESHOLD = type(uint256).max / 1e18;\\n\\n /// @notice Decimals that the answer of all price feeds should have.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable priceDecimals;\\n /// @notice Base factor to scale the price returned by the feed to 18 decimals.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable baseFactor;\\n /// @notice Base price used if the feed to fetch the price from is `BASE_FEED`.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable basePrice;\\n\\n /// @notice Tracks the markets' indexes that an account has entered as collateral.\\n mapping(address => uint256) public accountMarkets;\\n /// @notice Stores market parameters per each enabled market.\\n mapping(Market => MarketData) public markets;\\n /// @notice Array of all enabled markets.\\n Market[] public marketList;\\n\\n /// @notice Liquidation incentive factors for the liquidator and the lenders of the market where the debt is repaid.\\n LiquidationIncentive public liquidationIncentive;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(uint256 priceDecimals_) {\\n priceDecimals = priceDecimals_;\\n baseFactor = 10 ** (18 - priceDecimals_);\\n basePrice = 10 ** priceDecimals_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(LiquidationIncentive memory liquidationIncentive_) external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setLiquidationIncentive(liquidationIncentive_);\\n }\\n\\n /// @notice Allows assets of a certain market to be used as collateral for borrowing other assets.\\n /// @param market market to enabled as collateral.\\n function enterMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) != 0) return;\\n accountMarkets[msg.sender] = marketMap | marketMask;\\n\\n emit MarketEntered(market, msg.sender);\\n }\\n\\n /// @notice Removes market from sender's account liquidity calculation.\\n /// @dev Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral\\n /// for an outstanding borrow.\\n /// @param market market to be disabled as collateral.\\n function exitMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n (uint256 assets, uint256 debt) = market.accountSnapshot(msg.sender);\\n\\n // fail if the sender has a borrow balance\\n if (debt != 0) revert RemainingDebt();\\n\\n // fail if the sender is not permitted to redeem all of their assets\\n checkShortfall(market, msg.sender, assets);\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) == 0) return;\\n accountMarkets[msg.sender] = marketMap & ~marketMask;\\n\\n emit MarketExited(market, msg.sender);\\n }\\n\\n /// @notice Returns account's liquidity calculation.\\n /// @param account account in which the liquidity will be calculated.\\n /// @param marketToSimulate market in which to simulate withdraw operation.\\n /// @param withdrawAmount amount to simulate as withdraw.\\n /// @return sumCollateral sum of all collateral, already multiplied by each adjust factor (denominated in base).\\n /// @return sumDebtPlusEffects sum of all debt divided by adjust factor considering withdrawal (denominated in base).\\n function accountLiquidity(\\n address account,\\n Market marketToSimulate,\\n uint256 withdrawAmount\\n ) public view returns (uint256 sumCollateral, uint256 sumDebtPlusEffects) {\\n AccountLiquidity memory vars; // holds all our calculation results\\n\\n // for each asset the account is in\\n uint256 marketMap = accountMarkets[account];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 baseUnit = 10 ** m.decimals;\\n uint256 adjustFactor = m.adjustFactor;\\n\\n // read the balances\\n (vars.balance, vars.borrowBalance) = market.accountSnapshot(account);\\n\\n // get the normalized price of the asset (18 decimals)\\n vars.price = assetPrice(m.priceFeed);\\n\\n // sum all the collateral prices\\n sumCollateral += vars.balance.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n\\n // sum all the debt\\n sumDebtPlusEffects += vars.borrowBalance.mulDivUp(vars.price, baseUnit).divWadUp(adjustFactor);\\n\\n // simulate the effects of withdrawing from a pool\\n if (market == marketToSimulate) {\\n // calculate the effects of redeeming markets\\n // (having less collateral is the same as having more debt for this calculation)\\n if (withdrawAmount != 0) {\\n sumDebtPlusEffects += withdrawAmount.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n }\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Validates that the current state of the position and system are valid.\\n /// @dev To be called after adding the borrowed debt to the account position.\\n /// @param market address of the market where the borrow is made.\\n /// @param borrower address of the account that will repay the debt.\\n function checkBorrow(Market market, address borrower) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[borrower];\\n uint256 marketMask = 1 << m.index;\\n\\n // validate borrow state\\n if ((marketMap & marketMask) == 0) {\\n // only markets may call checkBorrow if borrower not in market\\n if (msg.sender != address(market)) revert NotMarket();\\n\\n accountMarkets[borrower] = marketMap | marketMask;\\n emit MarketEntered(market, borrower);\\n }\\n\\n // verify that current liquidity is not short\\n (uint256 collateral, uint256 debt) = accountLiquidity(borrower, Market(address(0)), 0);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Checks if the account has liquidity shortfall.\\n /// @param market address of the market where the operation will happen.\\n /// @param account address of the account to check for possible shortfall.\\n /// @param amount amount that the account wants to withdraw or transfer.\\n function checkShortfall(Market market, address account, uint256 amount) public view {\\n // if the account is not 'in' the market, bypass the liquidity check\\n if ((accountMarkets[account] & (1 << markets[market].index)) == 0) return;\\n\\n // otherwise, perform a hypothetical liquidity check to guard against shortfall\\n (uint256 collateral, uint256 debt) = accountLiquidity(account, market, amount);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Allows/rejects liquidation of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt is being repaid.\\n /// @param seizeMarket market from where the liquidator will seize assets.\\n /// @param borrower address in which the assets are being liquidated.\\n /// @param maxLiquidatorAssets maximum amount of debt the liquidator is willing to accept.\\n /// @return maxRepayAssets capped amount of debt the liquidator is allowed to repay.\\n function checkLiquidation(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 maxLiquidatorAssets\\n ) external view returns (uint256 maxRepayAssets) {\\n // if markets are listed, they have the same auditor\\n if (!markets[repayMarket].isListed || !markets[seizeMarket].isListed) revert MarketNotListed();\\n\\n MarketVars memory repay;\\n LiquidityVars memory base;\\n uint256 marketMap = accountMarkets[borrower];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage marketData = markets[market];\\n MarketVars memory m = MarketVars({\\n price: assetPrice(marketData.priceFeed),\\n adjustFactor: marketData.adjustFactor,\\n baseUnit: 10 ** marketData.decimals\\n });\\n\\n if (market == repayMarket) repay = m;\\n\\n (uint256 collateral, uint256 debt) = market.accountSnapshot(borrower);\\n\\n uint256 value = debt.mulDivUp(m.price, m.baseUnit);\\n base.totalDebt += value;\\n base.adjustedDebt += value.divWadUp(m.adjustFactor);\\n\\n value = collateral.mulDivDown(m.price, m.baseUnit);\\n base.totalCollateral += value;\\n base.adjustedCollateral += value.mulWadDown(m.adjustFactor);\\n if (market == seizeMarket) base.seizeAvailable = value;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n if (base.adjustedCollateral >= base.adjustedDebt) revert InsufficientShortfall();\\n\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n uint256 adjustFactor = base.adjustedCollateral.mulWadDown(base.totalDebt).divWadUp(\\n base.adjustedDebt.mulWadUp(base.totalCollateral)\\n );\\n uint256 closeFactor = (TARGET_HEALTH - base.adjustedCollateral.divWadUp(base.adjustedDebt)).divWadUp(\\n TARGET_HEALTH - adjustFactor.mulWadDown(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n );\\n maxRepayAssets = Math.min(\\n Math\\n .min(\\n base.totalDebt.mulWadUp(Math.min(1e18, closeFactor)),\\n base.seizeAvailable.divWadUp(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n )\\n .mulDivUp(repay.baseUnit, repay.price),\\n maxLiquidatorAssets < ASSETS_THRESHOLD\\n ? maxLiquidatorAssets.divWadDown(1e18 + memIncentive.lenders)\\n : maxLiquidatorAssets\\n );\\n }\\n\\n /// @notice Allow/rejects seizing of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market where the assets will be seized.\\n function checkSeize(Market repayMarket, Market seizeMarket) external view {\\n // if markets are listed, they also point to the same Auditor\\n if (!markets[seizeMarket].isListed || !markets[repayMarket].isListed) revert MarketNotListed();\\n }\\n\\n /// @notice Calculates the amount of collateral to be seized when a position is undercollateralized.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market from where the assets will be seized by the liquidator.\\n /// @param borrower account in which assets are being seized.\\n /// @param actualRepayAssets amount being repaid.\\n /// @return lendersAssets amount to be added for other lenders as a compensation of bad debt clearing.\\n /// @return seizeAssets amount that can be seized by the liquidator.\\n function calculateSeize(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 actualRepayAssets\\n ) external view returns (uint256 lendersAssets, uint256 seizeAssets) {\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n lendersAssets = actualRepayAssets.mulWadDown(memIncentive.lenders);\\n\\n // read prices for borrowed and collateral markets\\n uint256 priceBorrowed = assetPrice(markets[repayMarket].priceFeed);\\n uint256 priceCollateral = assetPrice(markets[seizeMarket].priceFeed);\\n uint256 baseAmount = actualRepayAssets.mulDivUp(priceBorrowed, 10 ** markets[repayMarket].decimals);\\n\\n seizeAssets = Math.min(\\n baseAmount.mulDivUp(10 ** markets[seizeMarket].decimals, priceCollateral).mulWadUp(\\n 1e18 + memIncentive.liquidator + memIncentive.lenders\\n ),\\n seizeMarket.maxWithdraw(borrower)\\n );\\n }\\n\\n /// @notice Checks if account has debt with no collateral, if so then call `clearBadDebt` from each market.\\n /// @dev Collateral is multiplied by price and adjust factor to be accurately evaluated as positive collateral asset.\\n /// @param account account in which debt is being checked.\\n function handleBadDebt(address account) external {\\n uint256 memMarketMap = accountMarkets[account];\\n uint256 marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 assets = market.maxWithdraw(account);\\n if (assets.mulDivDown(assetPrice(m.priceFeed), 10 ** m.decimals).mulWadDown(m.adjustFactor) > 0) return;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) marketList[i].clearBadDebt(account);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the asset price of a price feed.\\n /// @dev If Chainlink's asset price is <= 0 the call is reverted.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price.\\n /// @return The price of the asset scaled to 18-digit decimals.\\n function assetPrice(IPriceFeed priceFeed) public view returns (uint256) {\\n if (address(priceFeed) == BASE_FEED) return basePrice;\\n\\n int256 price = priceFeed.latestAnswer();\\n if (price <= 0) revert InvalidPrice();\\n return uint256(price) * baseFactor;\\n }\\n\\n /// @notice Retrieves all markets.\\n function allMarkets() external view returns (Market[] memory) {\\n return marketList;\\n }\\n\\n /// @notice Enables a certain market.\\n /// @dev Enabling more than 256 markets will cause an overflow when casting market index to uint8.\\n /// @param market market to add to the protocol.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n /// @param adjustFactor market's adjust factor for the underlying asset.\\n function enableMarket(\\n Market market,\\n IPriceFeed priceFeed,\\n uint128 adjustFactor\\n ) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (market.auditor() != this) revert AuditorMismatch();\\n if (markets[market].isListed) revert MarketAlreadyListed();\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n\\n uint8 decimals = market.decimals();\\n markets[market] = MarketData({\\n isListed: true,\\n adjustFactor: adjustFactor,\\n decimals: decimals,\\n index: uint8(marketList.length),\\n priceFeed: priceFeed\\n });\\n\\n marketList.push(market);\\n\\n emit MarketListed(market, decimals);\\n emit PriceFeedSet(market, priceFeed);\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the adjust factor for a certain market.\\n /// @param market address of the market to change adjust factor for.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n function setAdjustFactor(Market market, uint128 adjustFactor) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (!markets[market].isListed) revert MarketNotListed();\\n\\n markets[market].adjustFactor = adjustFactor;\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the Chainlink Price Feed Aggregator source for a market.\\n /// @param market market address of the asset.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n function setPriceFeed(Market market, IPriceFeed priceFeed) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n markets[market].priceFeed = priceFeed;\\n emit PriceFeedSet(market, priceFeed);\\n }\\n\\n /// @notice Sets liquidation incentive (liquidator and lenders) for the whole ecosystem.\\n /// @param liquidationIncentive_ new liquidation incentive.\\n function setLiquidationIncentive(\\n LiquidationIncentive memory liquidationIncentive_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n liquidationIncentive = liquidationIncentive_;\\n emit LiquidationIncentiveSet(liquidationIncentive_);\\n }\\n\\n /// @notice Emitted when a new market is listed for borrow/lending.\\n /// @param market address of the market that was listed.\\n /// @param decimals decimals of the market's underlying asset.\\n event MarketListed(Market indexed market, uint8 decimals);\\n\\n /// @notice Emitted when an account enters a market to use his deposit as collateral for a loan.\\n /// @param market address of the market that the account entered.\\n /// @param account address of the account that just entered a market.\\n event MarketEntered(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when an account leaves a market.\\n /// Means that they would stop using their deposit as collateral and won't ask for any loans in this market.\\n /// @param market address of the market that the account just left.\\n /// @param account address of the account that just left a market.\\n event MarketExited(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when a adjust factor is changed by admin.\\n /// @param market address of the market that has a new adjust factor.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n event AdjustFactorSet(Market indexed market, uint256 adjustFactor);\\n\\n /// @notice Emitted when a new liquidationIncentive has been set.\\n /// @param liquidationIncentive represented with 18 decimals.\\n event LiquidationIncentiveSet(LiquidationIncentive liquidationIncentive);\\n\\n /// @notice Emitted when a market and prie feed is changed by admin.\\n /// @param market address of the asset used to get the price.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n event PriceFeedSet(Market indexed market, IPriceFeed indexed priceFeed);\\n\\n /// @notice Stores the market parameters used for liquidity calculations.\\n /// @param adjustFactor used to asses the lending power of the market's underlying asset.\\n /// @param decimals number of decimals of the market's underlying asset.\\n /// @param index index of the market in the `marketList`.\\n /// @param isListed true if the market is enabled.\\n /// @param priceFeed address of the price feed used to query the asset's price.\\n struct MarketData {\\n uint128 adjustFactor;\\n uint8 decimals;\\n uint8 index;\\n bool isListed;\\n IPriceFeed priceFeed;\\n }\\n\\n /// @notice Stores the liquidator and lenders factors used in liquidations to calculate the amount to seize.\\n /// @param liquidator factor used to calculate the extra bonus a liquidator can seize.\\n /// @param lenders factor used to calculate the bonus that the pool lenders receive.\\n struct LiquidationIncentive {\\n uint128 liquidator;\\n uint128 lenders;\\n }\\n\\n /// @notice Used as memory access to temporary store account liquidity data.\\n /// @param balance collateral balance of the account.\\n /// @param borrowBalance borrow balance of the account.\\n /// @param price asset price returned by the price feed with 18 decimals.\\n struct AccountLiquidity {\\n uint256 balance;\\n uint256 borrowBalance;\\n uint256 price;\\n }\\n}\\n\\nerror AuditorMismatch();\\nerror InsufficientAccountLiquidity();\\nerror InsufficientShortfall();\\nerror InvalidPrice();\\nerror InvalidPriceFeed();\\nerror MarketAlreadyListed();\\nerror MarketNotListed();\\nerror NotMarket();\\nerror RemainingDebt();\\n\\nstruct MarketVars {\\n uint256 price;\\n uint256 baseUnit;\\n uint128 adjustFactor;\\n}\\n\\nstruct LiquidityVars {\\n uint256 totalDebt;\\n uint256 totalCollateral;\\n uint256 adjustedDebt;\\n uint256 adjustedCollateral;\\n uint256 seizeAvailable;\\n}\\n\",\"keccak256\":\"0x93d487fdf861e8f58edca8058bffec88f31d280846420faec8e3e7049d3068fd\",\"license\":\"BUSL-1.1\"},\"contracts/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\ncontract InterestRateModel {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n\\n /// @notice Threshold to define which method should be used to calculate the interest rates.\\n /// @dev When `eta` (`delta / alpha`) is lower than this value, use simpson's rule for approximation.\\n uint256 internal constant PRECISION_THRESHOLD = 7.5e14;\\n\\n /// @notice Scale factor of the fixed curve.\\n uint256 public immutable fixedCurveA;\\n /// @notice Origin intercept of the fixed curve.\\n int256 public immutable fixedCurveB;\\n /// @notice Asymptote of the fixed curve.\\n uint256 public immutable fixedMaxUtilization;\\n\\n /// @notice Scale factor of the floating curve.\\n uint256 public immutable floatingCurveA;\\n /// @notice Origin intercept of the floating curve.\\n int256 public immutable floatingCurveB;\\n /// @notice Asymptote of the floating curve.\\n uint256 public immutable floatingMaxUtilization;\\n\\n constructor(\\n uint256 fixedCurveA_,\\n int256 fixedCurveB_,\\n uint256 fixedMaxUtilization_,\\n uint256 floatingCurveA_,\\n int256 floatingCurveB_,\\n uint256 floatingMaxUtilization_\\n ) {\\n assert(fixedMaxUtilization_ > 1e18);\\n assert(floatingMaxUtilization_ > 1e18);\\n\\n fixedCurveA = fixedCurveA_;\\n fixedCurveB = fixedCurveB_;\\n fixedMaxUtilization = fixedMaxUtilization_;\\n\\n floatingCurveA = floatingCurveA_;\\n floatingCurveB = floatingCurveB_;\\n floatingMaxUtilization = floatingMaxUtilization_;\\n\\n // reverts if it's an invalid curve (such as one yielding a negative interest rate).\\n fixedRate(0, 0);\\n floatingRate(0);\\n }\\n\\n /// @notice Gets the rate to borrow a certain amount at a certain maturity with supply/demand values in the fixed rate\\n /// pool and assets from the backup supplier.\\n /// @param maturity maturity date for calculating days left to maturity.\\n /// @param amount the current borrow's amount.\\n /// @param borrowed ex-ante amount borrowed from this fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay (represented with 18 decimals).\\n function fixedBorrowRate(\\n uint256 maturity,\\n uint256 amount,\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256) {\\n if (block.timestamp >= maturity) revert AlreadyMatured();\\n\\n uint256 potentialAssets = supplied + backupAssets;\\n uint256 utilizationAfter = (borrowed + amount).divWadUp(potentialAssets);\\n\\n if (utilizationAfter > 1e18) revert UtilizationExceeded();\\n\\n uint256 utilizationBefore = borrowed.divWadDown(potentialAssets);\\n\\n return fixedRate(utilizationBefore, utilizationAfter).mulDivDown(maturity - block.timestamp, 365 days);\\n }\\n\\n /// @notice Returns the current annualized fixed rate to borrow with supply/demand values in the fixed rate pool and\\n /// assets from the backup supplier.\\n /// @param borrowed amount borrowed from the fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay, with 18 decimals precision.\\n /// @return utilization current utilization rate, with 18 decimals precision.\\n function minFixedRate(\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256 rate, uint256 utilization) {\\n utilization = borrowed.divWadUp(supplied + backupAssets);\\n rate = fixedRate(utilization, utilization);\\n }\\n\\n /// @notice Returns the interest rate integral from `u0` to `u1`, using the analytical solution (ln).\\n /// @dev Uses the fixed rate curve parameters.\\n /// Handles special case where delta utilization tends to zero, using simpson's rule.\\n /// @param utilizationBefore ex-ante utilization rate, with 18 decimals precision.\\n /// @param utilizationAfter ex-post utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function fixedRate(uint256 utilizationBefore, uint256 utilizationAfter) internal view returns (uint256) {\\n uint256 alpha = fixedMaxUtilization - utilizationBefore;\\n uint256 delta = utilizationAfter - utilizationBefore;\\n int256 r = int256(\\n delta.divWadDown(alpha) < PRECISION_THRESHOLD\\n ? (fixedCurveA.divWadDown(alpha) +\\n fixedCurveA.mulDivDown(4e18, fixedMaxUtilization - ((utilizationAfter + utilizationBefore) / 2)) +\\n fixedCurveA.divWadDown(fixedMaxUtilization - utilizationAfter)) / 6\\n : fixedCurveA.mulDivDown(\\n uint256(int256(alpha.divWadDown(fixedMaxUtilization - utilizationAfter)).lnWad()),\\n delta\\n )\\n ) + fixedCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n\\n /// @notice Returns the interest rate for an utilization rate.\\n /// @dev Uses the floating rate curve parameters.\\n /// @param utilization utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function floatingRate(uint256 utilization) public view returns (uint256) {\\n int256 r = int256(floatingCurveA.divWadDown(floatingMaxUtilization - utilization)) + floatingCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n}\\n\\nerror AlreadyMatured();\\nerror UtilizationExceeded();\\n\",\"keccak256\":\"0xfb1d32f03bb869906ce577bb0e4cbc3e141006c7087f4e826ce513a9c4582f57\",\"license\":\"BUSL-1.1\"},\"contracts/Market.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { ERC4626, ERC20, SafeTransferLib } from \\\"solmate/src/mixins/ERC4626.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"./RewardsController.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\n\\ncontract Market is Initializable, AccessControlUpgradeable, PausableUpgradeable, ERC4626 {\\n using FixedPointMathLib for int256;\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint128;\\n using SafeTransferLib for ERC20;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for uint256;\\n\\n bytes32 public constant PAUSER_ROLE = keccak256(\\\"PAUSER_ROLE\\\");\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n\\n /// @notice Tracks account's fixed deposit positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedDepositPositions;\\n /// @notice Tracks account's fixed borrow positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedBorrowPositions;\\n /// @notice Tracks fixed pools state by maturity.\\n mapping(uint256 => FixedLib.Pool) public fixedPools;\\n\\n /// @notice Tracks fixed deposit and borrow map and floating borrow shares of an account.\\n mapping(address => Account) public accounts;\\n\\n /// @notice Amount of assets lent by the floating pool to the fixed pools.\\n uint256 public floatingBackupBorrowed;\\n /// @notice Amount of assets lent by the floating pool to accounts.\\n uint256 public floatingDebt;\\n\\n /// @notice Accumulated earnings from extraordinary sources to be gradually distributed.\\n uint256 public earningsAccumulator;\\n /// @notice Rate per second to be charged to delayed fixed pools borrowers after maturity.\\n uint256 public penaltyRate;\\n /// @notice Rate charged to the fixed pool to be retained by the floating pool for initially providing liquidity.\\n uint256 public backupFeeRate;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is higher.\\n uint256 public dampSpeedUp;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is lower.\\n uint256 public dampSpeedDown;\\n\\n /// @notice Number of fixed pools to be active at the same time.\\n uint8 public maxFuturePools;\\n /// @notice Last time the accumulator distributed earnings.\\n uint32 public lastAccumulatorAccrual;\\n /// @notice Last time the floating debt was updated.\\n uint32 public lastFloatingDebtUpdate;\\n /// @notice Last time the floating assets average was updated.\\n uint32 public lastAverageUpdate;\\n\\n /// @notice Interest rate model contract used to get the borrow rates.\\n InterestRateModel public interestRateModel;\\n\\n /// @notice Factor used for gradual accrual of earnings to the floating pool.\\n uint128 public earningsAccumulatorSmoothFactor;\\n /// @notice Percentage factor that represents the liquidity reserves that can't be borrowed.\\n uint128 public reserveFactor;\\n\\n /// @notice Amount of floating assets deposited to the pool.\\n uint256 public floatingAssets;\\n /// @notice Average of the floating assets to get fixed borrow rates and prevent rate manipulation.\\n uint256 public floatingAssetsAverage;\\n\\n /// @notice Total amount of floating borrow shares assigned to floating borrow accounts.\\n uint256 public totalFloatingBorrowShares;\\n\\n /// @dev gap from deprecated state.\\n /// @custom:oz-renamed-from floatingUtilization\\n uint256 private __gap;\\n\\n /// @notice Address of the treasury that will receive the allocated earnings.\\n address public treasury;\\n /// @notice Rate to be charged by the treasury to floating and fixed borrows.\\n uint256 public treasuryFeeRate;\\n\\n /// @notice Address of the rewards controller that will accrue rewards for accounts operating with the Market.\\n RewardsController public rewardsController;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(ERC20 asset_, Auditor auditor_) ERC4626(asset_, \\\"\\\", \\\"\\\") {\\n auditor = auditor_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(\\n uint8 maxFuturePools_,\\n uint128 earningsAccumulatorSmoothFactor_,\\n InterestRateModel interestRateModel_,\\n uint256 penaltyRate_,\\n uint256 backupFeeRate_,\\n uint128 reserveFactor_,\\n uint256 dampSpeedUp_,\\n uint256 dampSpeedDown_\\n ) external initializer {\\n __AccessControl_init();\\n __Pausable_init();\\n\\n string memory assetSymbol = asset.symbol();\\n name = string.concat(\\\"exactly \\\", assetSymbol);\\n symbol = string.concat(\\\"exa\\\", assetSymbol);\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n lastAverageUpdate = uint32(block.timestamp);\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setMaxFuturePools(maxFuturePools_);\\n setEarningsAccumulatorSmoothFactor(earningsAccumulatorSmoothFactor_);\\n setInterestRateModel(interestRateModel_);\\n setPenaltyRate(penaltyRate_);\\n setBackupFeeRate(backupFeeRate_);\\n setReserveFactor(reserveFactor_);\\n setDampSpeed(dampSpeedUp_, dampSpeedDown_);\\n }\\n\\n /// @notice Borrows a certain amount from the floating pool.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return borrowShares shares corresponding to the borrowed assets.\\n function borrow(\\n uint256 assets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 borrowShares) {\\n spendAllowance(borrower, assets);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n\\n borrowShares = previewBorrow(assets);\\n\\n uint256 newFloatingDebt = floatingDebt + assets;\\n floatingDebt = newFloatingDebt;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed, also considering the reserves\\n if (floatingBackupBorrowed + newFloatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n\\n totalFloatingBorrowShares += borrowShares;\\n accounts[borrower].floatingBorrowShares += borrowShares;\\n\\n emit Borrow(msg.sender, receiver, borrower, assets, borrowShares);\\n emitMarketUpdate();\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Repays a certain amount of assets to the floating pool.\\n /// @param assets assets to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepay the actual amount that should be transferred into the protocol.\\n /// @return borrowShares subtracted shares from the borrower's accountability.\\n function repay(\\n uint256 assets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepay, uint256 borrowShares) {\\n (actualRepay, borrowShares) = noTransferRefund(previewRepay(assets), borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), actualRepay);\\n }\\n\\n /// @notice Repays a certain amount of shares to the floating pool.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return assets subtracted assets from the borrower's accountability.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function refund(\\n uint256 borrowShares,\\n address borrower\\n ) external whenNotPaused returns (uint256 assets, uint256 actualShares) {\\n (assets, actualShares) = noTransferRefund(borrowShares, borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Allows to (partially) repay a floating borrow. It does not transfer assets.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower the address of the account that has the debt.\\n /// @return assets the actual amount that should be transferred into the protocol.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function noTransferRefund(\\n uint256 borrowShares,\\n address borrower\\n ) internal returns (uint256 assets, uint256 actualShares) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n Account storage account = accounts[borrower];\\n uint256 accountBorrowShares = account.floatingBorrowShares;\\n actualShares = Math.min(borrowShares, accountBorrowShares);\\n assets = previewRefund(actualShares);\\n\\n if (assets == 0) revert ZeroRepay();\\n\\n floatingDebt -= assets;\\n account.floatingBorrowShares = accountBorrowShares - actualShares;\\n totalFloatingBorrowShares -= actualShares;\\n\\n emit Repay(msg.sender, borrower, assets, actualShares);\\n }\\n\\n /// @notice Deposits a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be deposited.\\n /// @param assets amount to receive from the msg.sender.\\n /// @param minAssetsRequired minimum amount of assets required by the depositor for the transaction to be accepted.\\n /// @param receiver address that will be able to withdraw the deposited assets.\\n /// @return positionAssets total amount of assets (principal + fee) to be withdrawn at maturity.\\n function depositAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 minAssetsRequired,\\n address receiver\\n ) external whenNotPaused returns (uint256 positionAssets) {\\n if (assets == 0) revert ZeroDeposit();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n (uint256 fee, uint256 backupFee) = pool.calculateDeposit(assets, backupFeeRate);\\n positionAssets = assets + fee;\\n if (positionAssets < minAssetsRequired) revert Disagreement();\\n\\n floatingBackupBorrowed -= pool.deposit(assets);\\n pool.unassignedEarnings -= fee + backupFee;\\n earningsAccumulator += backupFee;\\n\\n // update account's position\\n FixedLib.Position storage position = fixedDepositPositions[maturity][receiver];\\n\\n // if account doesn't have a current position, add it to the list\\n if (position.principal == 0) {\\n Account storage account = accounts[receiver];\\n account.fixedDeposits = account.fixedDeposits.setMaturity(maturity);\\n }\\n\\n position.principal += assets;\\n position.fee += fee;\\n\\n floatingAssets += backupEarnings;\\n\\n emit DepositAtMaturity(maturity, msg.sender, receiver, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Borrows a certain amount from a maturity.\\n /// @param maturity maturity date for repayment.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return assetsOwed total amount of assets (principal + fee) to be repaid at maturity.\\n function borrowAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 maxAssets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 assetsOwed) {\\n if (assets == 0) revert ZeroBorrow();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n uint256 fee = assets.mulWadDown(\\n interestRateModel.fixedBorrowRate(maturity, assets, pool.borrowed, pool.supplied, previewFloatingAssetsAverage())\\n );\\n assetsOwed = assets + fee;\\n\\n // validate that the account is not taking arbitrary fees\\n if (assetsOwed > maxAssets) revert Disagreement();\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n spendAllowance(borrower, assetsOwed);\\n\\n {\\n uint256 backupDebtAddition = pool.borrow(assets);\\n if (backupDebtAddition > 0) {\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed + backupDebtAddition;\\n depositToTreasury(updateFloatingDebt());\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n }\\n\\n {\\n // if account doesn't have a current position, add it to the list\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n if (position.principal == 0) {\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.setMaturity(maturity);\\n }\\n\\n // calculate what portion of the fees are to be accrued and what portion goes to earnings accumulator\\n (uint256 newUnassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(fee),\\n assets\\n );\\n if (newUnassignedEarnings > 0) pool.unassignedEarnings += newUnassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n fixedBorrowPositions[maturity][borrower] = FixedLib.Position(position.principal + assets, position.fee + fee);\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit BorrowAtMaturity(maturity, msg.sender, receiver, borrower, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Withdraws a certain amount from a maturity.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param maturity maturity date where the assets will be withdrawn.\\n /// @param positionAssets position size to be reduced.\\n /// @param minAssetsRequired minimum amount required by the account (if discount included for early withdrawal).\\n /// @param receiver address that will receive the withdrawn assets.\\n /// @param owner address that previously deposited the assets.\\n /// @return assetsDiscounted amount of assets withdrawn (can include a discount for early withdraw).\\n function withdrawAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 minAssetsRequired,\\n address receiver,\\n address owner\\n ) external returns (uint256 assetsDiscounted) {\\n if (positionAssets == 0) revert ZeroWithdraw();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedDepositPositions[maturity][owner];\\n\\n if (positionAssets > position.principal + position.fee) positionAssets = position.principal + position.fee;\\n\\n // verify if there are any penalties/fee for the account because of early withdrawal, if so discount\\n if (block.timestamp < maturity) {\\n assetsDiscounted = positionAssets.divWadDown(\\n 1e18 +\\n interestRateModel.fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n previewFloatingAssetsAverage()\\n )\\n );\\n } else {\\n assetsDiscounted = positionAssets;\\n }\\n\\n if (assetsDiscounted < minAssetsRequired) revert Disagreement();\\n\\n spendAllowance(owner, assetsDiscounted);\\n\\n {\\n // remove the supply from the fixed rate pool\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed +\\n pool.withdraw(\\n FixedLib.Position(position.principal, position.fee).scaleProportionally(positionAssets).principal\\n );\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets) revert InsufficientProtocolLiquidity();\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n\\n // all the fees go to unassigned or to the floating pool\\n (uint256 unassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(positionAssets - assetsDiscounted),\\n assetsDiscounted\\n );\\n pool.unassignedEarnings += unassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n // the account gets discounted the full amount\\n position.reduceProportionally(positionAssets);\\n if (position.principal | position.fee == 0) {\\n delete fixedDepositPositions[maturity][owner];\\n Account storage account = accounts[owner];\\n account.fixedDeposits = account.fixedDeposits.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedDepositPositions[maturity][owner] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit WithdrawAtMaturity(maturity, msg.sender, receiver, owner, positionAssets, assetsDiscounted);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransfer(receiver, assetsDiscounted);\\n }\\n\\n /// @notice Repays a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be repaid.\\n /// @param positionAssets amount to be paid for the borrower's debt.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepayAssets the actual amount that was transferred into the protocol.\\n function repayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepayAssets) {\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n actualRepayAssets = noTransferRepayAtMaturity(maturity, positionAssets, maxAssets, borrower, true);\\n emitMarketUpdate();\\n\\n asset.safeTransferFrom(msg.sender, address(this), actualRepayAssets);\\n }\\n\\n /// @notice Allows to (partially) repay a fixed rate position. It does not transfer assets.\\n /// @param maturity the maturity to access the pool.\\n /// @param positionAssets the amount of debt of the pool that should be paid.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower the address of the account that has the debt.\\n /// @param canDiscount should early repay discounts be applied.\\n /// @return actualRepayAssets the actual amount that should be transferred into the protocol.\\n function noTransferRepayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower,\\n bool canDiscount\\n ) internal returns (uint256 actualRepayAssets) {\\n if (positionAssets == 0) revert ZeroRepay();\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedBorrowPositions[maturity][borrower];\\n\\n uint256 debtCovered = Math.min(positionAssets, position.principal + position.fee);\\n\\n uint256 principalCovered = FixedLib\\n .Position(position.principal, position.fee)\\n .scaleProportionally(debtCovered)\\n .principal;\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n // early repayment allows a discount from the unassigned earnings\\n if (block.timestamp < maturity) {\\n if (canDiscount) {\\n // calculate the deposit fee considering the amount of debt the account'll pay\\n (uint256 discountFee, uint256 backupFee) = pool.calculateDeposit(principalCovered, backupFeeRate);\\n\\n // remove the fee from unassigned earnings\\n pool.unassignedEarnings -= discountFee + backupFee;\\n\\n // the fee charged to the fixed pool supplier goes to the earnings accumulator\\n earningsAccumulator += backupFee;\\n\\n // the fee gets discounted from the account through `actualRepayAssets`\\n actualRepayAssets = debtCovered - discountFee;\\n } else {\\n actualRepayAssets = debtCovered;\\n }\\n } else {\\n actualRepayAssets = debtCovered + debtCovered.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n\\n // all penalties go to the earnings accumulator\\n earningsAccumulator += actualRepayAssets - debtCovered;\\n }\\n\\n // verify that the account agrees to this discount or penalty\\n if (actualRepayAssets > maxAssets) revert Disagreement();\\n\\n // reduce the borrowed from the pool and might decrease the floating backup borrowed\\n floatingBackupBorrowed -= pool.repay(principalCovered);\\n\\n // update the account position\\n position.reduceProportionally(debtCovered);\\n if (position.principal | position.fee == 0) {\\n delete fixedBorrowPositions[maturity][borrower];\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedBorrowPositions[maturity][borrower] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, actualRepayAssets, debtCovered);\\n emitFixedEarningsUpdate(maturity);\\n }\\n\\n /// @notice Liquidates undercollateralized fixed/floating (or both) position(s).\\n /// @dev Msg.sender liquidates borrower's position(s) and repays a certain amount of debt for the floating pool,\\n /// or/and for multiple fixed pools, seizing a portion of borrower's collateral.\\n /// @param borrower account that has an outstanding debt across floating or fixed pools.\\n /// @param maxAssets maximum amount of debt that the liquidator is willing to accept. (it can be less)\\n /// @param seizeMarket market from which the collateral will be seized to give to the liquidator.\\n /// @return repaidAssets actual amount repaid.\\n function liquidate(\\n address borrower,\\n uint256 maxAssets,\\n Market seizeMarket\\n ) external whenNotPaused returns (uint256 repaidAssets) {\\n if (msg.sender == borrower) revert SelfLiquidation();\\n\\n maxAssets = auditor.checkLiquidation(this, seizeMarket, borrower, maxAssets);\\n if (maxAssets == 0) revert ZeroRepay();\\n\\n Account storage account = accounts[borrower];\\n\\n {\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0 && maxAssets != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 actualRepay;\\n if (block.timestamp < maturity) {\\n actualRepay = noTransferRepayAtMaturity(maturity, maxAssets, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n } else {\\n uint256 position;\\n {\\n FixedLib.Position storage p = fixedBorrowPositions[maturity][borrower];\\n position = p.principal + p.fee;\\n }\\n uint256 debt = position + position.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n actualRepay = debt > maxAssets ? maxAssets.mulDivDown(position, debt) : maxAssets;\\n\\n if (actualRepay == 0) maxAssets = 0;\\n else {\\n actualRepay = noTransferRepayAtMaturity(maturity, actualRepay, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n }\\n }\\n repaidAssets += actualRepay;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n if (maxAssets > 0 && account.floatingBorrowShares > 0) {\\n uint256 borrowShares = previewRepay(maxAssets);\\n if (borrowShares > 0) {\\n (uint256 actualRepayAssets, ) = noTransferRefund(borrowShares, borrower);\\n repaidAssets += actualRepayAssets;\\n }\\n }\\n\\n // reverts on failure\\n (uint256 lendersAssets, uint256 seizeAssets) = auditor.calculateSeize(this, seizeMarket, borrower, repaidAssets);\\n earningsAccumulator += lendersAssets;\\n\\n if (address(seizeMarket) == address(this)) {\\n internalSeize(this, msg.sender, borrower, seizeAssets);\\n } else {\\n seizeMarket.seize(msg.sender, borrower, seizeAssets);\\n\\n emitMarketUpdate();\\n }\\n\\n emit Liquidate(msg.sender, borrower, repaidAssets, lendersAssets, seizeMarket, seizeAssets);\\n\\n auditor.handleBadDebt(borrower);\\n\\n asset.safeTransferFrom(msg.sender, address(this), repaidAssets + lendersAssets);\\n }\\n\\n /// @notice Clears floating and fixed debt for an account spreading the losses to the `earningsAccumulator`.\\n /// @dev Can only be called from the auditor.\\n /// @param borrower account with insufficient collateral to be cleared the debt.\\n function clearBadDebt(address borrower) external {\\n if (msg.sender != address(auditor)) revert NotAuditor();\\n\\n floatingAssets += accrueAccumulatedEarnings();\\n Account storage account = accounts[borrower];\\n uint256 accumulator = earningsAccumulator;\\n uint256 totalBadDebt = 0;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 badDebt = position.principal + position.fee;\\n if (accumulator >= badDebt) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n accumulator -= badDebt;\\n totalBadDebt += badDebt;\\n floatingBackupBorrowed -= fixedPools[maturity].repay(position.principal);\\n delete fixedBorrowPositions[maturity][borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, badDebt, badDebt);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n if (account.floatingBorrowShares > 0 && (accumulator = previewRepay(accumulator)) > 0) {\\n (uint256 badDebt, ) = noTransferRefund(accumulator, borrower);\\n totalBadDebt += badDebt;\\n }\\n if (totalBadDebt > 0) {\\n earningsAccumulator -= totalBadDebt;\\n emit SpreadBadDebt(borrower, totalBadDebt);\\n }\\n emitMarketUpdate();\\n }\\n\\n /// @notice Public function to seize a certain amount of assets.\\n /// @dev Public function for liquidator to seize borrowers assets in the floating pool.\\n /// This function will only be called from another Market, on `liquidation` calls.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function seize(address liquidator, address borrower, uint256 assets) external whenNotPaused {\\n internalSeize(Market(msg.sender), liquidator, borrower, assets);\\n }\\n\\n /// @notice Internal function to seize a certain amount of assets.\\n /// @dev Internal function for liquidator to seize borrowers assets in the floating pool.\\n /// Will only be called from this Market on `liquidation` or through `seize` calls from another Market.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param seizeMarket address which is calling the seize function (see `seize` public function).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function internalSeize(Market seizeMarket, address liquidator, address borrower, uint256 assets) internal {\\n if (assets == 0) revert ZeroWithdraw();\\n\\n // reverts on failure\\n auditor.checkSeize(seizeMarket, this);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(borrower);\\n uint256 shares = previewWithdraw(assets);\\n beforeWithdraw(assets, shares);\\n _burn(borrower, shares);\\n emit Withdraw(msg.sender, liquidator, borrower, assets, shares);\\n emit Seize(liquidator, borrower, assets);\\n emitMarketUpdate();\\n\\n asset.safeTransfer(liquidator, assets);\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param assets amount of assets to be withdrawn from the floating pool.\\n function beforeWithdraw(uint256 assets, uint256) internal override {\\n updateFloatingAssetsAverage();\\n depositToTreasury(updateFloatingDebt());\\n uint256 earnings = accrueAccumulatedEarnings();\\n uint256 newFloatingAssets = floatingAssets + earnings - assets;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed\\n if (floatingBackupBorrowed + floatingDebt > newFloatingAssets) revert InsufficientProtocolLiquidity();\\n floatingAssets = newFloatingAssets;\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @param assets amount of assets to be deposited to the floating pool.\\n function afterDeposit(uint256 assets, uint256) internal override whenNotPaused {\\n updateFloatingAssetsAverage();\\n uint256 treasuryFee = updateFloatingDebt();\\n uint256 earnings = accrueAccumulatedEarnings();\\n floatingAssets += earnings + assets;\\n depositToTreasury(treasuryFee);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Withdraws the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param assets amount of underlying to be withdrawn.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return shares amount of shares redeemed for underlying asset.\\n function withdraw(uint256 assets, address receiver, address owner) public override returns (uint256 shares) {\\n auditor.checkShortfall(this, owner, assets);\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n shares = super.withdraw(assets, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Redeems the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param shares amount of shares to be redeemed for underlying asset.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return assets amount of underlying asset that was withdrawn.\\n function redeem(uint256 shares, address receiver, address owner) public override returns (uint256 assets) {\\n auditor.checkShortfall(this, owner, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n assets = super.redeem(shares, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n function _mint(address to, uint256 amount) internal override {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(to);\\n super._mint(to, amount);\\n }\\n\\n /// @notice Moves amount of shares from the caller's account to `to`.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that the caller doesn't have shortfall after transferring.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transfer(address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, msg.sender, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(msg.sender);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transfer(to, shares);\\n }\\n\\n /// @notice Moves amount of shares from `from` to `to` using the allowance mechanism.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that `from` address doesn't have shortfall after transferring.\\n /// @param from address from which the assets will be transferred.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transferFrom(address from, address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, from, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(from);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transferFrom(from, to, shares);\\n }\\n\\n /// @notice Gets current snapshot for an account across all maturities.\\n /// @param account account to return status snapshot in the specified maturity date.\\n /// @return the amount deposited to the floating pool and the amount owed to floating and fixed pools.\\n function accountSnapshot(address account) external view returns (uint256, uint256) {\\n return (convertToAssets(balanceOf[account]), previewDebt(account));\\n }\\n\\n /// @notice Gets all borrows and penalties for an account.\\n /// @param borrower account to return status snapshot for fixed and floating borrows.\\n /// @return debt the total debt, denominated in number of assets.\\n function previewDebt(address borrower) public view returns (uint256 debt) {\\n Account storage account = accounts[borrower];\\n uint256 memPenaltyRate = penaltyRate;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n // calculate all maturities using the base maturity and the following bits representing the following intervals\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 positionAssets = position.principal + position.fee;\\n\\n debt += positionAssets;\\n\\n if (block.timestamp > maturity) {\\n debt += positionAssets.mulWadDown((block.timestamp - maturity) * memPenaltyRate);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n // calculate floating borrowed debt\\n uint256 shares = account.floatingBorrowShares;\\n if (shares > 0) debt += previewRefund(shares);\\n }\\n\\n /// @notice Charges treasury fee to certain amount of earnings.\\n /// @param earnings amount of earnings.\\n /// @return earnings minus the fees charged by the treasury.\\n function chargeTreasuryFee(uint256 earnings) internal returns (uint256) {\\n uint256 fee = earnings.mulWadDown(treasuryFeeRate);\\n depositToTreasury(fee);\\n return earnings - fee;\\n }\\n\\n /// @notice Collects all earnings that are charged to borrowers that make use of fixed pool deposits' assets.\\n /// @param earnings amount of earnings.\\n function collectFreeLunch(uint256 earnings) internal {\\n if (earnings == 0) return;\\n\\n if (treasuryFeeRate > 0) {\\n depositToTreasury(earnings);\\n } else {\\n earningsAccumulator += earnings;\\n }\\n }\\n\\n /// @notice Deposits amount of assets on behalf of the treasury address.\\n /// @param fee amount of assets to be deposited.\\n function depositToTreasury(uint256 fee) internal {\\n if (fee > 0) {\\n _mint(treasury, previewDeposit(fee));\\n floatingAssets += fee;\\n }\\n }\\n\\n /// @notice Calculates the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings to be distributed from the accumulator.\\n function accumulatedEarnings() internal view returns (uint256 earnings) {\\n uint256 elapsed = block.timestamp - lastAccumulatorAccrual;\\n if (elapsed == 0) return 0;\\n return\\n earningsAccumulator.mulDivDown(\\n elapsed,\\n elapsed + earningsAccumulatorSmoothFactor.mulWadDown(maxFuturePools * FixedLib.INTERVAL)\\n );\\n }\\n\\n /// @notice Accrues the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings distributed from the accumulator.\\n function accrueAccumulatedEarnings() internal returns (uint256 earnings) {\\n earnings = accumulatedEarnings();\\n\\n earningsAccumulator -= earnings;\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n emit AccumulatorAccrual(block.timestamp);\\n }\\n\\n /// @notice Updates the `floatingAssetsAverage`.\\n function updateFloatingAssetsAverage() internal {\\n floatingAssetsAverage = previewFloatingAssetsAverage();\\n lastAverageUpdate = uint32(block.timestamp);\\n }\\n\\n /// @notice Returns the current `floatingAssetsAverage` without updating the storage variable.\\n /// @return projected `floatingAssetsAverage`.\\n function previewFloatingAssetsAverage() public view returns (uint256) {\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 memFloatingAssetsAverage = floatingAssetsAverage;\\n uint256 dampSpeedFactor = memFloatingAssets < memFloatingAssetsAverage ? dampSpeedDown : dampSpeedUp;\\n uint256 averageFactor = uint256(1e18 - (-int256(dampSpeedFactor * (block.timestamp - lastAverageUpdate))).expWad());\\n return memFloatingAssetsAverage.mulWadDown(1e18 - averageFactor) + averageFactor.mulWadDown(memFloatingAssets);\\n }\\n\\n /// @notice Updates the floating pool borrows' variables.\\n /// @return treasuryFee amount of fees charged by the treasury to the new calculated floating debt.\\n function updateFloatingDebt() internal returns (uint256 treasuryFee) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n\\n memFloatingDebt += newDebt;\\n treasuryFee = newDebt.mulWadDown(treasuryFeeRate);\\n floatingAssets = memFloatingAssets + newDebt - treasuryFee;\\n floatingDebt = memFloatingDebt;\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n emit FloatingDebtUpdate(block.timestamp, floatingUtilization);\\n }\\n\\n /// @notice Calculates the total floating debt, considering elapsed time since last update and current interest rate.\\n /// @return actual floating debt plus projected interest.\\n function totalFloatingBorrowAssets() public view returns (uint256) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n return memFloatingDebt + newDebt;\\n }\\n\\n /// @notice Calculates the floating pool balance plus earnings to be accrued at current timestamp\\n /// from maturities and accumulator.\\n /// @return actual floatingAssets plus earnings to be accrued at current timestamp.\\n function totalAssets() public view override returns (uint256) {\\n unchecked {\\n uint256 memMaxFuturePools = maxFuturePools;\\n uint256 backupEarnings = 0;\\n\\n uint256 latestMaturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL);\\n uint256 maxMaturity = latestMaturity + memMaxFuturePools * FixedLib.INTERVAL;\\n\\n for (uint256 maturity = latestMaturity; maturity <= maxMaturity; maturity += FixedLib.INTERVAL) {\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (maturity > lastAccrual) {\\n backupEarnings += block.timestamp < maturity\\n ? pool.unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual)\\n : pool.unassignedEarnings;\\n }\\n }\\n\\n return\\n floatingAssets +\\n backupEarnings +\\n accumulatedEarnings() +\\n (totalFloatingBorrowAssets() - floatingDebt).mulWadDown(1e18 - treasuryFeeRate);\\n }\\n }\\n\\n /// @notice Simulates the effects of a borrow at the current time, given current contract conditions.\\n /// @param assets amount of assets to borrow.\\n /// @return amount of shares that will be asigned to the account after the borrow.\\n function previewBorrow(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a repay at the current time, given current contract conditions.\\n /// @param assets amount of assets to repay.\\n /// @return amount of shares that will be subtracted from the account after the repay.\\n function previewRepay(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a refund at the current time, given current contract conditions.\\n /// @param shares amount of shares to subtract from caller's accountability.\\n /// @return amount of assets that will be repaid.\\n function previewRefund(uint256 shares) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalFloatingBorrowAssets(), supply);\\n }\\n\\n /// @notice Checks msg.sender's allowance over account's assets.\\n /// @param account account in which the allowance will be checked.\\n /// @param assets assets from account that msg.sender wants to operate on.\\n function spendAllowance(address account, uint256 assets) internal {\\n if (msg.sender != account) {\\n uint256 allowed = allowance[account][msg.sender]; // saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[account][msg.sender] = allowed - previewWithdraw(assets);\\n }\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed amount of the fixed pool.\\n function fixedPoolBorrowed(uint256 maturity) external view returns (uint256) {\\n return fixedPools[maturity].borrowed;\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed and supplied amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed and supplied amount of the fixed pool.\\n function fixedPoolBalance(uint256 maturity) external view returns (uint256, uint256) {\\n return (fixedPools[maturity].borrowed, fixedPools[maturity].supplied);\\n }\\n\\n /// @notice Emits MarketUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitMarketUpdate() internal {\\n emit MarketUpdate(\\n block.timestamp,\\n totalSupply,\\n floatingAssets,\\n totalFloatingBorrowShares,\\n floatingDebt,\\n earningsAccumulator\\n );\\n }\\n\\n /// @notice Emits FixedEarningsUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitFixedEarningsUpdate(uint256 maturity) internal {\\n emit FixedEarningsUpdate(block.timestamp, maturity, fixedPools[maturity].unassignedEarnings);\\n }\\n\\n /// @notice Sets the rate charged to the fixed depositors that the floating pool suppliers will retain for initially\\n /// providing liquidity.\\n /// @param backupFeeRate_ percentage amount represented with 18 decimals.\\n function setBackupFeeRate(uint256 backupFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n backupFeeRate = backupFeeRate_;\\n emit BackupFeeRateSet(backupFeeRate_);\\n }\\n\\n /// @notice Sets the damp speed used to update the floatingAssetsAverage.\\n /// @param up damp speed up, represented with 18 decimals.\\n /// @param down damp speed down, represented with 18 decimals.\\n function setDampSpeed(uint256 up, uint256 down) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n updateFloatingAssetsAverage();\\n dampSpeedUp = up;\\n dampSpeedDown = down;\\n emit DampSpeedSet(up, down);\\n }\\n\\n /// @notice Sets the factor used when smoothly accruing earnings to the floating pool.\\n /// @param earningsAccumulatorSmoothFactor_ represented with 18 decimals.\\n function setEarningsAccumulatorSmoothFactor(\\n uint128 earningsAccumulatorSmoothFactor_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n floatingAssets += accrueAccumulatedEarnings();\\n emitMarketUpdate();\\n earningsAccumulatorSmoothFactor = earningsAccumulatorSmoothFactor_;\\n emit EarningsAccumulatorSmoothFactorSet(earningsAccumulatorSmoothFactor_);\\n }\\n\\n /// @notice Sets the interest rate model to be used to calculate rates.\\n /// @param interestRateModel_ new interest rate model.\\n function setInterestRateModel(InterestRateModel interestRateModel_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(interestRateModel) != address(0)) depositToTreasury(updateFloatingDebt());\\n\\n interestRateModel = interestRateModel_;\\n emitMarketUpdate();\\n emit InterestRateModelSet(interestRateModel_);\\n }\\n\\n /// @notice Sets the rewards controller to update account rewards when operating with the Market.\\n /// @param rewardsController_ new rewards controller.\\n function setRewardsController(RewardsController rewardsController_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n rewardsController = rewardsController_;\\n emit RewardsControllerSet(rewardsController_);\\n }\\n\\n /// @notice Sets the protocol's max future pools for fixed borrowing and lending.\\n /// @dev If value is decreased, VALID maturities will become NOT_READY.\\n /// @param futurePools number of pools to be active at the same time.\\n function setMaxFuturePools(uint8 futurePools) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n maxFuturePools = futurePools;\\n emit MaxFuturePoolsSet(futurePools);\\n }\\n\\n /// @notice Sets the penalty rate per second.\\n /// @param penaltyRate_ percentage represented with 18 decimals.\\n function setPenaltyRate(uint256 penaltyRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n penaltyRate = penaltyRate_;\\n emit PenaltyRateSet(penaltyRate_);\\n }\\n\\n /// @notice Sets the percentage that represents the liquidity reserves that can't be borrowed.\\n /// @param reserveFactor_ parameter represented with 18 decimals.\\n function setReserveFactor(uint128 reserveFactor_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n reserveFactor = reserveFactor_;\\n emit ReserveFactorSet(reserveFactor_);\\n }\\n\\n /// @notice Sets the treasury variables.\\n /// @param treasury_ address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate_ represented with 18 decimals.\\n function setTreasury(address treasury_, uint256 treasuryFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n depositToTreasury(updateFloatingDebt());\\n treasury = treasury_;\\n treasuryFeeRate = treasuryFeeRate_;\\n emit TreasurySet(treasury_, treasuryFeeRate_);\\n }\\n\\n /// @notice Sets the pause state to true in case of emergency, triggered by an authorized account.\\n function pause() external onlyRole(PAUSER_ROLE) {\\n _pause();\\n }\\n\\n /// @notice Sets the pause state to false when threat is gone, triggered by an authorized account.\\n function unpause() external onlyRole(PAUSER_ROLE) {\\n _unpause();\\n }\\n\\n /// @notice Event emitted when an account borrows amount of assets from a floating pool.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of assets that were borrowed.\\n /// @param shares amount of borrow shares assigned to the account.\\n event Borrow(\\n address indexed caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /// @notice Emitted when an account repays amount of assets to a floating pool.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of assets that was repaid.\\n /// @param shares amount of borrow shares that were subtracted from the account's accountability.\\n event Repay(address indexed caller, address indexed borrower, uint256 assets, uint256 shares);\\n\\n /// @notice Emitted when an account deposits an amount of an asset to a certain fixed rate pool,\\n /// collecting fees at the end of the period.\\n /// @param maturity maturity at which the account will be able to collect his deposit + his fee.\\n /// @param caller address which deposited the assets.\\n /// @param owner address that will be able to withdraw the deposited assets.\\n /// @param assets amount of the asset that were deposited.\\n /// @param fee is the extra amount that it will be collected at maturity.\\n event DepositAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed owner,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account withdraws from a fixed rate pool.\\n /// @param maturity maturity where the account withdraw its deposits.\\n /// @param caller address which withdraw the asset.\\n /// @param receiver address which will be collecting the assets.\\n /// @param owner address which had the assets withdrawn.\\n /// @param positionAssets position size reduced.\\n /// @param assets amount of assets withdrawn (can include a discount for early withdraw).\\n event WithdrawAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 positionAssets,\\n uint256 assets\\n );\\n\\n /// @notice Emitted when an account borrows amount of an asset from a certain maturity date.\\n /// @param maturity maturity in which the account will have to repay the loan.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of the asset that were borrowed.\\n /// @param fee extra amount that will need to be paid at maturity.\\n event BorrowAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account repays its borrows after maturity.\\n /// @param maturity maturity where the account repaid its borrowed amounts.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount that was repaid.\\n /// @param positionAssets amount of the debt that was covered in this repayment (penalties could have been repaid).\\n event RepayAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed borrower,\\n uint256 assets,\\n uint256 positionAssets\\n );\\n\\n /// @notice Emitted when an account's position had a liquidation.\\n /// @param receiver address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of the asset that were repaid.\\n /// @param lendersAssets incentive paid to lenders.\\n /// @param seizeMarket address of the asset that were seized by the liquidator.\\n /// @param seizedAssets amount seized of the collateral.\\n event Liquidate(\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 lendersAssets,\\n Market indexed seizeMarket,\\n uint256 seizedAssets\\n );\\n\\n /// @notice Emitted when an account's collateral has been seized.\\n /// @param liquidator address which seized this collateral.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount seized of the collateral.\\n event Seize(address indexed liquidator, address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when an account is cleared from bad debt.\\n /// @param borrower address which was cleared from bad debt.\\n /// @param assets amount that was subtracted from the borrower's debt and spread to the `earningsAccumulator`.\\n event SpreadBadDebt(address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when the backupFeeRate parameter is changed by admin.\\n /// @param backupFeeRate rate charged to the fixed pools to be accrued by the floating depositors.\\n event BackupFeeRateSet(uint256 backupFeeRate);\\n\\n /// @notice Emitted when the damp speeds are changed by admin.\\n /// @param dampSpeedUp represented with 18 decimals.\\n /// @param dampSpeedDown represented with 18 decimals.\\n event DampSpeedSet(uint256 dampSpeedUp, uint256 dampSpeedDown);\\n\\n /// @notice Emitted when the earningsAccumulatorSmoothFactor is changed by admin.\\n /// @param earningsAccumulatorSmoothFactor factor represented with 18 decimals.\\n event EarningsAccumulatorSmoothFactorSet(uint256 earningsAccumulatorSmoothFactor);\\n\\n /// @notice Emitted when the interestRateModel is changed by admin.\\n /// @param interestRateModel new interest rate model to be used to calculate rates.\\n event InterestRateModelSet(InterestRateModel indexed interestRateModel);\\n\\n /// @notice Emitted when the maxFuturePools is changed by admin.\\n /// @param maxFuturePools represented with 0 decimals.\\n event MaxFuturePoolsSet(uint256 maxFuturePools);\\n\\n /// @notice Emitted when the penaltyRate is changed by admin.\\n /// @param penaltyRate penaltyRate percentage per second represented with 18 decimals.\\n event PenaltyRateSet(uint256 penaltyRate);\\n\\n /// @notice Emitted when the reserveFactor is changed by admin.\\n /// @param reserveFactor reserveFactor percentage.\\n event ReserveFactorSet(uint256 reserveFactor);\\n\\n /// @notice Emitted when the treasury variables are changed by admin.\\n /// @param treasury address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate represented with 18 decimals.\\n event TreasurySet(address indexed treasury, uint256 treasuryFeeRate);\\n\\n /// @notice Emitted when the rewardsController is changed by admin.\\n /// @param rewardsController new rewards controller to update account rewards when operating with the Market.\\n event RewardsControllerSet(RewardsController indexed rewardsController);\\n\\n /// @notice Emitted when market state is updated.\\n /// @param timestamp current timestamp.\\n /// @param floatingDepositShares total floating supply shares.\\n /// @param floatingAssets total floating supply assets.\\n /// @param floatingBorrowShares total floating borrow shares.\\n /// @param floatingDebt total floating borrow assets.\\n /// @param earningsAccumulator earnings accumulator.\\n event MarketUpdate(\\n uint256 timestamp,\\n uint256 floatingDepositShares,\\n uint256 floatingAssets,\\n uint256 floatingBorrowShares,\\n uint256 floatingDebt,\\n uint256 earningsAccumulator\\n );\\n\\n /// @notice Emitted when the earnings of a maturity are updated.\\n /// @param timestamp current timestamp.\\n /// @param maturity maturity date where the earnings were updated.\\n /// @param unassignedEarnings pending unassigned earnings.\\n event FixedEarningsUpdate(uint256 timestamp, uint256 indexed maturity, uint256 unassignedEarnings);\\n\\n /// @notice Emitted when accumulator distributes earnings.\\n /// @param timestamp current timestamp.\\n event AccumulatorAccrual(uint256 timestamp);\\n\\n /// @notice Emitted when the floating debt is updated.\\n /// @param timestamp current timestamp.\\n /// @param utilization new floating utilization.\\n event FloatingDebtUpdate(uint256 timestamp, uint256 utilization);\\n\\n /// @notice Stores fixed deposits and fixed borrows map and floating borrow shares of an account.\\n /// @param fixedDeposits encoded map maturity dates where the account supplied to.\\n /// @param fixedBorrows encoded map maturity dates where the account borrowed from.\\n /// @param floatingBorrowShares number of floating borrow shares assigned to the account.\\n struct Account {\\n uint256 fixedDeposits;\\n uint256 fixedBorrows;\\n uint256 floatingBorrowShares;\\n }\\n}\\n\\nerror Disagreement();\\nerror InsufficientProtocolLiquidity();\\nerror NotAuditor();\\nerror SelfLiquidation();\\nerror ZeroBorrow();\\nerror ZeroDeposit();\\nerror ZeroRepay();\\nerror ZeroWithdraw();\\n\",\"keccak256\":\"0x94894ef0aeac99df31979475878d006fb676a9d795d9cfc3b3b1ed321ed672d8\",\"license\":\"BUSL-1.1\"},\"contracts/RewardsController.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/src/utils/SafeTransferLib.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract RewardsController is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint64;\\n using FixedPointMathLib for int256;\\n using SafeTransferLib for ERC20;\\n\\n /// @notice Max utilization supported by the sigmoid function not to cause a division by zero (1e18 = WAD).\\n uint256 public constant UTILIZATION_CAP = 1e18 - 1;\\n /// @notice Tracks the reward distribution data for a given market.\\n mapping(Market => Distribution) public distribution;\\n /// @notice Tracks enabled asset rewards.\\n mapping(ERC20 => bool) public rewardEnabled;\\n /// @notice Stores registered asset rewards.\\n ERC20[] public rewardList;\\n /// @notice Stores Markets with distributions set.\\n Market[] public marketList;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev Can only be called once.\\n function initialize() external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded deposit.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleDeposit(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n ops[0] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n update(account, market, dist.availableRewards[r], ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded borrow.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleBorrow(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n (, , uint256 accountFloatingBorrowShares) = market.accounts(account);\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n ERC20 reward = dist.availableRewards[r];\\n ops[0] = AccountOperation({\\n operation: true,\\n balance: accountFloatingBorrowShares + accountFixedBorrowShares(market, account, dist.rewards[reward].start)\\n });\\n update(account, Market(msg.sender), reward, ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Claims all `msg.sender` rewards to the given account.\\n /// @param to The address to send the rewards to.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claimAll(address to) external returns (ERC20[] memory rewardsList, uint256[] memory claimedAmounts) {\\n return claim(allMarketsOperations(), to, rewardList);\\n }\\n\\n /// @notice Claims `msg.sender` rewards for the given operations and reward assets to the given account.\\n /// @param marketOps The operations to claim rewards for.\\n /// @param to The address to send the rewards to.\\n /// @param rewardsList The list of rewards assets to claim.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claim(\\n MarketOperation[] memory marketOps,\\n address to,\\n ERC20[] memory rewardsList\\n ) public returns (ERC20[] memory, uint256[] memory claimedAmounts) {\\n uint256 rewardsCount = rewardsList.length;\\n claimedAmounts = new uint256[](rewardsCount);\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n uint256 availableRewards = dist.availableRewardsCount;\\n for (uint128 r = 0; r < availableRewards; ) {\\n update(\\n msg.sender,\\n marketOperation.market,\\n dist.availableRewards[r],\\n accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n msg.sender,\\n dist.rewards[dist.availableRewards[r]].start\\n )\\n );\\n unchecked {\\n ++r;\\n }\\n }\\n for (uint256 r = 0; r < rewardsCount; ) {\\n RewardData storage rewardData = dist.rewards[rewardsList[r]];\\n for (uint256 o = 0; o < marketOperation.operations.length; ) {\\n uint256 rewardAmount = rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued;\\n if (rewardAmount != 0) {\\n claimedAmounts[r] += rewardAmount;\\n rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued = 0;\\n }\\n unchecked {\\n ++o;\\n }\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n for (uint256 r = 0; r < rewardsList.length; ) {\\n uint256 claimedAmount = claimedAmounts[r];\\n if (claimedAmount > 0) {\\n rewardsList[r].safeTransfer(to, claimedAmount);\\n emit Claim(msg.sender, rewardsList[r], to, claimedAmount);\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n return (rewardsList, claimedAmounts);\\n }\\n\\n /// @notice Gets the configuration of a given distribution.\\n /// @param market The market to get the distribution configuration for.\\n /// @param reward The reward asset.\\n /// @return The distribution configuration.\\n function rewardConfig(Market market, ERC20 reward) external view returns (Config memory) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return\\n Config({\\n market: market,\\n reward: reward,\\n priceFeed: rewardData.priceFeed,\\n start: rewardData.start,\\n distributionPeriod: rewardData.end - rewardData.start,\\n targetDebt: rewardData.targetDebt,\\n totalDistribution: rewardData.totalDistribution,\\n undistributedFactor: rewardData.undistributedFactor,\\n flipSpeed: rewardData.flipSpeed,\\n compensationFactor: rewardData.compensationFactor,\\n transitionFactor: rewardData.transitionFactor,\\n borrowAllocationWeightFactor: rewardData.borrowAllocationWeightFactor,\\n depositAllocationWeightAddend: rewardData.depositAllocationWeightAddend,\\n depositAllocationWeightFactor: rewardData.depositAllocationWeightFactor\\n });\\n }\\n\\n /// @notice Gets the amount of reward assets that are being distributed for a Market.\\n /// @param market Market to get the number of available rewards to distribute.\\n /// @return The amount reward assets set to a Market.\\n function availableRewardsCount(Market market) external view returns (uint256) {\\n return distribution[market].availableRewardsCount;\\n }\\n\\n /// @notice Gets the account data of a given account, Market, operation and reward asset.\\n /// @param account The account to get the operation data from.\\n /// @param market The market in which the operation was made.\\n /// @param operation True if the operation was a borrow, false if it was a deposit.\\n /// @param reward The reward asset.\\n /// @return accrued The accrued amount.\\n /// @return index The account index.\\n function accountOperation(\\n address account,\\n Market market,\\n bool operation,\\n ERC20 reward\\n ) external view returns (uint256, uint256) {\\n Account storage operationAccount = distribution[market].rewards[reward].accounts[account][operation];\\n return (operationAccount.accrued, operationAccount.index);\\n }\\n\\n /// @notice Gets the distribution `start`, `end` and `lastUpdate` value of a given market and reward.\\n /// @param market The market to get the distribution times.\\n /// @param reward The reward asset.\\n /// @return The distribution `start`, `end` and `lastUpdate` time.\\n function distributionTime(Market market, ERC20 reward) external view returns (uint32, uint32, uint32) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.start, rewardData.end, rewardData.lastUpdate);\\n }\\n\\n /// @notice Retrieves all rewards addresses.\\n function allRewards() external view returns (ERC20[] memory) {\\n return rewardList;\\n }\\n\\n /// @notice Gets all market and operations.\\n /// @return marketOps The list of market operations.\\n function allMarketsOperations() public view returns (MarketOperation[] memory marketOps) {\\n Market[] memory markets = marketList;\\n marketOps = new MarketOperation[](markets.length);\\n for (uint256 m = 0; m < markets.length; ) {\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[m] = MarketOperation({ market: markets[m], operations: ops });\\n unchecked {\\n ++m;\\n }\\n }\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account and reward asset.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function allClaimable(address account, ERC20 reward) external view returns (uint256 unclaimedRewards) {\\n return claimable(allMarketsOperations(), account, reward);\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account, Market operations and reward asset.\\n /// @param marketOps The list of Market operations to get the accrued and pending rewards from.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function claimable(\\n MarketOperation[] memory marketOps,\\n address account,\\n ERC20 reward\\n ) public view returns (uint256 unclaimedRewards) {\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n RewardData storage rewardData = dist.rewards[reward];\\n if (dist.availableRewardsCount == 0) {\\n unchecked {\\n ++i;\\n }\\n continue;\\n }\\n\\n AccountOperation[] memory ops = accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n account,\\n rewardData.start\\n );\\n uint256 balance;\\n for (uint256 o = 0; o < ops.length; ) {\\n unclaimedRewards += rewardData.accounts[account][ops[o].operation].accrued;\\n balance += ops[o].balance;\\n unchecked {\\n ++o;\\n }\\n }\\n if (balance > 0) {\\n unclaimedRewards += pendingRewards(\\n account,\\n reward,\\n AccountMarketOperation({ market: marketOperation.market, accountOperations: ops })\\n );\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Iterates and accrues all rewards for the operations of the given account in the given market.\\n /// @param account The account to accrue the rewards for.\\n /// @param market The Market in which the operations where made.\\n /// @param reward The reward asset.\\n /// @param ops The operations to accrue the rewards for.\\n function update(address account, Market market, ERC20 reward, AccountOperation[] memory ops) internal {\\n uint256 baseUnit = distribution[market].baseUnit;\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n {\\n uint256 lastUpdate = rewardData.lastUpdate;\\n // `lastUpdate` can be greater than `block.timestamp` if distribution is set to start on a future date\\n if (block.timestamp > lastUpdate) {\\n (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) = previewAllocation(\\n rewardData,\\n market,\\n block.timestamp - lastUpdate\\n );\\n if (borrowIndex > type(uint128).max || depositIndex > type(uint128).max) revert IndexOverflow();\\n rewardData.borrowIndex = uint128(borrowIndex);\\n rewardData.depositIndex = uint128(depositIndex);\\n rewardData.lastUpdate = uint32(block.timestamp);\\n rewardData.lastUndistributed = newUndistributed;\\n emit IndexUpdate(market, reward, borrowIndex, depositIndex, newUndistributed, block.timestamp);\\n }\\n }\\n\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 i = 0; i < ops.length; ) {\\n AccountOperation memory op = ops[i];\\n Account storage accountData = operationAccount[op.operation];\\n uint256 accountIndex = accountData.index;\\n uint256 newAccountIndex;\\n if (op.operation) {\\n newAccountIndex = rewardData.borrowIndex;\\n } else {\\n newAccountIndex = rewardData.depositIndex;\\n }\\n if (accountIndex != newAccountIndex) {\\n accountData.index = uint128(newAccountIndex);\\n if (op.balance != 0) {\\n uint256 rewardsAccrued = accountRewards(op.balance, newAccountIndex, accountIndex, baseUnit);\\n accountData.accrued += uint128(rewardsAccrued);\\n emit Accrue(market, reward, account, op.operation, accountIndex, newAccountIndex, rewardsAccrued);\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the equivalent of borrow shares from fixed pool principal borrows of an account.\\n /// @param market The Market to get the fixed borrows from.\\n /// @param account The account that borrowed from fixed pools.\\n /// @return fixedDebt The fixed borrow shares.\\n function accountFixedBorrowShares(\\n Market market,\\n address account,\\n uint32 start\\n ) internal view returns (uint256 fixedDebt) {\\n uint256 firstMaturity = start - (start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 principal, ) = market.fixedBorrowPositions(maturity, account);\\n fixedDebt += principal;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n fixedDebt = market.previewRepay(fixedDebt);\\n }\\n\\n /// @notice Gets the reward indexes and last amount of undistributed rewards for a given market and reward asset.\\n /// @param market The market to get the reward indexes for.\\n /// @param reward The reward asset to get the reward indexes for.\\n /// @return borrowIndex The index for the floating and fixed borrow operation.\\n /// @return depositIndex The index for the floating deposit operation.\\n /// @return lastUndistributed The last amount of undistributed rewards.\\n function rewardIndexes(Market market, ERC20 reward) external view returns (uint256, uint256, uint256) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.borrowIndex, rewardData.depositIndex, rewardData.lastUndistributed);\\n }\\n\\n /// @notice Calculates the rewards not accrued yet for the given operations of a given account and reward asset.\\n /// @param account The account to get the pending rewards for.\\n /// @param reward The reward asset to get the pending rewards for.\\n /// @param ops The operations to get the pending rewards for.\\n /// @return rewards The pending rewards for the given operations.\\n function pendingRewards(\\n address account,\\n ERC20 reward,\\n AccountMarketOperation memory ops\\n ) internal view returns (uint256 rewards) {\\n RewardData storage rewardData = distribution[ops.market].rewards[reward];\\n uint256 baseUnit = distribution[ops.market].baseUnit;\\n uint256 lastUpdate = rewardData.lastUpdate;\\n (uint256 borrowIndex, uint256 depositIndex, ) = previewAllocation(\\n rewardData,\\n ops.market,\\n block.timestamp > lastUpdate ? block.timestamp - lastUpdate : 0\\n );\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 o = 0; o < ops.accountOperations.length; ) {\\n uint256 nextIndex;\\n if (ops.accountOperations[o].operation) {\\n nextIndex = borrowIndex;\\n } else {\\n nextIndex = depositIndex;\\n }\\n\\n rewards += accountRewards(\\n ops.accountOperations[o].balance,\\n nextIndex,\\n operationAccount[ops.accountOperations[o].operation].index,\\n baseUnit\\n );\\n unchecked {\\n ++o;\\n }\\n }\\n }\\n\\n /// @notice Calculates and returns the new amount of rewards given by the difference between the `accountIndex` and\\n /// the `globalIndex`.\\n /// @param balance The account's balance in the operation's pool.\\n /// @param globalIndex Current index of the distribution.\\n /// @param accountIndex Last index stored for the account.\\n /// @param baseUnit One unit of the Market's asset (10**decimals).\\n /// @return The amount of new rewards to be accrued by the account.\\n function accountRewards(\\n uint256 balance,\\n uint256 globalIndex,\\n uint256 accountIndex,\\n uint256 baseUnit\\n ) internal pure returns (uint256) {\\n return balance.mulDivDown(globalIndex - accountIndex, baseUnit);\\n }\\n\\n /// @notice Retrieves projected distribution indexes and new undistributed amount for a given `deltaTime`.\\n /// @param market The market to calculate the indexes for.\\n /// @param reward The reward asset to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n Market market,\\n ERC20 reward,\\n uint256 deltaTime\\n ) external view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n return previewAllocation(distribution[market].rewards[reward], market, deltaTime);\\n }\\n\\n /// @notice Calculates and returns the distribution indexes and new undistributed tokens for a given `rewardData`.\\n /// @param rewardData The distribution's data.\\n /// @param market The market to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n RewardData storage rewardData,\\n Market market,\\n uint256 deltaTime\\n ) internal view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n TotalMarketBalance memory m;\\n m.debt = market.totalFloatingBorrowAssets();\\n m.supply = market.totalAssets();\\n TimeVars memory t;\\n t.start = rewardData.start;\\n t.end = rewardData.end;\\n {\\n uint256 firstMaturity = t.start - (t.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n uint256 fixedDebt;\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 borrowed, uint256 supplied) = market.fixedPoolBalance(maturity);\\n fixedDebt += borrowed;\\n m.supply += supplied;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n m.debt += fixedDebt;\\n m.fixedBorrowShares = market.previewRepay(fixedDebt);\\n }\\n uint256 target;\\n {\\n uint256 targetDebt = rewardData.targetDebt;\\n target = m.debt < targetDebt ? m.debt.divWadDown(targetDebt) : 1e18;\\n }\\n uint256 rewards;\\n {\\n uint256 releaseRate = rewardData.releaseRate;\\n uint256 lastUndistributed = rewardData.lastUndistributed;\\n t.period = t.end - t.start;\\n uint256 distributionFactor = t.period > 0\\n ? rewardData.undistributedFactor.mulDivDown(target, t.period * 1e18)\\n : 0;\\n if (block.timestamp <= t.end) {\\n if (distributionFactor > 0) {\\n uint256 exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n } else if (rewardData.lastUpdate > t.end) {\\n newUndistributed =\\n lastUndistributed -\\n lastUndistributed.mulWadUp(1e18 - uint256((-int256(distributionFactor * deltaTime)).expWad()));\\n rewards = uint256(-(int256(newUndistributed) - int256(lastUndistributed)));\\n } else {\\n uint256 exponential;\\n deltaTime = t.end - rewardData.lastUpdate;\\n if (distributionFactor > 0) {\\n exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n exponential = uint256((-int256(distributionFactor * (block.timestamp - t.end))).expWad());\\n newUndistributed = newUndistributed - newUndistributed.mulWadUp(1e18 - exponential);\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n }\\n if (rewards == 0) return (rewardData.borrowIndex, rewardData.depositIndex, newUndistributed);\\n }\\n {\\n AllocationVars memory v;\\n v.utilization = m.supply > 0 ? Math.min(m.debt.divWadDown(m.supply), UTILIZATION_CAP) : 0;\\n v.transitionFactor = rewardData.transitionFactor;\\n v.flipSpeed = rewardData.flipSpeed;\\n v.borrowAllocationWeightFactor = rewardData.borrowAllocationWeightFactor;\\n v.sigmoid = v.utilization > 0\\n ? uint256(1e18).divWadDown(\\n 1e18 +\\n uint256(\\n (-(v.flipSpeed *\\n (int256(v.utilization.divWadDown(1e18 - v.utilization)).lnWad() -\\n int256(v.transitionFactor.divWadDown(1e18 - v.transitionFactor)).lnWad())) / 1e18).expWad()\\n )\\n )\\n : 0;\\n v.borrowRewardRule = rewardData\\n .compensationFactor\\n .mulWadDown(\\n market.interestRateModel().floatingRate(v.utilization).mulWadDown(\\n 1e18 - v.utilization.mulWadUp(1e18 - market.treasuryFeeRate())\\n ) + v.borrowAllocationWeightFactor\\n )\\n .mulWadDown(1e18 - v.sigmoid);\\n v.depositRewardRule =\\n rewardData.depositAllocationWeightAddend.mulWadDown(1e18 - v.sigmoid) +\\n rewardData.depositAllocationWeightFactor.mulWadDown(v.sigmoid);\\n v.borrowAllocation = v.borrowRewardRule.divWadDown(v.borrowRewardRule + v.depositRewardRule);\\n v.depositAllocation = 1e18 - v.borrowAllocation;\\n {\\n uint256 totalDepositSupply = market.totalSupply();\\n uint256 totalBorrowSupply = market.totalFloatingBorrowShares() + m.fixedBorrowShares;\\n uint256 baseUnit = distribution[market].baseUnit;\\n borrowIndex =\\n rewardData.borrowIndex +\\n (totalBorrowSupply > 0 ? rewards.mulWadDown(v.borrowAllocation).mulDivDown(baseUnit, totalBorrowSupply) : 0);\\n depositIndex =\\n rewardData.depositIndex +\\n (\\n totalDepositSupply > 0\\n ? rewards.mulWadDown(v.depositAllocation).mulDivDown(baseUnit, totalDepositSupply)\\n : 0\\n );\\n }\\n }\\n }\\n\\n /// @notice Get account balances of the given Market operations.\\n /// @param market The address of the Market.\\n /// @param ops List of operations to retrieve account balance.\\n /// @param account Account to get the balance from.\\n /// @param distributionStart Timestamp of the start of the distribution to correctly get the rewarded fixed pools.\\n /// @return accountBalanceOps contains a list with account balance per each operation.\\n function accountBalanceOperations(\\n Market market,\\n bool[] memory ops,\\n address account,\\n uint32 distributionStart\\n ) internal view returns (AccountOperation[] memory accountBalanceOps) {\\n accountBalanceOps = new AccountOperation[](ops.length);\\n for (uint256 i = 0; i < ops.length; ) {\\n if (ops[i]) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n accountBalanceOps[i] = AccountOperation({\\n operation: true,\\n balance: floatingBorrowShares + accountFixedBorrowShares(market, account, distributionStart)\\n });\\n } else {\\n accountBalanceOps[i] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Withdraws the contract's balance of the given asset to the given address.\\n /// @param asset The asset to withdraw.\\n /// @param to The address to withdraw the asset to.\\n function withdraw(ERC20 asset, address to) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n asset.safeTransfer(to, asset.balanceOf(address(this)));\\n }\\n\\n /// @notice Enables or updates the reward distribution for the given markets and rewards.\\n /// @param configs The configurations to update each RewardData with.\\n function config(Config[] memory configs) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n for (uint256 i = 0; i < configs.length; ) {\\n // transitionFactor cannot be eq or higher than 1e18 to avoid division by zero or underflow\\n if (configs[i].transitionFactor >= 1e18) revert InvalidConfig();\\n // depositAllocationWeightFactor cannot be zero to avoid division by zero when sigmoid equals 1e18\\n if (configs[i].depositAllocationWeightFactor == 0) revert InvalidConfig();\\n\\n Distribution storage dist = distribution[configs[i].market];\\n RewardData storage rewardData = dist.rewards[configs[i].reward];\\n\\n if (dist.baseUnit == 0) {\\n // never initialized before, adding to the list of markets\\n marketList.push(configs[i].market);\\n }\\n if (!rewardEnabled[configs[i].reward]) {\\n // add reward address to global rewards list if still not enabled\\n rewardEnabled[configs[i].reward] = true;\\n rewardList.push(configs[i].reward);\\n }\\n if (rewardData.lastUpdate == 0) {\\n // add reward address to distribution data's available rewards if distribution is new\\n dist.availableRewards[dist.availableRewardsCount++] = configs[i].reward;\\n dist.baseUnit = 10 ** configs[i].market.decimals();\\n // set initial parameters if distribution is new\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n } else {\\n uint32 start = rewardData.start;\\n uint32 end = rewardData.end;\\n // update global indexes before updating distribution values\\n bool[] memory ops = new bool[](1);\\n ops[0] = true;\\n update(\\n address(0),\\n configs[i].market,\\n configs[i].reward,\\n accountBalanceOperations(configs[i].market, ops, address(0), start)\\n );\\n // properly update release rate\\n if (block.timestamp < end) {\\n uint256 released = 0;\\n uint256 elapsed = 0;\\n if (block.timestamp > start) {\\n released =\\n rewardData.lastConfigReleased +\\n rewardData.releaseRate *\\n (block.timestamp - rewardData.lastConfig);\\n elapsed = block.timestamp - start;\\n if (configs[i].totalDistribution <= released || configs[i].distributionPeriod <= elapsed) {\\n revert InvalidConfig();\\n }\\n rewardData.lastConfigReleased = released;\\n }\\n\\n rewardData.releaseRate =\\n (configs[i].totalDistribution - released) /\\n (configs[i].distributionPeriod - elapsed);\\n } else if (rewardData.start != configs[i].start) {\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n rewardData.lastConfigReleased = 0;\\n }\\n }\\n rewardData.lastConfig = uint32(block.timestamp);\\n rewardData.end = rewardData.start + uint32(configs[i].distributionPeriod);\\n rewardData.priceFeed = configs[i].priceFeed;\\n // set emission and distribution parameters\\n rewardData.totalDistribution = configs[i].totalDistribution;\\n rewardData.targetDebt = configs[i].targetDebt;\\n rewardData.undistributedFactor = configs[i].undistributedFactor;\\n rewardData.flipSpeed = configs[i].flipSpeed;\\n rewardData.compensationFactor = configs[i].compensationFactor;\\n rewardData.borrowAllocationWeightFactor = configs[i].borrowAllocationWeightFactor;\\n rewardData.depositAllocationWeightAddend = configs[i].depositAllocationWeightAddend;\\n rewardData.transitionFactor = configs[i].transitionFactor;\\n rewardData.depositAllocationWeightFactor = configs[i].depositAllocationWeightFactor;\\n\\n emit DistributionSet(configs[i].market, configs[i].reward, configs[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n struct TotalMarketBalance {\\n uint256 debt;\\n uint256 supply;\\n uint256 fixedBorrowShares;\\n }\\n\\n struct TimeVars {\\n uint256 start;\\n uint256 end;\\n uint256 period;\\n }\\n\\n struct AllocationVars {\\n uint256 utilization;\\n uint256 sigmoid;\\n uint256 borrowRewardRule;\\n uint256 depositRewardRule;\\n uint256 borrowAllocation;\\n uint256 depositAllocation;\\n uint256 transitionFactor;\\n int256 flipSpeed;\\n uint256 borrowAllocationWeightFactor;\\n }\\n\\n struct AccountOperation {\\n bool operation;\\n uint256 balance;\\n }\\n\\n struct MarketOperation {\\n Market market;\\n bool[] operations;\\n }\\n\\n struct AccountMarketOperation {\\n Market market;\\n AccountOperation[] accountOperations;\\n }\\n\\n struct Account {\\n // liquidity index of the reward distribution for the account\\n uint128 index;\\n // amount of accrued rewards for the account since last account index update\\n uint128 accrued;\\n }\\n\\n struct Config {\\n Market market;\\n ERC20 reward;\\n IPriceFeed priceFeed;\\n uint32 start;\\n uint256 distributionPeriod;\\n uint256 targetDebt;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n }\\n\\n struct RewardData {\\n // distribution model\\n uint256 targetDebt;\\n uint256 releaseRate;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n uint256 lastUndistributed;\\n // allocation model\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n // liquidity indexes of the reward distribution\\n uint128 borrowIndex;\\n uint128 depositIndex;\\n // distribution timestamps\\n uint32 start;\\n uint32 end;\\n uint32 lastUpdate;\\n // config helpers\\n uint32 lastConfig;\\n uint256 lastConfigReleased;\\n // price feed\\n IPriceFeed priceFeed;\\n // account addresses and their rewards data (index & accrued)\\n mapping(address => mapping(bool => Account)) accounts;\\n }\\n\\n struct Distribution {\\n // reward assets and their data\\n mapping(ERC20 => RewardData) rewards;\\n // list of reward asset addresses for the market\\n mapping(uint128 => ERC20) availableRewards;\\n // count of reward tokens for the market\\n uint8 availableRewardsCount;\\n // base unit of the market\\n uint256 baseUnit;\\n }\\n\\n /// @notice Emitted when rewards are accrued by an account.\\n /// @param market Market where the operation was made.\\n /// @param reward reward asset.\\n /// @param account account that accrued the rewards.\\n /// @param operation true if the operation was a borrow, false if it was a deposit.\\n /// @param accountIndex previous account index.\\n /// @param operationIndex new operation index that is assigned to the `accountIndex`.\\n /// @param rewardsAccrued amount of rewards accrued.\\n event Accrue(\\n Market indexed market,\\n ERC20 indexed reward,\\n address indexed account,\\n bool operation,\\n uint256 accountIndex,\\n uint256 operationIndex,\\n uint256 rewardsAccrued\\n );\\n\\n /// @notice Emitted when rewards are claimed by an account.\\n /// @param account account that claimed the rewards.\\n /// @param reward reward asset.\\n /// @param to account that received the rewards.\\n /// @param amount amount of rewards claimed.\\n event Claim(address indexed account, ERC20 indexed reward, address indexed to, uint256 amount);\\n\\n /// @notice Emitted when a distribution is set.\\n /// @param market Market whose distribution was set.\\n /// @param reward reward asset to be distributed when operating with the Market.\\n /// @param config configuration struct containing the distribution parameters.\\n event DistributionSet(Market indexed market, ERC20 indexed reward, Config config);\\n\\n /// @notice Emitted when the distribution indexes are updated.\\n /// @param market Market of the distribution.\\n /// @param reward reward asset.\\n /// @param borrowIndex index of the borrow operations of a distribution.\\n /// @param depositIndex index of the deposit operations of a distribution.\\n /// @param newUndistributed amount of undistributed rewards.\\n /// @param lastUpdate current timestamp.\\n event IndexUpdate(\\n Market indexed market,\\n ERC20 indexed reward,\\n uint256 borrowIndex,\\n uint256 depositIndex,\\n uint256 newUndistributed,\\n uint256 lastUpdate\\n );\\n}\\n\\nerror IndexOverflow();\\nerror InvalidConfig();\\n\",\"keccak256\":\"0x1542122ea5dfca16000fa7e476201de82eef8ff8d7f44601274e1ed12c60344f\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/Previewer.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { InterestRateModel as IRM, AlreadyMatured } from \\\"../InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"../RewardsController.sol\\\";\\nimport { FixedLib } from \\\"../utils/FixedLib.sol\\\";\\nimport { Auditor, IPriceFeed } from \\\"../Auditor.sol\\\";\\nimport { Market } from \\\"../Market.sol\\\";\\n\\n/// @title Previewer\\n/// @notice Contract to be consumed by Exactly's front-end dApp.\\ncontract Previewer {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for uint256;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IPriceFeed public immutable basePriceFeed;\\n\\n struct MarketAccount {\\n // market\\n Market market;\\n string symbol;\\n uint8 decimals;\\n address asset;\\n string assetName;\\n string assetSymbol;\\n InterestRateModel interestRateModel;\\n uint256 usdPrice;\\n uint256 penaltyRate;\\n uint256 adjustFactor;\\n uint8 maxFuturePools;\\n FixedPool[] fixedPools;\\n RewardRate[] rewardRates;\\n uint256 floatingBorrowRate;\\n uint256 floatingUtilization;\\n uint256 floatingBackupBorrowed;\\n uint256 floatingAvailableAssets;\\n uint256 totalFloatingBorrowAssets;\\n uint256 totalFloatingDepositAssets;\\n uint256 totalFloatingBorrowShares;\\n uint256 totalFloatingDepositShares;\\n // account\\n bool isCollateral;\\n uint256 maxBorrowAssets;\\n uint256 floatingBorrowShares;\\n uint256 floatingBorrowAssets;\\n uint256 floatingDepositShares;\\n uint256 floatingDepositAssets;\\n FixedPosition[] fixedDepositPositions;\\n FixedPosition[] fixedBorrowPositions;\\n ClaimableReward[] claimableRewards;\\n }\\n\\n struct RewardRate {\\n address asset;\\n string assetName;\\n string assetSymbol;\\n uint256 usdPrice;\\n uint256 borrow;\\n uint256 floatingDeposit;\\n uint256[] maturities;\\n }\\n\\n struct ClaimableReward {\\n address asset;\\n string assetName;\\n string assetSymbol;\\n uint256 amount;\\n }\\n\\n struct InterestRateModel {\\n address id;\\n uint256 fixedCurveA;\\n int256 fixedCurveB;\\n uint256 fixedMaxUtilization;\\n uint256 floatingCurveA;\\n int256 floatingCurveB;\\n uint256 floatingMaxUtilization;\\n }\\n\\n struct FixedPosition {\\n uint256 maturity;\\n uint256 previewValue;\\n FixedLib.Position position;\\n }\\n\\n struct FixedPreview {\\n uint256 maturity;\\n uint256 assets;\\n uint256 utilization;\\n }\\n\\n struct FixedPool {\\n uint256 maturity;\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 available;\\n uint256 utilization;\\n uint256 depositRate;\\n uint256 minBorrowRate;\\n uint256 optimalDeposit;\\n }\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IPriceFeed basePriceFeed_) {\\n auditor = auditor_;\\n basePriceFeed = basePriceFeed_;\\n }\\n\\n /// @notice Function to get a certain account extended data.\\n /// @param account address which the extended data will be calculated.\\n /// @return data extended accountability of all markets for the account.\\n function exactly(address account) external view returns (MarketAccount[] memory data) {\\n uint256 markets = auditor.accountMarkets(account);\\n uint256 maxValue = auditor.allMarkets().length;\\n (uint256 adjustedCollateral, uint256 adjustedDebt) = auditor.accountLiquidity(account, Market(address(0)), 0);\\n uint256 basePrice = address(basePriceFeed) != address(0)\\n ? uint256(basePriceFeed.latestAnswer()) * 10 ** (18 - basePriceFeed.decimals())\\n : 1e18;\\n data = new MarketAccount[](maxValue);\\n for (uint256 i = 0; i < maxValue; ++i) {\\n Market market = auditor.marketList(i);\\n Market.Account memory a;\\n Auditor.MarketData memory m;\\n (a.fixedDeposits, a.fixedBorrows, a.floatingBorrowShares) = market.accounts(account);\\n (m.adjustFactor, m.decimals, m.index, m.isListed, m.priceFeed) = auditor.markets(market);\\n IRM irm = market.interestRateModel();\\n data[i] = MarketAccount({\\n // market\\n market: market,\\n symbol: market.symbol(),\\n decimals: m.decimals,\\n asset: address(market.asset()),\\n assetName: market.asset().name(),\\n assetSymbol: market.asset().symbol(),\\n interestRateModel: InterestRateModel({\\n id: address(irm),\\n fixedCurveA: irm.fixedCurveA(),\\n fixedCurveB: irm.fixedCurveB(),\\n fixedMaxUtilization: irm.fixedMaxUtilization(),\\n floatingCurveA: irm.floatingCurveA(),\\n floatingCurveB: irm.floatingCurveB(),\\n floatingMaxUtilization: irm.floatingMaxUtilization()\\n }),\\n usdPrice: auditor.assetPrice(m.priceFeed).mulWadDown(basePrice),\\n penaltyRate: market.penaltyRate(),\\n adjustFactor: m.adjustFactor,\\n maxFuturePools: market.maxFuturePools(),\\n fixedPools: fixedPools(market),\\n rewardRates: rewardRates(market, basePrice),\\n floatingBorrowRate: irm.floatingRate(\\n market.floatingAssets() > 0 ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18) : 0\\n ),\\n floatingUtilization: market.floatingAssets() > 0\\n ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18)\\n : 0,\\n floatingBackupBorrowed: market.floatingBackupBorrowed(),\\n floatingAvailableAssets: floatingAvailableAssets(market),\\n totalFloatingBorrowAssets: market.totalFloatingBorrowAssets(),\\n totalFloatingDepositAssets: market.totalAssets(),\\n totalFloatingBorrowShares: market.totalFloatingBorrowShares(),\\n totalFloatingDepositShares: market.totalSupply(),\\n // account\\n isCollateral: markets & (1 << i) != 0 ? true : false,\\n maxBorrowAssets: adjustedCollateral >= adjustedDebt\\n ? (adjustedCollateral - adjustedDebt).mulDivUp(10 ** m.decimals, auditor.assetPrice(m.priceFeed)).mulWadUp(\\n m.adjustFactor\\n )\\n : 0,\\n floatingBorrowShares: a.floatingBorrowShares,\\n floatingBorrowAssets: maxRepay(market, account),\\n floatingDepositShares: market.balanceOf(account),\\n floatingDepositAssets: market.maxWithdraw(account),\\n fixedDepositPositions: fixedPositions(\\n market,\\n account,\\n a.fixedDeposits,\\n market.fixedDepositPositions,\\n this.previewWithdrawAtMaturity\\n ),\\n fixedBorrowPositions: fixedPositions(\\n market,\\n account,\\n a.fixedBorrows,\\n market.fixedBorrowPositions,\\n this.previewRepayAtMaturity\\n ),\\n claimableRewards: claimableRewards(market, account)\\n });\\n }\\n }\\n\\n /// @notice Gets the assets plus yield offered by a maturity when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be deposited.\\n /// @param assets amount of assets that will be deposited.\\n /// @return amount plus yield that the depositor will receive after maturity.\\n function previewDepositAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n if (block.timestamp > maturity) revert AlreadyMatured();\\n (uint256 borrowed, uint256 supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fixedDepositYield(market, maturity, assets),\\n utilization: memFloatingAssetsAverage > 0 ? borrowed.divWadUp(supplied + assets + memFloatingAssetsAverage) : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus yield offered by all VALID maturities when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be deposited.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewDepositAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n previews[i] = previewDepositAtMaturity(market, maturity, assets);\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount plus fees to be repaid at maturity when borrowing certain amount of assets.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be borrowed.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return positionAssets amount plus fees that the depositor will repay at maturity.\\n function previewBorrowAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n uint256 fees = assets.mulWadDown(\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n assets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n );\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fees,\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed + assets).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus fees offered by all VALID maturities when borrowing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewBorrowAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n try this.previewBorrowAtMaturity(market, maturity, assets) returns (FixedPreview memory preview) {\\n previews[i] = preview;\\n } catch {\\n previews[i] = FixedPreview({ maturity: maturity, assets: type(uint256).max, utilization: type(uint256).max });\\n }\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount to be withdrawn for a certain positionAmount of assets at maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be withdrawn.\\n /// @param positionAssets amount of assets that will be tried to withdraw.\\n /// @return withdrawAssets amount that will be withdrawn.\\n function previewWithdrawAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address owner\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedDepositPositions(maturity, owner);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets.divWadDown(\\n 1e18 +\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n )\\n : positionAssets,\\n utilization: memFloatingAssetsAverage > 0\\n ? pool.borrowed.divWadUp(pool.supplied + memFloatingAssetsAverage - principal)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets that will be repaid when repaying a certain amount at the current maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be repaid.\\n /// @param positionAssets amount of assets that will be subtracted from the position.\\n /// @param borrower address of the borrower.\\n /// @return repayAssets amount of assets that will be repaid.\\n function previewRepayAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address borrower\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedBorrowPositions(maturity, borrower);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets - fixedDepositYield(market, maturity, principal)\\n : positionAssets + positionAssets.mulWadDown((block.timestamp - maturity) * market.penaltyRate()),\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed - principal).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n function fixedPools(Market market) internal view returns (FixedPool[] memory pools) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n pools = new FixedPool[](market.maxFuturePools());\\n for (uint256 i = 0; i < market.maxFuturePools(); i++) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)\\n );\\n (uint256 minBorrowRate, uint256 utilization) = (market.previewFloatingAssetsAverage() + pool.supplied) > 0\\n ? market.interestRateModel().minFixedRate(pool.borrowed, pool.supplied, market.previewFloatingAssetsAverage())\\n : (0, 0);\\n\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n (block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)) - pool.lastAccrual\\n );\\n pools[i] = FixedPool({\\n maturity: block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1),\\n borrowed: pool.borrowed,\\n supplied: pool.supplied,\\n available: Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()) -\\n Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()),\\n market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt\\n ),\\n market.previewFloatingAssetsAverage()\\n ) +\\n pool.supplied -\\n Math.min(pool.supplied, pool.borrowed),\\n utilization: utilization,\\n optimalDeposit: pool.borrowed - Math.min(pool.borrowed, pool.supplied),\\n depositRate: uint256(365 days).mulDivDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied) > 0\\n ? (pool.unassignedEarnings.mulWadDown(1e18 - market.backupFeeRate())).divWadDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied)\\n )\\n : 0,\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1) - block.timestamp\\n ),\\n minBorrowRate: minBorrowRate\\n });\\n }\\n }\\n\\n function rewardRates(Market market, uint256 basePrice) internal view returns (RewardRate[] memory rewards) {\\n RewardsVars memory r;\\n r.controller = market.rewardsController();\\n if (address(r.controller) != address(0)) {\\n (, r.underlyingDecimals, , , r.underlyingPriceFeed) = auditor.markets(market);\\n unchecked {\\n r.underlyingBaseUnit = 10 ** r.underlyingDecimals;\\n }\\n r.deltaTime = 1 hours;\\n r.rewardList = r.controller.allRewards();\\n rewards = new RewardRate[](r.rewardList.length);\\n for (r.i = 0; r.i < r.rewardList.length; ++r.i) {\\n r.config = r.controller.rewardConfig(market, r.rewardList[r.i]);\\n (r.borrowIndex, r.depositIndex, ) = r.controller.rewardIndexes(market, r.rewardList[r.i]);\\n (r.projectedBorrowIndex, r.projectedDepositIndex, ) = r.controller.previewAllocation(\\n market,\\n r.rewardList[r.i],\\n block.timestamp > r.config.start ? r.deltaTime : 0\\n );\\n (r.start, , ) = r.controller.distributionTime(market, r.rewardList[r.i]);\\n r.firstMaturity = r.start - (r.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n r.maxMaturity =\\n block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n r.maturities = new uint256[]((r.maxMaturity - r.firstMaturity) / FixedLib.INTERVAL + 1);\\n r.start = 0;\\n for (r.maturity = r.firstMaturity; r.maturity <= r.maxMaturity; ) {\\n (uint256 borrowed, ) = market.fixedPoolBalance(r.maturity);\\n r.fixedDebt += borrowed;\\n r.maturities[r.start] = r.maturity;\\n unchecked {\\n r.maturity += FixedLib.INTERVAL;\\n ++r.start;\\n }\\n }\\n rewards[r.i] = RewardRate({\\n asset: address(r.rewardList[r.i]),\\n assetName: r.rewardList[r.i].name(),\\n assetSymbol: r.rewardList[r.i].symbol(),\\n usdPrice: auditor.assetPrice(r.config.priceFeed).mulWadDown(basePrice),\\n borrow: (market.totalFloatingBorrowAssets() + r.fixedDebt) > 0\\n ? (r.projectedBorrowIndex - r.borrowIndex)\\n .mulDivDown(market.totalFloatingBorrowShares() + market.previewRepay(r.fixedDebt), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n (market.totalFloatingBorrowAssets() + r.fixedDebt).mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n floatingDeposit: market.totalAssets() > 0\\n ? (r.projectedDepositIndex - r.depositIndex)\\n .mulDivDown(market.totalSupply(), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n market.totalAssets().mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n maturities: r.maturities\\n });\\n }\\n }\\n }\\n\\n function claimableRewards(Market market, address account) internal view returns (ClaimableReward[] memory rewards) {\\n RewardsController rewardsController = market.rewardsController();\\n if (address(rewardsController) != address(0)) {\\n ERC20[] memory rewardList = rewardsController.allRewards();\\n\\n rewards = new ClaimableReward[](rewardList.length);\\n RewardsController.MarketOperation[] memory marketOps = new RewardsController.MarketOperation[](1);\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[0] = RewardsController.MarketOperation({ market: market, operations: ops });\\n\\n for (uint256 i = 0; i < rewardList.length; ++i) {\\n rewards[i] = ClaimableReward({\\n asset: address(rewardList[i]),\\n assetName: rewardList[i].name(),\\n assetSymbol: rewardList[i].symbol(),\\n amount: rewardsController.claimable(marketOps, account, rewardList[i])\\n });\\n }\\n }\\n }\\n\\n function floatingAvailableAssets(Market market) internal view returns (uint256) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n uint256 maxAssets = (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor());\\n return maxAssets - Math.min(maxAssets, market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt);\\n }\\n\\n function fixedPositions(\\n Market market,\\n address account,\\n uint256 packedMaturities,\\n function(uint256, address) external view returns (uint256, uint256) getPosition,\\n function(Market, uint256, uint256, address) external view returns (FixedPreview memory) previewValue\\n ) internal view returns (FixedPosition[] memory userMaturityPositions) {\\n uint256 userMaturityCount = 0;\\n FixedPosition[] memory allMaturityPositions = new FixedPosition[](224);\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 positionAssets;\\n {\\n (uint256 principal, uint256 fee) = getPosition(maturity, account);\\n positionAssets = principal + fee;\\n allMaturityPositions[userMaturityCount].position = FixedLib.Position(principal, fee);\\n }\\n try previewValue(market, maturity, positionAssets, account) returns (FixedPreview memory fixedPreview) {\\n allMaturityPositions[userMaturityCount].previewValue = fixedPreview.assets;\\n } catch {\\n allMaturityPositions[userMaturityCount].previewValue = positionAssets;\\n }\\n allMaturityPositions[userMaturityCount].maturity = maturity;\\n ++userMaturityCount;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n\\n userMaturityPositions = new FixedPosition[](userMaturityCount);\\n for (uint256 i = 0; i < userMaturityCount; ++i) userMaturityPositions[i] = allMaturityPositions[i];\\n }\\n\\n function fixedDepositYield(Market market, uint256 maturity, uint256 assets) internal view returns (uint256 yield) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(maturity);\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n maturity - pool.lastAccrual\\n );\\n (yield, ) = pool.calculateDeposit(assets, market.backupFeeRate());\\n }\\n\\n function maxRepay(Market market, address borrower) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(borrower);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n\\n function newFloatingDebt(Market market) internal view returns (uint256) {\\n uint256 memFloatingDebt = market.floatingDebt();\\n uint256 memFloatingAssets = market.floatingAssets();\\n uint256 floatingUtilization = memFloatingAssets > 0\\n ? Math.min(memFloatingDebt.divWadUp(memFloatingAssets), 1e18)\\n : 0;\\n return\\n memFloatingDebt.mulWadDown(\\n market.interestRateModel().floatingRate(floatingUtilization).mulDivDown(\\n block.timestamp - market.lastFloatingDebtUpdate(),\\n 365 days\\n )\\n );\\n }\\n\\n struct RewardsVars {\\n RewardsController controller;\\n uint256 lastUpdate;\\n uint256 depositIndex;\\n uint256 borrowIndex;\\n uint256 projectedDepositIndex;\\n uint256 projectedBorrowIndex;\\n uint256 underlyingBaseUnit;\\n uint256[] maturities;\\n IPriceFeed underlyingPriceFeed;\\n RewardsController.Config config;\\n ERC20[] rewardList;\\n uint256 underlyingDecimals;\\n uint256 deltaTime;\\n uint256 i;\\n uint256 start;\\n uint256 maturity;\\n uint256 fixedDebt;\\n uint256 maxMaturity;\\n uint256 firstMaturity;\\n }\\n}\\n\\nerror InvalidRewardsLength();\\n\",\"keccak256\":\"0x8bcae310e44d6135ca8fe3a0d13735e9a9da40e8c9957063d07cdef508c03da7\",\"license\":\"BUSL-1.1\"},\"contracts/utils/FixedLib.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\nlibrary FixedLib {\\n using FixedPointMathLib for uint256;\\n\\n uint256 internal constant INTERVAL = 4 weeks;\\n\\n /// @notice Gets the amount of revenue sharing between the backup supplier and the new fixed pool supplier.\\n /// @param pool fixed rate pool.\\n /// @param amount amount being provided by the fixed pool supplier.\\n /// @param backupFeeRate rate charged to the fixed pool supplier to be accrued by the backup supplier.\\n /// @return yield amount to be offered to the fixed pool supplier.\\n /// @return backupFee yield to be accrued by the backup supplier for initially providing the liquidity.\\n function calculateDeposit(\\n Pool memory pool,\\n uint256 amount,\\n uint256 backupFeeRate\\n ) internal pure returns (uint256 yield, uint256 backupFee) {\\n uint256 memBackupSupplied = backupSupplied(pool);\\n if (memBackupSupplied != 0) {\\n yield = pool.unassignedEarnings.mulDivDown(Math.min(amount, memBackupSupplied), memBackupSupplied);\\n backupFee = yield.mulWadDown(backupFeeRate);\\n yield -= backupFee;\\n }\\n }\\n\\n /// @notice Registers an operation to add supply to a fixed rate pool and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be added to the supply.\\n /// @param amount amount to be added to the supply.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function deposit(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.supplied = supplied + amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to reduce borrowed amount from a fixed rate pool\\n /// and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be repaid.\\n /// @param amount amount to be added to the fixed rate pool.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function repay(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.borrowed = borrowed - amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to increase borrowed amount of a fixed rate pool\\n /// and potentially increase backup debt.\\n /// @param pool fixed rate pool where an amount will be borrowed.\\n /// @param amount amount to be borrowed from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function borrow(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 newBorrowed = borrowed + amount;\\n\\n backupDebtAddition = newBorrowed - Math.min(Math.max(borrowed, pool.supplied), newBorrowed);\\n pool.borrowed = newBorrowed;\\n }\\n\\n /// @notice Registers an operation to reduce supply from a fixed rate pool and potentially increase backup debt.\\n /// @param pool fixed rate pool where amount will be withdrawn.\\n /// @param amountToDiscount amount to be withdrawn from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function withdraw(Pool storage pool, uint256 amountToDiscount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n uint256 newSupply = supplied - amountToDiscount;\\n\\n backupDebtAddition = Math.min(supplied, borrowed) - Math.min(newSupply, borrowed);\\n pool.supplied = newSupply;\\n }\\n\\n /// @notice Accrues backup earnings from `unassignedEarnings` based on the `lastAccrual` time.\\n /// @param pool fixed rate pool where earnings will be accrued.\\n /// @param maturity maturity date of the pool.\\n /// @return backupEarnings amount of earnings to be distributed to the backup supplier.\\n function accrueEarnings(Pool storage pool, uint256 maturity) internal returns (uint256 backupEarnings) {\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (block.timestamp < maturity) {\\n uint256 unassignedEarnings = pool.unassignedEarnings;\\n pool.lastAccrual = block.timestamp;\\n backupEarnings = unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual);\\n pool.unassignedEarnings = unassignedEarnings - backupEarnings;\\n } else if (lastAccrual == maturity) {\\n backupEarnings = 0;\\n } else {\\n pool.lastAccrual = maturity;\\n backupEarnings = pool.unassignedEarnings;\\n pool.unassignedEarnings = 0;\\n }\\n }\\n\\n /// @notice Calculates the amount that a fixed rate pool borrowed from the backup supplier.\\n /// @param pool fixed rate pool.\\n /// @return amount borrowed from the fixed rate pool.\\n function backupSupplied(Pool memory pool) internal pure returns (uint256) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n return borrowed - Math.min(borrowed, supplied);\\n }\\n\\n /// @notice Modify positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it. Needs for the amount to be less than the principal and the fee\\n /// @param position original position to be scaled.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return scaled position.\\n function scaleProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 principal = amount.mulDivDown(position.principal, position.principal + position.fee);\\n position.principal = principal;\\n position.fee = amount - principal;\\n return position;\\n }\\n\\n /// @notice Reduce positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it.\\n /// @param position original position to be reduced.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return reduced position.\\n function reduceProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 positionAssets = position.principal + position.fee;\\n uint256 newPositionAssets = positionAssets - amount;\\n position.principal = newPositionAssets.mulDivDown(position.principal, positionAssets);\\n position.fee = newPositionAssets - position.principal;\\n return position;\\n }\\n\\n /// @notice Calculates what proportion of earnings would `borrowAmount` represent considering `backupSupplied`.\\n /// @param earnings amount to be distributed.\\n /// @param borrowAmount amount that will be checked if came from the backup supplier or fixed rate pool.\\n /// @return unassignedEarnings earnings to be added to `unassignedEarnings`.\\n /// @return backupEarnings earnings to be distributed to the backup supplier.\\n function distributeEarnings(\\n Pool memory pool,\\n uint256 earnings,\\n uint256 borrowAmount\\n ) internal pure returns (uint256 unassignedEarnings, uint256 backupEarnings) {\\n backupEarnings = borrowAmount == 0\\n ? 0\\n : earnings.mulDivDown(borrowAmount - Math.min(backupSupplied(pool), borrowAmount), borrowAmount);\\n unassignedEarnings = earnings - backupEarnings;\\n }\\n\\n /// @notice Adds a maturity date to the borrow or supply positions of the account.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity the new maturity where the account will borrow or supply to.\\n /// @return updated encoded maturity dates.\\n function setMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n // initialize the maturity with also the 1st bit on the 33th position set\\n if (encoded == 0) return maturity | (1 << 32);\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n if (maturity < baseMaturity) {\\n // if the new maturity is lower than the base, set it as the new base\\n // wipe clean the last 32 bits, shift the amount of `INTERVAL` and set the new value with the 33rd bit set\\n uint256 range = (baseMaturity - maturity) / INTERVAL;\\n if (encoded >> (256 - range) != 0) revert MaturityOverflow();\\n encoded = ((encoded >> 32) << (32 + range));\\n return maturity | encoded | (1 << 32);\\n } else {\\n uint256 range = (maturity - baseMaturity) / INTERVAL;\\n if (range > 223) revert MaturityOverflow();\\n return encoded | (1 << (32 + range));\\n }\\n }\\n\\n /// @notice Remove maturity from account's borrow or supplied positions.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity maturity date to be removed.\\n /// @return updated encoded maturity dates.\\n function clearMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n if (encoded == 0 || encoded == maturity | (1 << 32)) return 0;\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n // if the baseMaturity is the one being cleaned\\n if (maturity == baseMaturity) {\\n // wipe 32 bytes + 1 for the old base flag\\n uint256 packed = encoded >> 33;\\n uint256 range = 1;\\n while ((packed & 1) == 0 && packed != 0) {\\n unchecked {\\n ++range;\\n }\\n packed >>= 1;\\n }\\n encoded = ((encoded >> (32 + range)) << 32);\\n return (maturity + (range * INTERVAL)) | encoded;\\n } else {\\n // otherwise just clear the bit\\n return encoded & ~(1 << (32 + ((maturity - baseMaturity) / INTERVAL)));\\n }\\n }\\n\\n /// @notice Verifies that a maturity is `VALID`, `MATURED`, `NOT_READY` or `INVALID`.\\n /// @dev if expected state doesn't match the calculated one, it reverts with a custom error `UnmatchedPoolState`.\\n /// @param maturity timestamp of the maturity date to be verified.\\n /// @param maxPools number of pools available in the time horizon.\\n /// @param requiredState state required by the caller to be verified (see `State` for description).\\n /// @param alternativeState state required by the caller to be verified (see `State` for description).\\n function checkPoolState(uint256 maturity, uint8 maxPools, State requiredState, State alternativeState) internal view {\\n State state;\\n if (maturity % INTERVAL != 0) {\\n state = State.INVALID;\\n } else if (maturity <= block.timestamp) {\\n state = State.MATURED;\\n } else if (maturity > block.timestamp - (block.timestamp % INTERVAL) + (INTERVAL * maxPools)) {\\n state = State.NOT_READY;\\n } else {\\n state = State.VALID;\\n }\\n\\n if (state != requiredState && state != alternativeState) {\\n if (alternativeState == State.NONE) revert UnmatchedPoolState(uint8(state), uint8(requiredState));\\n\\n revert UnmatchedPoolStates(uint8(state), uint8(requiredState), uint8(alternativeState));\\n }\\n }\\n\\n /// @notice Stores the accountability of a fixed interest rate pool.\\n /// @param borrowed total amount borrowed from the pool.\\n /// @param supplied total amount supplied to the pool.\\n /// @param unassignedEarnings total amount of earnings not yet distributed and accrued.\\n /// @param lastAccrual timestamp for the last time that some earnings have been distributed to the backup supplier.\\n struct Pool {\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 unassignedEarnings;\\n uint256 lastAccrual;\\n }\\n\\n /// @notice Stores principal and fee of a borrow or a supply position of a account in a fixed rate pool.\\n /// @param principal amount borrowed or supplied to the fixed rate pool.\\n /// @param fee amount of fees to be repaid or earned at the maturity of the fixed rate pool.\\n struct Position {\\n uint256 principal;\\n uint256 fee;\\n }\\n\\n enum State {\\n NONE,\\n INVALID,\\n MATURED,\\n VALID,\\n NOT_READY\\n }\\n}\\n\\nerror MaturityOverflow();\\nerror UnmatchedPoolState(uint8 state, uint8 requiredState);\\nerror UnmatchedPoolStates(uint8 state, uint8 requiredState, uint8 alternativeState);\\n\",\"keccak256\":\"0x34f461426e416de7b4d38263269571d0274dda55df2e580e920196096b166c01\",\"license\":\"BUSL-1.1\"},\"contracts/utils/IPriceFeed.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\ninterface IPriceFeed {\\n function decimals() external view returns (uint8);\\n\\n function latestAnswer() external view returns (int256);\\n}\\n\",\"keccak256\":\"0xce1b3c2ebe700449e2e3c7637ffaf85e574eed3f79925feee22426b2c43fc667\",\"license\":\"BUSL-1.1\"},\"solmate/src/mixins/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\nimport {SafeTransferLib} from \\\"../utils/SafeTransferLib.sol\\\";\\nimport {FixedPointMathLib} from \\\"../utils/FixedPointMathLib.sol\\\";\\n\\n/// @notice Minimal ERC4626 tokenized Vault implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol)\\nabstract contract ERC4626 is ERC20 {\\n using SafeTransferLib for ERC20;\\n using FixedPointMathLib for uint256;\\n\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /*//////////////////////////////////////////////////////////////\\n IMMUTABLES\\n //////////////////////////////////////////////////////////////*/\\n\\n ERC20 public immutable asset;\\n\\n constructor(\\n ERC20 _asset,\\n string memory _name,\\n string memory _symbol\\n ) ERC20(_name, _symbol, _asset.decimals()) {\\n asset = _asset;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {\\n // Check for rounding error since we round down in previewDeposit.\\n require((shares = previewDeposit(assets)) != 0, \\\"ZERO_SHARES\\\");\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {\\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function withdraw(\\n uint256 assets,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 shares) {\\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\\n\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n function redeem(\\n uint256 shares,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 assets) {\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n // Check for rounding error since we round down in previewRedeem.\\n require((assets = previewRedeem(shares)) != 0, \\\"ZERO_ASSETS\\\");\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ACCOUNTING LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function totalAssets() public view virtual returns (uint256);\\n\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\\n }\\n\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);\\n }\\n\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return convertToShares(assets);\\n }\\n\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);\\n }\\n\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());\\n }\\n\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return convertToAssets(shares);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LIMIT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return convertToAssets(balanceOf[owner]);\\n }\\n\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf[owner];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL HOOKS LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}\\n\\n function afterDeposit(uint256 assets, uint256 shares) internal virtual {}\\n}\\n\",\"keccak256\":\"0xa0e0c28a727524fa94e7e6c1f4c793a6bd1e6d1bc652b7b02b343ebaf4cd774b\",\"license\":\"MIT\"},\"solmate/src/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0x43aa1509bb753f053143530705d9c4eee415691d26a4779769bf028a74e6ac69\",\"license\":\"MIT\"},\"solmate/src/utils/FixedPointMathLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Arithmetic library with operations for fixed-point numbers.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)\\nlibrary FixedPointMathLib {\\n /*//////////////////////////////////////////////////////////////\\n SIMPLIFIED FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\\n\\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\\n }\\n\\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\\n }\\n\\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\\n }\\n\\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\\n }\\n\\n function powWad(int256 x, int256 y) internal pure returns (int256) {\\n // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)\\n return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.\\n }\\n\\n function expWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n // When the result is < 0.5 we return zero. This happens when\\n // x <= floor(log(0.5e18) * 1e18) ~ -42e18\\n if (x <= -42139678854452767551) return 0;\\n\\n // When the result is > (2**255 - 1) / 1e18 we can not represent it as an\\n // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.\\n if (x >= 135305999368893231589) revert(\\\"EXP_OVERFLOW\\\");\\n\\n // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96\\n // for more intermediate precision and a binary basis. This base conversion\\n // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.\\n x = (x << 78) / 5**18;\\n\\n // Reduce range of x to (-\\u00bd ln 2, \\u00bd ln 2) * 2**96 by factoring out powers\\n // of two such that exp(x) = exp(x') * 2**k, where k is an integer.\\n // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).\\n int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;\\n x = x - k * 54916777467707473351141471128;\\n\\n // k is in the range [-61, 195].\\n\\n // Evaluate using a (6, 7)-term rational approximation.\\n // p is made monic, we'll multiply by a scale factor later.\\n int256 y = x + 1346386616545796478920950773328;\\n y = ((y * x) >> 96) + 57155421227552351082224309758442;\\n int256 p = y + x - 94201549194550492254356042504812;\\n p = ((p * y) >> 96) + 28719021644029726153956944680412240;\\n p = p * x + (4385272521454847904659076985693276 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n int256 q = x - 2855989394907223263936484059900;\\n q = ((q * x) >> 96) + 50020603652535783019961831881945;\\n q = ((q * x) >> 96) - 533845033583426703283633433725380;\\n q = ((q * x) >> 96) + 3604857256930695427073651918091429;\\n q = ((q * x) >> 96) - 14423608567350463180887372962807573;\\n q = ((q * x) >> 96) + 26449188498355588339934803723976023;\\n\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial won't have zeros in the domain as all its roots are complex.\\n // No scaling is necessary because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r should be in the range (0.09, 0.25) * 2**96.\\n\\n // We now need to multiply r by:\\n // * the scale factor s = ~6.031367120.\\n // * the 2**k factor from the range reduction.\\n // * the 1e18 / 2**96 factor for base conversion.\\n // We do this all at once, with an intermediate result in 2**213\\n // basis, so the final right shift is always by a positive amount.\\n r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));\\n }\\n }\\n\\n function lnWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n // We want to convert x from 10**18 fixed point to 2**96 fixed point.\\n // We do this by multiplying by 2**96 / 10**18. But since\\n // ln(x * C) = ln(x) + ln(C), we can simply do nothing here\\n // and add ln(2**96 / 10**18) at the end.\\n\\n // Reduce range of x to (1, 2) * 2**96\\n // ln(2^k * x) = k * ln(2) + ln(x)\\n int256 k = int256(log2(uint256(x))) - 96;\\n x <<= uint256(159 - k);\\n x = int256(uint256(x) >> 159);\\n\\n // Evaluate using a (8, 8)-term rational approximation.\\n // p is made monic, we will multiply by a scale factor later.\\n int256 p = x + 3273285459638523848632254066296;\\n p = ((p * x) >> 96) + 24828157081833163892658089445524;\\n p = ((p * x) >> 96) + 43456485725739037958740375743393;\\n p = ((p * x) >> 96) - 11111509109440967052023855526967;\\n p = ((p * x) >> 96) - 45023709667254063763336534515857;\\n p = ((p * x) >> 96) - 14706773417378608786704636184526;\\n p = p * x - (795164235651350426258249787498 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n // q is monic by convention.\\n int256 q = x + 5573035233440673466300451813936;\\n q = ((q * x) >> 96) + 71694874799317883764090561454958;\\n q = ((q * x) >> 96) + 283447036172924575727196451306956;\\n q = ((q * x) >> 96) + 401686690394027663651624208769553;\\n q = ((q * x) >> 96) + 204048457590392012362485061816622;\\n q = ((q * x) >> 96) + 31853899698501571402653359427138;\\n q = ((q * x) >> 96) + 909429971244387300277376558375;\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial is known not to have zeros in the domain.\\n // No scaling required because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r is in the range (0, 0.125) * 2**96\\n\\n // Finalization, we need to:\\n // * multiply by the scale factor s = 5.549\\u2026\\n // * add ln(2**96 / 10**18)\\n // * add k * ln(2)\\n // * multiply by 10**18 / 2**96 = 5**18 >> 78\\n\\n // mul s * 5e18 * 2**96, base is now 5**18 * 2**192\\n r *= 1677202110996718588342820967067443963516166;\\n // add ln(2) * k * 5e18 * 2**192\\n r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;\\n // add ln(2**96 / 10**18) * 5e18 * 2**192\\n r += 600920179829731861736702779321621459595472258049074101567377883020018308;\\n // base conversion: mul 2**18 / 2**192\\n r >>= 174;\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n LOW LEVEL FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function mulDivDown(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // Divide z by the denominator.\\n z := div(z, denominator)\\n }\\n }\\n\\n function mulDivUp(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // First, divide z - 1 by the denominator and add 1.\\n // We allow z - 1 to underflow if z is 0, because we multiply the\\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\\n }\\n }\\n\\n function rpow(\\n uint256 x,\\n uint256 n,\\n uint256 scalar\\n ) internal pure returns (uint256 z) {\\n assembly {\\n switch x\\n case 0 {\\n switch n\\n case 0 {\\n // 0 ** 0 = 1\\n z := scalar\\n }\\n default {\\n // 0 ** n = 0\\n z := 0\\n }\\n }\\n default {\\n switch mod(n, 2)\\n case 0 {\\n // If n is even, store scalar in z for now.\\n z := scalar\\n }\\n default {\\n // If n is odd, store x in z for now.\\n z := x\\n }\\n\\n // Shifting right by 1 is like dividing by 2.\\n let half := shr(1, scalar)\\n\\n for {\\n // Shift n right by 1 before looping to halve it.\\n n := shr(1, n)\\n } n {\\n // Shift n right by 1 each iteration to halve it.\\n n := shr(1, n)\\n } {\\n // Revert immediately if x ** 2 would overflow.\\n // Equivalent to iszero(eq(div(xx, x), x)) here.\\n if shr(128, x) {\\n revert(0, 0)\\n }\\n\\n // Store x squared.\\n let xx := mul(x, x)\\n\\n // Round to the nearest number.\\n let xxRound := add(xx, half)\\n\\n // Revert if xx + half overflowed.\\n if lt(xxRound, xx) {\\n revert(0, 0)\\n }\\n\\n // Set x to scaled xxRound.\\n x := div(xxRound, scalar)\\n\\n // If n is even:\\n if mod(n, 2) {\\n // Compute z * x.\\n let zx := mul(z, x)\\n\\n // If z * x overflowed:\\n if iszero(eq(div(zx, x), z)) {\\n // Revert if x is non-zero.\\n if iszero(iszero(x)) {\\n revert(0, 0)\\n }\\n }\\n\\n // Round to the nearest number.\\n let zxRound := add(zx, half)\\n\\n // Revert if zx + half overflowed.\\n if lt(zxRound, zx) {\\n revert(0, 0)\\n }\\n\\n // Return properly scaled zxRound.\\n z := div(zxRound, scalar)\\n }\\n }\\n }\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n GENERAL NUMBER UTILITIES\\n //////////////////////////////////////////////////////////////*/\\n\\n function sqrt(uint256 x) internal pure returns (uint256 z) {\\n assembly {\\n let y := x // We start y at x, which will help us make our initial estimate.\\n\\n z := 181 // The \\\"correct\\\" value is 1, but this saves a multiplication later.\\n\\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\\n\\n // We check y >= 2^(k + 8) but shift right by k bits\\n // each branch to ensure that if x >= 256, then y >= 256.\\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\\n y := shr(128, y)\\n z := shl(64, z)\\n }\\n if iszero(lt(y, 0x1000000000000000000)) {\\n y := shr(64, y)\\n z := shl(32, z)\\n }\\n if iszero(lt(y, 0x10000000000)) {\\n y := shr(32, y)\\n z := shl(16, z)\\n }\\n if iszero(lt(y, 0x1000000)) {\\n y := shr(16, y)\\n z := shl(8, z)\\n }\\n\\n // Goal was to get z*z*y within a small factor of x. More iterations could\\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\\n\\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\\n\\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\\n\\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\\n\\n // There is no overflow risk here since y < 2^136 after the first branch above.\\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\\n\\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n\\n // If x+1 is a perfect square, the Babylonian method cycles between\\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\\n z := sub(z, lt(div(x, z), z))\\n }\\n }\\n\\n function log2(uint256 x) internal pure returns (uint256 r) {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n assembly {\\n r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))\\n r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))\\n r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\\n r := or(r, shl(4, lt(0xffff, shr(r, x))))\\n r := or(r, shl(3, lt(0xff, shr(r, x))))\\n r := or(r, shl(2, lt(0xf, shr(r, x))))\\n r := or(r, shl(1, lt(0x3, shr(r, x))))\\n r := or(r, lt(0x1, shr(r, x)))\\n }\\n }\\n\\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := mod(x, y)\\n }\\n }\\n\\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := div(x, y)\\n }\\n }\\n\\n /// @dev Will return 0 instead of reverting if y is zero.\\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // Add 1 to x * y if x % y > 0.\\n z := add(gt(mod(x, y), 0), div(x, y))\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0bf1d4f3999a4471e0fded0a2f67e7fe328e2a27385348571b1fc0a8d9c9f62e\",\"license\":\"MIT\"},\"solmate/src/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Caution! This library won't check that a token has code, responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(4, from) // Append the \\\"from\\\" argument.\\n mstore(36, to) // Append the \\\"to\\\" argument.\\n mstore(68, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because that's the total length of our calldata (4 + 32 * 3)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 100, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x5f2e1158c68c1f3d15b80e8a7dd92b6849f873066969562ad33c0abb80e536ff\",\"license\":\"MIT\"}},\"version\":1}", - "bytecode": "0x60c06040523480156200001157600080fd5b5060405162005ec538038062005ec5833981016040819052620000349162000065565b6001600160a01b039182166080521660a052620000a4565b6001600160a01b03811681146200006257600080fd5b50565b600080604083850312156200007957600080fd5b825162000086816200004c565b602084015190925062000099816200004c565b809150509250929050565b60805160a051615d8c62000139600039600081816101910152818161060b0152818161064701526106df01526000818160f90152818161046c015281816104dd01528181610596015281816107e30152818161093e01528181610f730152818161167a01528181612d95015281816136000152818161372b0152818161380801528181613a2f0152613b060152615d8c6000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80637e789958116100665780637e789958146101335780638eab0a2a14610146578063b15a3f6114610159578063b18ba94514610179578063e41e75121461018c57600080fd5b8063109c46ce14610098578063157c9e0e146100c1578063221e81f6146100e15780633ec045a6146100f4575b600080fd5b6100ab6100a6366004614ddb565b6101b3565b6040516100b89190614e10565b60405180910390f35b6100d46100cf366004614e31565b610444565b6040516100b8919061510b565b6100ab6100ef3660046153e6565b6118b0565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b8565b6100ab6101413660046153e6565b611b79565b6100ab610154366004614ddb565b611ea4565b61016c610167366004615430565b61201c565b6040516100b8919061545c565b61016c610187366004615430565b61217a565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6101d760405180606001604052806000815260200160008152602001600081525090565b6102026040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa158015610247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026b91906154be565b505060208084019190915290825260408051630795bad560e11b815290516000926001600160a01b03891692630f2b75aa92600480830193928290030181865afa1580156102bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e191906154f4565b905060006103de876001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034a919061550d565b8451602086015160405163df635f3d60e01b8152600481018b9052602481018a905260448101929092526064820152608481018590526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa1580156103b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d791906154f4565b869061237a565b9050604051806060016040528087815260200182876103fd9190615540565b815260200160008411610411576000610437565b6104378486602001516104249190615540565b8651610431908a90615540565b90612398565b9052979650505050505050565b60405160016263e28d60e11b031981526001600160a01b0382811660048301526060916000917f0000000000000000000000000000000000000000000000000000000000000000169063ff383ae690602401602060405180830381865afa1580156104b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d791906154f4565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610539573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261056191908101906155f5565b51604051639e9d796760e01b81526001600160a01b0386811660048301526000602483018190526044830181905292935082917f000000000000000000000000000000000000000000000000000000000000000090911690639e9d7967906064016040805180830381865afa1580156105de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106029190615693565b909250905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661064557670de0b6b3a7640000610769565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c791906156c8565b6106d29060126156e3565b6106dd90600a6157e0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075f91906154f4565b61076991906157ef565b9050836001600160401b0381111561078357610783615553565b6040519080825280602002602001820160405280156107bc57816020015b6107a9614ae3565b8152602001906001900390816107a15790505b50955060005b848110156118a5576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610856919061550d565b905061087c60405180606001604052806000815260200160008152602001600081525090565b6040805160a0810182526000808252602082018190528183018190526060820181905260808201529051632f2e037160e11b81526001600160a01b038c81166004830152841690635e5c06e290602401606060405180830381865afa1580156108e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090d9190615806565b604085810191909152602085019190915290835251638e8f294b60e01b81526001600160a01b0384811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015610985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a9919061584b565b6001600160a01b039081166080870152901515606086015260ff918216604080870191909152929091166020808601919091526001600160801b03909316845281516379fed8ad60e11b815291516000939187169263f3fdb15a9260048083019391928290030181865afa158015610a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a49919061550d565b9050604051806103c00160405280856001600160a01b03168152602001856001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610aa4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610acc91908101906158bc565b8152602001836020015160ff168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b40919061550d565b6001600160a01b03168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb0919061550d565b6001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c1591908101906158bc565b8152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7c919061550d565b6001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce191908101906158bc565b81526020016040518060e00160405280846001600160a01b03168152602001846001600160a01b0316634d6fc5226040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6291906154f4565b8152602001846001600160a01b031663dfb08e106040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc991906154f4565b8152602001846001600160a01b0316630481520b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3091906154f4565b8152602001846001600160a01b031663b99699346040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9791906154f4565b8152602001846001600160a01b031663269801216040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe91906154f4565b8152602001846001600160a01b031663d83726856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6591906154f4565b8152508152602001611017887f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b05887608001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b602060405180830381865afa158015610fed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101191906154f4565b9061237a565b8152602001856001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561105a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107e91906154f4565b815260200183600001516001600160801b03168152602001856001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f891906156c8565b60ff168152602001611109866123ad565b81526020016111188689612cf9565b8152602001826001600160a01b03166384a874666000886001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119091906154f4565b1161119c576000611274565b611274611266896001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120491906154f4565b8a6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043191906154f4565b670de0b6b3a7640000613c3c565b6040518263ffffffff1660e01b815260040161129291815260200190565b602060405180830381865afa1580156112af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d391906154f4565b81526020016000866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133c91906154f4565b116113485760006113ee565b6113ee611266876001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561138c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b091906154f4565b886001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b8152602001856001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145591906154f4565b815260200161146386613c52565b8152602001856001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ca91906154f4565b8152602001856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561150d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153191906154f4565b8152602001856001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015611574573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159891906154f4565b8152602001856001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff91906154f4565b81526020016001871b8c1660000361161857600061161b565b60015b15158152602001888a1015611631576000611700565b61170084600001516001600160801b03166116fa8660200151600a61165691906157e0565b6080880151604051631710760b60e31b81526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063b883b05890602401602060405180830381865afa1580156116c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e791906154f4565b8d8f6116f3919061594f565b9190613dd2565b90613e00565b815260200184604001518152602001611719868f613e15565b81526040516370a0823160e01b81526001600160a01b038f811660048301526020909201918716906370a0823190602401602060405180830381865afa158015611767573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178b91906154f4565b815260405163ce96cb7760e01b81526001600160a01b038f8116600483015260209092019187169063ce96cb7790602401602060405180830381865afa1580156117d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fd91906154f4565b815260200161182f868f8760000151896001600160a01b031663ccfd8b11306001600160a01b0316637e789958613ef2565b8152602001611861868f8760200151896001600160a01b031663d2681a0b306001600160a01b031663221e81f6613ef2565b8152602001611870868f6141e0565b8152508b868151811061188557611885615962565b6020026020010181905250505050508061189e90615978565b90506107c2565b505050505050919050565b6118d460405180606001604052806000815260200160008152602001600081525090565b6118ff6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611944573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196891906154be565b50506020838101919091529082526040805180820182526000808252928101929092525163d2681a0b60e01b8152600481018790526001600160a01b03858116602483015288169063d2681a0b906044016040805180830381865afa1580156119d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f99190615693565b602083015281526000611a0c828761463f565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7691906154f4565b90506040518060600160405280898152602001894210611b1f57611b108b6001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ad1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af591906154f4565b611aff8c4261594f565b611b0991906157ef565b8a9061237a565b611b1a908a615540565b611b34565b611b2a8b8b8661468f565b611b34908a61594f565b815260200160008311611b48576000611b68565b611b68838760200151611b5b9190615540565b875161043190879061594f565b90529450505050505b949350505050565b611b9d60405180606001604052806000815260200160008152602001600081525090565b611bc86040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611c0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c3191906154be565b50506020838101919091529082526040805180820182526000808252928101929092525163ccfd8b1160e01b8152600481018790526001600160a01b03858116602483015288169063ccfd8b11906044016040805180830381865afa158015611c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc29190615693565b602083015281526000611cd5828761463f565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3f91906154f4565b90506040518060600160405280898152602001894210611d5f5788611e6a565b611e6a8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc4919061550d565b8751602089015160405163df635f3d60e01b8152600481018f9052602481018e905260448101929092526064820152608481018690526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa158015611e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5191906154f4565b611e6390670de0b6b3a7640000615540565b8a906147f8565b815260200160008311611e7e576000611b68565b611b6884848860200151611e929190615540565b611e9c919061594f565b875190612398565b611ec860405180606001604052806000815260200160008152602001600081525090565b82421115611ee9576040516305a29e1160e51b815260040160405180910390fd5b604051634e7c505960e01b81526004810184905260009081906001600160a01b03871690634e7c505990602401608060405180830381865afa158015611f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5791906154be565b5050915091506000866001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc191906154f4565b90506040518060600160405280878152602001611fdf89898961468f565b611fe99088615540565b815260200160008311611ffd576000610437565b6104378361200b8987615540565b6120159190615540565b8690612398565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561205e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208291906156c8565b60ff16905060006224ea0061209781426159a7565b6120a1904261594f565b6120ab9190615540565b9050816001600160401b038111156120c5576120c5615553565b60405190808252806020026020018201604052801561211a57816020015b61210760405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816120e35790505b50925060005b8281101561217157612133868387611ea4565b84828151811061214557612145615962565b602090810291909101015261215d6224ea0083615540565b91508061216981615978565b915050612120565b50505092915050565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156121bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e091906156c8565b60ff16905060006224ea006121f581426159a7565b6121ff904261594f565b6122099190615540565b9050816001600160401b0381111561222357612223615553565b60405190808252806020026020018201604052801561227857816020015b61226560405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816122415790505b50925060005b828110156121715760405163084e236760e11b81526001600160a01b03871660048201526024810183905260448101869052309063109c46ce90606401606060405180830381865afa9250505080156122f4575060408051601f3d908101601f191682019092526122f1918101906159bb565b60015b612339576040518060600160405280838152602001600019815260200160001981525084828151811061232957612329615962565b6020026020010181905250612359565b8085838151811061234c5761234c615962565b6020026020010181905250505b6123666224ea0083615540565b91508061237281615978565b91505061227e565b600061238f8383670de0b6b3a7640000614809565b90505b92915050565b600061238f83670de0b6b3a764000084613dd2565b606060006123ba83614828565b9050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241e91906156c8565b60ff166001600160401b0381111561243857612438615553565b6040519080825280602002602001820160405280156124b157816020015b61249e60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816124565790505b50915060005b836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061251991906156c8565b60ff16811015612cf25761254e6040518060800160405280600081526020016000815260200160008152602001600081525090565b6001600160a01b038516634e7c5059612568846001615540565b612575906224ea006157ef565b6125826224ea00426159a7565b61258c904261594f565b6125969190615540565b6040518263ffffffff1660e01b81526004016125b491815260200190565b608060405180830381865afa1580156125d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f591906154be565b606085015260408085019190915260208085018390529284528051630795bad560e11b815290516000938493849390926001600160a01b038c1692630f2b75aa92600480820193918290030181865afa158015612656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267a91906154f4565b6126849190615540565b11612691576000806127d9565b866001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f3919061550d565b6001600160a01b03166362caa049846000015185602001518a6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612749573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276d91906154f4565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016040805180830381865afa1580156127b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d99190615693565b915091506128448360600151426127f0919061594f565b6060850151612800876001615540565b61280d906224ea006157ef565b61281a6224ea00426159a7565b612824904261594f565b61282e9190615540565b612838919061594f565b60408601519190614809565b83604001818151612855919061594f565b90525060408051610100810190915280612870866001615540565b61287d906224ea006157ef565b61288a6224ea00426159a7565b612894904261594f565b61289e9190615540565b815260200184600001518152602001846020015181526020016128c985602001518660000151613c3c565b8560200151612b4c612a9f6129c18d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129399190615a16565b61294b90670de0b6b3a7640000615a31565b6001600160801b03168c8f6001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129b791906154f4565b6110119190615540565b8b8e6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a2491906154f4565b8f6001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8691906154f4565b612a909190615540565b612a9a9190615540565b613c3c565b612ae08d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b612aea919061594f565b8c6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9a91906154f4565b612b569190615540565b612b60919061594f565b8152602001828152602001612c936000612b8287600001518860200151613c3c565b8751612b8e919061594f565b11612b9a576000612c43565b612c43612baf87600001518860200151613c3c565b8751612bbb919061594f565b612c3d8c6001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2091906154f4565b612c3290670de0b6b3a764000061594f565b60408a01519061237a565b906147f8565b42612c4f896001615540565b612c5c906224ea006157ef565b612c696224ea00426159a7565b612c73904261594f565b612c7d9190615540565b612c87919061594f565b6301e133809190614809565b8152602001838152602001612cb085600001518660200151613c3c565b8551612cbc919061594f565b815250868581518110612cd157612cd1615962565b60200260200101819052505050508080612cea90615978565b9150506124b7565b5050919050565b6060612d03614c23565b836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d65919061550d565b6001600160a01b031680825215613c3557604051638e8f294b60e01b81526001600160a01b0385811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015612ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e00919061584b565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015612e74573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e9c9190810190615a51565b6101408201819052516001600160401b03811115612ebc57612ebc615553565b604051908082528060200260200182016040528015612f3657816020015b612f236040518060e0016040528060006001600160a01b031681526020016060815260200160608152602001600081526020016000815260200160008152602001606081525090565b815260200190600190039081612eda5790505b5060006101a083015291505b80610140015151816101a001511015613c355780600001516001600160a01b031663f2426f9a85836101400151846101a0015181518110612f8557612f85615962565b60200260200101516040518363ffffffff1660e01b8152600401612fbf9291906001600160a01b0392831681529116602082015260400190565b6101c060405180830381865afa158015612fdd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130019190615b1c565b81610120018190525080600001516001600160a01b03166344e250f885836101400151846101a001518151811061303a5761303a615962565b60200260200101516040518363ffffffff1660e01b81526004016130749291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa158015613091573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130b59190615806565b506040830152606082015280516101408201516101a083015181516001600160a01b039093169263fc196068928892909181106130f4576130f4615962565b60200260200101518461012001516060015163ffffffff164211613119576000613120565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613172573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131969190615806565b50608083015260a082015280516101408201516101a083015181516001600160a01b0390931692635684aa46928892909181106131d5576131d5615962565b60200260200101516040518363ffffffff1660e01b815260040161320f9291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa15801561322c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132509190615c10565b505063ffffffff166101c082018190526224ea00906132709082906159a7565b826101c00151613280919061594f565b61328a9190615540565b81610240018181525050836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132f691906156c8565b6133069060ff166224ea006157ef565b6133136224ea00426159a7565b61331d904261594f565b6133279190615540565b61022082018190526102408201516224ea0091613344919061594f565b61334e9190615c53565b613359906001615540565b6001600160401b0381111561337057613370615553565b604051908082528060200260200182016040528015613399578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e00151116134a1576101e0810151604051630156d37d60e31b81526000916001600160a01b03871691630ab69be8916133fc9160040190815260200190565b6040805180830381865afa158015613418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343c9190615693565b5090508082610200018181516134529190615540565b9052506101e082015160e08301516101c08401518151811061347657613476615962565b6020908102919091010152506101e0810180516224ea000190526101c08101805160010190526133b4565b6040518060e00160405280826101400151836101a00151815181106134c8576134c8615962565b60200260200101516001600160a01b03168152602001826101400151836101a00151815181106134fa576134fa615962565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561353f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261356791908101906158bc565b8152602001826101400151836101a001518151811061358857613588615962565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156135cd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135f591908101906158bc565b8152602001613662857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b058866101200151604001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b81526020016000836102000151876001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136d191906154f4565b6136db9190615540565b116136e7576000613976565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613976936301e1338093909261396f926137da917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613772573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379691906154f4565b8961020001518d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b03918216600482015261396f917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa15801561384f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061387391906154f4565b6110118e6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b81526004016138a991815260200190565b602060405180830381865afa1580156138c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138ea91906154f4565b8f6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015613928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394c91906154f4565b6139569190615540565b8c60c001518d606001518e60a0015161396f919061594f565b9190614809565b81526020016000866001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156139bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139df91906154f4565b116139eb576000613bef565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613bef936301e1338093909261396f92613ad8917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9a91906154f4565b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fed573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b03918216600482015261396f917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613b4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7191906154f4565b6110118e6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd691906154f4565b8c60c001518d604001518e6080015161396f919061594f565b81526020018260e0015181525082826101a0015181518110613c1357613c13615962565b6020026020010181905250806101a0018051613c2e90615978565b9052612f42565b5092915050565b6000818310613c4b578161238f565b5090919050565b600080613c5e83614828565b90506000613d21846001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cc79190615a16565b613cd990670de0b6b3a7640000615a31565b6001600160801b031683866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b9050613dc88183866001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d8a91906154f4565b876001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b611b71908261594f565b828202811515841585830485141716613dea57600080fd5b6001826001830304018115150290509392505050565b600061238f8383670de0b6b3a7640000613dd2565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa158015613e60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e849190615806565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa158015613ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7191906154f4565b6040805160e0808252611c2082019092526060916000918291816020015b613f18614d88565b815260200190600190039081613f10575050602089901c9890915063ffffffff165b881561412a57600189161561410f5760008060008a8a858f6040518363ffffffff1660e01b8152600401613f819291909182526001600160a01b0316602082015260400190565b6040805180830381865afa158015613f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fc19190615693565b9092509050613fd08183615540565b9250604051806040016040528083815260200182815250858781518110613ff957613ff9615962565b602002602001015160400181905250505086868d84848f6040518563ffffffff1660e01b815260040161405594939291906001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b606060405180830381865afa92505050801561408e575060408051601f3d908101601f1916820190925261408b918101906159bb565b60015b6140ba57808385815181106140a5576140a5615962565b602002602001015160200181815250506140e3565b80602001518486815181106140d1576140d1615962565b60200260200101516020018181525050505b818385815181106140f6576140f6615962565b60209081029190910101515261410b84615978565b9350505b60019890981c976141236224ea0082615540565b9050613f3a565b826001600160401b0381111561414257614142615553565b60405190808252806020026020018201604052801561417b57816020015b614168614d88565b8152602001906001900390816141605790505b50935060005b838110156141d15782818151811061419b5761419b615962565b60200260200101518582815181106141b5576141b5615962565b6020026020010181905250806141ca90615978565b9050614181565b50505050979650505050505050565b60606000836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa158015614222573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614246919061550d565b90506001600160a01b03811615613c35576000816001600160a01b031663b7eec4136040518163ffffffff1660e01b8152600401600060405180830381865afa158015614297573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526142bf9190810190615a51565b905080516001600160401b038111156142da576142da615553565b60405190808252806020026020018201604052801561433f57816020015b61432c604051806080016040528060006001600160a01b031681526020016060815260200160608152602001600081525090565b8152602001906001900390816142f85790505b5060408051600180825281830190925291945060009190816020015b60408051808201909152600081526060602082015281526020019060019003908161435b57505060408051600280825260608201835292935060009290916020830190803683370190505090506001816000815181106143bd576143bd615962565b6020026020010190151590811515815250506000816001815181106143e4576143e4615962565b6020026020010190151590811515815250506040518060400160405280886001600160a01b03168152602001828152508260008151811061442757614427615962565b602002602001018190525060005b835181101561463457604051806080016040528085838151811061445b5761445b615962565b60200260200101516001600160a01b0316815260200185838151811061448357614483615962565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156144c8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526144f091908101906158bc565b815260200185838151811061450757614507615962565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561454c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261457491908101906158bc565b8152602001866001600160a01b031663382e85ad868b89878151811061459c5761459c615962565b60200260200101516040518463ffffffff1660e01b81526004016145c293929190615c67565b602060405180830381865afa1580156145df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061460391906154f4565b81525086828151811061461857614618615962565b60200260200101819052508061462d90615978565b9050614435565b505050505092915050565b6040805180820190915260008082526020820152825160208401516000916146739161466b9082615540565b859190614809565b8085529050614682818461594f565b6020850152509192915050565b60006146bc6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa158015614701573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061472591906154be565b60608501819052604085019190915260208401919091529082526147689061474d904261594f565b606083015161475c908761594f565b60408401519190614809565b81604001818151614779919061594f565b915081815250506147ee83866001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156147c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147e691906154f4565b839190614a71565b5095945050505050565b600061238f83670de0b6b3a7640000845b82820281151584158583048514171661482157600080fd5b0492915050565b600080826001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015614869573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061488d91906154f4565b90506000836001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f391906154f4565b90506000808211614905576000614912565b6149126112668484612398565b9050614a68614a61866001600160a01b0316636eb9ffeb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061497c9190615d3b565b61498c9063ffffffff164261594f565b6301e13380886001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156149cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149f3919061550d565b6001600160a01b03166384a87466866040518263ffffffff1660e01b8152600401614a2091815260200190565b602060405180830381865afa158015614a3d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061396f91906154f4565b849061237a565b95945050505050565b6000806000614a7f86614ac4565b90508015614abb57614aa0614a948683613c3c565b60408801519083614809565b9250614aac838561237a565b9150614ab8828461594f565b92505b50935093915050565b8051602082015160009190614ad98282613c3c565b611b71908361594f565b604051806103c0016040528060006001600160a01b0316815260200160608152602001600060ff16815260200160006001600160a01b031681526020016060815260200160608152602001614b776040518060e0016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001600081526020016000815260200160008152602001600060ff1681526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160608152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b03168152602001614d43604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001614dbe604051806040016040528060008152602001600081525090565b905290565b6001600160a01b0381168114614dd857600080fd5b50565b600080600060608486031215614df057600080fd5b8335614dfb81614dc3565b95602085013595506040909401359392505050565b81518152602080830151908201526040808301519082015260608101612392565b600060208284031215614e4357600080fd5b8135614e4e81614dc3565b9392505050565b60005b83811015614e70578181015183820152602001614e58565b50506000910152565b60008151808452614e91816020860160208601614e55565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b83811015614f1e57815180518852838101518489015260408082015190890152606080820151908901526080808201519089015260a0808201519089015260c0808201519089015260e090810151908801526101009096019590820190600101614eb9565b509495945050505050565b600081518084526020808501808196508360051b810191508286016000805b8681101561500e578385038a52825180516001600160a01b031686528681015160e088880181905290614f7d82890182614e79565b915050604080830151888303828a0152614f978382614e79565b606085810151908b0152608080860151908b015260a080860151908b015260c0948501518a8203958b01959095528451808252948b0194879450908b01925090505b80831015614ff95783518252928901926001929092019190890190614fd9565b509b88019b9650505091850191600101614f48565b509298975050505050505050565b600081518084526020808501945080840160005b83811015614f1e578151805188528381015184890152604090810151805191890191909152830151606088015260809096019590820190600101615030565b600081518084526020808501808196508360051b8101915082860160005b858110156150fe578284038952815180516001600160a01b03168552858101516080878701819052906150c282880182614e79565b915050604080830151878303828901526150dc8382614e79565b606094850151989094019790975250509885019893509084019060010161508d565b5091979650505050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b838110156153d857888303603f19018552815180516001600160a01b0316845261048088820151818a87015261516a82870182614e79565b9150508782015161517f8987018260ff169052565b506060828101516001600160a01b031690860152608080830151868303828801526151aa8382614e79565b9250505060a080830151868303828801526151c58382614e79565b60c08581015180516001600160a01b03168a830152602081015160e08b015260408101516101008b015260608101516101208b015260808101516101408b015260a08101516101608b0152808201516101808b015291945092509050505060e08201516101a0818188015261010084015191506101c0828189015261012085015192506101e083818a01526101408601519350610200615269818b018660ff169052565b61016087015194506102208a8703818c01526152858787614ea5565b965061018088015195506102408b8803818d01526152a38888614f29565b958901516102608d81019190915294890151610280808e0191909152938901516102a0808e0191909152928901516102c0808e0191909152918901516102e0808e019190915290890151610300808e019190915294890151610320808e019190915293890151610340808e01919091529289015195975094955091939092610360929190615334848d018815159052565b918801516103808c810191909152908801516103a0808d0191909152918801516103c08c0152848801516103e08c0152838801516104008c0152828801518b88036104208d0152955090615388878761501c565b96508188015195508a87036104408c01526153a3878761501c565b96508088015197505050505050508481036104608601526153c4818361506f565b968901969450505090860190600101615132565b509098975050505050505050565b600080600080608085870312156153fc57600080fd5b843561540781614dc3565b93506020850135925060408501359150606085013561542581614dc3565b939692955090935050565b6000806040838503121561544357600080fd5b823561544e81614dc3565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156154b25761549f8385518051825260208082015190830152604090810151910152565b9284019260609290920191600101615478565b50909695505050505050565b600080600080608085870312156154d457600080fd5b505082516020840151604085015160609095015191969095509092509050565b60006020828403121561550657600080fd5b5051919050565b60006020828403121561551f57600080fd5b8151614e4e81614dc3565b634e487b7160e01b600052601160045260246000fd5b808201808211156123925761239261552a565b634e487b7160e01b600052604160045260246000fd5b6040516101c081016001600160401b038111828210171561558c5761558c615553565b60405290565b604051601f8201601f191681016001600160401b03811182821017156155ba576155ba615553565b604052919050565b60006001600160401b038211156155db576155db615553565b5060051b60200190565b80516155f081614dc3565b919050565b6000602080838503121561560857600080fd5b82516001600160401b0381111561561e57600080fd5b8301601f8101851361562f57600080fd5b805161564261563d826155c2565b615592565b81815260059190911b8201830190838101908783111561566157600080fd5b928401925b8284101561568857835161567981614dc3565b82529284019290840190615666565b979650505050505050565b600080604083850312156156a657600080fd5b505080516020909101519092909150565b805160ff811681146155f057600080fd5b6000602082840312156156da57600080fd5b61238f826156b7565b60ff82811682821603908111156123925761239261552a565b600181815b8085111561573757816000190482111561571d5761571d61552a565b8085161561572a57918102915b93841c9390800290615701565b509250929050565b60008261574e57506001612392565b8161575b57506000612392565b8160018114615771576002811461577b57615797565b6001915050612392565b60ff84111561578c5761578c61552a565b50506001821b612392565b5060208310610133831016604e8410600b84101617156157ba575081810a612392565b6157c483836156fc565b80600019048211156157d8576157d861552a565b029392505050565b600061238f60ff84168361573f565b80820281158282048414176123925761239261552a565b60008060006060848603121561581b57600080fd5b8351925060208401519150604084015190509250925092565b80516001600160801b03811681146155f057600080fd5b600080600080600060a0868803121561586357600080fd5b61586c86615834565b945061587a602087016156b7565b9350615888604087016156b7565b92506060860151801515811461589d57600080fd5b60808701519092506158ae81614dc3565b809150509295509295909350565b6000602082840312156158ce57600080fd5b81516001600160401b03808211156158e557600080fd5b818401915084601f8301126158f957600080fd5b81518181111561590b5761590b615553565b61591e601f8201601f1916602001615592565b915080825285602082850101111561593557600080fd5b615946816020840160208601614e55565b50949350505050565b818103818111156123925761239261552a565b634e487b7160e01b600052603260045260246000fd5b60006001820161598a5761598a61552a565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826159b6576159b6615991565b500690565b6000606082840312156159cd57600080fd5b604051606081018181106001600160401b03821117156159ef576159ef615553565b80604052508251815260208301516020820152604083015160408201528091505092915050565b600060208284031215615a2857600080fd5b61238f82615834565b6001600160801b03828116828216039080821115613c3557613c3561552a565b60006020808385031215615a6457600080fd5b82516001600160401b03811115615a7a57600080fd5b8301601f81018513615a8b57600080fd5b8051615a9961563d826155c2565b81815260059190911b82018301908381019087831115615ab857600080fd5b928401925b82841015615688578351615ad081614dc3565b82529284019290840190615abd565b805163ffffffff811681146155f057600080fd5b8051600f81900b81146155f057600080fd5b80516001600160401b03811681146155f057600080fd5b60006101c08284031215615b2f57600080fd5b615b37615569565b615b40836155e5565b8152615b4e602084016155e5565b6020820152615b5f604084016155e5565b6040820152615b7060608401615adf565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615bab818501615af3565b90820152610120615bbd848201615b05565b90820152610140615bcf848201615b05565b90820152610160615be1848201615b05565b90820152610180615bf3848201615b05565b908201526101a0615c05848201615b05565b908201529392505050565b600080600060608486031215615c2557600080fd5b615c2e84615adf565b9250615c3c60208501615adf565b9150615c4a60408501615adf565b90509250925092565b600082615c6257615c62615991565b500490565b6000606080830181845280875180835260808601915060808160051b87010192506020808a016000805b84811015615d0757898703607f19018652825180516001600160a01b0316885284015160408589018190528151908901819052908501908989019084905b80821015615cf157835115158352928701929187019160019190910190615ccf565b5090985050509483019491830191600101615c91565b505050839550615d218188018a6001600160a01b03169052565b5050505050611b7160408301846001600160a01b03169052565b600060208284031215615d4d57600080fd5b61238f82615adf56fea2646970667358221220093d1f3bd547fc6838ab3949c2cad17f1f26c083f0fb629588138cffbfcfe39e64736f6c63430008110033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c80637e789958116100665780637e789958146101335780638eab0a2a14610146578063b15a3f6114610159578063b18ba94514610179578063e41e75121461018c57600080fd5b8063109c46ce14610098578063157c9e0e146100c1578063221e81f6146100e15780633ec045a6146100f4575b600080fd5b6100ab6100a6366004614ddb565b6101b3565b6040516100b89190614e10565b60405180910390f35b6100d46100cf366004614e31565b610444565b6040516100b8919061510b565b6100ab6100ef3660046153e6565b6118b0565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b8565b6100ab6101413660046153e6565b611b79565b6100ab610154366004614ddb565b611ea4565b61016c610167366004615430565b61201c565b6040516100b8919061545c565b61016c610187366004615430565b61217a565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6101d760405180606001604052806000815260200160008152602001600081525090565b6102026040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa158015610247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026b91906154be565b505060208084019190915290825260408051630795bad560e11b815290516000926001600160a01b03891692630f2b75aa92600480830193928290030181865afa1580156102bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e191906154f4565b905060006103de876001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034a919061550d565b8451602086015160405163df635f3d60e01b8152600481018b9052602481018a905260448101929092526064820152608481018590526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa1580156103b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d791906154f4565b869061237a565b9050604051806060016040528087815260200182876103fd9190615540565b815260200160008411610411576000610437565b6104378486602001516104249190615540565b8651610431908a90615540565b90612398565b9052979650505050505050565b60405160016263e28d60e11b031981526001600160a01b0382811660048301526060916000917f0000000000000000000000000000000000000000000000000000000000000000169063ff383ae690602401602060405180830381865afa1580156104b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d791906154f4565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610539573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261056191908101906155f5565b51604051639e9d796760e01b81526001600160a01b0386811660048301526000602483018190526044830181905292935082917f000000000000000000000000000000000000000000000000000000000000000090911690639e9d7967906064016040805180830381865afa1580156105de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106029190615693565b909250905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661064557670de0b6b3a7640000610769565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c791906156c8565b6106d29060126156e3565b6106dd90600a6157e0565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075f91906154f4565b61076991906157ef565b9050836001600160401b0381111561078357610783615553565b6040519080825280602002602001820160405280156107bc57816020015b6107a9614ae3565b8152602001906001900390816107a15790505b50955060005b848110156118a5576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610856919061550d565b905061087c60405180606001604052806000815260200160008152602001600081525090565b6040805160a0810182526000808252602082018190528183018190526060820181905260808201529051632f2e037160e11b81526001600160a01b038c81166004830152841690635e5c06e290602401606060405180830381865afa1580156108e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090d9190615806565b604085810191909152602085019190915290835251638e8f294b60e01b81526001600160a01b0384811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015610985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a9919061584b565b6001600160a01b039081166080870152901515606086015260ff918216604080870191909152929091166020808601919091526001600160801b03909316845281516379fed8ad60e11b815291516000939187169263f3fdb15a9260048083019391928290030181865afa158015610a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a49919061550d565b9050604051806103c00160405280856001600160a01b03168152602001856001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610aa4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610acc91908101906158bc565b8152602001836020015160ff168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b40919061550d565b6001600160a01b03168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb0919061550d565b6001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c1591908101906158bc565b8152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7c919061550d565b6001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce191908101906158bc565b81526020016040518060e00160405280846001600160a01b03168152602001846001600160a01b0316634d6fc5226040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6291906154f4565b8152602001846001600160a01b031663dfb08e106040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc991906154f4565b8152602001846001600160a01b0316630481520b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3091906154f4565b8152602001846001600160a01b031663b99699346040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9791906154f4565b8152602001846001600160a01b031663269801216040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe91906154f4565b8152602001846001600160a01b031663d83726856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6591906154f4565b8152508152602001611017887f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b05887608001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b602060405180830381865afa158015610fed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101191906154f4565b9061237a565b8152602001856001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561105a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107e91906154f4565b815260200183600001516001600160801b03168152602001856001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f891906156c8565b60ff168152602001611109866123ad565b81526020016111188689612cf9565b8152602001826001600160a01b03166384a874666000886001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119091906154f4565b1161119c576000611274565b611274611266896001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120491906154f4565b8a6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043191906154f4565b670de0b6b3a7640000613c3c565b6040518263ffffffff1660e01b815260040161129291815260200190565b602060405180830381865afa1580156112af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d391906154f4565b81526020016000866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133c91906154f4565b116113485760006113ee565b6113ee611266876001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561138c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b091906154f4565b886001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b8152602001856001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145591906154f4565b815260200161146386613c52565b8152602001856001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ca91906154f4565b8152602001856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561150d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153191906154f4565b8152602001856001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015611574573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159891906154f4565b8152602001856001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff91906154f4565b81526020016001871b8c1660000361161857600061161b565b60015b15158152602001888a1015611631576000611700565b61170084600001516001600160801b03166116fa8660200151600a61165691906157e0565b6080880151604051631710760b60e31b81526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063b883b05890602401602060405180830381865afa1580156116c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e791906154f4565b8d8f6116f3919061594f565b9190613dd2565b90613e00565b815260200184604001518152602001611719868f613e15565b81526040516370a0823160e01b81526001600160a01b038f811660048301526020909201918716906370a0823190602401602060405180830381865afa158015611767573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178b91906154f4565b815260405163ce96cb7760e01b81526001600160a01b038f8116600483015260209092019187169063ce96cb7790602401602060405180830381865afa1580156117d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fd91906154f4565b815260200161182f868f8760000151896001600160a01b031663ccfd8b11306001600160a01b0316637e789958613ef2565b8152602001611861868f8760200151896001600160a01b031663d2681a0b306001600160a01b031663221e81f6613ef2565b8152602001611870868f6141e0565b8152508b868151811061188557611885615962565b6020026020010181905250505050508061189e90615978565b90506107c2565b505050505050919050565b6118d460405180606001604052806000815260200160008152602001600081525090565b6118ff6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611944573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196891906154be565b50506020838101919091529082526040805180820182526000808252928101929092525163d2681a0b60e01b8152600481018790526001600160a01b03858116602483015288169063d2681a0b906044016040805180830381865afa1580156119d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f99190615693565b602083015281526000611a0c828761463f565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7691906154f4565b90506040518060600160405280898152602001894210611b1f57611b108b6001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ad1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af591906154f4565b611aff8c4261594f565b611b0991906157ef565b8a9061237a565b611b1a908a615540565b611b34565b611b2a8b8b8661468f565b611b34908a61594f565b815260200160008311611b48576000611b68565b611b68838760200151611b5b9190615540565b875161043190879061594f565b90529450505050505b949350505050565b611b9d60405180606001604052806000815260200160008152602001600081525090565b611bc86040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611c0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c3191906154be565b50506020838101919091529082526040805180820182526000808252928101929092525163ccfd8b1160e01b8152600481018790526001600160a01b03858116602483015288169063ccfd8b11906044016040805180830381865afa158015611c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc29190615693565b602083015281526000611cd5828761463f565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3f91906154f4565b90506040518060600160405280898152602001894210611d5f5788611e6a565b611e6a8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc4919061550d565b8751602089015160405163df635f3d60e01b8152600481018f9052602481018e905260448101929092526064820152608481018690526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa158015611e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5191906154f4565b611e6390670de0b6b3a7640000615540565b8a906147f8565b815260200160008311611e7e576000611b68565b611b6884848860200151611e929190615540565b611e9c919061594f565b875190612398565b611ec860405180606001604052806000815260200160008152602001600081525090565b82421115611ee9576040516305a29e1160e51b815260040160405180910390fd5b604051634e7c505960e01b81526004810184905260009081906001600160a01b03871690634e7c505990602401608060405180830381865afa158015611f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5791906154be565b5050915091506000866001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc191906154f4565b90506040518060600160405280878152602001611fdf89898961468f565b611fe99088615540565b815260200160008311611ffd576000610437565b6104378361200b8987615540565b6120159190615540565b8690612398565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561205e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061208291906156c8565b60ff16905060006224ea0061209781426159a7565b6120a1904261594f565b6120ab9190615540565b9050816001600160401b038111156120c5576120c5615553565b60405190808252806020026020018201604052801561211a57816020015b61210760405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816120e35790505b50925060005b8281101561217157612133868387611ea4565b84828151811061214557612145615962565b602090810291909101015261215d6224ea0083615540565b91508061216981615978565b915050612120565b50505092915050565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156121bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e091906156c8565b60ff16905060006224ea006121f581426159a7565b6121ff904261594f565b6122099190615540565b9050816001600160401b0381111561222357612223615553565b60405190808252806020026020018201604052801561227857816020015b61226560405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816122415790505b50925060005b828110156121715760405163084e236760e11b81526001600160a01b03871660048201526024810183905260448101869052309063109c46ce90606401606060405180830381865afa9250505080156122f4575060408051601f3d908101601f191682019092526122f1918101906159bb565b60015b612339576040518060600160405280838152602001600019815260200160001981525084828151811061232957612329615962565b6020026020010181905250612359565b8085838151811061234c5761234c615962565b6020026020010181905250505b6123666224ea0083615540565b91508061237281615978565b91505061227e565b600061238f8383670de0b6b3a7640000614809565b90505b92915050565b600061238f83670de0b6b3a764000084613dd2565b606060006123ba83614828565b9050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241e91906156c8565b60ff166001600160401b0381111561243857612438615553565b6040519080825280602002602001820160405280156124b157816020015b61249e60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816124565790505b50915060005b836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061251991906156c8565b60ff16811015612cf25761254e6040518060800160405280600081526020016000815260200160008152602001600081525090565b6001600160a01b038516634e7c5059612568846001615540565b612575906224ea006157ef565b6125826224ea00426159a7565b61258c904261594f565b6125969190615540565b6040518263ffffffff1660e01b81526004016125b491815260200190565b608060405180830381865afa1580156125d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f591906154be565b606085015260408085019190915260208085018390529284528051630795bad560e11b815290516000938493849390926001600160a01b038c1692630f2b75aa92600480820193918290030181865afa158015612656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267a91906154f4565b6126849190615540565b11612691576000806127d9565b866001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f3919061550d565b6001600160a01b03166362caa049846000015185602001518a6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612749573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276d91906154f4565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016040805180830381865afa1580156127b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d99190615693565b915091506128448360600151426127f0919061594f565b6060850151612800876001615540565b61280d906224ea006157ef565b61281a6224ea00426159a7565b612824904261594f565b61282e9190615540565b612838919061594f565b60408601519190614809565b83604001818151612855919061594f565b90525060408051610100810190915280612870866001615540565b61287d906224ea006157ef565b61288a6224ea00426159a7565b612894904261594f565b61289e9190615540565b815260200184600001518152602001846020015181526020016128c985602001518660000151613c3c565b8560200151612b4c612a9f6129c18d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129399190615a16565b61294b90670de0b6b3a7640000615a31565b6001600160801b03168c8f6001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129b791906154f4565b6110119190615540565b8b8e6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a2491906154f4565b8f6001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8691906154f4565b612a909190615540565b612a9a9190615540565b613c3c565b612ae08d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b612aea919061594f565b8c6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9a91906154f4565b612b569190615540565b612b60919061594f565b8152602001828152602001612c936000612b8287600001518860200151613c3c565b8751612b8e919061594f565b11612b9a576000612c43565b612c43612baf87600001518860200151613c3c565b8751612bbb919061594f565b612c3d8c6001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2091906154f4565b612c3290670de0b6b3a764000061594f565b60408a01519061237a565b906147f8565b42612c4f896001615540565b612c5c906224ea006157ef565b612c696224ea00426159a7565b612c73904261594f565b612c7d9190615540565b612c87919061594f565b6301e133809190614809565b8152602001838152602001612cb085600001518660200151613c3c565b8551612cbc919061594f565b815250868581518110612cd157612cd1615962565b60200260200101819052505050508080612cea90615978565b9150506124b7565b5050919050565b6060612d03614c23565b836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d65919061550d565b6001600160a01b031680825215613c3557604051638e8f294b60e01b81526001600160a01b0385811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015612ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e00919061584b565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015612e74573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e9c9190810190615a51565b6101408201819052516001600160401b03811115612ebc57612ebc615553565b604051908082528060200260200182016040528015612f3657816020015b612f236040518060e0016040528060006001600160a01b031681526020016060815260200160608152602001600081526020016000815260200160008152602001606081525090565b815260200190600190039081612eda5790505b5060006101a083015291505b80610140015151816101a001511015613c355780600001516001600160a01b031663f2426f9a85836101400151846101a0015181518110612f8557612f85615962565b60200260200101516040518363ffffffff1660e01b8152600401612fbf9291906001600160a01b0392831681529116602082015260400190565b6101c060405180830381865afa158015612fdd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130019190615b1c565b81610120018190525080600001516001600160a01b03166344e250f885836101400151846101a001518151811061303a5761303a615962565b60200260200101516040518363ffffffff1660e01b81526004016130749291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa158015613091573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130b59190615806565b506040830152606082015280516101408201516101a083015181516001600160a01b039093169263fc196068928892909181106130f4576130f4615962565b60200260200101518461012001516060015163ffffffff164211613119576000613120565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613172573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131969190615806565b50608083015260a082015280516101408201516101a083015181516001600160a01b0390931692635684aa46928892909181106131d5576131d5615962565b60200260200101516040518363ffffffff1660e01b815260040161320f9291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa15801561322c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132509190615c10565b505063ffffffff166101c082018190526224ea00906132709082906159a7565b826101c00151613280919061594f565b61328a9190615540565b81610240018181525050836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132f691906156c8565b6133069060ff166224ea006157ef565b6133136224ea00426159a7565b61331d904261594f565b6133279190615540565b61022082018190526102408201516224ea0091613344919061594f565b61334e9190615c53565b613359906001615540565b6001600160401b0381111561337057613370615553565b604051908082528060200260200182016040528015613399578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e00151116134a1576101e0810151604051630156d37d60e31b81526000916001600160a01b03871691630ab69be8916133fc9160040190815260200190565b6040805180830381865afa158015613418573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061343c9190615693565b5090508082610200018181516134529190615540565b9052506101e082015160e08301516101c08401518151811061347657613476615962565b6020908102919091010152506101e0810180516224ea000190526101c08101805160010190526133b4565b6040518060e00160405280826101400151836101a00151815181106134c8576134c8615962565b60200260200101516001600160a01b03168152602001826101400151836101a00151815181106134fa576134fa615962565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561353f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261356791908101906158bc565b8152602001826101400151836101a001518151811061358857613588615962565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156135cd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526135f591908101906158bc565b8152602001613662857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b058866101200151604001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b81526020016000836102000151876001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136d191906154f4565b6136db9190615540565b116136e7576000613976565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613976936301e1338093909261396f926137da917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613772573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379691906154f4565b8961020001518d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b03918216600482015261396f917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa15801561384f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061387391906154f4565b6110118e6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b81526004016138a991815260200190565b602060405180830381865afa1580156138c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138ea91906154f4565b8f6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015613928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394c91906154f4565b6139569190615540565b8c60c001518d606001518e60a0015161396f919061594f565b9190614809565b81526020016000866001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156139bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139df91906154f4565b116139eb576000613bef565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613bef936301e1338093909261396f92613ad8917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613a76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a9a91906154f4565b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fed573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b03918216600482015261396f917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613b4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b7191906154f4565b6110118e6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd691906154f4565b8c60c001518d604001518e6080015161396f919061594f565b81526020018260e0015181525082826101a0015181518110613c1357613c13615962565b6020026020010181905250806101a0018051613c2e90615978565b9052612f42565b5092915050565b6000818310613c4b578161238f565b5090919050565b600080613c5e83614828565b90506000613d21846001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cc79190615a16565b613cd990670de0b6b3a7640000615a31565b6001600160801b031683866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b9050613dc88183866001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015613d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d8a91906154f4565b876001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b611b71908261594f565b828202811515841585830485141716613dea57600080fd5b6001826001830304018115150290509392505050565b600061238f8383670de0b6b3a7640000613dd2565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa158015613e60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e849190615806565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa158015613ece573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7191906154f4565b6040805160e0808252611c2082019092526060916000918291816020015b613f18614d88565b815260200190600190039081613f10575050602089901c9890915063ffffffff165b881561412a57600189161561410f5760008060008a8a858f6040518363ffffffff1660e01b8152600401613f819291909182526001600160a01b0316602082015260400190565b6040805180830381865afa158015613f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fc19190615693565b9092509050613fd08183615540565b9250604051806040016040528083815260200182815250858781518110613ff957613ff9615962565b602002602001015160400181905250505086868d84848f6040518563ffffffff1660e01b815260040161405594939291906001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b606060405180830381865afa92505050801561408e575060408051601f3d908101601f1916820190925261408b918101906159bb565b60015b6140ba57808385815181106140a5576140a5615962565b602002602001015160200181815250506140e3565b80602001518486815181106140d1576140d1615962565b60200260200101516020018181525050505b818385815181106140f6576140f6615962565b60209081029190910101515261410b84615978565b9350505b60019890981c976141236224ea0082615540565b9050613f3a565b826001600160401b0381111561414257614142615553565b60405190808252806020026020018201604052801561417b57816020015b614168614d88565b8152602001906001900390816141605790505b50935060005b838110156141d15782818151811061419b5761419b615962565b60200260200101518582815181106141b5576141b5615962565b6020026020010181905250806141ca90615978565b9050614181565b50505050979650505050505050565b60606000836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa158015614222573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614246919061550d565b90506001600160a01b03811615613c35576000816001600160a01b031663b7eec4136040518163ffffffff1660e01b8152600401600060405180830381865afa158015614297573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526142bf9190810190615a51565b905080516001600160401b038111156142da576142da615553565b60405190808252806020026020018201604052801561433f57816020015b61432c604051806080016040528060006001600160a01b031681526020016060815260200160608152602001600081525090565b8152602001906001900390816142f85790505b5060408051600180825281830190925291945060009190816020015b60408051808201909152600081526060602082015281526020019060019003908161435b57505060408051600280825260608201835292935060009290916020830190803683370190505090506001816000815181106143bd576143bd615962565b6020026020010190151590811515815250506000816001815181106143e4576143e4615962565b6020026020010190151590811515815250506040518060400160405280886001600160a01b03168152602001828152508260008151811061442757614427615962565b602002602001018190525060005b835181101561463457604051806080016040528085838151811061445b5761445b615962565b60200260200101516001600160a01b0316815260200185838151811061448357614483615962565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156144c8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526144f091908101906158bc565b815260200185838151811061450757614507615962565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa15801561454c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261457491908101906158bc565b8152602001866001600160a01b031663382e85ad868b89878151811061459c5761459c615962565b60200260200101516040518463ffffffff1660e01b81526004016145c293929190615c67565b602060405180830381865afa1580156145df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061460391906154f4565b81525086828151811061461857614618615962565b60200260200101819052508061462d90615978565b9050614435565b505050505092915050565b6040805180820190915260008082526020820152825160208401516000916146739161466b9082615540565b859190614809565b8085529050614682818461594f565b6020850152509192915050565b60006146bc6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa158015614701573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061472591906154be565b60608501819052604085019190915260208401919091529082526147689061474d904261594f565b606083015161475c908761594f565b60408401519190614809565b81604001818151614779919061594f565b915081815250506147ee83866001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156147c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147e691906154f4565b839190614a71565b5095945050505050565b600061238f83670de0b6b3a7640000845b82820281151584158583048514171661482157600080fd5b0492915050565b600080826001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015614869573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061488d91906154f4565b90506000836001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f391906154f4565b90506000808211614905576000614912565b6149126112668484612398565b9050614a68614a61866001600160a01b0316636eb9ffeb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061497c9190615d3b565b61498c9063ffffffff164261594f565b6301e13380886001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156149cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149f3919061550d565b6001600160a01b03166384a87466866040518263ffffffff1660e01b8152600401614a2091815260200190565b602060405180830381865afa158015614a3d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061396f91906154f4565b849061237a565b95945050505050565b6000806000614a7f86614ac4565b90508015614abb57614aa0614a948683613c3c565b60408801519083614809565b9250614aac838561237a565b9150614ab8828461594f565b92505b50935093915050565b8051602082015160009190614ad98282613c3c565b611b71908361594f565b604051806103c0016040528060006001600160a01b0316815260200160608152602001600060ff16815260200160006001600160a01b031681526020016060815260200160608152602001614b776040518060e0016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001600081526020016000815260200160008152602001600060ff1681526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160608152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b03168152602001614d43604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001614dbe604051806040016040528060008152602001600081525090565b905290565b6001600160a01b0381168114614dd857600080fd5b50565b600080600060608486031215614df057600080fd5b8335614dfb81614dc3565b95602085013595506040909401359392505050565b81518152602080830151908201526040808301519082015260608101612392565b600060208284031215614e4357600080fd5b8135614e4e81614dc3565b9392505050565b60005b83811015614e70578181015183820152602001614e58565b50506000910152565b60008151808452614e91816020860160208601614e55565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b83811015614f1e57815180518852838101518489015260408082015190890152606080820151908901526080808201519089015260a0808201519089015260c0808201519089015260e090810151908801526101009096019590820190600101614eb9565b509495945050505050565b600081518084526020808501808196508360051b810191508286016000805b8681101561500e578385038a52825180516001600160a01b031686528681015160e088880181905290614f7d82890182614e79565b915050604080830151888303828a0152614f978382614e79565b606085810151908b0152608080860151908b015260a080860151908b015260c0948501518a8203958b01959095528451808252948b0194879450908b01925090505b80831015614ff95783518252928901926001929092019190890190614fd9565b509b88019b9650505091850191600101614f48565b509298975050505050505050565b600081518084526020808501945080840160005b83811015614f1e578151805188528381015184890152604090810151805191890191909152830151606088015260809096019590820190600101615030565b600081518084526020808501808196508360051b8101915082860160005b858110156150fe578284038952815180516001600160a01b03168552858101516080878701819052906150c282880182614e79565b915050604080830151878303828901526150dc8382614e79565b606094850151989094019790975250509885019893509084019060010161508d565b5091979650505050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b838110156153d857888303603f19018552815180516001600160a01b0316845261048088820151818a87015261516a82870182614e79565b9150508782015161517f8987018260ff169052565b506060828101516001600160a01b031690860152608080830151868303828801526151aa8382614e79565b9250505060a080830151868303828801526151c58382614e79565b60c08581015180516001600160a01b03168a830152602081015160e08b015260408101516101008b015260608101516101208b015260808101516101408b015260a08101516101608b0152808201516101808b015291945092509050505060e08201516101a0818188015261010084015191506101c0828189015261012085015192506101e083818a01526101408601519350610200615269818b018660ff169052565b61016087015194506102208a8703818c01526152858787614ea5565b965061018088015195506102408b8803818d01526152a38888614f29565b958901516102608d81019190915294890151610280808e0191909152938901516102a0808e0191909152928901516102c0808e0191909152918901516102e0808e019190915290890151610300808e019190915294890151610320808e019190915293890151610340808e01919091529289015195975094955091939092610360929190615334848d018815159052565b918801516103808c810191909152908801516103a0808d0191909152918801516103c08c0152848801516103e08c0152838801516104008c0152828801518b88036104208d0152955090615388878761501c565b96508188015195508a87036104408c01526153a3878761501c565b96508088015197505050505050508481036104608601526153c4818361506f565b968901969450505090860190600101615132565b509098975050505050505050565b600080600080608085870312156153fc57600080fd5b843561540781614dc3565b93506020850135925060408501359150606085013561542581614dc3565b939692955090935050565b6000806040838503121561544357600080fd5b823561544e81614dc3565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156154b25761549f8385518051825260208082015190830152604090810151910152565b9284019260609290920191600101615478565b50909695505050505050565b600080600080608085870312156154d457600080fd5b505082516020840151604085015160609095015191969095509092509050565b60006020828403121561550657600080fd5b5051919050565b60006020828403121561551f57600080fd5b8151614e4e81614dc3565b634e487b7160e01b600052601160045260246000fd5b808201808211156123925761239261552a565b634e487b7160e01b600052604160045260246000fd5b6040516101c081016001600160401b038111828210171561558c5761558c615553565b60405290565b604051601f8201601f191681016001600160401b03811182821017156155ba576155ba615553565b604052919050565b60006001600160401b038211156155db576155db615553565b5060051b60200190565b80516155f081614dc3565b919050565b6000602080838503121561560857600080fd5b82516001600160401b0381111561561e57600080fd5b8301601f8101851361562f57600080fd5b805161564261563d826155c2565b615592565b81815260059190911b8201830190838101908783111561566157600080fd5b928401925b8284101561568857835161567981614dc3565b82529284019290840190615666565b979650505050505050565b600080604083850312156156a657600080fd5b505080516020909101519092909150565b805160ff811681146155f057600080fd5b6000602082840312156156da57600080fd5b61238f826156b7565b60ff82811682821603908111156123925761239261552a565b600181815b8085111561573757816000190482111561571d5761571d61552a565b8085161561572a57918102915b93841c9390800290615701565b509250929050565b60008261574e57506001612392565b8161575b57506000612392565b8160018114615771576002811461577b57615797565b6001915050612392565b60ff84111561578c5761578c61552a565b50506001821b612392565b5060208310610133831016604e8410600b84101617156157ba575081810a612392565b6157c483836156fc565b80600019048211156157d8576157d861552a565b029392505050565b600061238f60ff84168361573f565b80820281158282048414176123925761239261552a565b60008060006060848603121561581b57600080fd5b8351925060208401519150604084015190509250925092565b80516001600160801b03811681146155f057600080fd5b600080600080600060a0868803121561586357600080fd5b61586c86615834565b945061587a602087016156b7565b9350615888604087016156b7565b92506060860151801515811461589d57600080fd5b60808701519092506158ae81614dc3565b809150509295509295909350565b6000602082840312156158ce57600080fd5b81516001600160401b03808211156158e557600080fd5b818401915084601f8301126158f957600080fd5b81518181111561590b5761590b615553565b61591e601f8201601f1916602001615592565b915080825285602082850101111561593557600080fd5b615946816020840160208601614e55565b50949350505050565b818103818111156123925761239261552a565b634e487b7160e01b600052603260045260246000fd5b60006001820161598a5761598a61552a565b5060010190565b634e487b7160e01b600052601260045260246000fd5b6000826159b6576159b6615991565b500690565b6000606082840312156159cd57600080fd5b604051606081018181106001600160401b03821117156159ef576159ef615553565b80604052508251815260208301516020820152604083015160408201528091505092915050565b600060208284031215615a2857600080fd5b61238f82615834565b6001600160801b03828116828216039080821115613c3557613c3561552a565b60006020808385031215615a6457600080fd5b82516001600160401b03811115615a7a57600080fd5b8301601f81018513615a8b57600080fd5b8051615a9961563d826155c2565b81815260059190911b82018301908381019087831115615ab857600080fd5b928401925b82841015615688578351615ad081614dc3565b82529284019290840190615abd565b805163ffffffff811681146155f057600080fd5b8051600f81900b81146155f057600080fd5b80516001600160401b03811681146155f057600080fd5b60006101c08284031215615b2f57600080fd5b615b37615569565b615b40836155e5565b8152615b4e602084016155e5565b6020820152615b5f604084016155e5565b6040820152615b7060608401615adf565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615bab818501615af3565b90820152610120615bbd848201615b05565b90820152610140615bcf848201615b05565b90820152610160615be1848201615b05565b90820152610180615bf3848201615b05565b908201526101a0615c05848201615b05565b908201529392505050565b600080600060608486031215615c2557600080fd5b615c2e84615adf565b9250615c3c60208501615adf565b9150615c4a60408501615adf565b90509250925092565b600082615c6257615c62615991565b500490565b6000606080830181845280875180835260808601915060808160051b87010192506020808a016000805b84811015615d0757898703607f19018652825180516001600160a01b0316885284015160408589018190528151908901819052908501908989019084905b80821015615cf157835115158352928701929187019160019190910190615ccf565b5090985050509483019491830191600101615c91565b505050839550615d218188018a6001600160a01b03169052565b5050505050611b7160408301846001600160a01b03169052565b600060208284031215615d4d57600080fd5b61238f82615adf56fea2646970667358221220093d1f3bd547fc6838ab3949c2cad17f1f26c083f0fb629588138cffbfcfe39e64736f6c63430008110033", + "numDeployments": 4, + "solcInputHash": "0f3d5a71c203a330ccec578b8f3450f8", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"auditor_\",\"type\":\"address\"},{\"internalType\":\"contract IPriceFeed\",\"name\":\"basePriceFeed_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AlreadyMatured\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"auditor\",\"outputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"basePriceFeed\",\"outputs\":[{\"internalType\":\"contract IPriceFeed\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"exactly\",\"outputs\":[{\"components\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"decimals\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"id\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"fixedCurveA\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"fixedCurveB\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"fixedMaxUtilization\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingCurveA\",\"type\":\"uint256\"},{\"internalType\":\"int256\",\"name\":\"floatingCurveB\",\"type\":\"int256\"},{\"internalType\":\"uint256\",\"name\":\"floatingMaxUtilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.InterestRateModel\",\"name\":\"interestRateModel\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"usdPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"penaltyRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"adjustFactor\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"maxFuturePools\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowed\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"supplied\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"available\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"depositRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minBorrowRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimalDeposit\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPool[]\",\"name\":\"fixedPools\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"contract ERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"usdPrice\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrow\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingDeposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"maturities\",\"type\":\"uint256[]\"}],\"internalType\":\"struct Previewer.RewardRate[]\",\"name\":\"rewardRates\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"floatingBorrowRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingUtilization\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingBackupBorrowed\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingAvailableAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingDepositAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingBorrowShares\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalFloatingDepositShares\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"isCollateral\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingBorrowShares\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingDepositShares\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"floatingDepositAssets\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previewValue\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"internalType\":\"struct FixedLib.Position\",\"name\":\"position\",\"type\":\"tuple\"}],\"internalType\":\"struct Previewer.FixedPosition[]\",\"name\":\"fixedDepositPositions\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"previewValue\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"internalType\":\"struct FixedLib.Position\",\"name\":\"position\",\"type\":\"tuple\"}],\"internalType\":\"struct Previewer.FixedPosition[]\",\"name\":\"fixedBorrowPositions\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"assetName\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"assetSymbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.ClaimableReward[]\",\"name\":\"claimableRewards\",\"type\":\"tuple[]\"}],\"internalType\":\"struct Previewer.MarketAccount[]\",\"name\":\"data\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewBorrowAtAllMaturities\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview[]\",\"name\":\"previews\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewBorrowAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewDepositAtAllMaturities\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview[]\",\"name\":\"previews\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"}],\"name\":\"previewDepositAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionAssets\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"borrower\",\"type\":\"address\"}],\"name\":\"previewRepayAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"positionAssets\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"previewWithdrawAtMaturity\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"assets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"utilization\",\"type\":\"uint256\"}],\"internalType\":\"struct Previewer.FixedPreview\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"exactly(address)\":{\"params\":{\"account\":\"address which the extended data will be calculated.\"},\"returns\":{\"data\":\"extended accountability of all markets for the account.\"}},\"previewBorrowAtAllMaturities(address,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be borrowed.\",\"market\":\"address of the market.\"},\"returns\":{\"previews\":\"array containing amount plus yield that account will receive after each maturity.\"}},\"previewBorrowAtMaturity(address,uint256,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be borrowed.\",\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be borrowed.\"},\"returns\":{\"_0\":\"positionAssets amount plus fees that the depositor will repay at maturity.\"}},\"previewDepositAtAllMaturities(address,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be deposited.\",\"market\":\"address of the market.\"},\"returns\":{\"previews\":\"array containing amount plus yield that account will receive after each maturity.\"}},\"previewDepositAtMaturity(address,uint256,uint256)\":{\"params\":{\"assets\":\"amount of assets that will be deposited.\",\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be deposited.\"},\"returns\":{\"_0\":\"amount plus yield that the depositor will receive after maturity.\"}},\"previewRepayAtMaturity(address,uint256,uint256,address)\":{\"params\":{\"borrower\":\"address of the borrower.\",\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be repaid.\",\"positionAssets\":\"amount of assets that will be subtracted from the position.\"},\"returns\":{\"_0\":\"repayAssets amount of assets that will be repaid.\"}},\"previewWithdrawAtMaturity(address,uint256,uint256,address)\":{\"params\":{\"market\":\"address of the market.\",\"maturity\":\"maturity date/pool where the assets will be withdrawn.\",\"positionAssets\":\"amount of assets that will be tried to withdraw.\"},\"returns\":{\"_0\":\"withdrawAssets amount that will be withdrawn.\"}}},\"stateVariables\":{\"auditor\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"basePriceFeed\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"Previewer\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"exactly(address)\":{\"notice\":\"Function to get a certain account extended data.\"},\"previewBorrowAtAllMaturities(address,uint256)\":{\"notice\":\"Gets the assets plus fees offered by all VALID maturities when borrowing a certain amount.\"},\"previewBorrowAtMaturity(address,uint256,uint256)\":{\"notice\":\"Gets the amount plus fees to be repaid at maturity when borrowing certain amount of assets.\"},\"previewDepositAtAllMaturities(address,uint256)\":{\"notice\":\"Gets the assets plus yield offered by all VALID maturities when depositing a certain amount.\"},\"previewDepositAtMaturity(address,uint256,uint256)\":{\"notice\":\"Gets the assets plus yield offered by a maturity when depositing a certain amount.\"},\"previewRepayAtMaturity(address,uint256,uint256,address)\":{\"notice\":\"Gets the assets that will be repaid when repaying a certain amount at the current maturity.\"},\"previewWithdrawAtMaturity(address,uint256,uint256,address)\":{\"notice\":\"Gets the amount to be withdrawn for a certain positionAmount of assets at maturity.\"}},\"notice\":\"Contract to be consumed by Exactly's front-end dApp.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/Previewer.sol\":\"Previewer\"},\"debug\":{\"revertStrings\":\"strip\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IAccessControlUpgradeable.sol\\\";\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../utils/StringsUpgradeable.sol\\\";\\nimport \\\"../utils/introspection/ERC165Upgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module that allows children to implement role-based access\\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\\n * members except through off-chain means by accessing the contract event logs. Some\\n * applications may benefit from on-chain enumerability, for those cases see\\n * {AccessControlEnumerable}.\\n *\\n * Roles are referred to by their `bytes32` identifier. These should be exposed\\n * in the external API and be unique. The best way to achieve this is by\\n * using `public constant` hash digests:\\n *\\n * ```solidity\\n * bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\");\\n * ```\\n *\\n * Roles can be used to represent a set of permissions. To restrict access to a\\n * function call, use {hasRole}:\\n *\\n * ```solidity\\n * function foo() public {\\n * require(hasRole(MY_ROLE, msg.sender));\\n * ...\\n * }\\n * ```\\n *\\n * Roles can be granted and revoked dynamically via the {grantRole} and\\n * {revokeRole} functions. Each role has an associated admin role, and only\\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\\n *\\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\\n * that only accounts with this role will be able to grant or revoke other\\n * roles. More complex role relationships can be created by using\\n * {_setRoleAdmin}.\\n *\\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\\n * grant and revoke this role. Extra precautions should be taken to secure\\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\\n * to enforce additional security measures for this role.\\n */\\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {\\n function __AccessControl_init() internal onlyInitializing {\\n }\\n\\n function __AccessControl_init_unchained() internal onlyInitializing {\\n }\\n struct RoleData {\\n mapping(address => bool) members;\\n bytes32 adminRole;\\n }\\n\\n mapping(bytes32 => RoleData) private _roles;\\n\\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\\n\\n /**\\n * @dev Modifier that checks that an account has a specific role. Reverts\\n * with a standardized message including the required role.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n *\\n * _Available since v4.1._\\n */\\n modifier onlyRole(bytes32 role) {\\n _checkRole(role);\\n _;\\n }\\n\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);\\n }\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\\n return _roles[role].members[account];\\n }\\n\\n /**\\n * @dev Revert with a standard message if `_msgSender()` is missing `role`.\\n * Overriding this function changes the behavior of the {onlyRole} modifier.\\n *\\n * Format of the revert message is described in {_checkRole}.\\n *\\n * _Available since v4.6._\\n */\\n function _checkRole(bytes32 role) internal view virtual {\\n _checkRole(role, _msgSender());\\n }\\n\\n /**\\n * @dev Revert with a standard message if `account` is missing `role`.\\n *\\n * The format of the revert reason is given by the following regular expression:\\n *\\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\\n */\\n function _checkRole(bytes32 role, address account) internal view virtual {\\n if (!hasRole(role, account)) {\\n revert(\\n string(\\n abi.encodePacked(\\n \\\"AccessControl: account \\\",\\n StringsUpgradeable.toHexString(account),\\n \\\" is missing role \\\",\\n StringsUpgradeable.toHexString(uint256(role), 32)\\n )\\n )\\n );\\n }\\n }\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\\n return _roles[role].adminRole;\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function renounceRole(bytes32 role, address account) public virtual override {\\n require(account == _msgSender(), \\\"AccessControl: can only renounce roles for self\\\");\\n\\n _revokeRole(role, account);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event. Note that unlike {grantRole}, this function doesn't perform any\\n * checks on the calling account.\\n *\\n * May emit a {RoleGranted} event.\\n *\\n * [WARNING]\\n * ====\\n * This function should only be called from the constructor when setting\\n * up the initial roles for the system.\\n *\\n * Using this function in any other way is effectively circumventing the admin\\n * system imposed by {AccessControl}.\\n * ====\\n *\\n * NOTE: This function is deprecated in favor of {_grantRole}.\\n */\\n function _setupRole(bytes32 role, address account) internal virtual {\\n _grantRole(role, account);\\n }\\n\\n /**\\n * @dev Sets `adminRole` as ``role``'s admin role.\\n *\\n * Emits a {RoleAdminChanged} event.\\n */\\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\\n bytes32 previousAdminRole = getRoleAdmin(role);\\n _roles[role].adminRole = adminRole;\\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\\n }\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleGranted} event.\\n */\\n function _grantRole(bytes32 role, address account) internal virtual {\\n if (!hasRole(role, account)) {\\n _roles[role].members[account] = true;\\n emit RoleGranted(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * Internal function without access restriction.\\n *\\n * May emit a {RoleRevoked} event.\\n */\\n function _revokeRole(bytes32 role, address account) internal virtual {\\n if (hasRole(role, account)) {\\n _roles[role].members[account] = false;\\n emit RoleRevoked(role, account, _msgSender());\\n }\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0xfeefb24d068524440e1ba885efdf105d91f83504af3c2d745ffacc4595396831\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev External interface of AccessControl declared to support ERC165 detection.\\n */\\ninterface IAccessControlUpgradeable {\\n /**\\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\\n *\\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\\n * {RoleAdminChanged} not being emitted signaling this.\\n *\\n * _Available since v3.1._\\n */\\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\\n\\n /**\\n * @dev Emitted when `account` is granted `role`.\\n *\\n * `sender` is the account that originated the contract call, an admin role\\n * bearer except when using {AccessControl-_setupRole}.\\n */\\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Emitted when `account` is revoked `role`.\\n *\\n * `sender` is the account that originated the contract call:\\n * - if using `revokeRole`, it is the admin role bearer\\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\\n */\\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\\n\\n /**\\n * @dev Returns `true` if `account` has been granted `role`.\\n */\\n function hasRole(bytes32 role, address account) external view returns (bool);\\n\\n /**\\n * @dev Returns the admin role that controls `role`. See {grantRole} and\\n * {revokeRole}.\\n *\\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\\n */\\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\\n\\n /**\\n * @dev Grants `role` to `account`.\\n *\\n * If `account` had not been already granted `role`, emits a {RoleGranted}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function grantRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from `account`.\\n *\\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\\n *\\n * Requirements:\\n *\\n * - the caller must have ``role``'s admin role.\\n */\\n function revokeRole(bytes32 role, address account) external;\\n\\n /**\\n * @dev Revokes `role` from the calling account.\\n *\\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\\n * purpose is to provide a mechanism for accounts to lose their privileges\\n * if they are compromised (such as when a trusted device is misplaced).\\n *\\n * If the calling account had been granted `role`, emits a {RoleRevoked}\\n * event.\\n *\\n * Requirements:\\n *\\n * - the caller must be `account`.\\n */\\n function renounceRole(bytes32 role, address account) external;\\n}\\n\",\"keccak256\":\"0xb8f5302f12138c5561362e88a78d061573e6298b7a1a5afe84a1e2c8d4d5aeaa\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```solidity\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n *\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts.\\n *\\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\\n * constructor.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = !_initializing;\\n require(\\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n _initialized = 1;\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\\n * are added through upgrades and that require initialization.\\n *\\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\\n * cannot be nested. If one is invoked in the context of another, execution will revert.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n *\\n * WARNING: setting the version to 255 will prevent any future reinitialization.\\n *\\n * Emits an {Initialized} event.\\n */\\n modifier reinitializer(uint8 version) {\\n require(!_initializing && _initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n _initializing = true;\\n _;\\n _initializing = false;\\n emit Initialized(version);\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n *\\n * Emits an {Initialized} event the first time it is successfully executed.\\n */\\n function _disableInitializers() internal virtual {\\n require(!_initializing, \\\"Initializable: contract is initializing\\\");\\n if (_initialized != type(uint8).max) {\\n _initialized = type(uint8).max;\\n emit Initialized(type(uint8).max);\\n }\\n }\\n\\n /**\\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\\n */\\n function _getInitializedVersion() internal view returns (uint8) {\\n return _initialized;\\n }\\n\\n /**\\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\\n */\\n function _isInitializing() internal view returns (bool) {\\n return _initializing;\\n }\\n}\\n\",\"keccak256\":\"0x89be10e757d242e9b18d5a32c9fbe2019f6d63052bbe46397a430a1d60d7f794\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/ContextUpgradeable.sol\\\";\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract PausableUpgradeable is Initializable, ContextUpgradeable {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n function __Pausable_init() internal onlyInitializing {\\n __Pausable_init_unchained();\\n }\\n\\n function __Pausable_init_unchained() internal onlyInitializing {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n _requireNotPaused();\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n _requirePaused();\\n _;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Throws if the contract is paused.\\n */\\n function _requireNotPaused() internal view virtual {\\n require(!paused(), \\\"Pausable: paused\\\");\\n }\\n\\n /**\\n * @dev Throws if the contract is not paused.\\n */\\n function _requirePaused() internal view virtual {\\n require(paused(), \\\"Pausable: not paused\\\");\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[49] private __gap;\\n}\\n\",\"keccak256\":\"0x40c636b4572ff5f1dc50cf22097e93c0723ee14eff87e99ac2b02636eeca1250\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n *\\n * Furthermore, `isContract` will also return true if the target contract within\\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\\n * which only has an effect at the end of a transaction.\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\\n *\\n * _Available since v4.8._\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n if (success) {\\n if (returndata.length == 0) {\\n // only check isContract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n }\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason or using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n _revert(returndata, errorMessage);\\n }\\n }\\n\\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9c80f545915582e63fe206c6ce27cbe85a86fc10b9cd2a0e8c9488fb7c2ee422\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\nimport \\\"../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract ContextUpgradeable is Initializable {\\n function __Context_init() internal onlyInitializing {\\n }\\n\\n function __Context_init_unchained() internal onlyInitializing {\\n }\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x963ea7f0b48b032eef72fe3a7582edf78408d6f834115b9feadd673a4d5bd149\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./math/MathUpgradeable.sol\\\";\\nimport \\\"./math/SignedMathUpgradeable.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _SYMBOLS = \\\"0123456789abcdef\\\";\\n uint8 private constant _ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = MathUpgradeable.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\\n */\\n function toString(int256 value) internal pure returns (string memory) {\\n return string(abi.encodePacked(value < 0 ? \\\"-\\\" : \\\"\\\", toString(SignedMathUpgradeable.abs(value))));\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, MathUpgradeable.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\\n }\\n\\n /**\\n * @dev Returns true if the two strings are equal.\\n */\\n function equal(string memory a, string memory b) internal pure returns (bool) {\\n return keccak256(bytes(a)) == keccak256(bytes(b));\\n }\\n}\\n\",\"keccak256\":\"0xb96dc79b65b7c37937919dcdb356a969ce0aa2e8338322bf4dc027a3c9c9a7eb\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC165Upgradeable.sol\\\";\\nimport \\\"../../proxy/utils/Initializable.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC165} interface.\\n *\\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\\n * for the additional interface id that will be supported. For example:\\n *\\n * ```solidity\\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\\n * }\\n * ```\\n *\\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\\n */\\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\\n function __ERC165_init() internal onlyInitializing {\\n }\\n\\n function __ERC165_init_unchained() internal onlyInitializing {\\n }\\n /**\\n * @dev See {IERC165-supportsInterface}.\\n */\\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\\n return interfaceId == type(IERC165Upgradeable).interfaceId;\\n }\\n\\n /**\\n * @dev This empty reserved space is put in place to allow future versions to add new\\n * variables without shifting down storage in the inheritance chain.\\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n */\\n uint256[50] private __gap;\\n}\\n\",\"keccak256\":\"0x9a3b990bd56d139df3e454a9edf1c64668530b5a77fc32eb063bc206f958274a\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165Upgradeable {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xc6cef87559d0aeffdf0a99803de655938a7779ec0a3cd5d4383483ad85565a09\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary MathUpgradeable {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1, \\\"Math: mulDiv overflow\\\");\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2bc0007987c229ae7624eb29be6a9b84f6a6a5872f76248b15208b131ea41c4e\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMathUpgradeable {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two signed numbers.\\n */\\n function min(int256 a, int256 b) internal pure returns (int256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two signed numbers without overflow.\\n * The result is rounded towards zero.\\n */\\n function average(int256 a, int256 b) internal pure returns (int256) {\\n // Formula from the book \\\"Hacker's Delight\\\"\\n int256 x = (a & b) + ((a ^ b) >> 1);\\n return x + (int256(uint256(x) >> 255) & (a ^ b));\\n }\\n\\n /**\\n * @dev Returns the absolute unsigned value of a signed value.\\n */\\n function abs(int256 n) internal pure returns (uint256) {\\n unchecked {\\n // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x88f6b7bba3ee33eeb741f9a0f5bc98b6e6e352d0fe4905377bb328590f84095a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n enum Rounding {\\n Down, // Toward negative infinity\\n Up, // Toward infinity\\n Zero // Toward zero\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\\n * with further edits by Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod0 := mul(x, y)\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n require(denominator > prod1, \\\"Math: mulDiv overflow\\\");\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\\n // See https://cs.stackexchange.com/q/138556/92363.\\n\\n // Does not overflow because the denominator cannot be zero at this stage in the function.\\n uint256 twos = denominator & (~denominator + 1);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\\n // in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256, rounded down, of a positive value.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xe4455ac1eb7fc497bb7402579e7b4d64d928b846fce7d2b6fde06d366f21c2b3\",\"license\":\"MIT\"},\"contracts/Auditor.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract Auditor is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n\\n /// @notice Address that a market should have as price feed to consider as base price and avoid external price call.\\n address public constant BASE_FEED = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\\n /// @notice Target health factor that the account should have after it's liquidated to prevent cascade liquidations.\\n uint256 public constant TARGET_HEALTH = 1.25e18;\\n /// @notice Maximum value the liquidator can send and still have granular control of max assets.\\n /// Above this threshold, they should send `type(uint256).max`.\\n uint256 public constant ASSETS_THRESHOLD = type(uint256).max / 1e18;\\n\\n /// @notice Decimals that the answer of all price feeds should have.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 public immutable priceDecimals;\\n /// @notice Base factor to scale the price returned by the feed to 18 decimals.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable baseFactor;\\n /// @notice Base price used if the feed to fetch the price from is `BASE_FEED`.\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n uint256 internal immutable basePrice;\\n\\n /// @notice Tracks the markets' indexes that an account has entered as collateral.\\n mapping(address => uint256) public accountMarkets;\\n /// @notice Stores market parameters per each enabled market.\\n mapping(Market => MarketData) public markets;\\n /// @notice Array of all enabled markets.\\n Market[] public marketList;\\n\\n /// @notice Liquidation incentive factors for the liquidator and the lenders of the market where the debt is repaid.\\n LiquidationIncentive public liquidationIncentive;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(uint256 priceDecimals_) {\\n priceDecimals = priceDecimals_;\\n baseFactor = 10 ** (18 - priceDecimals_);\\n basePrice = 10 ** priceDecimals_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(LiquidationIncentive memory liquidationIncentive_) external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setLiquidationIncentive(liquidationIncentive_);\\n }\\n\\n /// @notice Allows assets of a certain market to be used as collateral for borrowing other assets.\\n /// @param market market to enabled as collateral.\\n function enterMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) != 0) return;\\n accountMarkets[msg.sender] = marketMap | marketMask;\\n\\n emit MarketEntered(market, msg.sender);\\n }\\n\\n /// @notice Removes market from sender's account liquidity calculation.\\n /// @dev Sender must not have an outstanding borrow balance in the asset, or be providing necessary collateral\\n /// for an outstanding borrow.\\n /// @param market market to be disabled as collateral.\\n function exitMarket(Market market) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n (uint256 assets, uint256 debt) = market.accountSnapshot(msg.sender);\\n\\n // fail if the sender has a borrow balance\\n if (debt != 0) revert RemainingDebt();\\n\\n // fail if the sender is not permitted to redeem all of their assets\\n checkShortfall(market, msg.sender, assets);\\n\\n uint256 marketMap = accountMarkets[msg.sender];\\n uint256 marketMask = 1 << m.index;\\n\\n if ((marketMap & marketMask) == 0) return;\\n accountMarkets[msg.sender] = marketMap & ~marketMask;\\n\\n emit MarketExited(market, msg.sender);\\n }\\n\\n /// @notice Returns account's liquidity calculation.\\n /// @param account account in which the liquidity will be calculated.\\n /// @param marketToSimulate market in which to simulate withdraw operation.\\n /// @param withdrawAmount amount to simulate as withdraw.\\n /// @return sumCollateral sum of all collateral, already multiplied by each adjust factor (denominated in base).\\n /// @return sumDebtPlusEffects sum of all debt divided by adjust factor considering withdrawal (denominated in base).\\n function accountLiquidity(\\n address account,\\n Market marketToSimulate,\\n uint256 withdrawAmount\\n ) public view returns (uint256 sumCollateral, uint256 sumDebtPlusEffects) {\\n AccountLiquidity memory vars; // holds all our calculation results\\n\\n // for each asset the account is in\\n uint256 marketMap = accountMarkets[account];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 baseUnit = 10 ** m.decimals;\\n uint256 adjustFactor = m.adjustFactor;\\n\\n // read the balances\\n (vars.balance, vars.borrowBalance) = market.accountSnapshot(account);\\n\\n // get the normalized price of the asset (18 decimals)\\n vars.price = assetPrice(m.priceFeed);\\n\\n // sum all the collateral prices\\n sumCollateral += vars.balance.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n\\n // sum all the debt\\n sumDebtPlusEffects += vars.borrowBalance.mulDivUp(vars.price, baseUnit).divWadUp(adjustFactor);\\n\\n // simulate the effects of withdrawing from a pool\\n if (market == marketToSimulate) {\\n // calculate the effects of redeeming markets\\n // (having less collateral is the same as having more debt for this calculation)\\n if (withdrawAmount != 0) {\\n sumDebtPlusEffects += withdrawAmount.mulDivDown(vars.price, baseUnit).mulWadDown(adjustFactor);\\n }\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Validates that the current state of the position and system are valid.\\n /// @dev To be called after adding the borrowed debt to the account position.\\n /// @param market address of the market where the borrow is made.\\n /// @param borrower address of the account that will repay the debt.\\n function checkBorrow(Market market, address borrower) external {\\n MarketData storage m = markets[market];\\n if (!m.isListed) revert MarketNotListed();\\n\\n uint256 marketMap = accountMarkets[borrower];\\n uint256 marketMask = 1 << m.index;\\n\\n // validate borrow state\\n if ((marketMap & marketMask) == 0) {\\n // only markets may call checkBorrow if borrower not in market\\n if (msg.sender != address(market)) revert NotMarket();\\n\\n accountMarkets[borrower] = marketMap | marketMask;\\n emit MarketEntered(market, borrower);\\n }\\n\\n // verify that current liquidity is not short\\n (uint256 collateral, uint256 debt) = accountLiquidity(borrower, Market(address(0)), 0);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Checks if the account has liquidity shortfall.\\n /// @param market address of the market where the operation will happen.\\n /// @param account address of the account to check for possible shortfall.\\n /// @param amount amount that the account wants to withdraw or transfer.\\n function checkShortfall(Market market, address account, uint256 amount) public view {\\n // if the account is not 'in' the market, bypass the liquidity check\\n if ((accountMarkets[account] & (1 << markets[market].index)) == 0) return;\\n\\n // otherwise, perform a hypothetical liquidity check to guard against shortfall\\n (uint256 collateral, uint256 debt) = accountLiquidity(account, market, amount);\\n if (collateral < debt) revert InsufficientAccountLiquidity();\\n }\\n\\n /// @notice Allows/rejects liquidation of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt is being repaid.\\n /// @param seizeMarket market from where the liquidator will seize assets.\\n /// @param borrower address in which the assets are being liquidated.\\n /// @param maxLiquidatorAssets maximum amount of debt the liquidator is willing to accept.\\n /// @return maxRepayAssets capped amount of debt the liquidator is allowed to repay.\\n function checkLiquidation(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 maxLiquidatorAssets\\n ) external view returns (uint256 maxRepayAssets) {\\n // if markets are listed, they have the same auditor\\n if (!markets[repayMarket].isListed || !markets[seizeMarket].isListed) revert MarketNotListed();\\n\\n MarketVars memory repay;\\n LiquidityVars memory base;\\n uint256 marketMap = accountMarkets[borrower];\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage marketData = markets[market];\\n MarketVars memory m = MarketVars({\\n price: assetPrice(marketData.priceFeed),\\n adjustFactor: marketData.adjustFactor,\\n baseUnit: 10 ** marketData.decimals\\n });\\n\\n if (market == repayMarket) repay = m;\\n\\n (uint256 collateral, uint256 debt) = market.accountSnapshot(borrower);\\n\\n uint256 value = debt.mulDivUp(m.price, m.baseUnit);\\n base.totalDebt += value;\\n base.adjustedDebt += value.divWadUp(m.adjustFactor);\\n\\n value = collateral.mulDivDown(m.price, m.baseUnit);\\n base.totalCollateral += value;\\n base.adjustedCollateral += value.mulWadDown(m.adjustFactor);\\n if (market == seizeMarket) base.seizeAvailable = value;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n if (base.adjustedCollateral >= base.adjustedDebt) revert InsufficientShortfall();\\n\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n uint256 adjustFactor = base.adjustedCollateral.mulWadDown(base.totalDebt).divWadUp(\\n base.adjustedDebt.mulWadUp(base.totalCollateral)\\n );\\n uint256 closeFactor = (TARGET_HEALTH - base.adjustedCollateral.divWadUp(base.adjustedDebt)).divWadUp(\\n TARGET_HEALTH - adjustFactor.mulWadDown(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n );\\n maxRepayAssets = Math.min(\\n Math\\n .min(\\n base.totalDebt.mulWadUp(Math.min(1e18, closeFactor)),\\n base.seizeAvailable.divWadUp(1e18 + memIncentive.liquidator + memIncentive.lenders)\\n )\\n .mulDivUp(repay.baseUnit, repay.price),\\n maxLiquidatorAssets < ASSETS_THRESHOLD\\n ? maxLiquidatorAssets.divWadDown(1e18 + memIncentive.lenders)\\n : maxLiquidatorAssets\\n );\\n }\\n\\n /// @notice Allow/rejects seizing of assets.\\n /// @dev This function can be called externally, but only will have effect when called from a market.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market where the assets will be seized.\\n function checkSeize(Market repayMarket, Market seizeMarket) external view {\\n // if markets are listed, they also point to the same Auditor\\n if (!markets[seizeMarket].isListed || !markets[repayMarket].isListed) revert MarketNotListed();\\n }\\n\\n /// @notice Calculates the amount of collateral to be seized when a position is undercollateralized.\\n /// @param repayMarket market from where the debt will be repaid.\\n /// @param seizeMarket market from where the assets will be seized by the liquidator.\\n /// @param borrower account in which assets are being seized.\\n /// @param actualRepayAssets amount being repaid.\\n /// @return lendersAssets amount to be added for other lenders as a compensation of bad debt clearing.\\n /// @return seizeAssets amount that can be seized by the liquidator.\\n function calculateSeize(\\n Market repayMarket,\\n Market seizeMarket,\\n address borrower,\\n uint256 actualRepayAssets\\n ) external view returns (uint256 lendersAssets, uint256 seizeAssets) {\\n LiquidationIncentive memory memIncentive = liquidationIncentive;\\n lendersAssets = actualRepayAssets.mulWadDown(memIncentive.lenders);\\n\\n // read prices for borrowed and collateral markets\\n uint256 priceBorrowed = assetPrice(markets[repayMarket].priceFeed);\\n uint256 priceCollateral = assetPrice(markets[seizeMarket].priceFeed);\\n uint256 baseAmount = actualRepayAssets.mulDivUp(priceBorrowed, 10 ** markets[repayMarket].decimals);\\n\\n seizeAssets = Math.min(\\n baseAmount.mulDivUp(10 ** markets[seizeMarket].decimals, priceCollateral).mulWadUp(\\n 1e18 + memIncentive.liquidator + memIncentive.lenders\\n ),\\n seizeMarket.maxWithdraw(borrower)\\n );\\n }\\n\\n /// @notice Checks if account has debt with no collateral, if so then call `clearBadDebt` from each market.\\n /// @dev Collateral is multiplied by price and adjust factor to be accurately evaluated as positive collateral asset.\\n /// @param account account in which debt is being checked.\\n function handleBadDebt(address account) external {\\n uint256 memMarketMap = accountMarkets[account];\\n uint256 marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) {\\n Market market = marketList[i];\\n MarketData storage m = markets[market];\\n uint256 assets = market.maxWithdraw(account);\\n if (assets.mulDivDown(assetPrice(m.priceFeed), 10 ** m.decimals).mulWadDown(m.adjustFactor) > 0) return;\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n\\n marketMap = memMarketMap;\\n for (uint256 i = 0; marketMap != 0; marketMap >>= 1) {\\n if (marketMap & 1 != 0) marketList[i].clearBadDebt(account);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the asset price of a price feed.\\n /// @dev If Chainlink's asset price is <= 0 the call is reverted.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price.\\n /// @return The price of the asset scaled to 18-digit decimals.\\n function assetPrice(IPriceFeed priceFeed) public view returns (uint256) {\\n if (address(priceFeed) == BASE_FEED) return basePrice;\\n\\n int256 price = priceFeed.latestAnswer();\\n if (price <= 0) revert InvalidPrice();\\n return uint256(price) * baseFactor;\\n }\\n\\n /// @notice Retrieves all markets.\\n function allMarkets() external view returns (Market[] memory) {\\n return marketList;\\n }\\n\\n /// @notice Enables a certain market.\\n /// @dev Enabling more than 256 markets will cause an overflow when casting market index to uint8.\\n /// @param market market to add to the protocol.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n /// @param adjustFactor market's adjust factor for the underlying asset.\\n function enableMarket(\\n Market market,\\n IPriceFeed priceFeed,\\n uint128 adjustFactor\\n ) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (market.auditor() != this) revert AuditorMismatch();\\n if (markets[market].isListed) revert MarketAlreadyListed();\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n\\n uint8 decimals = market.decimals();\\n markets[market] = MarketData({\\n isListed: true,\\n adjustFactor: adjustFactor,\\n decimals: decimals,\\n index: uint8(marketList.length),\\n priceFeed: priceFeed\\n });\\n\\n marketList.push(market);\\n\\n emit MarketListed(market, decimals);\\n emit PriceFeedSet(market, priceFeed);\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the adjust factor for a certain market.\\n /// @param market address of the market to change adjust factor for.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n function setAdjustFactor(Market market, uint128 adjustFactor) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (!markets[market].isListed) revert MarketNotListed();\\n\\n markets[market].adjustFactor = adjustFactor;\\n emit AdjustFactorSet(market, adjustFactor);\\n }\\n\\n /// @notice Sets the Chainlink Price Feed Aggregator source for a market.\\n /// @param market market address of the asset.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n function setPriceFeed(Market market, IPriceFeed priceFeed) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(priceFeed) != BASE_FEED && priceFeed.decimals() != priceDecimals) revert InvalidPriceFeed();\\n markets[market].priceFeed = priceFeed;\\n emit PriceFeedSet(market, priceFeed);\\n }\\n\\n /// @notice Sets liquidation incentive (liquidator and lenders) for the whole ecosystem.\\n /// @param liquidationIncentive_ new liquidation incentive.\\n function setLiquidationIncentive(\\n LiquidationIncentive memory liquidationIncentive_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n liquidationIncentive = liquidationIncentive_;\\n emit LiquidationIncentiveSet(liquidationIncentive_);\\n }\\n\\n /// @notice Emitted when a new market is listed for borrow/lending.\\n /// @param market address of the market that was listed.\\n /// @param decimals decimals of the market's underlying asset.\\n event MarketListed(Market indexed market, uint8 decimals);\\n\\n /// @notice Emitted when an account enters a market to use his deposit as collateral for a loan.\\n /// @param market address of the market that the account entered.\\n /// @param account address of the account that just entered a market.\\n event MarketEntered(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when an account leaves a market.\\n /// Means that they would stop using their deposit as collateral and won't ask for any loans in this market.\\n /// @param market address of the market that the account just left.\\n /// @param account address of the account that just left a market.\\n event MarketExited(Market indexed market, address indexed account);\\n\\n /// @notice Emitted when a adjust factor is changed by admin.\\n /// @param market address of the market that has a new adjust factor.\\n /// @param adjustFactor adjust factor for the underlying asset.\\n event AdjustFactorSet(Market indexed market, uint256 adjustFactor);\\n\\n /// @notice Emitted when a new liquidationIncentive has been set.\\n /// @param liquidationIncentive represented with 18 decimals.\\n event LiquidationIncentiveSet(LiquidationIncentive liquidationIncentive);\\n\\n /// @notice Emitted when a market and prie feed is changed by admin.\\n /// @param market address of the asset used to get the price.\\n /// @param priceFeed address of Chainlink's Price Feed aggregator used to query the asset price in base.\\n event PriceFeedSet(Market indexed market, IPriceFeed indexed priceFeed);\\n\\n /// @notice Stores the market parameters used for liquidity calculations.\\n /// @param adjustFactor used to asses the lending power of the market's underlying asset.\\n /// @param decimals number of decimals of the market's underlying asset.\\n /// @param index index of the market in the `marketList`.\\n /// @param isListed true if the market is enabled.\\n /// @param priceFeed address of the price feed used to query the asset's price.\\n struct MarketData {\\n uint128 adjustFactor;\\n uint8 decimals;\\n uint8 index;\\n bool isListed;\\n IPriceFeed priceFeed;\\n }\\n\\n /// @notice Stores the liquidator and lenders factors used in liquidations to calculate the amount to seize.\\n /// @param liquidator factor used to calculate the extra bonus a liquidator can seize.\\n /// @param lenders factor used to calculate the bonus that the pool lenders receive.\\n struct LiquidationIncentive {\\n uint128 liquidator;\\n uint128 lenders;\\n }\\n\\n /// @notice Used as memory access to temporary store account liquidity data.\\n /// @param balance collateral balance of the account.\\n /// @param borrowBalance borrow balance of the account.\\n /// @param price asset price returned by the price feed with 18 decimals.\\n struct AccountLiquidity {\\n uint256 balance;\\n uint256 borrowBalance;\\n uint256 price;\\n }\\n}\\n\\nerror AuditorMismatch();\\nerror InsufficientAccountLiquidity();\\nerror InsufficientShortfall();\\nerror InvalidPrice();\\nerror InvalidPriceFeed();\\nerror MarketAlreadyListed();\\nerror MarketNotListed();\\nerror NotMarket();\\nerror RemainingDebt();\\n\\nstruct MarketVars {\\n uint256 price;\\n uint256 baseUnit;\\n uint128 adjustFactor;\\n}\\n\\nstruct LiquidityVars {\\n uint256 totalDebt;\\n uint256 totalCollateral;\\n uint256 adjustedDebt;\\n uint256 adjustedCollateral;\\n uint256 seizeAvailable;\\n}\\n\",\"keccak256\":\"0x93d487fdf861e8f58edca8058bffec88f31d280846420faec8e3e7049d3068fd\",\"license\":\"BUSL-1.1\"},\"contracts/InterestRateModel.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\ncontract InterestRateModel {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n\\n /// @notice Threshold to define which method should be used to calculate the interest rates.\\n /// @dev When `eta` (`delta / alpha`) is lower than this value, use simpson's rule for approximation.\\n uint256 internal constant PRECISION_THRESHOLD = 7.5e14;\\n\\n /// @notice Scale factor of the fixed curve.\\n uint256 public immutable fixedCurveA;\\n /// @notice Origin intercept of the fixed curve.\\n int256 public immutable fixedCurveB;\\n /// @notice Asymptote of the fixed curve.\\n uint256 public immutable fixedMaxUtilization;\\n\\n /// @notice Scale factor of the floating curve.\\n uint256 public immutable floatingCurveA;\\n /// @notice Origin intercept of the floating curve.\\n int256 public immutable floatingCurveB;\\n /// @notice Asymptote of the floating curve.\\n uint256 public immutable floatingMaxUtilization;\\n\\n constructor(\\n uint256 fixedCurveA_,\\n int256 fixedCurveB_,\\n uint256 fixedMaxUtilization_,\\n uint256 floatingCurveA_,\\n int256 floatingCurveB_,\\n uint256 floatingMaxUtilization_\\n ) {\\n assert(fixedMaxUtilization_ > 1e18);\\n assert(floatingMaxUtilization_ > 1e18);\\n\\n fixedCurveA = fixedCurveA_;\\n fixedCurveB = fixedCurveB_;\\n fixedMaxUtilization = fixedMaxUtilization_;\\n\\n floatingCurveA = floatingCurveA_;\\n floatingCurveB = floatingCurveB_;\\n floatingMaxUtilization = floatingMaxUtilization_;\\n\\n // reverts if it's an invalid curve (such as one yielding a negative interest rate).\\n fixedRate(0, 0);\\n floatingRate(0);\\n }\\n\\n /// @notice Gets the rate to borrow a certain amount at a certain maturity with supply/demand values in the fixed rate\\n /// pool and assets from the backup supplier.\\n /// @param maturity maturity date for calculating days left to maturity.\\n /// @param amount the current borrow's amount.\\n /// @param borrowed ex-ante amount borrowed from this fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay (represented with 18 decimals).\\n function fixedBorrowRate(\\n uint256 maturity,\\n uint256 amount,\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256) {\\n if (block.timestamp >= maturity) revert AlreadyMatured();\\n\\n uint256 potentialAssets = supplied + backupAssets;\\n uint256 utilizationAfter = (borrowed + amount).divWadUp(potentialAssets);\\n\\n if (utilizationAfter > 1e18) revert UtilizationExceeded();\\n\\n uint256 utilizationBefore = borrowed.divWadDown(potentialAssets);\\n\\n return fixedRate(utilizationBefore, utilizationAfter).mulDivDown(maturity - block.timestamp, 365 days);\\n }\\n\\n /// @notice Returns the current annualized fixed rate to borrow with supply/demand values in the fixed rate pool and\\n /// assets from the backup supplier.\\n /// @param borrowed amount borrowed from the fixed rate pool.\\n /// @param supplied deposits in the fixed rate pool.\\n /// @param backupAssets backup supplier assets.\\n /// @return rate of the fee that the borrower will have to pay, with 18 decimals precision.\\n /// @return utilization current utilization rate, with 18 decimals precision.\\n function minFixedRate(\\n uint256 borrowed,\\n uint256 supplied,\\n uint256 backupAssets\\n ) external view returns (uint256 rate, uint256 utilization) {\\n utilization = borrowed.divWadUp(supplied + backupAssets);\\n rate = fixedRate(utilization, utilization);\\n }\\n\\n /// @notice Returns the interest rate integral from `u0` to `u1`, using the analytical solution (ln).\\n /// @dev Uses the fixed rate curve parameters.\\n /// Handles special case where delta utilization tends to zero, using simpson's rule.\\n /// @param utilizationBefore ex-ante utilization rate, with 18 decimals precision.\\n /// @param utilizationAfter ex-post utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function fixedRate(uint256 utilizationBefore, uint256 utilizationAfter) internal view returns (uint256) {\\n uint256 alpha = fixedMaxUtilization - utilizationBefore;\\n uint256 delta = utilizationAfter - utilizationBefore;\\n int256 r = int256(\\n delta.divWadDown(alpha) < PRECISION_THRESHOLD\\n ? (fixedCurveA.divWadDown(alpha) +\\n fixedCurveA.mulDivDown(4e18, fixedMaxUtilization - ((utilizationAfter + utilizationBefore) / 2)) +\\n fixedCurveA.divWadDown(fixedMaxUtilization - utilizationAfter)) / 6\\n : fixedCurveA.mulDivDown(\\n uint256(int256(alpha.divWadDown(fixedMaxUtilization - utilizationAfter)).lnWad()),\\n delta\\n )\\n ) + fixedCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n\\n /// @notice Returns the interest rate for an utilization rate.\\n /// @dev Uses the floating rate curve parameters.\\n /// @param utilization utilization rate, with 18 decimals precision.\\n /// @return the interest rate, with 18 decimals precision.\\n function floatingRate(uint256 utilization) public view returns (uint256) {\\n int256 r = int256(floatingCurveA.divWadDown(floatingMaxUtilization - utilization)) + floatingCurveB;\\n assert(r >= 0);\\n return uint256(r);\\n }\\n}\\n\\nerror AlreadyMatured();\\nerror UtilizationExceeded();\\n\",\"keccak256\":\"0xfb1d32f03bb869906ce577bb0e4cbc3e141006c7087f4e826ce513a9c4582f57\",\"license\":\"BUSL-1.1\"},\"contracts/Market.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { PausableUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { ERC4626, ERC20, SafeTransferLib } from \\\"solmate/src/mixins/ERC4626.sol\\\";\\nimport { InterestRateModel } from \\\"./InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"./RewardsController.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\n\\ncontract Market is Initializable, AccessControlUpgradeable, PausableUpgradeable, ERC4626 {\\n using FixedPointMathLib for int256;\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint128;\\n using SafeTransferLib for ERC20;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for uint256;\\n\\n bytes32 public constant PAUSER_ROLE = keccak256(\\\"PAUSER_ROLE\\\");\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n\\n /// @notice Tracks account's fixed deposit positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedDepositPositions;\\n /// @notice Tracks account's fixed borrow positions by maturity, account and position.\\n mapping(uint256 => mapping(address => FixedLib.Position)) public fixedBorrowPositions;\\n /// @notice Tracks fixed pools state by maturity.\\n mapping(uint256 => FixedLib.Pool) public fixedPools;\\n\\n /// @notice Tracks fixed deposit and borrow map and floating borrow shares of an account.\\n mapping(address => Account) public accounts;\\n\\n /// @notice Amount of assets lent by the floating pool to the fixed pools.\\n uint256 public floatingBackupBorrowed;\\n /// @notice Amount of assets lent by the floating pool to accounts.\\n uint256 public floatingDebt;\\n\\n /// @notice Accumulated earnings from extraordinary sources to be gradually distributed.\\n uint256 public earningsAccumulator;\\n /// @notice Rate per second to be charged to delayed fixed pools borrowers after maturity.\\n uint256 public penaltyRate;\\n /// @notice Rate charged to the fixed pool to be retained by the floating pool for initially providing liquidity.\\n uint256 public backupFeeRate;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is higher.\\n uint256 public dampSpeedUp;\\n /// @notice Damp speed factor to update `floatingAssetsAverage` when `floatingAssets` is lower.\\n uint256 public dampSpeedDown;\\n\\n /// @notice Number of fixed pools to be active at the same time.\\n uint8 public maxFuturePools;\\n /// @notice Last time the accumulator distributed earnings.\\n uint32 public lastAccumulatorAccrual;\\n /// @notice Last time the floating debt was updated.\\n uint32 public lastFloatingDebtUpdate;\\n /// @notice Last time the floating assets average was updated.\\n uint32 public lastAverageUpdate;\\n\\n /// @notice Interest rate model contract used to get the borrow rates.\\n InterestRateModel public interestRateModel;\\n\\n /// @notice Factor used for gradual accrual of earnings to the floating pool.\\n uint128 public earningsAccumulatorSmoothFactor;\\n /// @notice Percentage factor that represents the liquidity reserves that can't be borrowed.\\n uint128 public reserveFactor;\\n\\n /// @notice Amount of floating assets deposited to the pool.\\n uint256 public floatingAssets;\\n /// @notice Average of the floating assets to get fixed borrow rates and prevent rate manipulation.\\n uint256 public floatingAssetsAverage;\\n\\n /// @notice Total amount of floating borrow shares assigned to floating borrow accounts.\\n uint256 public totalFloatingBorrowShares;\\n\\n /// @dev gap from deprecated state.\\n /// @custom:oz-renamed-from floatingUtilization\\n uint256 private __gap;\\n\\n /// @notice Address of the treasury that will receive the allocated earnings.\\n address public treasury;\\n /// @notice Rate to be charged by the treasury to floating and fixed borrows.\\n uint256 public treasuryFeeRate;\\n\\n /// @notice Address of the rewards controller that will accrue rewards for accounts operating with the Market.\\n RewardsController public rewardsController;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(ERC20 asset_, Auditor auditor_) ERC4626(asset_, \\\"\\\", \\\"\\\") {\\n auditor = auditor_;\\n\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev can only be called once.\\n function initialize(\\n uint8 maxFuturePools_,\\n uint128 earningsAccumulatorSmoothFactor_,\\n InterestRateModel interestRateModel_,\\n uint256 penaltyRate_,\\n uint256 backupFeeRate_,\\n uint128 reserveFactor_,\\n uint256 dampSpeedUp_,\\n uint256 dampSpeedDown_\\n ) external initializer {\\n __AccessControl_init();\\n __Pausable_init();\\n\\n string memory assetSymbol = asset.symbol();\\n name = string.concat(\\\"exactly \\\", assetSymbol);\\n symbol = string.concat(\\\"exa\\\", assetSymbol);\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n lastAverageUpdate = uint32(block.timestamp);\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n\\n setMaxFuturePools(maxFuturePools_);\\n setEarningsAccumulatorSmoothFactor(earningsAccumulatorSmoothFactor_);\\n setInterestRateModel(interestRateModel_);\\n setPenaltyRate(penaltyRate_);\\n setBackupFeeRate(backupFeeRate_);\\n setReserveFactor(reserveFactor_);\\n setDampSpeed(dampSpeedUp_, dampSpeedDown_);\\n }\\n\\n /// @notice Borrows a certain amount from the floating pool.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return borrowShares shares corresponding to the borrowed assets.\\n function borrow(\\n uint256 assets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 borrowShares) {\\n spendAllowance(borrower, assets);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n\\n borrowShares = previewBorrow(assets);\\n\\n uint256 newFloatingDebt = floatingDebt + assets;\\n floatingDebt = newFloatingDebt;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed, also considering the reserves\\n if (floatingBackupBorrowed + newFloatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n\\n totalFloatingBorrowShares += borrowShares;\\n accounts[borrower].floatingBorrowShares += borrowShares;\\n\\n emit Borrow(msg.sender, receiver, borrower, assets, borrowShares);\\n emitMarketUpdate();\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Repays a certain amount of assets to the floating pool.\\n /// @param assets assets to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepay the actual amount that should be transferred into the protocol.\\n /// @return borrowShares subtracted shares from the borrower's accountability.\\n function repay(\\n uint256 assets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepay, uint256 borrowShares) {\\n (actualRepay, borrowShares) = noTransferRefund(previewRepay(assets), borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), actualRepay);\\n }\\n\\n /// @notice Repays a certain amount of shares to the floating pool.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower address of the account that has the debt.\\n /// @return assets subtracted assets from the borrower's accountability.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function refund(\\n uint256 borrowShares,\\n address borrower\\n ) external whenNotPaused returns (uint256 assets, uint256 actualShares) {\\n (assets, actualShares) = noTransferRefund(borrowShares, borrower);\\n emitMarketUpdate();\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Allows to (partially) repay a floating borrow. It does not transfer assets.\\n /// @param borrowShares shares to be subtracted from the borrower's accountability.\\n /// @param borrower the address of the account that has the debt.\\n /// @return assets the actual amount that should be transferred into the protocol.\\n /// @return actualShares actual subtracted shares from the borrower's accountability.\\n function noTransferRefund(\\n uint256 borrowShares,\\n address borrower\\n ) internal returns (uint256 assets, uint256 actualShares) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n depositToTreasury(updateFloatingDebt());\\n Account storage account = accounts[borrower];\\n uint256 accountBorrowShares = account.floatingBorrowShares;\\n actualShares = Math.min(borrowShares, accountBorrowShares);\\n assets = previewRefund(actualShares);\\n\\n if (assets == 0) revert ZeroRepay();\\n\\n floatingDebt -= assets;\\n account.floatingBorrowShares = accountBorrowShares - actualShares;\\n totalFloatingBorrowShares -= actualShares;\\n\\n emit Repay(msg.sender, borrower, assets, actualShares);\\n }\\n\\n /// @notice Deposits a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be deposited.\\n /// @param assets amount to receive from the msg.sender.\\n /// @param minAssetsRequired minimum amount of assets required by the depositor for the transaction to be accepted.\\n /// @param receiver address that will be able to withdraw the deposited assets.\\n /// @return positionAssets total amount of assets (principal + fee) to be withdrawn at maturity.\\n function depositAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 minAssetsRequired,\\n address receiver\\n ) external whenNotPaused returns (uint256 positionAssets) {\\n if (assets == 0) revert ZeroDeposit();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n (uint256 fee, uint256 backupFee) = pool.calculateDeposit(assets, backupFeeRate);\\n positionAssets = assets + fee;\\n if (positionAssets < minAssetsRequired) revert Disagreement();\\n\\n floatingBackupBorrowed -= pool.deposit(assets);\\n pool.unassignedEarnings -= fee + backupFee;\\n earningsAccumulator += backupFee;\\n\\n // update account's position\\n FixedLib.Position storage position = fixedDepositPositions[maturity][receiver];\\n\\n // if account doesn't have a current position, add it to the list\\n if (position.principal == 0) {\\n Account storage account = accounts[receiver];\\n account.fixedDeposits = account.fixedDeposits.setMaturity(maturity);\\n }\\n\\n position.principal += assets;\\n position.fee += fee;\\n\\n floatingAssets += backupEarnings;\\n\\n emit DepositAtMaturity(maturity, msg.sender, receiver, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n }\\n\\n /// @notice Borrows a certain amount from a maturity.\\n /// @param maturity maturity date for repayment.\\n /// @param assets amount to be sent to receiver and repaid by borrower.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept.\\n /// @param receiver address that will receive the borrowed assets.\\n /// @param borrower address that will repay the borrowed assets.\\n /// @return assetsOwed total amount of assets (principal + fee) to be repaid at maturity.\\n function borrowAtMaturity(\\n uint256 maturity,\\n uint256 assets,\\n uint256 maxAssets,\\n address receiver,\\n address borrower\\n ) external whenNotPaused returns (uint256 assetsOwed) {\\n if (assets == 0) revert ZeroBorrow();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.NONE);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n uint256 fee = assets.mulWadDown(\\n interestRateModel.fixedBorrowRate(maturity, assets, pool.borrowed, pool.supplied, previewFloatingAssetsAverage())\\n );\\n assetsOwed = assets + fee;\\n\\n // validate that the account is not taking arbitrary fees\\n if (assetsOwed > maxAssets) revert Disagreement();\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n spendAllowance(borrower, assetsOwed);\\n\\n {\\n uint256 backupDebtAddition = pool.borrow(assets);\\n if (backupDebtAddition > 0) {\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed + backupDebtAddition;\\n depositToTreasury(updateFloatingDebt());\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets.mulWadDown(1e18 - reserveFactor)) {\\n revert InsufficientProtocolLiquidity();\\n }\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n }\\n\\n {\\n // if account doesn't have a current position, add it to the list\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n if (position.principal == 0) {\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.setMaturity(maturity);\\n }\\n\\n // calculate what portion of the fees are to be accrued and what portion goes to earnings accumulator\\n (uint256 newUnassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(fee),\\n assets\\n );\\n if (newUnassignedEarnings > 0) pool.unassignedEarnings += newUnassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n fixedBorrowPositions[maturity][borrower] = FixedLib.Position(position.principal + assets, position.fee + fee);\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit BorrowAtMaturity(maturity, msg.sender, receiver, borrower, assets, fee);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n auditor.checkBorrow(this, borrower);\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /// @notice Withdraws a certain amount from a maturity.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param maturity maturity date where the assets will be withdrawn.\\n /// @param positionAssets position size to be reduced.\\n /// @param minAssetsRequired minimum amount required by the account (if discount included for early withdrawal).\\n /// @param receiver address that will receive the withdrawn assets.\\n /// @param owner address that previously deposited the assets.\\n /// @return assetsDiscounted amount of assets withdrawn (can include a discount for early withdraw).\\n function withdrawAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 minAssetsRequired,\\n address receiver,\\n address owner\\n ) external returns (uint256 assetsDiscounted) {\\n if (positionAssets == 0) revert ZeroWithdraw();\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedDepositPositions[maturity][owner];\\n\\n if (positionAssets > position.principal + position.fee) positionAssets = position.principal + position.fee;\\n\\n // verify if there are any penalties/fee for the account because of early withdrawal, if so discount\\n if (block.timestamp < maturity) {\\n assetsDiscounted = positionAssets.divWadDown(\\n 1e18 +\\n interestRateModel.fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n previewFloatingAssetsAverage()\\n )\\n );\\n } else {\\n assetsDiscounted = positionAssets;\\n }\\n\\n if (assetsDiscounted < minAssetsRequired) revert Disagreement();\\n\\n spendAllowance(owner, assetsDiscounted);\\n\\n {\\n // remove the supply from the fixed rate pool\\n uint256 newFloatingBackupBorrowed = floatingBackupBorrowed +\\n pool.withdraw(\\n FixedLib.Position(position.principal, position.fee).scaleProportionally(positionAssets).principal\\n );\\n if (newFloatingBackupBorrowed + floatingDebt > floatingAssets) revert InsufficientProtocolLiquidity();\\n floatingBackupBorrowed = newFloatingBackupBorrowed;\\n }\\n\\n // all the fees go to unassigned or to the floating pool\\n (uint256 unassignedEarnings, uint256 newBackupEarnings) = pool.distributeEarnings(\\n chargeTreasuryFee(positionAssets - assetsDiscounted),\\n assetsDiscounted\\n );\\n pool.unassignedEarnings += unassignedEarnings;\\n collectFreeLunch(newBackupEarnings);\\n\\n // the account gets discounted the full amount\\n position.reduceProportionally(positionAssets);\\n if (position.principal | position.fee == 0) {\\n delete fixedDepositPositions[maturity][owner];\\n Account storage account = accounts[owner];\\n account.fixedDeposits = account.fixedDeposits.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedDepositPositions[maturity][owner] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit WithdrawAtMaturity(maturity, msg.sender, receiver, owner, positionAssets, assetsDiscounted);\\n emitMarketUpdate();\\n emitFixedEarningsUpdate(maturity);\\n\\n asset.safeTransfer(receiver, assetsDiscounted);\\n }\\n\\n /// @notice Repays a certain amount to a maturity.\\n /// @param maturity maturity date where the assets will be repaid.\\n /// @param positionAssets amount to be paid for the borrower's debt.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower address of the account that has the debt.\\n /// @return actualRepayAssets the actual amount that was transferred into the protocol.\\n function repayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower\\n ) external whenNotPaused returns (uint256 actualRepayAssets) {\\n // reverts on failure\\n FixedLib.checkPoolState(maturity, maxFuturePools, FixedLib.State.VALID, FixedLib.State.MATURED);\\n\\n actualRepayAssets = noTransferRepayAtMaturity(maturity, positionAssets, maxAssets, borrower, true);\\n emitMarketUpdate();\\n\\n asset.safeTransferFrom(msg.sender, address(this), actualRepayAssets);\\n }\\n\\n /// @notice Allows to (partially) repay a fixed rate position. It does not transfer assets.\\n /// @param maturity the maturity to access the pool.\\n /// @param positionAssets the amount of debt of the pool that should be paid.\\n /// @param maxAssets maximum amount of debt that the account is willing to accept to be repaid.\\n /// @param borrower the address of the account that has the debt.\\n /// @param canDiscount should early repay discounts be applied.\\n /// @return actualRepayAssets the actual amount that should be transferred into the protocol.\\n function noTransferRepayAtMaturity(\\n uint256 maturity,\\n uint256 positionAssets,\\n uint256 maxAssets,\\n address borrower,\\n bool canDiscount\\n ) internal returns (uint256 actualRepayAssets) {\\n if (positionAssets == 0) revert ZeroRepay();\\n\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n\\n uint256 backupEarnings = pool.accrueEarnings(maturity);\\n\\n FixedLib.Position memory position = fixedBorrowPositions[maturity][borrower];\\n\\n uint256 debtCovered = Math.min(positionAssets, position.principal + position.fee);\\n\\n uint256 principalCovered = FixedLib\\n .Position(position.principal, position.fee)\\n .scaleProportionally(debtCovered)\\n .principal;\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n\\n // early repayment allows a discount from the unassigned earnings\\n if (block.timestamp < maturity) {\\n if (canDiscount) {\\n // calculate the deposit fee considering the amount of debt the account'll pay\\n (uint256 discountFee, uint256 backupFee) = pool.calculateDeposit(principalCovered, backupFeeRate);\\n\\n // remove the fee from unassigned earnings\\n pool.unassignedEarnings -= discountFee + backupFee;\\n\\n // the fee charged to the fixed pool supplier goes to the earnings accumulator\\n earningsAccumulator += backupFee;\\n\\n // the fee gets discounted from the account through `actualRepayAssets`\\n actualRepayAssets = debtCovered - discountFee;\\n } else {\\n actualRepayAssets = debtCovered;\\n }\\n } else {\\n actualRepayAssets = debtCovered + debtCovered.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n\\n // all penalties go to the earnings accumulator\\n earningsAccumulator += actualRepayAssets - debtCovered;\\n }\\n\\n // verify that the account agrees to this discount or penalty\\n if (actualRepayAssets > maxAssets) revert Disagreement();\\n\\n // reduce the borrowed from the pool and might decrease the floating backup borrowed\\n floatingBackupBorrowed -= pool.repay(principalCovered);\\n\\n // update the account position\\n position.reduceProportionally(debtCovered);\\n if (position.principal | position.fee == 0) {\\n delete fixedBorrowPositions[maturity][borrower];\\n Account storage account = accounts[borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n } else {\\n // proportionally reduce the values\\n fixedBorrowPositions[maturity][borrower] = position;\\n }\\n\\n floatingAssets += backupEarnings;\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, actualRepayAssets, debtCovered);\\n emitFixedEarningsUpdate(maturity);\\n }\\n\\n /// @notice Liquidates undercollateralized fixed/floating (or both) position(s).\\n /// @dev Msg.sender liquidates borrower's position(s) and repays a certain amount of debt for the floating pool,\\n /// or/and for multiple fixed pools, seizing a portion of borrower's collateral.\\n /// @param borrower account that has an outstanding debt across floating or fixed pools.\\n /// @param maxAssets maximum amount of debt that the liquidator is willing to accept. (it can be less)\\n /// @param seizeMarket market from which the collateral will be seized to give to the liquidator.\\n /// @return repaidAssets actual amount repaid.\\n function liquidate(\\n address borrower,\\n uint256 maxAssets,\\n Market seizeMarket\\n ) external whenNotPaused returns (uint256 repaidAssets) {\\n if (msg.sender == borrower) revert SelfLiquidation();\\n\\n maxAssets = auditor.checkLiquidation(this, seizeMarket, borrower, maxAssets);\\n if (maxAssets == 0) revert ZeroRepay();\\n\\n Account storage account = accounts[borrower];\\n\\n {\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0 && maxAssets != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 actualRepay;\\n if (block.timestamp < maturity) {\\n actualRepay = noTransferRepayAtMaturity(maturity, maxAssets, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n } else {\\n uint256 position;\\n {\\n FixedLib.Position storage p = fixedBorrowPositions[maturity][borrower];\\n position = p.principal + p.fee;\\n }\\n uint256 debt = position + position.mulWadDown((block.timestamp - maturity) * penaltyRate);\\n actualRepay = debt > maxAssets ? maxAssets.mulDivDown(position, debt) : maxAssets;\\n\\n if (actualRepay == 0) maxAssets = 0;\\n else {\\n actualRepay = noTransferRepayAtMaturity(maturity, actualRepay, maxAssets, borrower, false);\\n maxAssets -= actualRepay;\\n }\\n }\\n repaidAssets += actualRepay;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n if (maxAssets > 0 && account.floatingBorrowShares > 0) {\\n uint256 borrowShares = previewRepay(maxAssets);\\n if (borrowShares > 0) {\\n (uint256 actualRepayAssets, ) = noTransferRefund(borrowShares, borrower);\\n repaidAssets += actualRepayAssets;\\n }\\n }\\n\\n // reverts on failure\\n (uint256 lendersAssets, uint256 seizeAssets) = auditor.calculateSeize(this, seizeMarket, borrower, repaidAssets);\\n earningsAccumulator += lendersAssets;\\n\\n if (address(seizeMarket) == address(this)) {\\n internalSeize(this, msg.sender, borrower, seizeAssets);\\n } else {\\n seizeMarket.seize(msg.sender, borrower, seizeAssets);\\n\\n emitMarketUpdate();\\n }\\n\\n emit Liquidate(msg.sender, borrower, repaidAssets, lendersAssets, seizeMarket, seizeAssets);\\n\\n auditor.handleBadDebt(borrower);\\n\\n asset.safeTransferFrom(msg.sender, address(this), repaidAssets + lendersAssets);\\n }\\n\\n /// @notice Clears floating and fixed debt for an account spreading the losses to the `earningsAccumulator`.\\n /// @dev Can only be called from the auditor.\\n /// @param borrower account with insufficient collateral to be cleared the debt.\\n function clearBadDebt(address borrower) external {\\n if (msg.sender != address(auditor)) revert NotAuditor();\\n\\n floatingAssets += accrueAccumulatedEarnings();\\n Account storage account = accounts[borrower];\\n uint256 accumulator = earningsAccumulator;\\n uint256 totalBadDebt = 0;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 badDebt = position.principal + position.fee;\\n if (accumulator >= badDebt) {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleBorrow(borrower);\\n accumulator -= badDebt;\\n totalBadDebt += badDebt;\\n floatingBackupBorrowed -= fixedPools[maturity].repay(position.principal);\\n delete fixedBorrowPositions[maturity][borrower];\\n account.fixedBorrows = account.fixedBorrows.clearMaturity(maturity);\\n\\n emit RepayAtMaturity(maturity, msg.sender, borrower, badDebt, badDebt);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n if (account.floatingBorrowShares > 0 && (accumulator = previewRepay(accumulator)) > 0) {\\n (uint256 badDebt, ) = noTransferRefund(accumulator, borrower);\\n totalBadDebt += badDebt;\\n }\\n if (totalBadDebt > 0) {\\n earningsAccumulator -= totalBadDebt;\\n emit SpreadBadDebt(borrower, totalBadDebt);\\n }\\n emitMarketUpdate();\\n }\\n\\n /// @notice Public function to seize a certain amount of assets.\\n /// @dev Public function for liquidator to seize borrowers assets in the floating pool.\\n /// This function will only be called from another Market, on `liquidation` calls.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function seize(address liquidator, address borrower, uint256 assets) external whenNotPaused {\\n internalSeize(Market(msg.sender), liquidator, borrower, assets);\\n }\\n\\n /// @notice Internal function to seize a certain amount of assets.\\n /// @dev Internal function for liquidator to seize borrowers assets in the floating pool.\\n /// Will only be called from this Market on `liquidation` or through `seize` calls from another Market.\\n /// That's why msg.sender needs to be passed to the internal function (to be validated as a Market).\\n /// @param seizeMarket address which is calling the seize function (see `seize` public function).\\n /// @param liquidator address which will receive the seized assets.\\n /// @param borrower address from which the assets will be seized.\\n /// @param assets amount to be removed from borrower's possession.\\n function internalSeize(Market seizeMarket, address liquidator, address borrower, uint256 assets) internal {\\n if (assets == 0) revert ZeroWithdraw();\\n\\n // reverts on failure\\n auditor.checkSeize(seizeMarket, this);\\n\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(borrower);\\n uint256 shares = previewWithdraw(assets);\\n beforeWithdraw(assets, shares);\\n _burn(borrower, shares);\\n emit Withdraw(msg.sender, liquidator, borrower, assets, shares);\\n emit Seize(liquidator, borrower, assets);\\n emitMarketUpdate();\\n\\n asset.safeTransfer(liquidator, assets);\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// @param assets amount of assets to be withdrawn from the floating pool.\\n function beforeWithdraw(uint256 assets, uint256) internal override {\\n updateFloatingAssetsAverage();\\n depositToTreasury(updateFloatingDebt());\\n uint256 earnings = accrueAccumulatedEarnings();\\n uint256 newFloatingAssets = floatingAssets + earnings - assets;\\n // check if the underlying liquidity that the account wants to withdraw is borrowed\\n if (floatingBackupBorrowed + floatingDebt > newFloatingAssets) revert InsufficientProtocolLiquidity();\\n floatingAssets = newFloatingAssets;\\n }\\n\\n /// @notice Hook to update the floating pool average, floating pool balance and distribute earnings from accumulator.\\n /// @param assets amount of assets to be deposited to the floating pool.\\n function afterDeposit(uint256 assets, uint256) internal override whenNotPaused {\\n updateFloatingAssetsAverage();\\n uint256 treasuryFee = updateFloatingDebt();\\n uint256 earnings = accrueAccumulatedEarnings();\\n floatingAssets += earnings + assets;\\n depositToTreasury(treasuryFee);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Withdraws the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param assets amount of underlying to be withdrawn.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return shares amount of shares redeemed for underlying asset.\\n function withdraw(uint256 assets, address receiver, address owner) public override returns (uint256 shares) {\\n auditor.checkShortfall(this, owner, assets);\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n shares = super.withdraw(assets, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n /// @notice Redeems the owner's floating pool assets to the receiver address.\\n /// @dev Makes sure that the owner doesn't have shortfall after withdrawing.\\n /// @param shares amount of shares to be redeemed for underlying asset.\\n /// @param receiver address to which the assets will be transferred.\\n /// @param owner address which owns the floating pool assets.\\n /// @return assets amount of underlying asset that was withdrawn.\\n function redeem(uint256 shares, address receiver, address owner) public override returns (uint256 assets) {\\n auditor.checkShortfall(this, owner, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(owner);\\n assets = super.redeem(shares, receiver, owner);\\n emitMarketUpdate();\\n }\\n\\n function _mint(address to, uint256 amount) internal override {\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) memRewardsController.handleDeposit(to);\\n super._mint(to, amount);\\n }\\n\\n /// @notice Moves amount of shares from the caller's account to `to`.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that the caller doesn't have shortfall after transferring.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transfer(address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, msg.sender, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(msg.sender);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transfer(to, shares);\\n }\\n\\n /// @notice Moves amount of shares from `from` to `to` using the allowance mechanism.\\n /// @dev It's expected that this function can't be paused to prevent freezing account funds.\\n /// Makes sure that `from` address doesn't have shortfall after transferring.\\n /// @param from address from which the assets will be transferred.\\n /// @param to address to which the assets will be transferred.\\n /// @param shares amount of shares to be transferred.\\n function transferFrom(address from, address to, uint256 shares) public override returns (bool) {\\n auditor.checkShortfall(this, from, previewRedeem(shares));\\n RewardsController memRewardsController = rewardsController;\\n if (address(memRewardsController) != address(0)) {\\n memRewardsController.handleDeposit(from);\\n memRewardsController.handleDeposit(to);\\n }\\n return super.transferFrom(from, to, shares);\\n }\\n\\n /// @notice Gets current snapshot for an account across all maturities.\\n /// @param account account to return status snapshot in the specified maturity date.\\n /// @return the amount deposited to the floating pool and the amount owed to floating and fixed pools.\\n function accountSnapshot(address account) external view returns (uint256, uint256) {\\n return (convertToAssets(balanceOf[account]), previewDebt(account));\\n }\\n\\n /// @notice Gets all borrows and penalties for an account.\\n /// @param borrower account to return status snapshot for fixed and floating borrows.\\n /// @return debt the total debt, denominated in number of assets.\\n function previewDebt(address borrower) public view returns (uint256 debt) {\\n Account storage account = accounts[borrower];\\n uint256 memPenaltyRate = penaltyRate;\\n uint256 packedMaturities = account.fixedBorrows;\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n // calculate all maturities using the base maturity and the following bits representing the following intervals\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n FixedLib.Position storage position = fixedBorrowPositions[maturity][borrower];\\n uint256 positionAssets = position.principal + position.fee;\\n\\n debt += positionAssets;\\n\\n if (block.timestamp > maturity) {\\n debt += positionAssets.mulWadDown((block.timestamp - maturity) * memPenaltyRate);\\n }\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n // calculate floating borrowed debt\\n uint256 shares = account.floatingBorrowShares;\\n if (shares > 0) debt += previewRefund(shares);\\n }\\n\\n /// @notice Charges treasury fee to certain amount of earnings.\\n /// @param earnings amount of earnings.\\n /// @return earnings minus the fees charged by the treasury.\\n function chargeTreasuryFee(uint256 earnings) internal returns (uint256) {\\n uint256 fee = earnings.mulWadDown(treasuryFeeRate);\\n depositToTreasury(fee);\\n return earnings - fee;\\n }\\n\\n /// @notice Collects all earnings that are charged to borrowers that make use of fixed pool deposits' assets.\\n /// @param earnings amount of earnings.\\n function collectFreeLunch(uint256 earnings) internal {\\n if (earnings == 0) return;\\n\\n if (treasuryFeeRate > 0) {\\n depositToTreasury(earnings);\\n } else {\\n earningsAccumulator += earnings;\\n }\\n }\\n\\n /// @notice Deposits amount of assets on behalf of the treasury address.\\n /// @param fee amount of assets to be deposited.\\n function depositToTreasury(uint256 fee) internal {\\n if (fee > 0) {\\n _mint(treasury, previewDeposit(fee));\\n floatingAssets += fee;\\n }\\n }\\n\\n /// @notice Calculates the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings to be distributed from the accumulator.\\n function accumulatedEarnings() internal view returns (uint256 earnings) {\\n uint256 elapsed = block.timestamp - lastAccumulatorAccrual;\\n if (elapsed == 0) return 0;\\n return\\n earningsAccumulator.mulDivDown(\\n elapsed,\\n elapsed + earningsAccumulatorSmoothFactor.mulWadDown(maxFuturePools * FixedLib.INTERVAL)\\n );\\n }\\n\\n /// @notice Accrues the earnings to be distributed from the accumulator given the current timestamp.\\n /// @return earnings distributed from the accumulator.\\n function accrueAccumulatedEarnings() internal returns (uint256 earnings) {\\n earnings = accumulatedEarnings();\\n\\n earningsAccumulator -= earnings;\\n lastAccumulatorAccrual = uint32(block.timestamp);\\n emit AccumulatorAccrual(block.timestamp);\\n }\\n\\n /// @notice Updates the `floatingAssetsAverage`.\\n function updateFloatingAssetsAverage() internal {\\n floatingAssetsAverage = previewFloatingAssetsAverage();\\n lastAverageUpdate = uint32(block.timestamp);\\n }\\n\\n /// @notice Returns the current `floatingAssetsAverage` without updating the storage variable.\\n /// @return projected `floatingAssetsAverage`.\\n function previewFloatingAssetsAverage() public view returns (uint256) {\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 memFloatingAssetsAverage = floatingAssetsAverage;\\n uint256 dampSpeedFactor = memFloatingAssets < memFloatingAssetsAverage ? dampSpeedDown : dampSpeedUp;\\n uint256 averageFactor = uint256(1e18 - (-int256(dampSpeedFactor * (block.timestamp - lastAverageUpdate))).expWad());\\n return memFloatingAssetsAverage.mulWadDown(1e18 - averageFactor) + averageFactor.mulWadDown(memFloatingAssets);\\n }\\n\\n /// @notice Updates the floating pool borrows' variables.\\n /// @return treasuryFee amount of fees charged by the treasury to the new calculated floating debt.\\n function updateFloatingDebt() internal returns (uint256 treasuryFee) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n\\n memFloatingDebt += newDebt;\\n treasuryFee = newDebt.mulWadDown(treasuryFeeRate);\\n floatingAssets = memFloatingAssets + newDebt - treasuryFee;\\n floatingDebt = memFloatingDebt;\\n lastFloatingDebtUpdate = uint32(block.timestamp);\\n emit FloatingDebtUpdate(block.timestamp, floatingUtilization);\\n }\\n\\n /// @notice Calculates the total floating debt, considering elapsed time since last update and current interest rate.\\n /// @return actual floating debt plus projected interest.\\n function totalFloatingBorrowAssets() public view returns (uint256) {\\n uint256 memFloatingDebt = floatingDebt;\\n uint256 memFloatingAssets = floatingAssets;\\n uint256 floatingUtilization = memFloatingAssets > 0 ? memFloatingDebt.divWadUp(memFloatingAssets) : 0;\\n uint256 newDebt = memFloatingDebt.mulWadDown(\\n interestRateModel.floatingRate(floatingUtilization).mulDivDown(block.timestamp - lastFloatingDebtUpdate, 365 days)\\n );\\n return memFloatingDebt + newDebt;\\n }\\n\\n /// @notice Calculates the floating pool balance plus earnings to be accrued at current timestamp\\n /// from maturities and accumulator.\\n /// @return actual floatingAssets plus earnings to be accrued at current timestamp.\\n function totalAssets() public view override returns (uint256) {\\n unchecked {\\n uint256 memMaxFuturePools = maxFuturePools;\\n uint256 backupEarnings = 0;\\n\\n uint256 latestMaturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL);\\n uint256 maxMaturity = latestMaturity + memMaxFuturePools * FixedLib.INTERVAL;\\n\\n for (uint256 maturity = latestMaturity; maturity <= maxMaturity; maturity += FixedLib.INTERVAL) {\\n FixedLib.Pool storage pool = fixedPools[maturity];\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (maturity > lastAccrual) {\\n backupEarnings += block.timestamp < maturity\\n ? pool.unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual)\\n : pool.unassignedEarnings;\\n }\\n }\\n\\n return\\n floatingAssets +\\n backupEarnings +\\n accumulatedEarnings() +\\n (totalFloatingBorrowAssets() - floatingDebt).mulWadDown(1e18 - treasuryFeeRate);\\n }\\n }\\n\\n /// @notice Simulates the effects of a borrow at the current time, given current contract conditions.\\n /// @param assets amount of assets to borrow.\\n /// @return amount of shares that will be asigned to the account after the borrow.\\n function previewBorrow(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a repay at the current time, given current contract conditions.\\n /// @param assets amount of assets to repay.\\n /// @return amount of shares that will be subtracted from the account after the repay.\\n function previewRepay(uint256 assets) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalFloatingBorrowAssets());\\n }\\n\\n /// @notice Simulates the effects of a refund at the current time, given current contract conditions.\\n /// @param shares amount of shares to subtract from caller's accountability.\\n /// @return amount of assets that will be repaid.\\n function previewRefund(uint256 shares) public view returns (uint256) {\\n uint256 supply = totalFloatingBorrowShares; // Saves an extra SLOAD if totalFloatingBorrowShares is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalFloatingBorrowAssets(), supply);\\n }\\n\\n /// @notice Checks msg.sender's allowance over account's assets.\\n /// @param account account in which the allowance will be checked.\\n /// @param assets assets from account that msg.sender wants to operate on.\\n function spendAllowance(address account, uint256 assets) internal {\\n if (msg.sender != account) {\\n uint256 allowed = allowance[account][msg.sender]; // saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[account][msg.sender] = allowed - previewWithdraw(assets);\\n }\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed amount of the fixed pool.\\n function fixedPoolBorrowed(uint256 maturity) external view returns (uint256) {\\n return fixedPools[maturity].borrowed;\\n }\\n\\n /// @notice Retrieves a fixed pool's borrowed and supplied amount.\\n /// @param maturity maturity date of the fixed pool.\\n /// @return borrowed and supplied amount of the fixed pool.\\n function fixedPoolBalance(uint256 maturity) external view returns (uint256, uint256) {\\n return (fixedPools[maturity].borrowed, fixedPools[maturity].supplied);\\n }\\n\\n /// @notice Emits MarketUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitMarketUpdate() internal {\\n emit MarketUpdate(\\n block.timestamp,\\n totalSupply,\\n floatingAssets,\\n totalFloatingBorrowShares,\\n floatingDebt,\\n earningsAccumulator\\n );\\n }\\n\\n /// @notice Emits FixedEarningsUpdate event.\\n /// @dev Internal function to avoid code duplication.\\n function emitFixedEarningsUpdate(uint256 maturity) internal {\\n emit FixedEarningsUpdate(block.timestamp, maturity, fixedPools[maturity].unassignedEarnings);\\n }\\n\\n /// @notice Sets the rate charged to the fixed depositors that the floating pool suppliers will retain for initially\\n /// providing liquidity.\\n /// @param backupFeeRate_ percentage amount represented with 18 decimals.\\n function setBackupFeeRate(uint256 backupFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n backupFeeRate = backupFeeRate_;\\n emit BackupFeeRateSet(backupFeeRate_);\\n }\\n\\n /// @notice Sets the damp speed used to update the floatingAssetsAverage.\\n /// @param up damp speed up, represented with 18 decimals.\\n /// @param down damp speed down, represented with 18 decimals.\\n function setDampSpeed(uint256 up, uint256 down) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n updateFloatingAssetsAverage();\\n dampSpeedUp = up;\\n dampSpeedDown = down;\\n emit DampSpeedSet(up, down);\\n }\\n\\n /// @notice Sets the factor used when smoothly accruing earnings to the floating pool.\\n /// @param earningsAccumulatorSmoothFactor_ represented with 18 decimals.\\n function setEarningsAccumulatorSmoothFactor(\\n uint128 earningsAccumulatorSmoothFactor_\\n ) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n floatingAssets += accrueAccumulatedEarnings();\\n emitMarketUpdate();\\n earningsAccumulatorSmoothFactor = earningsAccumulatorSmoothFactor_;\\n emit EarningsAccumulatorSmoothFactorSet(earningsAccumulatorSmoothFactor_);\\n }\\n\\n /// @notice Sets the interest rate model to be used to calculate rates.\\n /// @param interestRateModel_ new interest rate model.\\n function setInterestRateModel(InterestRateModel interestRateModel_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n if (address(interestRateModel) != address(0)) depositToTreasury(updateFloatingDebt());\\n\\n interestRateModel = interestRateModel_;\\n emitMarketUpdate();\\n emit InterestRateModelSet(interestRateModel_);\\n }\\n\\n /// @notice Sets the rewards controller to update account rewards when operating with the Market.\\n /// @param rewardsController_ new rewards controller.\\n function setRewardsController(RewardsController rewardsController_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n rewardsController = rewardsController_;\\n emit RewardsControllerSet(rewardsController_);\\n }\\n\\n /// @notice Sets the protocol's max future pools for fixed borrowing and lending.\\n /// @dev If value is decreased, VALID maturities will become NOT_READY.\\n /// @param futurePools number of pools to be active at the same time.\\n function setMaxFuturePools(uint8 futurePools) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n maxFuturePools = futurePools;\\n emit MaxFuturePoolsSet(futurePools);\\n }\\n\\n /// @notice Sets the penalty rate per second.\\n /// @param penaltyRate_ percentage represented with 18 decimals.\\n function setPenaltyRate(uint256 penaltyRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n penaltyRate = penaltyRate_;\\n emit PenaltyRateSet(penaltyRate_);\\n }\\n\\n /// @notice Sets the percentage that represents the liquidity reserves that can't be borrowed.\\n /// @param reserveFactor_ parameter represented with 18 decimals.\\n function setReserveFactor(uint128 reserveFactor_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n reserveFactor = reserveFactor_;\\n emit ReserveFactorSet(reserveFactor_);\\n }\\n\\n /// @notice Sets the treasury variables.\\n /// @param treasury_ address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate_ represented with 18 decimals.\\n function setTreasury(address treasury_, uint256 treasuryFeeRate_) public onlyRole(DEFAULT_ADMIN_ROLE) {\\n depositToTreasury(updateFloatingDebt());\\n treasury = treasury_;\\n treasuryFeeRate = treasuryFeeRate_;\\n emit TreasurySet(treasury_, treasuryFeeRate_);\\n }\\n\\n /// @notice Sets the pause state to true in case of emergency, triggered by an authorized account.\\n function pause() external onlyRole(PAUSER_ROLE) {\\n _pause();\\n }\\n\\n /// @notice Sets the pause state to false when threat is gone, triggered by an authorized account.\\n function unpause() external onlyRole(PAUSER_ROLE) {\\n _unpause();\\n }\\n\\n /// @notice Event emitted when an account borrows amount of assets from a floating pool.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of assets that were borrowed.\\n /// @param shares amount of borrow shares assigned to the account.\\n event Borrow(\\n address indexed caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /// @notice Emitted when an account repays amount of assets to a floating pool.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of assets that was repaid.\\n /// @param shares amount of borrow shares that were subtracted from the account's accountability.\\n event Repay(address indexed caller, address indexed borrower, uint256 assets, uint256 shares);\\n\\n /// @notice Emitted when an account deposits an amount of an asset to a certain fixed rate pool,\\n /// collecting fees at the end of the period.\\n /// @param maturity maturity at which the account will be able to collect his deposit + his fee.\\n /// @param caller address which deposited the assets.\\n /// @param owner address that will be able to withdraw the deposited assets.\\n /// @param assets amount of the asset that were deposited.\\n /// @param fee is the extra amount that it will be collected at maturity.\\n event DepositAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed owner,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account withdraws from a fixed rate pool.\\n /// @param maturity maturity where the account withdraw its deposits.\\n /// @param caller address which withdraw the asset.\\n /// @param receiver address which will be collecting the assets.\\n /// @param owner address which had the assets withdrawn.\\n /// @param positionAssets position size reduced.\\n /// @param assets amount of assets withdrawn (can include a discount for early withdraw).\\n event WithdrawAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 positionAssets,\\n uint256 assets\\n );\\n\\n /// @notice Emitted when an account borrows amount of an asset from a certain maturity date.\\n /// @param maturity maturity in which the account will have to repay the loan.\\n /// @param caller address which borrowed the asset.\\n /// @param receiver address that received the borrowed assets.\\n /// @param borrower address which will be repaying the borrowed assets.\\n /// @param assets amount of the asset that were borrowed.\\n /// @param fee extra amount that will need to be paid at maturity.\\n event BorrowAtMaturity(\\n uint256 indexed maturity,\\n address caller,\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 fee\\n );\\n\\n /// @notice Emitted when an account repays its borrows after maturity.\\n /// @param maturity maturity where the account repaid its borrowed amounts.\\n /// @param caller address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount that was repaid.\\n /// @param positionAssets amount of the debt that was covered in this repayment (penalties could have been repaid).\\n event RepayAtMaturity(\\n uint256 indexed maturity,\\n address indexed caller,\\n address indexed borrower,\\n uint256 assets,\\n uint256 positionAssets\\n );\\n\\n /// @notice Emitted when an account's position had a liquidation.\\n /// @param receiver address which repaid the previously borrowed amount.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount of the asset that were repaid.\\n /// @param lendersAssets incentive paid to lenders.\\n /// @param seizeMarket address of the asset that were seized by the liquidator.\\n /// @param seizedAssets amount seized of the collateral.\\n event Liquidate(\\n address indexed receiver,\\n address indexed borrower,\\n uint256 assets,\\n uint256 lendersAssets,\\n Market indexed seizeMarket,\\n uint256 seizedAssets\\n );\\n\\n /// @notice Emitted when an account's collateral has been seized.\\n /// @param liquidator address which seized this collateral.\\n /// @param borrower address which had the original debt.\\n /// @param assets amount seized of the collateral.\\n event Seize(address indexed liquidator, address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when an account is cleared from bad debt.\\n /// @param borrower address which was cleared from bad debt.\\n /// @param assets amount that was subtracted from the borrower's debt and spread to the `earningsAccumulator`.\\n event SpreadBadDebt(address indexed borrower, uint256 assets);\\n\\n /// @notice Emitted when the backupFeeRate parameter is changed by admin.\\n /// @param backupFeeRate rate charged to the fixed pools to be accrued by the floating depositors.\\n event BackupFeeRateSet(uint256 backupFeeRate);\\n\\n /// @notice Emitted when the damp speeds are changed by admin.\\n /// @param dampSpeedUp represented with 18 decimals.\\n /// @param dampSpeedDown represented with 18 decimals.\\n event DampSpeedSet(uint256 dampSpeedUp, uint256 dampSpeedDown);\\n\\n /// @notice Emitted when the earningsAccumulatorSmoothFactor is changed by admin.\\n /// @param earningsAccumulatorSmoothFactor factor represented with 18 decimals.\\n event EarningsAccumulatorSmoothFactorSet(uint256 earningsAccumulatorSmoothFactor);\\n\\n /// @notice Emitted when the interestRateModel is changed by admin.\\n /// @param interestRateModel new interest rate model to be used to calculate rates.\\n event InterestRateModelSet(InterestRateModel indexed interestRateModel);\\n\\n /// @notice Emitted when the maxFuturePools is changed by admin.\\n /// @param maxFuturePools represented with 0 decimals.\\n event MaxFuturePoolsSet(uint256 maxFuturePools);\\n\\n /// @notice Emitted when the penaltyRate is changed by admin.\\n /// @param penaltyRate penaltyRate percentage per second represented with 18 decimals.\\n event PenaltyRateSet(uint256 penaltyRate);\\n\\n /// @notice Emitted when the reserveFactor is changed by admin.\\n /// @param reserveFactor reserveFactor percentage.\\n event ReserveFactorSet(uint256 reserveFactor);\\n\\n /// @notice Emitted when the treasury variables are changed by admin.\\n /// @param treasury address of the treasury that will receive the minted eTokens.\\n /// @param treasuryFeeRate represented with 18 decimals.\\n event TreasurySet(address indexed treasury, uint256 treasuryFeeRate);\\n\\n /// @notice Emitted when the rewardsController is changed by admin.\\n /// @param rewardsController new rewards controller to update account rewards when operating with the Market.\\n event RewardsControllerSet(RewardsController indexed rewardsController);\\n\\n /// @notice Emitted when market state is updated.\\n /// @param timestamp current timestamp.\\n /// @param floatingDepositShares total floating supply shares.\\n /// @param floatingAssets total floating supply assets.\\n /// @param floatingBorrowShares total floating borrow shares.\\n /// @param floatingDebt total floating borrow assets.\\n /// @param earningsAccumulator earnings accumulator.\\n event MarketUpdate(\\n uint256 timestamp,\\n uint256 floatingDepositShares,\\n uint256 floatingAssets,\\n uint256 floatingBorrowShares,\\n uint256 floatingDebt,\\n uint256 earningsAccumulator\\n );\\n\\n /// @notice Emitted when the earnings of a maturity are updated.\\n /// @param timestamp current timestamp.\\n /// @param maturity maturity date where the earnings were updated.\\n /// @param unassignedEarnings pending unassigned earnings.\\n event FixedEarningsUpdate(uint256 timestamp, uint256 indexed maturity, uint256 unassignedEarnings);\\n\\n /// @notice Emitted when accumulator distributes earnings.\\n /// @param timestamp current timestamp.\\n event AccumulatorAccrual(uint256 timestamp);\\n\\n /// @notice Emitted when the floating debt is updated.\\n /// @param timestamp current timestamp.\\n /// @param utilization new floating utilization.\\n event FloatingDebtUpdate(uint256 timestamp, uint256 utilization);\\n\\n /// @notice Stores fixed deposits and fixed borrows map and floating borrow shares of an account.\\n /// @param fixedDeposits encoded map maturity dates where the account supplied to.\\n /// @param fixedBorrows encoded map maturity dates where the account borrowed from.\\n /// @param floatingBorrowShares number of floating borrow shares assigned to the account.\\n struct Account {\\n uint256 fixedDeposits;\\n uint256 fixedBorrows;\\n uint256 floatingBorrowShares;\\n }\\n}\\n\\nerror Disagreement();\\nerror InsufficientProtocolLiquidity();\\nerror NotAuditor();\\nerror SelfLiquidation();\\nerror ZeroBorrow();\\nerror ZeroDeposit();\\nerror ZeroRepay();\\nerror ZeroWithdraw();\\n\",\"keccak256\":\"0x94894ef0aeac99df31979475878d006fb676a9d795d9cfc3b3b1ed321ed672d8\",\"license\":\"BUSL-1.1\"},\"contracts/RewardsController.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Initializable } from \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { AccessControlUpgradeable } from \\\"@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { SafeTransferLib } from \\\"solmate/src/utils/SafeTransferLib.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { IPriceFeed } from \\\"./utils/IPriceFeed.sol\\\";\\nimport { FixedLib } from \\\"./utils/FixedLib.sol\\\";\\nimport { Auditor } from \\\"./Auditor.sol\\\";\\nimport { Market } from \\\"./Market.sol\\\";\\n\\ncontract RewardsController is Initializable, AccessControlUpgradeable {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for uint64;\\n using FixedPointMathLib for int256;\\n using SafeTransferLib for ERC20;\\n\\n /// @notice Max utilization supported by the sigmoid function not to cause a division by zero (1e18 = WAD).\\n uint256 public constant UTILIZATION_CAP = 1e18 - 1;\\n /// @notice Tracks the reward distribution data for a given market.\\n mapping(Market => Distribution) public distribution;\\n /// @notice Tracks enabled asset rewards.\\n mapping(ERC20 => bool) public rewardEnabled;\\n /// @notice Stores registered asset rewards.\\n ERC20[] public rewardList;\\n /// @notice Stores Markets with distributions set.\\n Market[] public marketList;\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /// @notice Initializes the contract.\\n /// @dev Can only be called once.\\n function initialize() external initializer {\\n __AccessControl_init();\\n\\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded deposit.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleDeposit(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n ops[0] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n update(account, market, dist.availableRewards[r], ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Hook to be called by the Market to update the index of the account that made a rewarded borrow.\\n /// @dev There's no need to check that `msg.sender` is a valid Market as it won't have available rewards if it's not.\\n /// @param account The account to which the index is updated.\\n function handleBorrow(address account) external {\\n Market market = Market(msg.sender);\\n AccountOperation[] memory ops = new AccountOperation[](1);\\n (, , uint256 accountFloatingBorrowShares) = market.accounts(account);\\n\\n Distribution storage dist = distribution[market];\\n uint256 available = dist.availableRewardsCount;\\n for (uint128 r = 0; r < available; ) {\\n ERC20 reward = dist.availableRewards[r];\\n ops[0] = AccountOperation({\\n operation: true,\\n balance: accountFloatingBorrowShares + accountFixedBorrowShares(market, account, dist.rewards[reward].start)\\n });\\n update(account, Market(msg.sender), reward, ops);\\n unchecked {\\n ++r;\\n }\\n }\\n }\\n\\n /// @notice Claims all `msg.sender` rewards to the given account.\\n /// @param to The address to send the rewards to.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claimAll(address to) external returns (ERC20[] memory rewardsList, uint256[] memory claimedAmounts) {\\n return claim(allMarketsOperations(), to, rewardList);\\n }\\n\\n /// @notice Claims `msg.sender` rewards for the given operations and reward assets to the given account.\\n /// @param marketOps The operations to claim rewards for.\\n /// @param to The address to send the rewards to.\\n /// @param rewardsList The list of rewards assets to claim.\\n /// @return rewardsList The list of rewards assets.\\n /// @return claimedAmounts The list of claimed amounts.\\n function claim(\\n MarketOperation[] memory marketOps,\\n address to,\\n ERC20[] memory rewardsList\\n ) public returns (ERC20[] memory, uint256[] memory claimedAmounts) {\\n uint256 rewardsCount = rewardsList.length;\\n claimedAmounts = new uint256[](rewardsCount);\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n uint256 availableRewards = dist.availableRewardsCount;\\n for (uint128 r = 0; r < availableRewards; ) {\\n update(\\n msg.sender,\\n marketOperation.market,\\n dist.availableRewards[r],\\n accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n msg.sender,\\n dist.rewards[dist.availableRewards[r]].start\\n )\\n );\\n unchecked {\\n ++r;\\n }\\n }\\n for (uint256 r = 0; r < rewardsCount; ) {\\n RewardData storage rewardData = dist.rewards[rewardsList[r]];\\n for (uint256 o = 0; o < marketOperation.operations.length; ) {\\n uint256 rewardAmount = rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued;\\n if (rewardAmount != 0) {\\n claimedAmounts[r] += rewardAmount;\\n rewardData.accounts[msg.sender][marketOperation.operations[o]].accrued = 0;\\n }\\n unchecked {\\n ++o;\\n }\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n for (uint256 r = 0; r < rewardsList.length; ) {\\n uint256 claimedAmount = claimedAmounts[r];\\n if (claimedAmount > 0) {\\n rewardsList[r].safeTransfer(to, claimedAmount);\\n emit Claim(msg.sender, rewardsList[r], to, claimedAmount);\\n }\\n unchecked {\\n ++r;\\n }\\n }\\n return (rewardsList, claimedAmounts);\\n }\\n\\n /// @notice Gets the configuration of a given distribution.\\n /// @param market The market to get the distribution configuration for.\\n /// @param reward The reward asset.\\n /// @return The distribution configuration.\\n function rewardConfig(Market market, ERC20 reward) external view returns (Config memory) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return\\n Config({\\n market: market,\\n reward: reward,\\n priceFeed: rewardData.priceFeed,\\n start: rewardData.start,\\n distributionPeriod: rewardData.end - rewardData.start,\\n targetDebt: rewardData.targetDebt,\\n totalDistribution: rewardData.totalDistribution,\\n undistributedFactor: rewardData.undistributedFactor,\\n flipSpeed: rewardData.flipSpeed,\\n compensationFactor: rewardData.compensationFactor,\\n transitionFactor: rewardData.transitionFactor,\\n borrowAllocationWeightFactor: rewardData.borrowAllocationWeightFactor,\\n depositAllocationWeightAddend: rewardData.depositAllocationWeightAddend,\\n depositAllocationWeightFactor: rewardData.depositAllocationWeightFactor\\n });\\n }\\n\\n /// @notice Gets the amount of reward assets that are being distributed for a Market.\\n /// @param market Market to get the number of available rewards to distribute.\\n /// @return The amount reward assets set to a Market.\\n function availableRewardsCount(Market market) external view returns (uint256) {\\n return distribution[market].availableRewardsCount;\\n }\\n\\n /// @notice Gets the account data of a given account, Market, operation and reward asset.\\n /// @param account The account to get the operation data from.\\n /// @param market The market in which the operation was made.\\n /// @param operation True if the operation was a borrow, false if it was a deposit.\\n /// @param reward The reward asset.\\n /// @return accrued The accrued amount.\\n /// @return index The account index.\\n function accountOperation(\\n address account,\\n Market market,\\n bool operation,\\n ERC20 reward\\n ) external view returns (uint256, uint256) {\\n Account storage operationAccount = distribution[market].rewards[reward].accounts[account][operation];\\n return (operationAccount.accrued, operationAccount.index);\\n }\\n\\n /// @notice Gets the distribution `start`, `end` and `lastUpdate` value of a given market and reward.\\n /// @param market The market to get the distribution times.\\n /// @param reward The reward asset.\\n /// @return The distribution `start`, `end` and `lastUpdate` time.\\n function distributionTime(Market market, ERC20 reward) external view returns (uint32, uint32, uint32) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.start, rewardData.end, rewardData.lastUpdate);\\n }\\n\\n /// @notice Retrieves all rewards addresses.\\n function allRewards() external view returns (ERC20[] memory) {\\n return rewardList;\\n }\\n\\n /// @notice Gets all market and operations.\\n /// @return marketOps The list of market operations.\\n function allMarketsOperations() public view returns (MarketOperation[] memory marketOps) {\\n Market[] memory markets = marketList;\\n marketOps = new MarketOperation[](markets.length);\\n for (uint256 m = 0; m < markets.length; ) {\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[m] = MarketOperation({ market: markets[m], operations: ops });\\n unchecked {\\n ++m;\\n }\\n }\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account and reward asset.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function allClaimable(address account, ERC20 reward) external view returns (uint256 unclaimedRewards) {\\n return claimable(allMarketsOperations(), account, reward);\\n }\\n\\n /// @notice Gets the claimable amount of rewards for a given account, Market operations and reward asset.\\n /// @param marketOps The list of Market operations to get the accrued and pending rewards from.\\n /// @param account The account to get the claimable amount for.\\n /// @param reward The reward asset.\\n /// @return unclaimedRewards The claimable amount for the given account.\\n function claimable(\\n MarketOperation[] memory marketOps,\\n address account,\\n ERC20 reward\\n ) public view returns (uint256 unclaimedRewards) {\\n for (uint256 i = 0; i < marketOps.length; ) {\\n MarketOperation memory marketOperation = marketOps[i];\\n Distribution storage dist = distribution[marketOperation.market];\\n RewardData storage rewardData = dist.rewards[reward];\\n if (dist.availableRewardsCount == 0) {\\n unchecked {\\n ++i;\\n }\\n continue;\\n }\\n\\n AccountOperation[] memory ops = accountBalanceOperations(\\n marketOperation.market,\\n marketOperation.operations,\\n account,\\n rewardData.start\\n );\\n uint256 balance;\\n for (uint256 o = 0; o < ops.length; ) {\\n unclaimedRewards += rewardData.accounts[account][ops[o].operation].accrued;\\n balance += ops[o].balance;\\n unchecked {\\n ++o;\\n }\\n }\\n if (balance > 0) {\\n unclaimedRewards += pendingRewards(\\n account,\\n reward,\\n AccountMarketOperation({ market: marketOperation.market, accountOperations: ops })\\n );\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Iterates and accrues all rewards for the operations of the given account in the given market.\\n /// @param account The account to accrue the rewards for.\\n /// @param market The Market in which the operations where made.\\n /// @param reward The reward asset.\\n /// @param ops The operations to accrue the rewards for.\\n function update(address account, Market market, ERC20 reward, AccountOperation[] memory ops) internal {\\n uint256 baseUnit = distribution[market].baseUnit;\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n {\\n uint256 lastUpdate = rewardData.lastUpdate;\\n // `lastUpdate` can be greater than `block.timestamp` if distribution is set to start on a future date\\n if (block.timestamp > lastUpdate) {\\n (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) = previewAllocation(\\n rewardData,\\n market,\\n block.timestamp - lastUpdate\\n );\\n if (borrowIndex > type(uint128).max || depositIndex > type(uint128).max) revert IndexOverflow();\\n rewardData.borrowIndex = uint128(borrowIndex);\\n rewardData.depositIndex = uint128(depositIndex);\\n rewardData.lastUpdate = uint32(block.timestamp);\\n rewardData.lastUndistributed = newUndistributed;\\n emit IndexUpdate(market, reward, borrowIndex, depositIndex, newUndistributed, block.timestamp);\\n }\\n }\\n\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 i = 0; i < ops.length; ) {\\n AccountOperation memory op = ops[i];\\n Account storage accountData = operationAccount[op.operation];\\n uint256 accountIndex = accountData.index;\\n uint256 newAccountIndex;\\n if (op.operation) {\\n newAccountIndex = rewardData.borrowIndex;\\n } else {\\n newAccountIndex = rewardData.depositIndex;\\n }\\n if (accountIndex != newAccountIndex) {\\n accountData.index = uint128(newAccountIndex);\\n if (op.balance != 0) {\\n uint256 rewardsAccrued = accountRewards(op.balance, newAccountIndex, accountIndex, baseUnit);\\n accountData.accrued += uint128(rewardsAccrued);\\n emit Accrue(market, reward, account, op.operation, accountIndex, newAccountIndex, rewardsAccrued);\\n }\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Gets the equivalent of borrow shares from fixed pool principal borrows of an account.\\n /// @param market The Market to get the fixed borrows from.\\n /// @param account The account that borrowed from fixed pools.\\n /// @return fixedDebt The fixed borrow shares.\\n function accountFixedBorrowShares(\\n Market market,\\n address account,\\n uint32 start\\n ) internal view returns (uint256 fixedDebt) {\\n uint256 firstMaturity = start - (start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 principal, ) = market.fixedBorrowPositions(maturity, account);\\n fixedDebt += principal;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n fixedDebt = market.previewRepay(fixedDebt);\\n }\\n\\n /// @notice Gets the reward indexes and last amount of undistributed rewards for a given market and reward asset.\\n /// @param market The market to get the reward indexes for.\\n /// @param reward The reward asset to get the reward indexes for.\\n /// @return borrowIndex The index for the floating and fixed borrow operation.\\n /// @return depositIndex The index for the floating deposit operation.\\n /// @return lastUndistributed The last amount of undistributed rewards.\\n function rewardIndexes(Market market, ERC20 reward) external view returns (uint256, uint256, uint256) {\\n RewardData storage rewardData = distribution[market].rewards[reward];\\n return (rewardData.borrowIndex, rewardData.depositIndex, rewardData.lastUndistributed);\\n }\\n\\n /// @notice Calculates the rewards not accrued yet for the given operations of a given account and reward asset.\\n /// @param account The account to get the pending rewards for.\\n /// @param reward The reward asset to get the pending rewards for.\\n /// @param ops The operations to get the pending rewards for.\\n /// @return rewards The pending rewards for the given operations.\\n function pendingRewards(\\n address account,\\n ERC20 reward,\\n AccountMarketOperation memory ops\\n ) internal view returns (uint256 rewards) {\\n RewardData storage rewardData = distribution[ops.market].rewards[reward];\\n uint256 baseUnit = distribution[ops.market].baseUnit;\\n uint256 lastUpdate = rewardData.lastUpdate;\\n (uint256 borrowIndex, uint256 depositIndex, ) = previewAllocation(\\n rewardData,\\n ops.market,\\n block.timestamp > lastUpdate ? block.timestamp - lastUpdate : 0\\n );\\n mapping(bool => Account) storage operationAccount = rewardData.accounts[account];\\n for (uint256 o = 0; o < ops.accountOperations.length; ) {\\n uint256 nextIndex;\\n if (ops.accountOperations[o].operation) {\\n nextIndex = borrowIndex;\\n } else {\\n nextIndex = depositIndex;\\n }\\n\\n rewards += accountRewards(\\n ops.accountOperations[o].balance,\\n nextIndex,\\n operationAccount[ops.accountOperations[o].operation].index,\\n baseUnit\\n );\\n unchecked {\\n ++o;\\n }\\n }\\n }\\n\\n /// @notice Calculates and returns the new amount of rewards given by the difference between the `accountIndex` and\\n /// the `globalIndex`.\\n /// @param balance The account's balance in the operation's pool.\\n /// @param globalIndex Current index of the distribution.\\n /// @param accountIndex Last index stored for the account.\\n /// @param baseUnit One unit of the Market's asset (10**decimals).\\n /// @return The amount of new rewards to be accrued by the account.\\n function accountRewards(\\n uint256 balance,\\n uint256 globalIndex,\\n uint256 accountIndex,\\n uint256 baseUnit\\n ) internal pure returns (uint256) {\\n return balance.mulDivDown(globalIndex - accountIndex, baseUnit);\\n }\\n\\n /// @notice Retrieves projected distribution indexes and new undistributed amount for a given `deltaTime`.\\n /// @param market The market to calculate the indexes for.\\n /// @param reward The reward asset to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n Market market,\\n ERC20 reward,\\n uint256 deltaTime\\n ) external view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n return previewAllocation(distribution[market].rewards[reward], market, deltaTime);\\n }\\n\\n /// @notice Calculates and returns the distribution indexes and new undistributed tokens for a given `rewardData`.\\n /// @param rewardData The distribution's data.\\n /// @param market The market to calculate the indexes for.\\n /// @param deltaTime The elapsed time since the last update.\\n /// @return borrowIndex The index for the borrow operation.\\n /// @return depositIndex The index for the deposit operation.\\n /// @return newUndistributed The new undistributed rewards of the distribution.\\n function previewAllocation(\\n RewardData storage rewardData,\\n Market market,\\n uint256 deltaTime\\n ) internal view returns (uint256 borrowIndex, uint256 depositIndex, uint256 newUndistributed) {\\n TotalMarketBalance memory m;\\n m.debt = market.totalFloatingBorrowAssets();\\n m.supply = market.totalAssets();\\n TimeVars memory t;\\n t.start = rewardData.start;\\n t.end = rewardData.end;\\n {\\n uint256 firstMaturity = t.start - (t.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n uint256 maxMaturity = block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n uint256 fixedDebt;\\n for (uint256 maturity = firstMaturity; maturity <= maxMaturity; ) {\\n (uint256 borrowed, uint256 supplied) = market.fixedPoolBalance(maturity);\\n fixedDebt += borrowed;\\n m.supply += supplied;\\n unchecked {\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n m.debt += fixedDebt;\\n m.fixedBorrowShares = market.previewRepay(fixedDebt);\\n }\\n uint256 target;\\n {\\n uint256 targetDebt = rewardData.targetDebt;\\n target = m.debt < targetDebt ? m.debt.divWadDown(targetDebt) : 1e18;\\n }\\n uint256 rewards;\\n {\\n uint256 releaseRate = rewardData.releaseRate;\\n uint256 lastUndistributed = rewardData.lastUndistributed;\\n t.period = t.end - t.start;\\n uint256 distributionFactor = t.period > 0\\n ? rewardData.undistributedFactor.mulDivDown(target, t.period * 1e18)\\n : 0;\\n if (block.timestamp <= t.end) {\\n if (distributionFactor > 0) {\\n uint256 exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n } else if (rewardData.lastUpdate > t.end) {\\n newUndistributed =\\n lastUndistributed -\\n lastUndistributed.mulWadUp(1e18 - uint256((-int256(distributionFactor * deltaTime)).expWad()));\\n rewards = uint256(-(int256(newUndistributed) - int256(lastUndistributed)));\\n } else {\\n uint256 exponential;\\n deltaTime = t.end - rewardData.lastUpdate;\\n if (distributionFactor > 0) {\\n exponential = uint256((-int256(distributionFactor * deltaTime)).expWad());\\n newUndistributed =\\n lastUndistributed.mulWadDown(exponential) +\\n releaseRate.mulDivDown(1e18 - target, distributionFactor).mulWadUp(1e18 - exponential);\\n } else {\\n newUndistributed = lastUndistributed + releaseRate.mulWadDown(1e18 - target) * deltaTime;\\n }\\n exponential = uint256((-int256(distributionFactor * (block.timestamp - t.end))).expWad());\\n newUndistributed = newUndistributed - newUndistributed.mulWadUp(1e18 - exponential);\\n rewards = uint256(int256(releaseRate * deltaTime) - (int256(newUndistributed) - int256(lastUndistributed)));\\n }\\n if (rewards == 0) return (rewardData.borrowIndex, rewardData.depositIndex, newUndistributed);\\n }\\n {\\n AllocationVars memory v;\\n v.utilization = m.supply > 0 ? Math.min(m.debt.divWadDown(m.supply), UTILIZATION_CAP) : 0;\\n v.transitionFactor = rewardData.transitionFactor;\\n v.flipSpeed = rewardData.flipSpeed;\\n v.borrowAllocationWeightFactor = rewardData.borrowAllocationWeightFactor;\\n v.sigmoid = v.utilization > 0\\n ? uint256(1e18).divWadDown(\\n 1e18 +\\n uint256(\\n (-(v.flipSpeed *\\n (int256(v.utilization.divWadDown(1e18 - v.utilization)).lnWad() -\\n int256(v.transitionFactor.divWadDown(1e18 - v.transitionFactor)).lnWad())) / 1e18).expWad()\\n )\\n )\\n : 0;\\n v.borrowRewardRule = rewardData\\n .compensationFactor\\n .mulWadDown(\\n market.interestRateModel().floatingRate(v.utilization).mulWadDown(\\n 1e18 - v.utilization.mulWadUp(1e18 - market.treasuryFeeRate())\\n ) + v.borrowAllocationWeightFactor\\n )\\n .mulWadDown(1e18 - v.sigmoid);\\n v.depositRewardRule =\\n rewardData.depositAllocationWeightAddend.mulWadDown(1e18 - v.sigmoid) +\\n rewardData.depositAllocationWeightFactor.mulWadDown(v.sigmoid);\\n v.borrowAllocation = v.borrowRewardRule.divWadDown(v.borrowRewardRule + v.depositRewardRule);\\n v.depositAllocation = 1e18 - v.borrowAllocation;\\n {\\n uint256 totalDepositSupply = market.totalSupply();\\n uint256 totalBorrowSupply = market.totalFloatingBorrowShares() + m.fixedBorrowShares;\\n uint256 baseUnit = distribution[market].baseUnit;\\n borrowIndex =\\n rewardData.borrowIndex +\\n (totalBorrowSupply > 0 ? rewards.mulWadDown(v.borrowAllocation).mulDivDown(baseUnit, totalBorrowSupply) : 0);\\n depositIndex =\\n rewardData.depositIndex +\\n (\\n totalDepositSupply > 0\\n ? rewards.mulWadDown(v.depositAllocation).mulDivDown(baseUnit, totalDepositSupply)\\n : 0\\n );\\n }\\n }\\n }\\n\\n /// @notice Get account balances of the given Market operations.\\n /// @param market The address of the Market.\\n /// @param ops List of operations to retrieve account balance.\\n /// @param account Account to get the balance from.\\n /// @param distributionStart Timestamp of the start of the distribution to correctly get the rewarded fixed pools.\\n /// @return accountBalanceOps contains a list with account balance per each operation.\\n function accountBalanceOperations(\\n Market market,\\n bool[] memory ops,\\n address account,\\n uint32 distributionStart\\n ) internal view returns (AccountOperation[] memory accountBalanceOps) {\\n accountBalanceOps = new AccountOperation[](ops.length);\\n for (uint256 i = 0; i < ops.length; ) {\\n if (ops[i]) {\\n (, , uint256 floatingBorrowShares) = market.accounts(account);\\n accountBalanceOps[i] = AccountOperation({\\n operation: true,\\n balance: floatingBorrowShares + accountFixedBorrowShares(market, account, distributionStart)\\n });\\n } else {\\n accountBalanceOps[i] = AccountOperation({ operation: false, balance: market.balanceOf(account) });\\n }\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n /// @notice Withdraws the contract's balance of the given asset to the given address.\\n /// @param asset The asset to withdraw.\\n /// @param to The address to withdraw the asset to.\\n function withdraw(ERC20 asset, address to) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n asset.safeTransfer(to, asset.balanceOf(address(this)));\\n }\\n\\n /// @notice Enables or updates the reward distribution for the given markets and rewards.\\n /// @param configs The configurations to update each RewardData with.\\n function config(Config[] memory configs) external onlyRole(DEFAULT_ADMIN_ROLE) {\\n for (uint256 i = 0; i < configs.length; ) {\\n // transitionFactor cannot be eq or higher than 1e18 to avoid division by zero or underflow\\n if (configs[i].transitionFactor >= 1e18) revert InvalidConfig();\\n // depositAllocationWeightFactor cannot be zero to avoid division by zero when sigmoid equals 1e18\\n if (configs[i].depositAllocationWeightFactor == 0) revert InvalidConfig();\\n\\n Distribution storage dist = distribution[configs[i].market];\\n RewardData storage rewardData = dist.rewards[configs[i].reward];\\n\\n if (dist.baseUnit == 0) {\\n // never initialized before, adding to the list of markets\\n marketList.push(configs[i].market);\\n }\\n if (!rewardEnabled[configs[i].reward]) {\\n // add reward address to global rewards list if still not enabled\\n rewardEnabled[configs[i].reward] = true;\\n rewardList.push(configs[i].reward);\\n }\\n if (rewardData.lastUpdate == 0) {\\n // add reward address to distribution data's available rewards if distribution is new\\n dist.availableRewards[dist.availableRewardsCount++] = configs[i].reward;\\n dist.baseUnit = 10 ** configs[i].market.decimals();\\n // set initial parameters if distribution is new\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n } else {\\n uint32 start = rewardData.start;\\n uint32 end = rewardData.end;\\n // update global indexes before updating distribution values\\n bool[] memory ops = new bool[](1);\\n ops[0] = true;\\n update(\\n address(0),\\n configs[i].market,\\n configs[i].reward,\\n accountBalanceOperations(configs[i].market, ops, address(0), start)\\n );\\n // properly update release rate\\n if (block.timestamp < end) {\\n uint256 released = 0;\\n uint256 elapsed = 0;\\n if (block.timestamp > start) {\\n released =\\n rewardData.lastConfigReleased +\\n rewardData.releaseRate *\\n (block.timestamp - rewardData.lastConfig);\\n elapsed = block.timestamp - start;\\n if (configs[i].totalDistribution <= released || configs[i].distributionPeriod <= elapsed) {\\n revert InvalidConfig();\\n }\\n rewardData.lastConfigReleased = released;\\n }\\n\\n rewardData.releaseRate =\\n (configs[i].totalDistribution - released) /\\n (configs[i].distributionPeriod - elapsed);\\n } else if (rewardData.start != configs[i].start) {\\n rewardData.start = configs[i].start;\\n rewardData.lastUpdate = configs[i].start;\\n rewardData.releaseRate = configs[i].totalDistribution / configs[i].distributionPeriod;\\n rewardData.lastConfigReleased = 0;\\n }\\n }\\n rewardData.lastConfig = uint32(block.timestamp);\\n rewardData.end = rewardData.start + uint32(configs[i].distributionPeriod);\\n rewardData.priceFeed = configs[i].priceFeed;\\n // set emission and distribution parameters\\n rewardData.totalDistribution = configs[i].totalDistribution;\\n rewardData.targetDebt = configs[i].targetDebt;\\n rewardData.undistributedFactor = configs[i].undistributedFactor;\\n rewardData.flipSpeed = configs[i].flipSpeed;\\n rewardData.compensationFactor = configs[i].compensationFactor;\\n rewardData.borrowAllocationWeightFactor = configs[i].borrowAllocationWeightFactor;\\n rewardData.depositAllocationWeightAddend = configs[i].depositAllocationWeightAddend;\\n rewardData.transitionFactor = configs[i].transitionFactor;\\n rewardData.depositAllocationWeightFactor = configs[i].depositAllocationWeightFactor;\\n\\n emit DistributionSet(configs[i].market, configs[i].reward, configs[i]);\\n unchecked {\\n ++i;\\n }\\n }\\n }\\n\\n struct TotalMarketBalance {\\n uint256 debt;\\n uint256 supply;\\n uint256 fixedBorrowShares;\\n }\\n\\n struct TimeVars {\\n uint256 start;\\n uint256 end;\\n uint256 period;\\n }\\n\\n struct AllocationVars {\\n uint256 utilization;\\n uint256 sigmoid;\\n uint256 borrowRewardRule;\\n uint256 depositRewardRule;\\n uint256 borrowAllocation;\\n uint256 depositAllocation;\\n uint256 transitionFactor;\\n int256 flipSpeed;\\n uint256 borrowAllocationWeightFactor;\\n }\\n\\n struct AccountOperation {\\n bool operation;\\n uint256 balance;\\n }\\n\\n struct MarketOperation {\\n Market market;\\n bool[] operations;\\n }\\n\\n struct AccountMarketOperation {\\n Market market;\\n AccountOperation[] accountOperations;\\n }\\n\\n struct Account {\\n // liquidity index of the reward distribution for the account\\n uint128 index;\\n // amount of accrued rewards for the account since last account index update\\n uint128 accrued;\\n }\\n\\n struct Config {\\n Market market;\\n ERC20 reward;\\n IPriceFeed priceFeed;\\n uint32 start;\\n uint256 distributionPeriod;\\n uint256 targetDebt;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n }\\n\\n struct RewardData {\\n // distribution model\\n uint256 targetDebt;\\n uint256 releaseRate;\\n uint256 totalDistribution;\\n uint256 undistributedFactor;\\n uint256 lastUndistributed;\\n // allocation model\\n int128 flipSpeed;\\n uint64 compensationFactor;\\n uint64 transitionFactor;\\n uint64 borrowAllocationWeightFactor;\\n uint64 depositAllocationWeightAddend;\\n uint64 depositAllocationWeightFactor;\\n // liquidity indexes of the reward distribution\\n uint128 borrowIndex;\\n uint128 depositIndex;\\n // distribution timestamps\\n uint32 start;\\n uint32 end;\\n uint32 lastUpdate;\\n // config helpers\\n uint32 lastConfig;\\n uint256 lastConfigReleased;\\n // price feed\\n IPriceFeed priceFeed;\\n // account addresses and their rewards data (index & accrued)\\n mapping(address => mapping(bool => Account)) accounts;\\n }\\n\\n struct Distribution {\\n // reward assets and their data\\n mapping(ERC20 => RewardData) rewards;\\n // list of reward asset addresses for the market\\n mapping(uint128 => ERC20) availableRewards;\\n // count of reward tokens for the market\\n uint8 availableRewardsCount;\\n // base unit of the market\\n uint256 baseUnit;\\n }\\n\\n /// @notice Emitted when rewards are accrued by an account.\\n /// @param market Market where the operation was made.\\n /// @param reward reward asset.\\n /// @param account account that accrued the rewards.\\n /// @param operation true if the operation was a borrow, false if it was a deposit.\\n /// @param accountIndex previous account index.\\n /// @param operationIndex new operation index that is assigned to the `accountIndex`.\\n /// @param rewardsAccrued amount of rewards accrued.\\n event Accrue(\\n Market indexed market,\\n ERC20 indexed reward,\\n address indexed account,\\n bool operation,\\n uint256 accountIndex,\\n uint256 operationIndex,\\n uint256 rewardsAccrued\\n );\\n\\n /// @notice Emitted when rewards are claimed by an account.\\n /// @param account account that claimed the rewards.\\n /// @param reward reward asset.\\n /// @param to account that received the rewards.\\n /// @param amount amount of rewards claimed.\\n event Claim(address indexed account, ERC20 indexed reward, address indexed to, uint256 amount);\\n\\n /// @notice Emitted when a distribution is set.\\n /// @param market Market whose distribution was set.\\n /// @param reward reward asset to be distributed when operating with the Market.\\n /// @param config configuration struct containing the distribution parameters.\\n event DistributionSet(Market indexed market, ERC20 indexed reward, Config config);\\n\\n /// @notice Emitted when the distribution indexes are updated.\\n /// @param market Market of the distribution.\\n /// @param reward reward asset.\\n /// @param borrowIndex index of the borrow operations of a distribution.\\n /// @param depositIndex index of the deposit operations of a distribution.\\n /// @param newUndistributed amount of undistributed rewards.\\n /// @param lastUpdate current timestamp.\\n event IndexUpdate(\\n Market indexed market,\\n ERC20 indexed reward,\\n uint256 borrowIndex,\\n uint256 depositIndex,\\n uint256 newUndistributed,\\n uint256 lastUpdate\\n );\\n}\\n\\nerror IndexOverflow();\\nerror InvalidConfig();\\n\",\"keccak256\":\"0x1542122ea5dfca16000fa7e476201de82eef8ff8d7f44601274e1ed12c60344f\",\"license\":\"BUSL-1.1\"},\"contracts/periphery/Previewer.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\nimport { MathUpgradeable as Math } from \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport { ERC20 } from \\\"solmate/src/tokens/ERC20.sol\\\";\\nimport { InterestRateModel as IRM, AlreadyMatured } from \\\"../InterestRateModel.sol\\\";\\nimport { RewardsController } from \\\"../RewardsController.sol\\\";\\nimport { FixedLib } from \\\"../utils/FixedLib.sol\\\";\\nimport { Auditor, IPriceFeed } from \\\"../Auditor.sol\\\";\\nimport { Market } from \\\"../Market.sol\\\";\\n\\n/// @title Previewer\\n/// @notice Contract to be consumed by Exactly's front-end dApp.\\ncontract Previewer {\\n using FixedPointMathLib for uint256;\\n using FixedPointMathLib for int256;\\n using FixedLib for FixedLib.Position;\\n using FixedLib for FixedLib.Pool;\\n using FixedLib for uint256;\\n\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n Auditor public immutable auditor;\\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\\n IPriceFeed public immutable basePriceFeed;\\n\\n struct MarketAccount {\\n // market\\n Market market;\\n string symbol;\\n uint8 decimals;\\n address asset;\\n string assetName;\\n string assetSymbol;\\n InterestRateModel interestRateModel;\\n uint256 usdPrice;\\n uint256 penaltyRate;\\n uint256 adjustFactor;\\n uint8 maxFuturePools;\\n FixedPool[] fixedPools;\\n RewardRate[] rewardRates;\\n uint256 floatingBorrowRate;\\n uint256 floatingUtilization;\\n uint256 floatingBackupBorrowed;\\n uint256 floatingAvailableAssets;\\n uint256 totalFloatingBorrowAssets;\\n uint256 totalFloatingDepositAssets;\\n uint256 totalFloatingBorrowShares;\\n uint256 totalFloatingDepositShares;\\n // account\\n bool isCollateral;\\n uint256 maxBorrowAssets;\\n uint256 floatingBorrowShares;\\n uint256 floatingBorrowAssets;\\n uint256 floatingDepositShares;\\n uint256 floatingDepositAssets;\\n FixedPosition[] fixedDepositPositions;\\n FixedPosition[] fixedBorrowPositions;\\n ClaimableReward[] claimableRewards;\\n }\\n\\n struct RewardRate {\\n ERC20 asset;\\n string assetName;\\n string assetSymbol;\\n uint256 usdPrice;\\n uint256 borrow;\\n uint256 floatingDeposit;\\n uint256[] maturities;\\n }\\n\\n struct ClaimableReward {\\n address asset;\\n string assetName;\\n string assetSymbol;\\n uint256 amount;\\n }\\n\\n struct InterestRateModel {\\n address id;\\n uint256 fixedCurveA;\\n int256 fixedCurveB;\\n uint256 fixedMaxUtilization;\\n uint256 floatingCurveA;\\n int256 floatingCurveB;\\n uint256 floatingMaxUtilization;\\n }\\n\\n struct FixedPosition {\\n uint256 maturity;\\n uint256 previewValue;\\n FixedLib.Position position;\\n }\\n\\n struct FixedPreview {\\n uint256 maturity;\\n uint256 assets;\\n uint256 utilization;\\n }\\n\\n struct FixedPool {\\n uint256 maturity;\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 available;\\n uint256 utilization;\\n uint256 depositRate;\\n uint256 minBorrowRate;\\n uint256 optimalDeposit;\\n }\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IPriceFeed basePriceFeed_) {\\n auditor = auditor_;\\n basePriceFeed = basePriceFeed_;\\n }\\n\\n /// @notice Function to get a certain account extended data.\\n /// @param account address which the extended data will be calculated.\\n /// @return data extended accountability of all markets for the account.\\n function exactly(address account) external view returns (MarketAccount[] memory data) {\\n uint256 markets = auditor.accountMarkets(account);\\n uint256 maxValue = auditor.allMarkets().length;\\n (uint256 adjustedCollateral, uint256 adjustedDebt) = auditor.accountLiquidity(account, Market(address(0)), 0);\\n uint256 basePrice = address(basePriceFeed) != address(0)\\n ? uint256(basePriceFeed.latestAnswer()) * 10 ** (18 - basePriceFeed.decimals())\\n : 1e18;\\n data = new MarketAccount[](maxValue);\\n for (uint256 i = 0; i < maxValue; ++i) {\\n Market market = auditor.marketList(i);\\n Market.Account memory a;\\n Auditor.MarketData memory m;\\n (a.fixedDeposits, a.fixedBorrows, a.floatingBorrowShares) = market.accounts(account);\\n (m.adjustFactor, m.decimals, m.index, m.isListed, m.priceFeed) = auditor.markets(market);\\n IRM irm = market.interestRateModel();\\n data[i] = MarketAccount({\\n // market\\n market: market,\\n symbol: market.symbol(),\\n decimals: m.decimals,\\n asset: address(market.asset()),\\n assetName: market.asset().name(),\\n assetSymbol: market.asset().symbol(),\\n interestRateModel: InterestRateModel({\\n id: address(irm),\\n fixedCurveA: irm.fixedCurveA(),\\n fixedCurveB: irm.fixedCurveB(),\\n fixedMaxUtilization: irm.fixedMaxUtilization(),\\n floatingCurveA: irm.floatingCurveA(),\\n floatingCurveB: irm.floatingCurveB(),\\n floatingMaxUtilization: irm.floatingMaxUtilization()\\n }),\\n usdPrice: auditor.assetPrice(m.priceFeed).mulWadDown(basePrice),\\n penaltyRate: market.penaltyRate(),\\n adjustFactor: m.adjustFactor,\\n maxFuturePools: market.maxFuturePools(),\\n fixedPools: fixedPools(market),\\n rewardRates: rewardRates(market, basePrice),\\n floatingBorrowRate: irm.floatingRate(\\n market.floatingAssets() > 0 ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18) : 0\\n ),\\n floatingUtilization: market.floatingAssets() > 0\\n ? Math.min(market.floatingDebt().divWadUp(market.floatingAssets()), 1e18)\\n : 0,\\n floatingBackupBorrowed: market.floatingBackupBorrowed(),\\n floatingAvailableAssets: floatingAvailableAssets(market),\\n totalFloatingBorrowAssets: market.totalFloatingBorrowAssets(),\\n totalFloatingDepositAssets: market.totalAssets(),\\n totalFloatingBorrowShares: market.totalFloatingBorrowShares(),\\n totalFloatingDepositShares: market.totalSupply(),\\n // account\\n isCollateral: markets & (1 << i) != 0 ? true : false,\\n maxBorrowAssets: adjustedCollateral >= adjustedDebt\\n ? (adjustedCollateral - adjustedDebt).mulDivUp(10 ** m.decimals, auditor.assetPrice(m.priceFeed)).mulWadUp(\\n m.adjustFactor\\n )\\n : 0,\\n floatingBorrowShares: a.floatingBorrowShares,\\n floatingBorrowAssets: maxRepay(market, account),\\n floatingDepositShares: market.balanceOf(account),\\n floatingDepositAssets: market.maxWithdraw(account),\\n fixedDepositPositions: fixedPositions(\\n market,\\n account,\\n a.fixedDeposits,\\n market.fixedDepositPositions,\\n this.previewWithdrawAtMaturity\\n ),\\n fixedBorrowPositions: fixedPositions(\\n market,\\n account,\\n a.fixedBorrows,\\n market.fixedBorrowPositions,\\n this.previewRepayAtMaturity\\n ),\\n claimableRewards: claimableRewards(market, account)\\n });\\n }\\n }\\n\\n /// @notice Gets the assets plus yield offered by a maturity when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be deposited.\\n /// @param assets amount of assets that will be deposited.\\n /// @return amount plus yield that the depositor will receive after maturity.\\n function previewDepositAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n if (block.timestamp > maturity) revert AlreadyMatured();\\n (uint256 borrowed, uint256 supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fixedDepositYield(market, maturity, assets),\\n utilization: memFloatingAssetsAverage > 0 ? borrowed.divWadUp(supplied + assets + memFloatingAssetsAverage) : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus yield offered by all VALID maturities when depositing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be deposited.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewDepositAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n previews[i] = previewDepositAtMaturity(market, maturity, assets);\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount plus fees to be repaid at maturity when borrowing certain amount of assets.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be borrowed.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return positionAssets amount plus fees that the depositor will repay at maturity.\\n function previewBorrowAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 assets\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n uint256 fees = assets.mulWadDown(\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n assets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n );\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: assets + fees,\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed + assets).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets plus fees offered by all VALID maturities when borrowing a certain amount.\\n /// @param market address of the market.\\n /// @param assets amount of assets that will be borrowed.\\n /// @return previews array containing amount plus yield that account will receive after each maturity.\\n function previewBorrowAtAllMaturities(\\n Market market,\\n uint256 assets\\n ) public view returns (FixedPreview[] memory previews) {\\n uint256 maxFuturePools = market.maxFuturePools();\\n uint256 maturity = block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n previews = new FixedPreview[](maxFuturePools);\\n for (uint256 i = 0; i < maxFuturePools; i++) {\\n try this.previewBorrowAtMaturity(market, maturity, assets) returns (FixedPreview memory preview) {\\n previews[i] = preview;\\n } catch {\\n previews[i] = FixedPreview({ maturity: maturity, assets: type(uint256).max, utilization: type(uint256).max });\\n }\\n maturity += FixedLib.INTERVAL;\\n }\\n }\\n\\n /// @notice Gets the amount to be withdrawn for a certain positionAmount of assets at maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be withdrawn.\\n /// @param positionAssets amount of assets that will be tried to withdraw.\\n /// @return withdrawAssets amount that will be withdrawn.\\n function previewWithdrawAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address owner\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedDepositPositions(maturity, owner);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets.divWadDown(\\n 1e18 +\\n market.interestRateModel().fixedBorrowRate(\\n maturity,\\n positionAssets,\\n pool.borrowed,\\n pool.supplied,\\n memFloatingAssetsAverage\\n )\\n )\\n : positionAssets,\\n utilization: memFloatingAssetsAverage > 0\\n ? pool.borrowed.divWadUp(pool.supplied + memFloatingAssetsAverage - principal)\\n : 0\\n });\\n }\\n\\n /// @notice Gets the assets that will be repaid when repaying a certain amount at the current maturity.\\n /// @param market address of the market.\\n /// @param maturity maturity date/pool where the assets will be repaid.\\n /// @param positionAssets amount of assets that will be subtracted from the position.\\n /// @param borrower address of the borrower.\\n /// @return repayAssets amount of assets that will be repaid.\\n function previewRepayAtMaturity(\\n Market market,\\n uint256 maturity,\\n uint256 positionAssets,\\n address borrower\\n ) public view returns (FixedPreview memory) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, , ) = market.fixedPools(maturity);\\n FixedLib.Position memory position;\\n (position.principal, position.fee) = market.fixedBorrowPositions(maturity, borrower);\\n uint256 principal = position.scaleProportionally(positionAssets).principal;\\n uint256 memFloatingAssetsAverage = market.previewFloatingAssetsAverage();\\n\\n return\\n FixedPreview({\\n maturity: maturity,\\n assets: block.timestamp < maturity\\n ? positionAssets - fixedDepositYield(market, maturity, principal)\\n : positionAssets + positionAssets.mulWadDown((block.timestamp - maturity) * market.penaltyRate()),\\n utilization: memFloatingAssetsAverage > 0\\n ? (pool.borrowed - principal).divWadUp(pool.supplied + memFloatingAssetsAverage)\\n : 0\\n });\\n }\\n\\n function fixedPools(Market market) internal view returns (FixedPool[] memory pools) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n pools = new FixedPool[](market.maxFuturePools());\\n for (uint256 i = 0; i < market.maxFuturePools(); i++) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)\\n );\\n (uint256 minBorrowRate, uint256 utilization) = (market.previewFloatingAssetsAverage() + pool.supplied) > 0\\n ? market.interestRateModel().minFixedRate(pool.borrowed, pool.supplied, market.previewFloatingAssetsAverage())\\n : (0, 0);\\n\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n (block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1)) - pool.lastAccrual\\n );\\n pools[i] = FixedPool({\\n maturity: block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1),\\n borrowed: pool.borrowed,\\n supplied: pool.supplied,\\n available: Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()) -\\n Math.min(\\n (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor()),\\n market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt\\n ),\\n market.previewFloatingAssetsAverage()\\n ) +\\n pool.supplied -\\n Math.min(pool.supplied, pool.borrowed),\\n utilization: utilization,\\n optimalDeposit: pool.borrowed - Math.min(pool.borrowed, pool.supplied),\\n depositRate: uint256(365 days).mulDivDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied) > 0\\n ? (pool.unassignedEarnings.mulWadDown(1e18 - market.backupFeeRate())).divWadDown(\\n pool.borrowed - Math.min(pool.borrowed, pool.supplied)\\n )\\n : 0,\\n block.timestamp - (block.timestamp % FixedLib.INTERVAL) + FixedLib.INTERVAL * (i + 1) - block.timestamp\\n ),\\n minBorrowRate: minBorrowRate\\n });\\n }\\n }\\n\\n function rewardRates(Market market, uint256 basePrice) internal view returns (RewardRate[] memory rewards) {\\n RewardsVars memory r;\\n r.controller = market.rewardsController();\\n if (address(r.controller) != address(0)) {\\n (, r.underlyingDecimals, , , r.underlyingPriceFeed) = auditor.markets(market);\\n unchecked {\\n r.underlyingBaseUnit = 10 ** r.underlyingDecimals;\\n }\\n r.deltaTime = 1 hours;\\n r.rewardList = r.controller.allRewards();\\n rewards = new RewardRate[](r.rewardList.length);\\n {\\n uint256 index;\\n for (r.i = 0; r.i < r.rewardList.length; ++r.i) {\\n (r.start, , ) = r.controller.distributionTime(market, r.rewardList[r.i]);\\n if (r.start == 0) continue;\\n rewards[index++].asset = r.rewardList[r.i];\\n }\\n RewardRate[] memory rewardList = rewards;\\n rewards = new RewardRate[](index);\\n for (r.i = 0; r.i < rewards.length; ++r.i) rewards[r.i] = rewardList[r.i];\\n }\\n for (r.i = 0; r.i < rewards.length; ++r.i) {\\n r.config = r.controller.rewardConfig(market, rewards[r.i].asset);\\n (r.borrowIndex, r.depositIndex, ) = r.controller.rewardIndexes(market, rewards[r.i].asset);\\n (r.projectedBorrowIndex, r.projectedDepositIndex, ) = r.controller.previewAllocation(\\n market,\\n rewards[r.i].asset,\\n block.timestamp > r.config.start ? r.deltaTime : 0\\n );\\n r.firstMaturity = r.start - (r.start % FixedLib.INTERVAL) + FixedLib.INTERVAL;\\n r.maxMaturity =\\n block.timestamp -\\n (block.timestamp % FixedLib.INTERVAL) +\\n (FixedLib.INTERVAL * market.maxFuturePools());\\n r.maturities = new uint256[]((r.maxMaturity - r.firstMaturity) / FixedLib.INTERVAL + 1);\\n r.start = 0;\\n for (r.maturity = r.firstMaturity; r.maturity <= r.maxMaturity; ) {\\n (uint256 borrowed, ) = market.fixedPoolBalance(r.maturity);\\n r.fixedDebt += borrowed;\\n r.maturities[r.start] = r.maturity;\\n unchecked {\\n r.maturity += FixedLib.INTERVAL;\\n ++r.start;\\n }\\n }\\n rewards[r.i] = RewardRate({\\n asset: rewards[r.i].asset,\\n assetName: rewards[r.i].asset.name(),\\n assetSymbol: rewards[r.i].asset.symbol(),\\n usdPrice: auditor.assetPrice(r.config.priceFeed).mulWadDown(basePrice),\\n borrow: (market.totalFloatingBorrowAssets() + r.fixedDebt) > 0\\n ? (r.projectedBorrowIndex - r.borrowIndex)\\n .mulDivDown(market.totalFloatingBorrowShares() + market.previewRepay(r.fixedDebt), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n (market.totalFloatingBorrowAssets() + r.fixedDebt).mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n floatingDeposit: market.totalAssets() > 0\\n ? (r.projectedDepositIndex - r.depositIndex)\\n .mulDivDown(market.totalSupply(), r.underlyingBaseUnit)\\n .mulWadDown(auditor.assetPrice(r.config.priceFeed))\\n .mulDivDown(\\n r.underlyingBaseUnit,\\n market.totalAssets().mulWadDown(auditor.assetPrice(r.underlyingPriceFeed))\\n )\\n .mulDivDown(365 days, r.deltaTime)\\n : 0,\\n maturities: r.maturities\\n });\\n }\\n }\\n }\\n\\n function claimableRewards(Market market, address account) internal view returns (ClaimableReward[] memory rewards) {\\n RewardsController rewardsController = market.rewardsController();\\n if (address(rewardsController) != address(0)) {\\n ERC20[] memory rewardList = rewardsController.allRewards();\\n\\n rewards = new ClaimableReward[](rewardList.length);\\n RewardsController.MarketOperation[] memory marketOps = new RewardsController.MarketOperation[](1);\\n bool[] memory ops = new bool[](2);\\n ops[0] = true;\\n ops[1] = false;\\n marketOps[0] = RewardsController.MarketOperation({ market: market, operations: ops });\\n\\n for (uint256 i = 0; i < rewardList.length; ++i) {\\n rewards[i] = ClaimableReward({\\n asset: address(rewardList[i]),\\n assetName: rewardList[i].name(),\\n assetSymbol: rewardList[i].symbol(),\\n amount: rewardsController.claimable(marketOps, account, rewardList[i])\\n });\\n }\\n }\\n }\\n\\n function floatingAvailableAssets(Market market) internal view returns (uint256) {\\n uint256 freshFloatingDebt = newFloatingDebt(market);\\n uint256 maxAssets = (market.floatingAssets() + freshFloatingDebt).mulWadDown(1e18 - market.reserveFactor());\\n return maxAssets - Math.min(maxAssets, market.floatingBackupBorrowed() + market.floatingDebt() + freshFloatingDebt);\\n }\\n\\n function fixedPositions(\\n Market market,\\n address account,\\n uint256 packedMaturities,\\n function(uint256, address) external view returns (uint256, uint256) getPosition,\\n function(Market, uint256, uint256, address) external view returns (FixedPreview memory) previewValue\\n ) internal view returns (FixedPosition[] memory userMaturityPositions) {\\n uint256 userMaturityCount = 0;\\n FixedPosition[] memory allMaturityPositions = new FixedPosition[](224);\\n uint256 maturity = packedMaturities & ((1 << 32) - 1);\\n packedMaturities = packedMaturities >> 32;\\n while (packedMaturities != 0) {\\n if (packedMaturities & 1 != 0) {\\n uint256 positionAssets;\\n {\\n (uint256 principal, uint256 fee) = getPosition(maturity, account);\\n positionAssets = principal + fee;\\n allMaturityPositions[userMaturityCount].position = FixedLib.Position(principal, fee);\\n }\\n try previewValue(market, maturity, positionAssets, account) returns (FixedPreview memory fixedPreview) {\\n allMaturityPositions[userMaturityCount].previewValue = fixedPreview.assets;\\n } catch {\\n allMaturityPositions[userMaturityCount].previewValue = positionAssets;\\n }\\n allMaturityPositions[userMaturityCount].maturity = maturity;\\n ++userMaturityCount;\\n }\\n packedMaturities >>= 1;\\n maturity += FixedLib.INTERVAL;\\n }\\n\\n userMaturityPositions = new FixedPosition[](userMaturityCount);\\n for (uint256 i = 0; i < userMaturityCount; ++i) userMaturityPositions[i] = allMaturityPositions[i];\\n }\\n\\n function fixedDepositYield(Market market, uint256 maturity, uint256 assets) internal view returns (uint256 yield) {\\n FixedLib.Pool memory pool;\\n (pool.borrowed, pool.supplied, pool.unassignedEarnings, pool.lastAccrual) = market.fixedPools(maturity);\\n pool.unassignedEarnings -= pool.unassignedEarnings.mulDivDown(\\n block.timestamp - pool.lastAccrual,\\n maturity - pool.lastAccrual\\n );\\n (yield, ) = pool.calculateDeposit(assets, market.backupFeeRate());\\n }\\n\\n function maxRepay(Market market, address borrower) internal view returns (uint256) {\\n (, , uint256 floatingBorrowShares) = market.accounts(borrower);\\n return market.previewRefund(floatingBorrowShares);\\n }\\n\\n function newFloatingDebt(Market market) internal view returns (uint256) {\\n uint256 memFloatingDebt = market.floatingDebt();\\n uint256 memFloatingAssets = market.floatingAssets();\\n uint256 floatingUtilization = memFloatingAssets > 0\\n ? Math.min(memFloatingDebt.divWadUp(memFloatingAssets), 1e18)\\n : 0;\\n return\\n memFloatingDebt.mulWadDown(\\n market.interestRateModel().floatingRate(floatingUtilization).mulDivDown(\\n block.timestamp - market.lastFloatingDebtUpdate(),\\n 365 days\\n )\\n );\\n }\\n\\n struct RewardsVars {\\n RewardsController controller;\\n uint256 lastUpdate;\\n uint256 depositIndex;\\n uint256 borrowIndex;\\n uint256 projectedDepositIndex;\\n uint256 projectedBorrowIndex;\\n uint256 underlyingBaseUnit;\\n uint256[] maturities;\\n IPriceFeed underlyingPriceFeed;\\n RewardsController.Config config;\\n ERC20[] rewardList;\\n uint256 underlyingDecimals;\\n uint256 deltaTime;\\n uint256 i;\\n uint256 start;\\n uint256 maturity;\\n uint256 fixedDebt;\\n uint256 maxMaturity;\\n uint256 firstMaturity;\\n }\\n}\\n\\nerror InvalidRewardsLength();\\n\",\"keccak256\":\"0x49580c383ef1adee2e988a4590f68315ad85e14dbb2bfa1f5d3becf0d9eff940\",\"license\":\"BUSL-1.1\"},\"contracts/utils/FixedLib.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\nimport { Math } from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport { FixedPointMathLib } from \\\"solmate/src/utils/FixedPointMathLib.sol\\\";\\n\\nlibrary FixedLib {\\n using FixedPointMathLib for uint256;\\n\\n uint256 internal constant INTERVAL = 4 weeks;\\n\\n /// @notice Gets the amount of revenue sharing between the backup supplier and the new fixed pool supplier.\\n /// @param pool fixed rate pool.\\n /// @param amount amount being provided by the fixed pool supplier.\\n /// @param backupFeeRate rate charged to the fixed pool supplier to be accrued by the backup supplier.\\n /// @return yield amount to be offered to the fixed pool supplier.\\n /// @return backupFee yield to be accrued by the backup supplier for initially providing the liquidity.\\n function calculateDeposit(\\n Pool memory pool,\\n uint256 amount,\\n uint256 backupFeeRate\\n ) internal pure returns (uint256 yield, uint256 backupFee) {\\n uint256 memBackupSupplied = backupSupplied(pool);\\n if (memBackupSupplied != 0) {\\n yield = pool.unassignedEarnings.mulDivDown(Math.min(amount, memBackupSupplied), memBackupSupplied);\\n backupFee = yield.mulWadDown(backupFeeRate);\\n yield -= backupFee;\\n }\\n }\\n\\n /// @notice Registers an operation to add supply to a fixed rate pool and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be added to the supply.\\n /// @param amount amount to be added to the supply.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function deposit(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.supplied = supplied + amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to reduce borrowed amount from a fixed rate pool\\n /// and potentially reduce backup debt.\\n /// @param pool fixed rate pool where an amount will be repaid.\\n /// @param amount amount to be added to the fixed rate pool.\\n /// @return backupDebtReduction amount that will be reduced from the backup debt.\\n function repay(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtReduction) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n pool.borrowed = borrowed - amount;\\n backupDebtReduction = Math.min(borrowed - Math.min(borrowed, supplied), amount);\\n }\\n\\n /// @notice Registers an operation to increase borrowed amount of a fixed rate pool\\n /// and potentially increase backup debt.\\n /// @param pool fixed rate pool where an amount will be borrowed.\\n /// @param amount amount to be borrowed from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function borrow(Pool storage pool, uint256 amount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 newBorrowed = borrowed + amount;\\n\\n backupDebtAddition = newBorrowed - Math.min(Math.max(borrowed, pool.supplied), newBorrowed);\\n pool.borrowed = newBorrowed;\\n }\\n\\n /// @notice Registers an operation to reduce supply from a fixed rate pool and potentially increase backup debt.\\n /// @param pool fixed rate pool where amount will be withdrawn.\\n /// @param amountToDiscount amount to be withdrawn from the fixed rate pool.\\n /// @return backupDebtAddition amount of new debt that needs to be borrowed from the backup supplier.\\n function withdraw(Pool storage pool, uint256 amountToDiscount) internal returns (uint256 backupDebtAddition) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n uint256 newSupply = supplied - amountToDiscount;\\n\\n backupDebtAddition = Math.min(supplied, borrowed) - Math.min(newSupply, borrowed);\\n pool.supplied = newSupply;\\n }\\n\\n /// @notice Accrues backup earnings from `unassignedEarnings` based on the `lastAccrual` time.\\n /// @param pool fixed rate pool where earnings will be accrued.\\n /// @param maturity maturity date of the pool.\\n /// @return backupEarnings amount of earnings to be distributed to the backup supplier.\\n function accrueEarnings(Pool storage pool, uint256 maturity) internal returns (uint256 backupEarnings) {\\n uint256 lastAccrual = pool.lastAccrual;\\n\\n if (block.timestamp < maturity) {\\n uint256 unassignedEarnings = pool.unassignedEarnings;\\n pool.lastAccrual = block.timestamp;\\n backupEarnings = unassignedEarnings.mulDivDown(block.timestamp - lastAccrual, maturity - lastAccrual);\\n pool.unassignedEarnings = unassignedEarnings - backupEarnings;\\n } else if (lastAccrual == maturity) {\\n backupEarnings = 0;\\n } else {\\n pool.lastAccrual = maturity;\\n backupEarnings = pool.unassignedEarnings;\\n pool.unassignedEarnings = 0;\\n }\\n }\\n\\n /// @notice Calculates the amount that a fixed rate pool borrowed from the backup supplier.\\n /// @param pool fixed rate pool.\\n /// @return amount borrowed from the fixed rate pool.\\n function backupSupplied(Pool memory pool) internal pure returns (uint256) {\\n uint256 borrowed = pool.borrowed;\\n uint256 supplied = pool.supplied;\\n return borrowed - Math.min(borrowed, supplied);\\n }\\n\\n /// @notice Modify positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it. Needs for the amount to be less than the principal and the fee\\n /// @param position original position to be scaled.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return scaled position.\\n function scaleProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 principal = amount.mulDivDown(position.principal, position.principal + position.fee);\\n position.principal = principal;\\n position.fee = amount - principal;\\n return position;\\n }\\n\\n /// @notice Reduce positions based on a certain amount, keeping the original principal/fee ratio.\\n /// @dev modifies the original struct and returns it.\\n /// @param position original position to be reduced.\\n /// @param amount to be used as a full value (principal + interest).\\n /// @return reduced position.\\n function reduceProportionally(Position memory position, uint256 amount) internal pure returns (Position memory) {\\n uint256 positionAssets = position.principal + position.fee;\\n uint256 newPositionAssets = positionAssets - amount;\\n position.principal = newPositionAssets.mulDivDown(position.principal, positionAssets);\\n position.fee = newPositionAssets - position.principal;\\n return position;\\n }\\n\\n /// @notice Calculates what proportion of earnings would `borrowAmount` represent considering `backupSupplied`.\\n /// @param earnings amount to be distributed.\\n /// @param borrowAmount amount that will be checked if came from the backup supplier or fixed rate pool.\\n /// @return unassignedEarnings earnings to be added to `unassignedEarnings`.\\n /// @return backupEarnings earnings to be distributed to the backup supplier.\\n function distributeEarnings(\\n Pool memory pool,\\n uint256 earnings,\\n uint256 borrowAmount\\n ) internal pure returns (uint256 unassignedEarnings, uint256 backupEarnings) {\\n backupEarnings = borrowAmount == 0\\n ? 0\\n : earnings.mulDivDown(borrowAmount - Math.min(backupSupplied(pool), borrowAmount), borrowAmount);\\n unassignedEarnings = earnings - backupEarnings;\\n }\\n\\n /// @notice Adds a maturity date to the borrow or supply positions of the account.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity the new maturity where the account will borrow or supply to.\\n /// @return updated encoded maturity dates.\\n function setMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n // initialize the maturity with also the 1st bit on the 33th position set\\n if (encoded == 0) return maturity | (1 << 32);\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n if (maturity < baseMaturity) {\\n // if the new maturity is lower than the base, set it as the new base\\n // wipe clean the last 32 bits, shift the amount of `INTERVAL` and set the new value with the 33rd bit set\\n uint256 range = (baseMaturity - maturity) / INTERVAL;\\n if (encoded >> (256 - range) != 0) revert MaturityOverflow();\\n encoded = ((encoded >> 32) << (32 + range));\\n return maturity | encoded | (1 << 32);\\n } else {\\n uint256 range = (maturity - baseMaturity) / INTERVAL;\\n if (range > 223) revert MaturityOverflow();\\n return encoded | (1 << (32 + range));\\n }\\n }\\n\\n /// @notice Remove maturity from account's borrow or supplied positions.\\n /// @param encoded encoded maturity dates where the account borrowed or supplied to.\\n /// @param maturity maturity date to be removed.\\n /// @return updated encoded maturity dates.\\n function clearMaturity(uint256 encoded, uint256 maturity) internal pure returns (uint256) {\\n if (encoded == 0 || encoded == maturity | (1 << 32)) return 0;\\n\\n uint256 baseMaturity = encoded & ((1 << 32) - 1);\\n // if the baseMaturity is the one being cleaned\\n if (maturity == baseMaturity) {\\n // wipe 32 bytes + 1 for the old base flag\\n uint256 packed = encoded >> 33;\\n uint256 range = 1;\\n while ((packed & 1) == 0 && packed != 0) {\\n unchecked {\\n ++range;\\n }\\n packed >>= 1;\\n }\\n encoded = ((encoded >> (32 + range)) << 32);\\n return (maturity + (range * INTERVAL)) | encoded;\\n } else {\\n // otherwise just clear the bit\\n return encoded & ~(1 << (32 + ((maturity - baseMaturity) / INTERVAL)));\\n }\\n }\\n\\n /// @notice Verifies that a maturity is `VALID`, `MATURED`, `NOT_READY` or `INVALID`.\\n /// @dev if expected state doesn't match the calculated one, it reverts with a custom error `UnmatchedPoolState`.\\n /// @param maturity timestamp of the maturity date to be verified.\\n /// @param maxPools number of pools available in the time horizon.\\n /// @param requiredState state required by the caller to be verified (see `State` for description).\\n /// @param alternativeState state required by the caller to be verified (see `State` for description).\\n function checkPoolState(uint256 maturity, uint8 maxPools, State requiredState, State alternativeState) internal view {\\n State state;\\n if (maturity % INTERVAL != 0) {\\n state = State.INVALID;\\n } else if (maturity <= block.timestamp) {\\n state = State.MATURED;\\n } else if (maturity > block.timestamp - (block.timestamp % INTERVAL) + (INTERVAL * maxPools)) {\\n state = State.NOT_READY;\\n } else {\\n state = State.VALID;\\n }\\n\\n if (state != requiredState && state != alternativeState) {\\n if (alternativeState == State.NONE) revert UnmatchedPoolState(uint8(state), uint8(requiredState));\\n\\n revert UnmatchedPoolStates(uint8(state), uint8(requiredState), uint8(alternativeState));\\n }\\n }\\n\\n /// @notice Stores the accountability of a fixed interest rate pool.\\n /// @param borrowed total amount borrowed from the pool.\\n /// @param supplied total amount supplied to the pool.\\n /// @param unassignedEarnings total amount of earnings not yet distributed and accrued.\\n /// @param lastAccrual timestamp for the last time that some earnings have been distributed to the backup supplier.\\n struct Pool {\\n uint256 borrowed;\\n uint256 supplied;\\n uint256 unassignedEarnings;\\n uint256 lastAccrual;\\n }\\n\\n /// @notice Stores principal and fee of a borrow or a supply position of a account in a fixed rate pool.\\n /// @param principal amount borrowed or supplied to the fixed rate pool.\\n /// @param fee amount of fees to be repaid or earned at the maturity of the fixed rate pool.\\n struct Position {\\n uint256 principal;\\n uint256 fee;\\n }\\n\\n enum State {\\n NONE,\\n INVALID,\\n MATURED,\\n VALID,\\n NOT_READY\\n }\\n}\\n\\nerror MaturityOverflow();\\nerror UnmatchedPoolState(uint8 state, uint8 requiredState);\\nerror UnmatchedPoolStates(uint8 state, uint8 requiredState, uint8 alternativeState);\\n\",\"keccak256\":\"0x34f461426e416de7b4d38263269571d0274dda55df2e580e920196096b166c01\",\"license\":\"BUSL-1.1\"},\"contracts/utils/IPriceFeed.sol\":{\"content\":\"// SPDX-License-Identifier: BUSL-1.1\\npragma solidity 0.8.17;\\n\\ninterface IPriceFeed {\\n function decimals() external view returns (uint8);\\n\\n function latestAnswer() external view returns (int256);\\n}\\n\",\"keccak256\":\"0xce1b3c2ebe700449e2e3c7637ffaf85e574eed3f79925feee22426b2c43fc667\",\"license\":\"BUSL-1.1\"},\"solmate/src/mixins/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\nimport {SafeTransferLib} from \\\"../utils/SafeTransferLib.sol\\\";\\nimport {FixedPointMathLib} from \\\"../utils/FixedPointMathLib.sol\\\";\\n\\n/// @notice Minimal ERC4626 tokenized Vault implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol)\\nabstract contract ERC4626 is ERC20 {\\n using SafeTransferLib for ERC20;\\n using FixedPointMathLib for uint256;\\n\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed caller,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /*//////////////////////////////////////////////////////////////\\n IMMUTABLES\\n //////////////////////////////////////////////////////////////*/\\n\\n ERC20 public immutable asset;\\n\\n constructor(\\n ERC20 _asset,\\n string memory _name,\\n string memory _symbol\\n ) ERC20(_name, _symbol, _asset.decimals()) {\\n asset = _asset;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {\\n // Check for rounding error since we round down in previewDeposit.\\n require((shares = previewDeposit(assets)) != 0, \\\"ZERO_SHARES\\\");\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {\\n assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.\\n\\n // Need to transfer before minting or ERC777s could reenter.\\n asset.safeTransferFrom(msg.sender, address(this), assets);\\n\\n _mint(receiver, shares);\\n\\n emit Deposit(msg.sender, receiver, assets, shares);\\n\\n afterDeposit(assets, shares);\\n }\\n\\n function withdraw(\\n uint256 assets,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 shares) {\\n shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.\\n\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n function redeem(\\n uint256 shares,\\n address receiver,\\n address owner\\n ) public virtual returns (uint256 assets) {\\n if (msg.sender != owner) {\\n uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;\\n }\\n\\n // Check for rounding error since we round down in previewRedeem.\\n require((assets = previewRedeem(shares)) != 0, \\\"ZERO_ASSETS\\\");\\n\\n beforeWithdraw(assets, shares);\\n\\n _burn(owner, shares);\\n\\n emit Withdraw(msg.sender, receiver, owner, assets, shares);\\n\\n asset.safeTransfer(receiver, assets);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ACCOUNTING LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function totalAssets() public view virtual returns (uint256);\\n\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());\\n }\\n\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);\\n }\\n\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return convertToShares(assets);\\n }\\n\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);\\n }\\n\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.\\n\\n return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());\\n }\\n\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return convertToAssets(shares);\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n DEPOSIT/WITHDRAWAL LIMIT LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return convertToAssets(balanceOf[owner]);\\n }\\n\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf[owner];\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL HOOKS LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}\\n\\n function afterDeposit(uint256 assets, uint256 shares) internal virtual {}\\n}\\n\",\"keccak256\":\"0xa0e0c28a727524fa94e7e6c1f4c793a6bd1e6d1bc652b7b02b343ebaf4cd774b\",\"license\":\"MIT\"},\"solmate/src/tokens/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)\\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\\nabstract contract ERC20 {\\n /*//////////////////////////////////////////////////////////////\\n EVENTS\\n //////////////////////////////////////////////////////////////*/\\n\\n event Transfer(address indexed from, address indexed to, uint256 amount);\\n\\n event Approval(address indexed owner, address indexed spender, uint256 amount);\\n\\n /*//////////////////////////////////////////////////////////////\\n METADATA STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n string public name;\\n\\n string public symbol;\\n\\n uint8 public immutable decimals;\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 public totalSupply;\\n\\n mapping(address => uint256) public balanceOf;\\n\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 STORAGE\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal immutable INITIAL_CHAIN_ID;\\n\\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\\n\\n mapping(address => uint256) public nonces;\\n\\n /*//////////////////////////////////////////////////////////////\\n CONSTRUCTOR\\n //////////////////////////////////////////////////////////////*/\\n\\n constructor(\\n string memory _name,\\n string memory _symbol,\\n uint8 _decimals\\n ) {\\n name = _name;\\n symbol = _symbol;\\n decimals = _decimals;\\n\\n INITIAL_CHAIN_ID = block.chainid;\\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function approve(address spender, uint256 amount) public virtual returns (bool) {\\n allowance[msg.sender][spender] = amount;\\n\\n emit Approval(msg.sender, spender, amount);\\n\\n return true;\\n }\\n\\n function transfer(address to, uint256 amount) public virtual returns (bool) {\\n balanceOf[msg.sender] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(msg.sender, to, amount);\\n\\n return true;\\n }\\n\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual returns (bool) {\\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\\n\\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\\n\\n balanceOf[from] -= amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(from, to, amount);\\n\\n return true;\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n EIP-2612 LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) public virtual {\\n require(deadline >= block.timestamp, \\\"PERMIT_DEADLINE_EXPIRED\\\");\\n\\n // Unchecked because the only math done is incrementing\\n // the owner's nonce which cannot realistically overflow.\\n unchecked {\\n address recoveredAddress = ecrecover(\\n keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n ),\\n owner,\\n spender,\\n value,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n ),\\n v,\\n r,\\n s\\n );\\n\\n require(recoveredAddress != address(0) && recoveredAddress == owner, \\\"INVALID_SIGNER\\\");\\n\\n allowance[recoveredAddress][spender] = value;\\n }\\n\\n emit Approval(owner, spender, value);\\n }\\n\\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\\n }\\n\\n function computeDomainSeparator() internal view virtual returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"),\\n keccak256(bytes(name)),\\n keccak256(\\\"1\\\"),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n INTERNAL MINT/BURN LOGIC\\n //////////////////////////////////////////////////////////////*/\\n\\n function _mint(address to, uint256 amount) internal virtual {\\n totalSupply += amount;\\n\\n // Cannot overflow because the sum of all user\\n // balances can't exceed the max uint256 value.\\n unchecked {\\n balanceOf[to] += amount;\\n }\\n\\n emit Transfer(address(0), to, amount);\\n }\\n\\n function _burn(address from, uint256 amount) internal virtual {\\n balanceOf[from] -= amount;\\n\\n // Cannot underflow because a user's balance\\n // will never be larger than the total supply.\\n unchecked {\\n totalSupply -= amount;\\n }\\n\\n emit Transfer(from, address(0), amount);\\n }\\n}\\n\",\"keccak256\":\"0x43aa1509bb753f053143530705d9c4eee415691d26a4779769bf028a74e6ac69\",\"license\":\"MIT\"},\"solmate/src/utils/FixedPointMathLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\n/// @notice Arithmetic library with operations for fixed-point numbers.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)\\nlibrary FixedPointMathLib {\\n /*//////////////////////////////////////////////////////////////\\n SIMPLIFIED FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\\n\\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\\n }\\n\\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\\n }\\n\\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\\n }\\n\\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\\n }\\n\\n function powWad(int256 x, int256 y) internal pure returns (int256) {\\n // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)\\n return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.\\n }\\n\\n function expWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n // When the result is < 0.5 we return zero. This happens when\\n // x <= floor(log(0.5e18) * 1e18) ~ -42e18\\n if (x <= -42139678854452767551) return 0;\\n\\n // When the result is > (2**255 - 1) / 1e18 we can not represent it as an\\n // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.\\n if (x >= 135305999368893231589) revert(\\\"EXP_OVERFLOW\\\");\\n\\n // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96\\n // for more intermediate precision and a binary basis. This base conversion\\n // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.\\n x = (x << 78) / 5**18;\\n\\n // Reduce range of x to (-\\u00bd ln 2, \\u00bd ln 2) * 2**96 by factoring out powers\\n // of two such that exp(x) = exp(x') * 2**k, where k is an integer.\\n // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).\\n int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;\\n x = x - k * 54916777467707473351141471128;\\n\\n // k is in the range [-61, 195].\\n\\n // Evaluate using a (6, 7)-term rational approximation.\\n // p is made monic, we'll multiply by a scale factor later.\\n int256 y = x + 1346386616545796478920950773328;\\n y = ((y * x) >> 96) + 57155421227552351082224309758442;\\n int256 p = y + x - 94201549194550492254356042504812;\\n p = ((p * y) >> 96) + 28719021644029726153956944680412240;\\n p = p * x + (4385272521454847904659076985693276 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n int256 q = x - 2855989394907223263936484059900;\\n q = ((q * x) >> 96) + 50020603652535783019961831881945;\\n q = ((q * x) >> 96) - 533845033583426703283633433725380;\\n q = ((q * x) >> 96) + 3604857256930695427073651918091429;\\n q = ((q * x) >> 96) - 14423608567350463180887372962807573;\\n q = ((q * x) >> 96) + 26449188498355588339934803723976023;\\n\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial won't have zeros in the domain as all its roots are complex.\\n // No scaling is necessary because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r should be in the range (0.09, 0.25) * 2**96.\\n\\n // We now need to multiply r by:\\n // * the scale factor s = ~6.031367120.\\n // * the 2**k factor from the range reduction.\\n // * the 1e18 / 2**96 factor for base conversion.\\n // We do this all at once, with an intermediate result in 2**213\\n // basis, so the final right shift is always by a positive amount.\\n r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));\\n }\\n }\\n\\n function lnWad(int256 x) internal pure returns (int256 r) {\\n unchecked {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n // We want to convert x from 10**18 fixed point to 2**96 fixed point.\\n // We do this by multiplying by 2**96 / 10**18. But since\\n // ln(x * C) = ln(x) + ln(C), we can simply do nothing here\\n // and add ln(2**96 / 10**18) at the end.\\n\\n // Reduce range of x to (1, 2) * 2**96\\n // ln(2^k * x) = k * ln(2) + ln(x)\\n int256 k = int256(log2(uint256(x))) - 96;\\n x <<= uint256(159 - k);\\n x = int256(uint256(x) >> 159);\\n\\n // Evaluate using a (8, 8)-term rational approximation.\\n // p is made monic, we will multiply by a scale factor later.\\n int256 p = x + 3273285459638523848632254066296;\\n p = ((p * x) >> 96) + 24828157081833163892658089445524;\\n p = ((p * x) >> 96) + 43456485725739037958740375743393;\\n p = ((p * x) >> 96) - 11111509109440967052023855526967;\\n p = ((p * x) >> 96) - 45023709667254063763336534515857;\\n p = ((p * x) >> 96) - 14706773417378608786704636184526;\\n p = p * x - (795164235651350426258249787498 << 96);\\n\\n // We leave p in 2**192 basis so we don't need to scale it back up for the division.\\n // q is monic by convention.\\n int256 q = x + 5573035233440673466300451813936;\\n q = ((q * x) >> 96) + 71694874799317883764090561454958;\\n q = ((q * x) >> 96) + 283447036172924575727196451306956;\\n q = ((q * x) >> 96) + 401686690394027663651624208769553;\\n q = ((q * x) >> 96) + 204048457590392012362485061816622;\\n q = ((q * x) >> 96) + 31853899698501571402653359427138;\\n q = ((q * x) >> 96) + 909429971244387300277376558375;\\n assembly {\\n // Div in assembly because solidity adds a zero check despite the unchecked.\\n // The q polynomial is known not to have zeros in the domain.\\n // No scaling required because p is already 2**96 too large.\\n r := sdiv(p, q)\\n }\\n\\n // r is in the range (0, 0.125) * 2**96\\n\\n // Finalization, we need to:\\n // * multiply by the scale factor s = 5.549\\u2026\\n // * add ln(2**96 / 10**18)\\n // * add k * ln(2)\\n // * multiply by 10**18 / 2**96 = 5**18 >> 78\\n\\n // mul s * 5e18 * 2**96, base is now 5**18 * 2**192\\n r *= 1677202110996718588342820967067443963516166;\\n // add ln(2) * k * 5e18 * 2**192\\n r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;\\n // add ln(2**96 / 10**18) * 5e18 * 2**192\\n r += 600920179829731861736702779321621459595472258049074101567377883020018308;\\n // base conversion: mul 2**18 / 2**192\\n r >>= 174;\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n LOW LEVEL FIXED POINT OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function mulDivDown(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // Divide z by the denominator.\\n z := div(z, denominator)\\n }\\n }\\n\\n function mulDivUp(\\n uint256 x,\\n uint256 y,\\n uint256 denominator\\n ) internal pure returns (uint256 z) {\\n assembly {\\n // Store x * y in z for now.\\n z := mul(x, y)\\n\\n // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\\n if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\\n revert(0, 0)\\n }\\n\\n // First, divide z - 1 by the denominator and add 1.\\n // We allow z - 1 to underflow if z is 0, because we multiply the\\n // end result by 0 if z is zero, ensuring we return 0 if z is zero.\\n z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\\n }\\n }\\n\\n function rpow(\\n uint256 x,\\n uint256 n,\\n uint256 scalar\\n ) internal pure returns (uint256 z) {\\n assembly {\\n switch x\\n case 0 {\\n switch n\\n case 0 {\\n // 0 ** 0 = 1\\n z := scalar\\n }\\n default {\\n // 0 ** n = 0\\n z := 0\\n }\\n }\\n default {\\n switch mod(n, 2)\\n case 0 {\\n // If n is even, store scalar in z for now.\\n z := scalar\\n }\\n default {\\n // If n is odd, store x in z for now.\\n z := x\\n }\\n\\n // Shifting right by 1 is like dividing by 2.\\n let half := shr(1, scalar)\\n\\n for {\\n // Shift n right by 1 before looping to halve it.\\n n := shr(1, n)\\n } n {\\n // Shift n right by 1 each iteration to halve it.\\n n := shr(1, n)\\n } {\\n // Revert immediately if x ** 2 would overflow.\\n // Equivalent to iszero(eq(div(xx, x), x)) here.\\n if shr(128, x) {\\n revert(0, 0)\\n }\\n\\n // Store x squared.\\n let xx := mul(x, x)\\n\\n // Round to the nearest number.\\n let xxRound := add(xx, half)\\n\\n // Revert if xx + half overflowed.\\n if lt(xxRound, xx) {\\n revert(0, 0)\\n }\\n\\n // Set x to scaled xxRound.\\n x := div(xxRound, scalar)\\n\\n // If n is even:\\n if mod(n, 2) {\\n // Compute z * x.\\n let zx := mul(z, x)\\n\\n // If z * x overflowed:\\n if iszero(eq(div(zx, x), z)) {\\n // Revert if x is non-zero.\\n if iszero(iszero(x)) {\\n revert(0, 0)\\n }\\n }\\n\\n // Round to the nearest number.\\n let zxRound := add(zx, half)\\n\\n // Revert if zx + half overflowed.\\n if lt(zxRound, zx) {\\n revert(0, 0)\\n }\\n\\n // Return properly scaled zxRound.\\n z := div(zxRound, scalar)\\n }\\n }\\n }\\n }\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n GENERAL NUMBER UTILITIES\\n //////////////////////////////////////////////////////////////*/\\n\\n function sqrt(uint256 x) internal pure returns (uint256 z) {\\n assembly {\\n let y := x // We start y at x, which will help us make our initial estimate.\\n\\n z := 181 // The \\\"correct\\\" value is 1, but this saves a multiplication later.\\n\\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\\n\\n // We check y >= 2^(k + 8) but shift right by k bits\\n // each branch to ensure that if x >= 256, then y >= 256.\\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\\n y := shr(128, y)\\n z := shl(64, z)\\n }\\n if iszero(lt(y, 0x1000000000000000000)) {\\n y := shr(64, y)\\n z := shl(32, z)\\n }\\n if iszero(lt(y, 0x10000000000)) {\\n y := shr(32, y)\\n z := shl(16, z)\\n }\\n if iszero(lt(y, 0x1000000)) {\\n y := shr(16, y)\\n z := shl(8, z)\\n }\\n\\n // Goal was to get z*z*y within a small factor of x. More iterations could\\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\\n\\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\\n\\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\\n\\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\\n\\n // There is no overflow risk here since y < 2^136 after the first branch above.\\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\\n\\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n z := shr(1, add(z, div(x, z)))\\n\\n // If x+1 is a perfect square, the Babylonian method cycles between\\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\\n z := sub(z, lt(div(x, z), z))\\n }\\n }\\n\\n function log2(uint256 x) internal pure returns (uint256 r) {\\n require(x > 0, \\\"UNDEFINED\\\");\\n\\n assembly {\\n r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))\\n r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))\\n r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\\n r := or(r, shl(4, lt(0xffff, shr(r, x))))\\n r := or(r, shl(3, lt(0xff, shr(r, x))))\\n r := or(r, shl(2, lt(0xf, shr(r, x))))\\n r := or(r, shl(1, lt(0x3, shr(r, x))))\\n r := or(r, lt(0x1, shr(r, x)))\\n }\\n }\\n\\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := mod(x, y)\\n }\\n }\\n\\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // z will equal 0 if y is 0, unlike in Solidity where it will revert.\\n z := div(x, y)\\n }\\n }\\n\\n /// @dev Will return 0 instead of reverting if y is zero.\\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\\n assembly {\\n // Add 1 to x * y if x % y > 0.\\n z := add(gt(mod(x, y), 0), div(x, y))\\n }\\n }\\n}\\n\",\"keccak256\":\"0x0bf1d4f3999a4471e0fded0a2f67e7fe328e2a27385348571b1fc0a8d9c9f62e\",\"license\":\"MIT\"},\"solmate/src/utils/SafeTransferLib.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity >=0.8.0;\\n\\nimport {ERC20} from \\\"../tokens/ERC20.sol\\\";\\n\\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)\\n/// @dev Caution! This library won't check that a token has code, responsibility is delegated to the caller.\\nlibrary SafeTransferLib {\\n /*//////////////////////////////////////////////////////////////\\n ETH OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferETH(address to, uint256 amount) internal {\\n bool success;\\n\\n assembly {\\n // Transfer the ETH and store if it succeeded or not.\\n success := call(gas(), to, amount, 0, 0, 0, 0)\\n }\\n\\n require(success, \\\"ETH_TRANSFER_FAILED\\\");\\n }\\n\\n /*//////////////////////////////////////////////////////////////\\n ERC20 OPERATIONS\\n //////////////////////////////////////////////////////////////*/\\n\\n function safeTransferFrom(\\n ERC20 token,\\n address from,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\\n mstore(4, from) // Append the \\\"from\\\" argument.\\n mstore(36, to) // Append the \\\"to\\\" argument.\\n mstore(68, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 100 because that's the total length of our calldata (4 + 32 * 3)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 100, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FROM_FAILED\\\");\\n }\\n\\n function safeTransfer(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"TRANSFER_FAILED\\\");\\n }\\n\\n function safeApprove(\\n ERC20 token,\\n address to,\\n uint256 amount\\n ) internal {\\n bool success;\\n\\n assembly {\\n // We'll write our calldata to this slot below, but restore it later.\\n let memPointer := mload(0x40)\\n\\n // Write the abi-encoded calldata into memory, beginning with the function selector.\\n mstore(0, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\\n mstore(4, to) // Append the \\\"to\\\" argument.\\n mstore(36, amount) // Append the \\\"amount\\\" argument.\\n\\n success := and(\\n // Set success to whether the call reverted, if not we check it either\\n // returned exactly 1 (can't just be non-zero data), or had no return data.\\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\\n // We use 68 because that's the total length of our calldata (4 + 32 * 2)\\n // Counterintuitively, this call() must be positioned after the or() in the\\n // surrounding and() because and() evaluates its arguments from right to left.\\n call(gas(), token, 0, 0, 68, 0, 32)\\n )\\n\\n mstore(0x60, 0) // Restore the zero slot to zero.\\n mstore(0x40, memPointer) // Restore the memPointer.\\n }\\n\\n require(success, \\\"APPROVE_FAILED\\\");\\n }\\n}\\n\",\"keccak256\":\"0x5f2e1158c68c1f3d15b80e8a7dd92b6849f873066969562ad33c0abb80e536ff\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b506040516200601538038062006015833981016040819052620000349162000065565b6001600160a01b039182166080521660a052620000a4565b6001600160a01b03811681146200006257600080fd5b50565b600080604083850312156200007957600080fd5b825162000086816200004c565b602084015190925062000099816200004c565b809150509250929050565b60805160a051615edc62000139600039600081816101910152818161060b0152818161064701526106df01526000818160f90152818161046c015281816104dd01528181610596015281816107e30152818161093e01528181610f730152818161167a01528181612d950152818161370a015281816138350152818161391201528181613b390152613c100152615edc6000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c80637e789958116100665780637e789958146101335780638eab0a2a14610146578063b15a3f6114610159578063b18ba94514610179578063e41e75121461018c57600080fd5b8063109c46ce14610098578063157c9e0e146100c1578063221e81f6146100e15780633ec045a6146100f4575b600080fd5b6100ab6100a6366004614f2b565b6101b3565b6040516100b89190614f60565b60405180910390f35b6100d46100cf366004614f81565b610444565b6040516100b8919061525b565b6100ab6100ef366004615536565b6118b0565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b8565b6100ab610141366004615536565b611b79565b6100ab610154366004614f2b565b611ea4565b61016c610167366004615580565b61201c565b6040516100b891906155ac565b61016c610187366004615580565b61217a565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6101d760405180606001604052806000815260200160008152602001600081525090565b6102026040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa158015610247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026b919061560e565b505060208084019190915290825260408051630795bad560e11b815290516000926001600160a01b03891692630f2b75aa92600480830193928290030181865afa1580156102bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e19190615644565b905060006103de876001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034a919061565d565b8451602086015160405163df635f3d60e01b8152600481018b9052602481018a905260448101929092526064820152608481018590526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa1580156103b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d79190615644565b869061237a565b9050604051806060016040528087815260200182876103fd9190615690565b815260200160008411610411576000610437565b6104378486602001516104249190615690565b8651610431908a90615690565b90612398565b9052979650505050505050565b60405160016263e28d60e11b031981526001600160a01b0382811660048301526060916000917f0000000000000000000000000000000000000000000000000000000000000000169063ff383ae690602401602060405180830381865afa1580156104b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d79190615644565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610539573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105619190810190615745565b51604051639e9d796760e01b81526001600160a01b0386811660048301526000602483018190526044830181905292935082917f000000000000000000000000000000000000000000000000000000000000000090911690639e9d7967906064016040805180830381865afa1580156105de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060291906157e3565b909250905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661064557670de0b6b3a7640000610769565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c79190615818565b6106d2906012615833565b6106dd90600a615930565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075f9190615644565b610769919061593f565b9050836001600160401b03811115610783576107836156a3565b6040519080825280602002602001820160405280156107bc57816020015b6107a9614bed565b8152602001906001900390816107a15790505b50955060005b848110156118a5576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610856919061565d565b905061087c60405180606001604052806000815260200160008152602001600081525090565b6040805160a0810182526000808252602082018190528183018190526060820181905260808201529051632f2e037160e11b81526001600160a01b038c81166004830152841690635e5c06e290602401606060405180830381865afa1580156108e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090d9190615956565b604085810191909152602085019190915290835251638e8f294b60e01b81526001600160a01b0384811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015610985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a9919061599b565b6001600160a01b039081166080870152901515606086015260ff918216604080870191909152929091166020808601919091526001600160801b03909316845281516379fed8ad60e11b815291516000939187169263f3fdb15a9260048083019391928290030181865afa158015610a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a49919061565d565b9050604051806103c00160405280856001600160a01b03168152602001856001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610aa4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610acc9190810190615a0c565b8152602001836020015160ff168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b40919061565d565b6001600160a01b03168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb0919061565d565b6001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c159190810190615a0c565b8152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7c919061565d565b6001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce19190810190615a0c565b81526020016040518060e00160405280846001600160a01b03168152602001846001600160a01b0316634d6fc5226040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d629190615644565b8152602001846001600160a01b031663dfb08e106040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc99190615644565b8152602001846001600160a01b0316630481520b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190615644565b8152602001846001600160a01b031663b99699346040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e979190615644565b8152602001846001600160a01b031663269801216040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe9190615644565b8152602001846001600160a01b031663d83726856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f659190615644565b8152508152602001611017887f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b05887608001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b602060405180830381865afa158015610fed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110119190615644565b9061237a565b8152602001856001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561105a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107e9190615644565b815260200183600001516001600160801b03168152602001856001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f89190615818565b60ff168152602001611109866123ad565b81526020016111188689612cf9565b8152602001826001600160a01b03166384a874666000886001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111909190615644565b1161119c576000611274565b611274611266896001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112049190615644565b8a6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104319190615644565b670de0b6b3a7640000613d46565b6040518263ffffffff1660e01b815260040161129291815260200190565b602060405180830381865afa1580156112af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d39190615644565b81526020016000866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133c9190615644565b116113485760006113ee565b6113ee611266876001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561138c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b09190615644565b886001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b8152602001856001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114559190615644565b815260200161146386613d5c565b8152602001856001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ca9190615644565b8152602001856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561150d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115319190615644565b8152602001856001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015611574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115989190615644565b8152602001856001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff9190615644565b81526020016001871b8c1660000361161857600061161b565b60015b15158152602001888a1015611631576000611700565b61170084600001516001600160801b03166116fa8660200151600a6116569190615930565b6080880151604051631710760b60e31b81526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063b883b05890602401602060405180830381865afa1580156116c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e79190615644565b8d8f6116f39190615a9f565b9190613edc565b90613f0a565b815260200184604001518152602001611719868f613f1f565b81526040516370a0823160e01b81526001600160a01b038f811660048301526020909201918716906370a0823190602401602060405180830381865afa158015611767573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178b9190615644565b815260405163ce96cb7760e01b81526001600160a01b038f8116600483015260209092019187169063ce96cb7790602401602060405180830381865afa1580156117d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fd9190615644565b815260200161182f868f8760000151896001600160a01b031663ccfd8b11306001600160a01b0316637e789958613ffc565b8152602001611861868f8760200151896001600160a01b031663d2681a0b306001600160a01b031663221e81f6613ffc565b8152602001611870868f6142ea565b8152508b868151811061188557611885615ab2565b6020026020010181905250505050508061189e90615ac8565b90506107c2565b505050505050919050565b6118d460405180606001604052806000815260200160008152602001600081525090565b6118ff6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611944573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611968919061560e565b50506020838101919091529082526040805180820182526000808252928101929092525163d2681a0b60e01b8152600481018790526001600160a01b03858116602483015288169063d2681a0b906044016040805180830381865afa1580156119d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f991906157e3565b602083015281526000611a0c8287614749565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a769190615644565b90506040518060600160405280898152602001894210611b1f57611b108b6001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ad1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af59190615644565b611aff8c42615a9f565b611b09919061593f565b8a9061237a565b611b1a908a615690565b611b34565b611b2a8b8b86614799565b611b34908a615a9f565b815260200160008311611b48576000611b68565b611b68838760200151611b5b9190615690565b8751610431908790615a9f565b90529450505050505b949350505050565b611b9d60405180606001604052806000815260200160008152602001600081525090565b611bc86040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611c0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c31919061560e565b50506020838101919091529082526040805180820182526000808252928101929092525163ccfd8b1160e01b8152600481018790526001600160a01b03858116602483015288169063ccfd8b11906044016040805180830381865afa158015611c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc291906157e3565b602083015281526000611cd58287614749565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3f9190615644565b90506040518060600160405280898152602001894210611d5f5788611e6a565b611e6a8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc4919061565d565b8751602089015160405163df635f3d60e01b8152600481018f9052602481018e905260448101929092526064820152608481018690526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa158015611e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e519190615644565b611e6390670de0b6b3a7640000615690565b8a90614902565b815260200160008311611e7e576000611b68565b611b6884848860200151611e929190615690565b611e9c9190615a9f565b875190612398565b611ec860405180606001604052806000815260200160008152602001600081525090565b82421115611ee9576040516305a29e1160e51b815260040160405180910390fd5b604051634e7c505960e01b81526004810184905260009081906001600160a01b03871690634e7c505990602401608060405180830381865afa158015611f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f57919061560e565b5050915091506000866001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc19190615644565b90506040518060600160405280878152602001611fdf898989614799565b611fe99088615690565b815260200160008311611ffd576000610437565b6104378361200b8987615690565b6120159190615690565b8690612398565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561205e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120829190615818565b60ff16905060006224ea006120978142615af7565b6120a19042615a9f565b6120ab9190615690565b9050816001600160401b038111156120c5576120c56156a3565b60405190808252806020026020018201604052801561211a57816020015b61210760405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816120e35790505b50925060005b8281101561217157612133868387611ea4565b84828151811061214557612145615ab2565b602090810291909101015261215d6224ea0083615690565b91508061216981615ac8565b915050612120565b50505092915050565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156121bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e09190615818565b60ff16905060006224ea006121f58142615af7565b6121ff9042615a9f565b6122099190615690565b9050816001600160401b03811115612223576122236156a3565b60405190808252806020026020018201604052801561227857816020015b61226560405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816122415790505b50925060005b828110156121715760405163084e236760e11b81526001600160a01b03871660048201526024810183905260448101869052309063109c46ce90606401606060405180830381865afa9250505080156122f4575060408051601f3d908101601f191682019092526122f191810190615b0b565b60015b612339576040518060600160405280838152602001600019815260200160001981525084828151811061232957612329615ab2565b6020026020010181905250612359565b8085838151811061234c5761234c615ab2565b6020026020010181905250505b6123666224ea0083615690565b91508061237281615ac8565b91505061227e565b600061238f8383670de0b6b3a7640000614913565b90505b92915050565b600061238f83670de0b6b3a764000084613edc565b606060006123ba83614932565b9050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241e9190615818565b60ff166001600160401b03811115612438576124386156a3565b6040519080825280602002602001820160405280156124b157816020015b61249e60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816124565790505b50915060005b836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125199190615818565b60ff16811015612cf25761254e6040518060800160405280600081526020016000815260200160008152602001600081525090565b6001600160a01b038516634e7c5059612568846001615690565b612575906224ea0061593f565b6125826224ea0042615af7565b61258c9042615a9f565b6125969190615690565b6040518263ffffffff1660e01b81526004016125b491815260200190565b608060405180830381865afa1580156125d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f5919061560e565b606085015260408085019190915260208085018390529284528051630795bad560e11b815290516000938493849390926001600160a01b038c1692630f2b75aa92600480820193918290030181865afa158015612656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267a9190615644565b6126849190615690565b11612691576000806127d9565b866001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f3919061565d565b6001600160a01b03166362caa049846000015185602001518a6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612749573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276d9190615644565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016040805180830381865afa1580156127b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d991906157e3565b915091506128448360600151426127f09190615a9f565b6060850151612800876001615690565b61280d906224ea0061593f565b61281a6224ea0042615af7565b6128249042615a9f565b61282e9190615690565b6128389190615a9f565b60408601519190614913565b836040018181516128559190615a9f565b90525060408051610100810190915280612870866001615690565b61287d906224ea0061593f565b61288a6224ea0042615af7565b6128949042615a9f565b61289e9190615690565b815260200184600001518152602001846020015181526020016128c985602001518660000151613d46565b8560200151612b4c612a9f6129c18d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129399190615b66565b61294b90670de0b6b3a7640000615b81565b6001600160801b03168c8f6001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129b79190615644565b6110119190615690565b8b8e6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a249190615644565b8f6001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a869190615644565b612a909190615690565b612a9a9190615690565b613d46565b612ae08d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b612aea9190615a9f565b8c6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9a9190615644565b612b569190615690565b612b609190615a9f565b8152602001828152602001612c936000612b8287600001518860200151613d46565b8751612b8e9190615a9f565b11612b9a576000612c43565b612c43612baf87600001518860200151613d46565b8751612bbb9190615a9f565b612c3d8c6001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c209190615644565b612c3290670de0b6b3a7640000615a9f565b60408a01519061237a565b90614902565b42612c4f896001615690565b612c5c906224ea0061593f565b612c696224ea0042615af7565b612c739042615a9f565b612c7d9190615690565b612c879190615a9f565b6301e133809190614913565b8152602001838152602001612cb085600001518660200151613d46565b8551612cbc9190615a9f565b815250868581518110612cd157612cd1615ab2565b60200260200101819052505050508080612cea90615ac8565b9150506124b7565b5050919050565b6060612d03614d2d565b836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d65919061565d565b6001600160a01b031680825215613d3f57604051638e8f294b60e01b81526001600160a01b0385811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015612ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e00919061599b565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015612e74573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e9c9190810190615ba1565b6101408201819052516001600160401b03811115612ebc57612ebc6156a3565b604051908082528060200260200182016040528015612ef557816020015b612ee2614e92565b815260200190600190039081612eda5790505b5060006101a083018190529092505b81610140015151826101a0015110156130495781600001516001600160a01b0316635684aa4686846101400151856101a0015181518110612f4757612f47615ab2565b60200260200101516040518363ffffffff1660e01b8152600401612f819291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa158015612f9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc29190615c43565b505063ffffffff166101c083018190521561303257816101400151826101a0015181518110612ff357612ff3615ab2565b602002602001015183828061300790615ac8565b93508151811061301957613019615ab2565b60209081029190910101516001600160a01b0390911690525b816101a001805161304290615ac8565b9052612f04565b82816001600160401b03811115613062576130626156a3565b60405190808252806020026020018201604052801561309b57816020015b613088614e92565b8152602001906001900390816130805790505b5060006101a085015293505b8351836101a00151101561310d5780836101a00151815181106130cc576130cc615ab2565b602002602001015184846101a00151815181106130eb576130eb615ab2565b6020026020010181905250826101a001805161310690615ac8565b90526130a7565b505060006101a08201525b8151816101a001511015613d3f5780600001516001600160a01b031663f2426f9a8584846101a001518151811061315157613151615ab2565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016101c060405180830381865afa1580156131a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cd9190615caf565b81610120018190525080600001516001600160a01b03166344e250f88584846101a001518151811061320157613201615ab2565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401606060405180830381865afa158015613258573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327c9190615956565b506040830152606082015280516101a082015183516001600160a01b039092169163fc19606891879186919081106132b6576132b6615ab2565b6020026020010151600001518461012001516060015163ffffffff1642116132df5760006132e6565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061335c9190615956565b50608083015260a08201526101c08101516224ea009061337d908290615af7565b826101c0015161338d9190615a9f565b6133979190615690565b81610240018181525050836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134039190615818565b6134139060ff166224ea0061593f565b6134206224ea0042615af7565b61342a9042615a9f565b6134349190615690565b61022082018190526102408201516224ea00916134519190615a9f565b61345b9190615da3565b613466906001615690565b6001600160401b0381111561347d5761347d6156a3565b6040519080825280602002602001820160405280156134a6578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e00151116135ae576101e0810151604051630156d37d60e31b81526000916001600160a01b03871691630ab69be8916135099160040190815260200190565b6040805180830381865afa158015613525573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354991906157e3565b50905080826102000181815161355f9190615690565b9052506101e082015160e08301516101c08401518151811061358357613583615ab2565b6020908102919091010152506101e0810180516224ea000190526101c08101805160010190526134c1565b6040518060e0016040528083836101a00151815181106135d0576135d0615ab2565b6020026020010151600001516001600160a01b0316815260200183836101a001518151811061360157613601615ab2565b6020026020010151600001516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561364a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136729190810190615a0c565b815260200183836101a001518151811061368e5761368e615ab2565b6020026020010151600001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156136d7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136ff9190810190615a0c565b815260200161376c857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b058866101200151604001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b81526020016000836102000151876001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137db9190615644565b6137e59190615690565b116137f1576000613a80565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613a80936301e13380939092613a79926138e4917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa15801561387c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138a09190615644565b8961020001518d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b039182166004820152613a79917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613959573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061397d9190615644565b6110118e6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b81526004016139b391815260200190565b602060405180830381865afa1580156139d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139f49190615644565b8f6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015613a32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a569190615644565b613a609190615690565b8c60c001518d606001518e60a00151613a799190615a9f565b9190614913565b81526020016000866001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ac5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ae99190615644565b11613af5576000613cf9565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613cf9936301e13380939092613a7992613be2917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ba49190615644565b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fed573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b039182166004820152613a79917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c7b9190615644565b6110118e6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ce09190615644565b8c60c001518d604001518e60800151613a799190615a9f565b81526020018260e0015181525082826101a0015181518110613d1d57613d1d615ab2565b6020026020010181905250806101a0018051613d3890615ac8565b9052613118565b5092915050565b6000818310613d55578161238f565b5090919050565b600080613d6883614932565b90506000613e2b846001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dd19190615b66565b613de390670de0b6b3a7640000615b81565b6001600160801b031683866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b9050613ed28183866001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e949190615644565b876001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b611b719082615a9f565b828202811515841585830485141716613ef457600080fd5b6001826001830304018115150290509392505050565b600061238f8383670de0b6b3a7640000613edc565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa158015613f6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f8e9190615956565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa158015613fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b719190615644565b6040805160e0808252611c2082019092526060916000918291816020015b614022614ed8565b81526020019060019003908161401a575050602089901c9890915063ffffffff165b88156142345760018916156142195760008060008a8a858f6040518363ffffffff1660e01b815260040161408b9291909182526001600160a01b0316602082015260400190565b6040805180830381865afa1580156140a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140cb91906157e3565b90925090506140da8183615690565b925060405180604001604052808381526020018281525085878151811061410357614103615ab2565b602002602001015160400181905250505086868d84848f6040518563ffffffff1660e01b815260040161415f94939291906001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b606060405180830381865afa925050508015614198575060408051601f3d908101601f1916820190925261419591810190615b0b565b60015b6141c457808385815181106141af576141af615ab2565b602002602001015160200181815250506141ed565b80602001518486815181106141db576141db615ab2565b60200260200101516020018181525050505b8183858151811061420057614200615ab2565b60209081029190910101515261421584615ac8565b9350505b60019890981c9761422d6224ea0082615690565b9050614044565b826001600160401b0381111561424c5761424c6156a3565b60405190808252806020026020018201604052801561428557816020015b614272614ed8565b81526020019060019003908161426a5790505b50935060005b838110156142db578281815181106142a5576142a5615ab2565b60200260200101518582815181106142bf576142bf615ab2565b6020026020010181905250806142d490615ac8565b905061428b565b50505050979650505050505050565b60606000836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa15801561432c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614350919061565d565b90506001600160a01b03811615613d3f576000816001600160a01b031663b7eec4136040518163ffffffff1660e01b8152600401600060405180830381865afa1580156143a1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526143c99190810190615ba1565b905080516001600160401b038111156143e4576143e46156a3565b60405190808252806020026020018201604052801561444957816020015b614436604051806080016040528060006001600160a01b031681526020016060815260200160608152602001600081525090565b8152602001906001900390816144025790505b5060408051600180825281830190925291945060009190816020015b60408051808201909152600081526060602082015281526020019060019003908161446557505060408051600280825260608201835292935060009290916020830190803683370190505090506001816000815181106144c7576144c7615ab2565b6020026020010190151590811515815250506000816001815181106144ee576144ee615ab2565b6020026020010190151590811515815250506040518060400160405280886001600160a01b03168152602001828152508260008151811061453157614531615ab2565b602002602001018190525060005b835181101561473e57604051806080016040528085838151811061456557614565615ab2565b60200260200101516001600160a01b0316815260200185838151811061458d5761458d615ab2565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156145d2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526145fa9190810190615a0c565b815260200185838151811061461157614611615ab2565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015614656573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261467e9190810190615a0c565b8152602001866001600160a01b031663382e85ad868b8987815181106146a6576146a6615ab2565b60200260200101516040518463ffffffff1660e01b81526004016146cc93929190615db7565b602060405180830381865afa1580156146e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061470d9190615644565b81525086828151811061472257614722615ab2565b60200260200101819052508061473790615ac8565b905061453f565b505050505092915050565b60408051808201909152600080825260208201528251602084015160009161477d916147759082615690565b859190614913565b808552905061478c8184615a9f565b6020850152509192915050565b60006147c66040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa15801561480b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482f919061560e565b6060850181905260408501919091526020840191909152908252614872906148579042615a9f565b60608301516148669087615a9f565b60408401519190614913565b816040018181516148839190615a9f565b915081815250506148f883866001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f09190615644565b839190614b7b565b5095945050505050565b600061238f83670de0b6b3a7640000845b82820281151584158583048514171661492b57600080fd5b0492915050565b600080826001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015614973573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149979190615644565b90506000836001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156149d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149fd9190615644565b90506000808211614a0f576000614a1c565b614a1c6112668484612398565b9050614b72614b6b866001600160a01b0316636eb9ffeb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a869190615e8b565b614a969063ffffffff1642615a9f565b6301e13380886001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614afd919061565d565b6001600160a01b03166384a87466866040518263ffffffff1660e01b8152600401614b2a91815260200190565b602060405180830381865afa158015614b47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a799190615644565b849061237a565b95945050505050565b6000806000614b8986614bce565b90508015614bc557614baa614b9e8683613d46565b60408801519083614913565b9250614bb6838561237a565b9150614bc28284615a9f565b92505b50935093915050565b8051602082015160009190614be38282613d46565b611b719083615a9f565b604051806103c0016040528060006001600160a01b0316815260200160608152602001600060ff16815260200160006001600160a01b031681526020016060815260200160608152602001614c816040518060e0016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001600081526020016000815260200160008152602001600060ff1681526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160608152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b03168152602001614e4d604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040518060e0016040528060006001600160a01b031681526020016060815260200160608152602001600081526020016000815260200160008152602001606081525090565b60405180606001604052806000815260200160008152602001614f0e604051806040016040528060008152602001600081525090565b905290565b6001600160a01b0381168114614f2857600080fd5b50565b600080600060608486031215614f4057600080fd5b8335614f4b81614f13565b95602085013595506040909401359392505050565b81518152602080830151908201526040808301519082015260608101612392565b600060208284031215614f9357600080fd5b8135614f9e81614f13565b9392505050565b60005b83811015614fc0578181015183820152602001614fa8565b50506000910152565b60008151808452614fe1816020860160208601614fa5565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b8381101561506e57815180518852838101518489015260408082015190890152606080820151908901526080808201519089015260a0808201519089015260c0808201519089015260e090810151908801526101009096019590820190600101615009565b509495945050505050565b600081518084526020808501808196508360051b810191508286016000805b8681101561515e578385038a52825180516001600160a01b031686528681015160e0888801819052906150cd82890182614fc9565b915050604080830151888303828a01526150e78382614fc9565b606085810151908b0152608080860151908b015260a080860151908b015260c0948501518a8203958b01959095528451808252948b0194879450908b01925090505b808310156151495783518252928901926001929092019190890190615129565b509b88019b9650505091850191600101615098565b509298975050505050505050565b600081518084526020808501945080840160005b8381101561506e578151805188528381015184890152604090810151805191890191909152830151606088015260809096019590820190600101615180565b600081518084526020808501808196508360051b8101915082860160005b8581101561524e578284038952815180516001600160a01b031685528581015160808787018190529061521282880182614fc9565b9150506040808301518783038289015261522c8382614fc9565b60609485015198909401979097525050988501989350908401906001016151dd565b5091979650505050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561552857888303603f19018552815180516001600160a01b0316845261048088820151818a8701526152ba82870182614fc9565b915050878201516152cf8987018260ff169052565b506060828101516001600160a01b031690860152608080830151868303828801526152fa8382614fc9565b9250505060a080830151868303828801526153158382614fc9565b60c08581015180516001600160a01b03168a830152602081015160e08b015260408101516101008b015260608101516101208b015260808101516101408b015260a08101516101608b0152808201516101808b015291945092509050505060e08201516101a0818188015261010084015191506101c0828189015261012085015192506101e083818a015261014086015193506102006153b9818b018660ff169052565b61016087015194506102208a8703818c01526153d58787614ff5565b965061018088015195506102408b8803818d01526153f38888615079565b958901516102608d81019190915294890151610280808e0191909152938901516102a0808e0191909152928901516102c0808e0191909152918901516102e0808e019190915290890151610300808e019190915294890151610320808e019190915293890151610340808e01919091529289015195975094955091939092610360929190615484848d018815159052565b918801516103808c810191909152908801516103a0808d0191909152918801516103c08c0152848801516103e08c0152838801516104008c0152828801518b88036104208d01529550906154d8878761516c565b96508188015195508a87036104408c01526154f3878761516c565b965080880151975050505050505084810361046086015261551481836151bf565b968901969450505090860190600101615282565b509098975050505050505050565b6000806000806080858703121561554c57600080fd5b843561555781614f13565b93506020850135925060408501359150606085013561557581614f13565b939692955090935050565b6000806040838503121561559357600080fd5b823561559e81614f13565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b81811015615602576155ef8385518051825260208082015190830152604090810151910152565b92840192606092909201916001016155c8565b50909695505050505050565b6000806000806080858703121561562457600080fd5b505082516020840151604085015160609095015191969095509092509050565b60006020828403121561565657600080fd5b5051919050565b60006020828403121561566f57600080fd5b8151614f9e81614f13565b634e487b7160e01b600052601160045260246000fd5b808201808211156123925761239261567a565b634e487b7160e01b600052604160045260246000fd5b6040516101c081016001600160401b03811182821017156156dc576156dc6156a3565b60405290565b604051601f8201601f191681016001600160401b038111828210171561570a5761570a6156a3565b604052919050565b60006001600160401b0382111561572b5761572b6156a3565b5060051b60200190565b805161574081614f13565b919050565b6000602080838503121561575857600080fd5b82516001600160401b0381111561576e57600080fd5b8301601f8101851361577f57600080fd5b805161579261578d82615712565b6156e2565b81815260059190911b820183019083810190878311156157b157600080fd5b928401925b828410156157d85783516157c981614f13565b825292840192908401906157b6565b979650505050505050565b600080604083850312156157f657600080fd5b505080516020909101519092909150565b805160ff8116811461574057600080fd5b60006020828403121561582a57600080fd5b61238f82615807565b60ff82811682821603908111156123925761239261567a565b600181815b8085111561588757816000190482111561586d5761586d61567a565b8085161561587a57918102915b93841c9390800290615851565b509250929050565b60008261589e57506001612392565b816158ab57506000612392565b81600181146158c157600281146158cb576158e7565b6001915050612392565b60ff8411156158dc576158dc61567a565b50506001821b612392565b5060208310610133831016604e8410600b841016171561590a575081810a612392565b615914838361584c565b80600019048211156159285761592861567a565b029392505050565b600061238f60ff84168361588f565b80820281158282048414176123925761239261567a565b60008060006060848603121561596b57600080fd5b8351925060208401519150604084015190509250925092565b80516001600160801b038116811461574057600080fd5b600080600080600060a086880312156159b357600080fd5b6159bc86615984565b94506159ca60208701615807565b93506159d860408701615807565b9250606086015180151581146159ed57600080fd5b60808701519092506159fe81614f13565b809150509295509295909350565b600060208284031215615a1e57600080fd5b81516001600160401b0380821115615a3557600080fd5b818401915084601f830112615a4957600080fd5b815181811115615a5b57615a5b6156a3565b615a6e601f8201601f19166020016156e2565b9150808252856020828501011115615a8557600080fd5b615a96816020840160208601614fa5565b50949350505050565b818103818111156123925761239261567a565b634e487b7160e01b600052603260045260246000fd5b600060018201615ada57615ada61567a565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082615b0657615b06615ae1565b500690565b600060608284031215615b1d57600080fd5b604051606081018181106001600160401b0382111715615b3f57615b3f6156a3565b80604052508251815260208301516020820152604083015160408201528091505092915050565b600060208284031215615b7857600080fd5b61238f82615984565b6001600160801b03828116828216039080821115613d3f57613d3f61567a565b60006020808385031215615bb457600080fd5b82516001600160401b03811115615bca57600080fd5b8301601f81018513615bdb57600080fd5b8051615be961578d82615712565b81815260059190911b82018301908381019087831115615c0857600080fd5b928401925b828410156157d8578351615c2081614f13565b82529284019290840190615c0d565b805163ffffffff8116811461574057600080fd5b600080600060608486031215615c5857600080fd5b615c6184615c2f565b9250615c6f60208501615c2f565b9150615c7d60408501615c2f565b90509250925092565b8051600f81900b811461574057600080fd5b80516001600160401b038116811461574057600080fd5b60006101c08284031215615cc257600080fd5b615cca6156b9565b615cd383615735565b8152615ce160208401615735565b6020820152615cf260408401615735565b6040820152615d0360608401615c2f565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615d3e818501615c86565b90820152610120615d50848201615c98565b90820152610140615d62848201615c98565b90820152610160615d74848201615c98565b90820152610180615d86848201615c98565b908201526101a0615d98848201615c98565b908201529392505050565b600082615db257615db2615ae1565b500490565b6000606080830181845280875180835260808601915060808160051b87010192506020808a016000805b84811015615e5757898703607f19018652825180516001600160a01b0316885284015160408589018190528151908901819052908501908989019084905b80821015615e4157835115158352928701929187019160019190910190615e1f565b5090985050509483019491830191600101615de1565b505050839550615e718188018a6001600160a01b03169052565b5050505050611b7160408301846001600160a01b03169052565b600060208284031215615e9d57600080fd5b61238f82615c2f56fea264697066735822122058c4a71334a5b908365a5edf431df76721c877fb6a15b2608af0fc2fc554c70364736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c80637e789958116100665780637e789958146101335780638eab0a2a14610146578063b15a3f6114610159578063b18ba94514610179578063e41e75121461018c57600080fd5b8063109c46ce14610098578063157c9e0e146100c1578063221e81f6146100e15780633ec045a6146100f4575b600080fd5b6100ab6100a6366004614f2b565b6101b3565b6040516100b89190614f60565b60405180910390f35b6100d46100cf366004614f81565b610444565b6040516100b8919061525b565b6100ab6100ef366004615536565b6118b0565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b8565b6100ab610141366004615536565b611b79565b6100ab610154366004614f2b565b611ea4565b61016c610167366004615580565b61201c565b6040516100b891906155ac565b61016c610187366004615580565b61217a565b61011b7f000000000000000000000000000000000000000000000000000000000000000081565b6101d760405180606001604052806000815260200160008152602001600081525090565b6102026040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa158015610247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026b919061560e565b505060208084019190915290825260408051630795bad560e11b815290516000926001600160a01b03891692630f2b75aa92600480830193928290030181865afa1580156102bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e19190615644565b905060006103de876001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034a919061565d565b8451602086015160405163df635f3d60e01b8152600481018b9052602481018a905260448101929092526064820152608481018590526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa1580156103b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d79190615644565b869061237a565b9050604051806060016040528087815260200182876103fd9190615690565b815260200160008411610411576000610437565b6104378486602001516104249190615690565b8651610431908a90615690565b90612398565b9052979650505050505050565b60405160016263e28d60e11b031981526001600160a01b0382811660048301526060916000917f0000000000000000000000000000000000000000000000000000000000000000169063ff383ae690602401602060405180830381865afa1580156104b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d79190615644565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610539573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105619190810190615745565b51604051639e9d796760e01b81526001600160a01b0386811660048301526000602483018190526044830181905292935082917f000000000000000000000000000000000000000000000000000000000000000090911690639e9d7967906064016040805180830381865afa1580156105de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060291906157e3565b909250905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661064557670de0b6b3a7640000610769565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c79190615818565b6106d2906012615833565b6106dd90600a615930565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561073b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061075f9190615644565b610769919061593f565b9050836001600160401b03811115610783576107836156a3565b6040519080825280602002602001820160405280156107bc57816020015b6107a9614bed565b8152602001906001900390816107a15790505b50955060005b848110156118a5576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa158015610832573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610856919061565d565b905061087c60405180606001604052806000815260200160008152602001600081525090565b6040805160a0810182526000808252602082018190528183018190526060820181905260808201529051632f2e037160e11b81526001600160a01b038c81166004830152841690635e5c06e290602401606060405180830381865afa1580156108e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090d9190615956565b604085810191909152602085019190915290835251638e8f294b60e01b81526001600160a01b0384811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015610985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a9919061599b565b6001600160a01b039081166080870152901515606086015260ff918216604080870191909152929091166020808601919091526001600160801b03909316845281516379fed8ad60e11b815291516000939187169263f3fdb15a9260048083019391928290030181865afa158015610a25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a49919061565d565b9050604051806103c00160405280856001600160a01b03168152602001856001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610aa4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610acc9190810190615a0c565b8152602001836020015160ff168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b40919061565d565b6001600160a01b03168152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb0919061565d565b6001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c159190810190615a0c565b8152602001856001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c7c919061565d565b6001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610cb9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ce19190810190615a0c565b81526020016040518060e00160405280846001600160a01b03168152602001846001600160a01b0316634d6fc5226040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d629190615644565b8152602001846001600160a01b031663dfb08e106040518163ffffffff1660e01b8152600401602060405180830381865afa158015610da5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc99190615644565b8152602001846001600160a01b0316630481520b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e309190615644565b8152602001846001600160a01b031663b99699346040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e979190615644565b8152602001846001600160a01b031663269801216040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eda573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efe9190615644565b8152602001846001600160a01b031663d83726856040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f659190615644565b8152508152602001611017887f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b05887608001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b602060405180830381865afa158015610fed573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110119190615644565b9061237a565b8152602001856001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561105a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107e9190615644565b815260200183600001516001600160801b03168152602001856001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f89190615818565b60ff168152602001611109866123ad565b81526020016111188689612cf9565b8152602001826001600160a01b03166384a874666000886001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561116c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111909190615644565b1161119c576000611274565b611274611266896001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112049190615644565b8a6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104319190615644565b670de0b6b3a7640000613d46565b6040518263ffffffff1660e01b815260040161129291815260200190565b602060405180830381865afa1580156112af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d39190615644565b81526020016000866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015611318573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061133c9190615644565b116113485760006113ee565b6113ee611266876001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa15801561138c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113b09190615644565b886001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015611242573d6000803e3d6000fd5b8152602001856001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114559190615644565b815260200161146386613d5c565b8152602001856001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ca9190615644565b8152602001856001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561150d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115319190615644565b8152602001856001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015611574573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115989190615644565b8152602001856001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ff9190615644565b81526020016001871b8c1660000361161857600061161b565b60015b15158152602001888a1015611631576000611700565b61170084600001516001600160801b03166116fa8660200151600a6116569190615930565b6080880151604051631710760b60e31b81526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063b883b05890602401602060405180830381865afa1580156116c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e79190615644565b8d8f6116f39190615a9f565b9190613edc565b90613f0a565b815260200184604001518152602001611719868f613f1f565b81526040516370a0823160e01b81526001600160a01b038f811660048301526020909201918716906370a0823190602401602060405180830381865afa158015611767573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178b9190615644565b815260405163ce96cb7760e01b81526001600160a01b038f8116600483015260209092019187169063ce96cb7790602401602060405180830381865afa1580156117d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fd9190615644565b815260200161182f868f8760000151896001600160a01b031663ccfd8b11306001600160a01b0316637e789958613ffc565b8152602001611861868f8760200151896001600160a01b031663d2681a0b306001600160a01b031663221e81f6613ffc565b8152602001611870868f6142ea565b8152508b868151811061188557611885615ab2565b6020026020010181905250505050508061189e90615ac8565b90506107c2565b505050505050919050565b6118d460405180606001604052806000815260200160008152602001600081525090565b6118ff6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611944573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611968919061560e565b50506020838101919091529082526040805180820182526000808252928101929092525163d2681a0b60e01b8152600481018790526001600160a01b03858116602483015288169063d2681a0b906044016040805180830381865afa1580156119d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f991906157e3565b602083015281526000611a0c8287614749565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a769190615644565b90506040518060600160405280898152602001894210611b1f57611b108b6001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ad1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af59190615644565b611aff8c42615a9f565b611b09919061593f565b8a9061237a565b611b1a908a615690565b611b34565b611b2a8b8b86614799565b611b34908a615a9f565b815260200160008311611b48576000611b68565b611b68838760200151611b5b9190615690565b8751610431908790615a9f565b90529450505050505b949350505050565b611b9d60405180606001604052806000815260200160008152602001600081525090565b611bc86040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018690526001600160a01b03871690634e7c505990602401608060405180830381865afa158015611c0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c31919061560e565b50506020838101919091529082526040805180820182526000808252928101929092525163ccfd8b1160e01b8152600481018790526001600160a01b03858116602483015288169063ccfd8b11906044016040805180830381865afa158015611c9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc291906157e3565b602083015281526000611cd58287614749565b6000015190506000886001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3f9190615644565b90506040518060600160405280898152602001894210611d5f5788611e6a565b611e6a8b6001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc4919061565d565b8751602089015160405163df635f3d60e01b8152600481018f9052602481018e905260448101929092526064820152608481018690526001600160a01b03919091169063df635f3d9060a401602060405180830381865afa158015611e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e519190615644565b611e6390670de0b6b3a7640000615690565b8a90614902565b815260200160008311611e7e576000611b68565b611b6884848860200151611e929190615690565b611e9c9190615a9f565b875190612398565b611ec860405180606001604052806000815260200160008152602001600081525090565b82421115611ee9576040516305a29e1160e51b815260040160405180910390fd5b604051634e7c505960e01b81526004810184905260009081906001600160a01b03871690634e7c505990602401608060405180830381865afa158015611f33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f57919061560e565b5050915091506000866001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc19190615644565b90506040518060600160405280878152602001611fdf898989614799565b611fe99088615690565b815260200160008311611ffd576000610437565b6104378361200b8987615690565b6120159190615690565b8690612398565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561205e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120829190615818565b60ff16905060006224ea006120978142615af7565b6120a19042615a9f565b6120ab9190615690565b9050816001600160401b038111156120c5576120c56156a3565b60405190808252806020026020018201604052801561211a57816020015b61210760405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816120e35790505b50925060005b8281101561217157612133868387611ea4565b84828151811061214557612145615ab2565b602090810291909101015261215d6224ea0083615690565b91508061216981615ac8565b915050612120565b50505092915050565b60606000836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156121bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121e09190615818565b60ff16905060006224ea006121f58142615af7565b6121ff9042615a9f565b6122099190615690565b9050816001600160401b03811115612223576122236156a3565b60405190808252806020026020018201604052801561227857816020015b61226560405180606001604052806000815260200160008152602001600081525090565b8152602001906001900390816122415790505b50925060005b828110156121715760405163084e236760e11b81526001600160a01b03871660048201526024810183905260448101869052309063109c46ce90606401606060405180830381865afa9250505080156122f4575060408051601f3d908101601f191682019092526122f191810190615b0b565b60015b612339576040518060600160405280838152602001600019815260200160001981525084828151811061232957612329615ab2565b6020026020010181905250612359565b8085838151811061234c5761234c615ab2565b6020026020010181905250505b6123666224ea0083615690565b91508061237281615ac8565b91505061227e565b600061238f8383670de0b6b3a7640000614913565b90505b92915050565b600061238f83670de0b6b3a764000084613edc565b606060006123ba83614932565b9050826001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241e9190615818565b60ff166001600160401b03811115612438576124386156a3565b6040519080825280602002602001820160405280156124b157816020015b61249e60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001906001900390816124565790505b50915060005b836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125199190615818565b60ff16811015612cf25761254e6040518060800160405280600081526020016000815260200160008152602001600081525090565b6001600160a01b038516634e7c5059612568846001615690565b612575906224ea0061593f565b6125826224ea0042615af7565b61258c9042615a9f565b6125969190615690565b6040518263ffffffff1660e01b81526004016125b491815260200190565b608060405180830381865afa1580156125d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f5919061560e565b606085015260408085019190915260208085018390529284528051630795bad560e11b815290516000938493849390926001600160a01b038c1692630f2b75aa92600480820193918290030181865afa158015612656573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061267a9190615644565b6126849190615690565b11612691576000806127d9565b866001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f3919061565d565b6001600160a01b03166362caa049846000015185602001518a6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612749573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276d9190615644565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016040805180830381865afa1580156127b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d991906157e3565b915091506128448360600151426127f09190615a9f565b6060850151612800876001615690565b61280d906224ea0061593f565b61281a6224ea0042615af7565b6128249042615a9f565b61282e9190615690565b6128389190615a9f565b60408601519190614913565b836040018181516128559190615a9f565b90525060408051610100810190915280612870866001615690565b61287d906224ea0061593f565b61288a6224ea0042615af7565b6128949042615a9f565b61289e9190615690565b815260200184600001518152602001846020015181526020016128c985602001518660000151613d46565b8560200151612b4c612a9f6129c18d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129399190615b66565b61294b90670de0b6b3a7640000615b81565b6001600160801b03168c8f6001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129b79190615644565b6110119190615690565b8b8e6001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a249190615644565b8f6001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a869190615644565b612a909190615690565b612a9a9190615690565b613d46565b612ae08d6001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015612915573d6000803e3d6000fd5b612aea9190615a9f565b8c6001600160a01b0316630f2b75aa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a9a9190615644565b612b569190615690565b612b609190615a9f565b8152602001828152602001612c936000612b8287600001518860200151613d46565b8751612b8e9190615a9f565b11612b9a576000612c43565b612c43612baf87600001518860200151613d46565b8751612bbb9190615a9f565b612c3d8c6001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c209190615644565b612c3290670de0b6b3a7640000615a9f565b60408a01519061237a565b90614902565b42612c4f896001615690565b612c5c906224ea0061593f565b612c696224ea0042615af7565b612c739042615a9f565b612c7d9190615690565b612c879190615a9f565b6301e133809190614913565b8152602001838152602001612cb085600001518660200151613d46565b8551612cbc9190615a9f565b815250868581518110612cd157612cd1615ab2565b60200260200101819052505050508080612cea90615ac8565b9150506124b7565b5050919050565b6060612d03614d2d565b836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d65919061565d565b6001600160a01b031680825215613d3f57604051638e8f294b60e01b81526001600160a01b0385811660048301527f00000000000000000000000000000000000000000000000000000000000000001690638e8f294b9060240160a060405180830381865afa158015612ddc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e00919061599b565b6001600160a01b0390811661010087015260ff9093166101608601819052600a0a60c08601525050610e1061018084015282516040805163b7eec41360e01b8152905191909216925063b7eec413916004808201926000929091908290030181865afa158015612e74573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612e9c9190810190615ba1565b6101408201819052516001600160401b03811115612ebc57612ebc6156a3565b604051908082528060200260200182016040528015612ef557816020015b612ee2614e92565b815260200190600190039081612eda5790505b5060006101a083018190529092505b81610140015151826101a0015110156130495781600001516001600160a01b0316635684aa4686846101400151856101a0015181518110612f4757612f47615ab2565b60200260200101516040518363ffffffff1660e01b8152600401612f819291906001600160a01b0392831681529116602082015260400190565b606060405180830381865afa158015612f9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fc29190615c43565b505063ffffffff166101c083018190521561303257816101400151826101a0015181518110612ff357612ff3615ab2565b602002602001015183828061300790615ac8565b93508151811061301957613019615ab2565b60209081029190910101516001600160a01b0390911690525b816101a001805161304290615ac8565b9052612f04565b82816001600160401b03811115613062576130626156a3565b60405190808252806020026020018201604052801561309b57816020015b613088614e92565b8152602001906001900390816130805790505b5060006101a085015293505b8351836101a00151101561310d5780836101a00151815181106130cc576130cc615ab2565b602002602001015184846101a00151815181106130eb576130eb615ab2565b6020026020010181905250826101a001805161310690615ac8565b90526130a7565b505060006101a08201525b8151816101a001511015613d3f5780600001516001600160a01b031663f2426f9a8584846101a001518151811061315157613151615ab2565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016101c060405180830381865afa1580156131a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cd9190615caf565b81610120018190525080600001516001600160a01b03166344e250f88584846101a001518151811061320157613201615ab2565b6020908102919091010151516040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401606060405180830381865afa158015613258573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061327c9190615956565b506040830152606082015280516101a082015183516001600160a01b039092169163fc19606891879186919081106132b6576132b6615ab2565b6020026020010151600001518461012001516060015163ffffffff1642116132df5760006132e6565b8461018001515b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401606060405180830381865afa158015613338573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061335c9190615956565b50608083015260a08201526101c08101516224ea009061337d908290615af7565b826101c0015161338d9190615a9f565b6133979190615690565b81610240018181525050836001600160a01b0316630e52dbec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134039190615818565b6134139060ff166224ea0061593f565b6134206224ea0042615af7565b61342a9042615a9f565b6134349190615690565b61022082018190526102408201516224ea00916134519190615a9f565b61345b9190615da3565b613466906001615690565b6001600160401b0381111561347d5761347d6156a3565b6040519080825280602002602001820160405280156134a6578160200160208202803683370190505b5060e082015260006101c08201526102408101516101e08201525b806102200151816101e00151116135ae576101e0810151604051630156d37d60e31b81526000916001600160a01b03871691630ab69be8916135099160040190815260200190565b6040805180830381865afa158015613525573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061354991906157e3565b50905080826102000181815161355f9190615690565b9052506101e082015160e08301516101c08401518151811061358357613583615ab2565b6020908102919091010152506101e0810180516224ea000190526101c08101805160010190526134c1565b6040518060e0016040528083836101a00151815181106135d0576135d0615ab2565b6020026020010151600001516001600160a01b0316815260200183836101a001518151811061360157613601615ab2565b6020026020010151600001516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa15801561364a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136729190810190615a0c565b815260200183836101a001518151811061368e5761368e615ab2565b6020026020010151600001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156136d7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526136ff9190810190615a0c565b815260200161376c857f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b883b058866101200151604001516040518263ffffffff1660e01b8152600401610fd091906001600160a01b0391909116815260200190565b81526020016000836102000151876001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156137b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137db9190615644565b6137e59190615690565b116137f1576000613a80565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613a80936301e13380939092613a79926138e4917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa15801561387c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138a09190615644565b8961020001518d6001600160a01b031663eee8c9e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b039182166004820152613a79917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613959573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061397d9190615644565b6110118e6001600160a01b031663bf722ca28d61020001516040518263ffffffff1660e01b81526004016139b391815260200190565b602060405180830381865afa1580156139d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139f49190615644565b8f6001600160a01b0316638d0e5f026040518163ffffffff1660e01b8152600401602060405180830381865afa158015613a32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a569190615644565b613a609190615690565b8c60c001518d606001518e60a00151613a799190615a9f565b9190614913565b81526020016000866001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613ac5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ae99190615644565b11613af5576000613cf9565b61018083015160c0840151610100850151604051631710760b60e31b81526001600160a01b039182166004820152613cf9936301e13380939092613a7992613be2917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ba49190615644565b8c6001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fed573d6000803e3d6000fd5b6101208901516040908101519051631710760b60e31b81526001600160a01b039182166004820152613a79917f0000000000000000000000000000000000000000000000000000000000000000169063b883b05890602401602060405180830381865afa158015613c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c7b9190615644565b6110118e6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613ce09190615644565b8c60c001518d604001518e60800151613a799190615a9f565b81526020018260e0015181525082826101a0015181518110613d1d57613d1d615ab2565b6020026020010181905250806101a0018051613d3890615ac8565b9052613118565b5092915050565b6000818310613d55578161238f565b5090919050565b600080613d6883614932565b90506000613e2b846001600160a01b0316634322b7146040518163ffffffff1660e01b8152600401602060405180830381865afa158015613dad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613dd19190615b66565b613de390670de0b6b3a7640000615b81565b6001600160801b031683866001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa158015612993573d6000803e3d6000fd5b9050613ed28183866001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015613e70573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e949190615644565b876001600160a01b0316638c3cba5a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a62573d6000803e3d6000fd5b611b719082615a9f565b828202811515841585830485141716613ef457600080fd5b6001826001830304018115150290509392505050565b600061238f8383670de0b6b3a7640000613edc565b604051632f2e037160e11b81526001600160a01b0382811660048301526000918291851690635e5c06e290602401606060405180830381865afa158015613f6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f8e9190615956565b60405163023effef60e51b8152600481018290529093506001600160a01b03871692506347dffde09150602401602060405180830381865afa158015613fd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b719190615644565b6040805160e0808252611c2082019092526060916000918291816020015b614022614ed8565b81526020019060019003908161401a575050602089901c9890915063ffffffff165b88156142345760018916156142195760008060008a8a858f6040518363ffffffff1660e01b815260040161408b9291909182526001600160a01b0316602082015260400190565b6040805180830381865afa1580156140a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140cb91906157e3565b90925090506140da8183615690565b925060405180604001604052808381526020018281525085878151811061410357614103615ab2565b602002602001015160400181905250505086868d84848f6040518563ffffffff1660e01b815260040161415f94939291906001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b606060405180830381865afa925050508015614198575060408051601f3d908101601f1916820190925261419591810190615b0b565b60015b6141c457808385815181106141af576141af615ab2565b602002602001015160200181815250506141ed565b80602001518486815181106141db576141db615ab2565b60200260200101516020018181525050505b8183858151811061420057614200615ab2565b60209081029190910101515261421584615ac8565b9350505b60019890981c9761422d6224ea0082615690565b9050614044565b826001600160401b0381111561424c5761424c6156a3565b60405190808252806020026020018201604052801561428557816020015b614272614ed8565b81526020019060019003908161426a5790505b50935060005b838110156142db578281815181106142a5576142a5615ab2565b60200260200101518582815181106142bf576142bf615ab2565b6020026020010181905250806142d490615ac8565b905061428b565b50505050979650505050505050565b60606000836001600160a01b0316636bb65f536040518163ffffffff1660e01b8152600401602060405180830381865afa15801561432c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614350919061565d565b90506001600160a01b03811615613d3f576000816001600160a01b031663b7eec4136040518163ffffffff1660e01b8152600401600060405180830381865afa1580156143a1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526143c99190810190615ba1565b905080516001600160401b038111156143e4576143e46156a3565b60405190808252806020026020018201604052801561444957816020015b614436604051806080016040528060006001600160a01b031681526020016060815260200160608152602001600081525090565b8152602001906001900390816144025790505b5060408051600180825281830190925291945060009190816020015b60408051808201909152600081526060602082015281526020019060019003908161446557505060408051600280825260608201835292935060009290916020830190803683370190505090506001816000815181106144c7576144c7615ab2565b6020026020010190151590811515815250506000816001815181106144ee576144ee615ab2565b6020026020010190151590811515815250506040518060400160405280886001600160a01b03168152602001828152508260008151811061453157614531615ab2565b602002602001018190525060005b835181101561473e57604051806080016040528085838151811061456557614565615ab2565b60200260200101516001600160a01b0316815260200185838151811061458d5761458d615ab2565b60200260200101516001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156145d2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526145fa9190810190615a0c565b815260200185838151811061461157614611615ab2565b60200260200101516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015614656573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261467e9190810190615a0c565b8152602001866001600160a01b031663382e85ad868b8987815181106146a6576146a6615ab2565b60200260200101516040518463ffffffff1660e01b81526004016146cc93929190615db7565b602060405180830381865afa1580156146e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061470d9190615644565b81525086828151811061472257614722615ab2565b60200260200101819052508061473790615ac8565b905061453f565b505050505092915050565b60408051808201909152600080825260208201528251602084015160009161477d916147759082615690565b859190614913565b808552905061478c8184615a9f565b6020850152509192915050565b60006147c66040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018590526001600160a01b03861690634e7c505990602401608060405180830381865afa15801561480b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061482f919061560e565b6060850181905260408501919091526020840191909152908252614872906148579042615a9f565b60608301516148669087615a9f565b60408401519190614913565b816040018181516148839190615a9f565b915081815250506148f883866001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156148cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148f09190615644565b839190614b7b565b5095945050505050565b600061238f83670de0b6b3a7640000845b82820281151584158583048514171661492b57600080fd5b0492915050565b600080826001600160a01b0316631a90f1866040518163ffffffff1660e01b8152600401602060405180830381865afa158015614973573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149979190615644565b90506000836001600160a01b0316632e0af0086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156149d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149fd9190615644565b90506000808211614a0f576000614a1c565b614a1c6112668484612398565b9050614b72614b6b866001600160a01b0316636eb9ffeb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a869190615e8b565b614a969063ffffffff1642615a9f565b6301e13380886001600160a01b031663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015614ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614afd919061565d565b6001600160a01b03166384a87466866040518263ffffffff1660e01b8152600401614b2a91815260200190565b602060405180830381865afa158015614b47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a799190615644565b849061237a565b95945050505050565b6000806000614b8986614bce565b90508015614bc557614baa614b9e8683613d46565b60408801519083614913565b9250614bb6838561237a565b9150614bc28284615a9f565b92505b50935093915050565b8051602082015160009190614be38282613d46565b611b719083615a9f565b604051806103c0016040528060006001600160a01b0316815260200160608152602001600060ff16815260200160006001600160a01b031681526020016060815260200160608152602001614c816040518060e0016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001600081526020016000815260200160008152602001600060ff1681526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160608152602001606081525090565b60405180610260016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b03168152602001614e4d604051806101c0016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600063ffffffff168152602001600081526020016000815260200160008152602001600081526020016000600f0b815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b0316815260200160006001600160401b031681525090565b81526020016060815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040518060e0016040528060006001600160a01b031681526020016060815260200160608152602001600081526020016000815260200160008152602001606081525090565b60405180606001604052806000815260200160008152602001614f0e604051806040016040528060008152602001600081525090565b905290565b6001600160a01b0381168114614f2857600080fd5b50565b600080600060608486031215614f4057600080fd5b8335614f4b81614f13565b95602085013595506040909401359392505050565b81518152602080830151908201526040808301519082015260608101612392565b600060208284031215614f9357600080fd5b8135614f9e81614f13565b9392505050565b60005b83811015614fc0578181015183820152602001614fa8565b50506000910152565b60008151808452614fe1816020860160208601614fa5565b601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b8381101561506e57815180518852838101518489015260408082015190890152606080820151908901526080808201519089015260a0808201519089015260c0808201519089015260e090810151908801526101009096019590820190600101615009565b509495945050505050565b600081518084526020808501808196508360051b810191508286016000805b8681101561515e578385038a52825180516001600160a01b031686528681015160e0888801819052906150cd82890182614fc9565b915050604080830151888303828a01526150e78382614fc9565b606085810151908b0152608080860151908b015260a080860151908b015260c0948501518a8203958b01959095528451808252948b0194879450908b01925090505b808310156151495783518252928901926001929092019190890190615129565b509b88019b9650505091850191600101615098565b509298975050505050505050565b600081518084526020808501945080840160005b8381101561506e578151805188528381015184890152604090810151805191890191909152830151606088015260809096019590820190600101615180565b600081518084526020808501808196508360051b8101915082860160005b8581101561524e578284038952815180516001600160a01b031685528581015160808787018190529061521282880182614fc9565b9150506040808301518783038289015261522c8382614fc9565b60609485015198909401979097525050988501989350908401906001016151dd565b5091979650505050505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561552857888303603f19018552815180516001600160a01b0316845261048088820151818a8701526152ba82870182614fc9565b915050878201516152cf8987018260ff169052565b506060828101516001600160a01b031690860152608080830151868303828801526152fa8382614fc9565b9250505060a080830151868303828801526153158382614fc9565b60c08581015180516001600160a01b03168a830152602081015160e08b015260408101516101008b015260608101516101208b015260808101516101408b015260a08101516101608b0152808201516101808b015291945092509050505060e08201516101a0818188015261010084015191506101c0828189015261012085015192506101e083818a015261014086015193506102006153b9818b018660ff169052565b61016087015194506102208a8703818c01526153d58787614ff5565b965061018088015195506102408b8803818d01526153f38888615079565b958901516102608d81019190915294890151610280808e0191909152938901516102a0808e0191909152928901516102c0808e0191909152918901516102e0808e019190915290890151610300808e019190915294890151610320808e019190915293890151610340808e01919091529289015195975094955091939092610360929190615484848d018815159052565b918801516103808c810191909152908801516103a0808d0191909152918801516103c08c0152848801516103e08c0152838801516104008c0152828801518b88036104208d01529550906154d8878761516c565b96508188015195508a87036104408c01526154f3878761516c565b965080880151975050505050505084810361046086015261551481836151bf565b968901969450505090860190600101615282565b509098975050505050505050565b6000806000806080858703121561554c57600080fd5b843561555781614f13565b93506020850135925060408501359150606085013561557581614f13565b939692955090935050565b6000806040838503121561559357600080fd5b823561559e81614f13565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b81811015615602576155ef8385518051825260208082015190830152604090810151910152565b92840192606092909201916001016155c8565b50909695505050505050565b6000806000806080858703121561562457600080fd5b505082516020840151604085015160609095015191969095509092509050565b60006020828403121561565657600080fd5b5051919050565b60006020828403121561566f57600080fd5b8151614f9e81614f13565b634e487b7160e01b600052601160045260246000fd5b808201808211156123925761239261567a565b634e487b7160e01b600052604160045260246000fd5b6040516101c081016001600160401b03811182821017156156dc576156dc6156a3565b60405290565b604051601f8201601f191681016001600160401b038111828210171561570a5761570a6156a3565b604052919050565b60006001600160401b0382111561572b5761572b6156a3565b5060051b60200190565b805161574081614f13565b919050565b6000602080838503121561575857600080fd5b82516001600160401b0381111561576e57600080fd5b8301601f8101851361577f57600080fd5b805161579261578d82615712565b6156e2565b81815260059190911b820183019083810190878311156157b157600080fd5b928401925b828410156157d85783516157c981614f13565b825292840192908401906157b6565b979650505050505050565b600080604083850312156157f657600080fd5b505080516020909101519092909150565b805160ff8116811461574057600080fd5b60006020828403121561582a57600080fd5b61238f82615807565b60ff82811682821603908111156123925761239261567a565b600181815b8085111561588757816000190482111561586d5761586d61567a565b8085161561587a57918102915b93841c9390800290615851565b509250929050565b60008261589e57506001612392565b816158ab57506000612392565b81600181146158c157600281146158cb576158e7565b6001915050612392565b60ff8411156158dc576158dc61567a565b50506001821b612392565b5060208310610133831016604e8410600b841016171561590a575081810a612392565b615914838361584c565b80600019048211156159285761592861567a565b029392505050565b600061238f60ff84168361588f565b80820281158282048414176123925761239261567a565b60008060006060848603121561596b57600080fd5b8351925060208401519150604084015190509250925092565b80516001600160801b038116811461574057600080fd5b600080600080600060a086880312156159b357600080fd5b6159bc86615984565b94506159ca60208701615807565b93506159d860408701615807565b9250606086015180151581146159ed57600080fd5b60808701519092506159fe81614f13565b809150509295509295909350565b600060208284031215615a1e57600080fd5b81516001600160401b0380821115615a3557600080fd5b818401915084601f830112615a4957600080fd5b815181811115615a5b57615a5b6156a3565b615a6e601f8201601f19166020016156e2565b9150808252856020828501011115615a8557600080fd5b615a96816020840160208601614fa5565b50949350505050565b818103818111156123925761239261567a565b634e487b7160e01b600052603260045260246000fd5b600060018201615ada57615ada61567a565b5060010190565b634e487b7160e01b600052601260045260246000fd5b600082615b0657615b06615ae1565b500690565b600060608284031215615b1d57600080fd5b604051606081018181106001600160401b0382111715615b3f57615b3f6156a3565b80604052508251815260208301516020820152604083015160408201528091505092915050565b600060208284031215615b7857600080fd5b61238f82615984565b6001600160801b03828116828216039080821115613d3f57613d3f61567a565b60006020808385031215615bb457600080fd5b82516001600160401b03811115615bca57600080fd5b8301601f81018513615bdb57600080fd5b8051615be961578d82615712565b81815260059190911b82018301908381019087831115615c0857600080fd5b928401925b828410156157d8578351615c2081614f13565b82529284019290840190615c0d565b805163ffffffff8116811461574057600080fd5b600080600060608486031215615c5857600080fd5b615c6184615c2f565b9250615c6f60208501615c2f565b9150615c7d60408501615c2f565b90509250925092565b8051600f81900b811461574057600080fd5b80516001600160401b038116811461574057600080fd5b60006101c08284031215615cc257600080fd5b615cca6156b9565b615cd383615735565b8152615ce160208401615735565b6020820152615cf260408401615735565b6040820152615d0360608401615c2f565b60608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e0820152610100615d3e818501615c86565b90820152610120615d50848201615c98565b90820152610140615d62848201615c98565b90820152610160615d74848201615c98565b90820152610180615d86848201615c98565b908201526101a0615d98848201615c98565b908201529392505050565b600082615db257615db2615ae1565b500490565b6000606080830181845280875180835260808601915060808160051b87010192506020808a016000805b84811015615e5757898703607f19018652825180516001600160a01b0316885284015160408589018190528151908901819052908501908989019084905b80821015615e4157835115158352928701929187019160019190910190615e1f565b5090985050509483019491830191600101615de1565b505050839550615e718188018a6001600160a01b03169052565b5050505050611b7160408301846001600160a01b03169052565b600060208284031215615e9d57600080fd5b61238f82615c2f56fea264697066735822122058c4a71334a5b908365a5edf431df76721c877fb6a15b2608af0fc2fc554c70364736f6c63430008110033", "devdoc": { "kind": "dev", "methods": {