From e2a4b018c753411f9c06a254091090a0ab7010d9 Mon Sep 17 00:00:00 2001 From: danilo neves cruz Date: Wed, 7 Jun 2023 18:56:14 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20mainnet:=20deploy=20new=20debt?= =?UTF-8?q?=20manager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/famous-parrots-pay.md | 5 + .openzeppelin/mainnet.json | 52 +++ deployments/mainnet/DebtManager.json | 364 +++++++++++++----- .../mainnet/DebtManager_Implementation.json | 357 ++++++++++++++--- deployments/mainnet/DebtManager_Proxy.json | 122 +++--- 5 files changed, 694 insertions(+), 206 deletions(-) create mode 100644 .changeset/famous-parrots-pay.md diff --git a/.changeset/famous-parrots-pay.md b/.changeset/famous-parrots-pay.md new file mode 100644 index 000000000..59a567eac --- /dev/null +++ b/.changeset/famous-parrots-pay.md @@ -0,0 +1,5 @@ +--- +"@exactly/protocol": patch +--- + +🚀 mainnet: deploy new debt manager diff --git a/.openzeppelin/mainnet.json b/.openzeppelin/mainnet.json index bad1af81a..d846eec91 100644 --- a/.openzeppelin/mainnet.json +++ b/.openzeppelin/mainnet.json @@ -60,6 +60,11 @@ "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", "txHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", "kind": "transparent" + }, + { + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", + "txHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", + "kind": "transparent" } ], "impls": { @@ -14971,6 +14976,53 @@ } } } + }, + "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74": { + "address": "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74", + "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:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "callHash", + "offset": 0, + "slot": "1", + "type": "t_bytes32", + "contract": "DebtManager", + "src": "contracts/periphery/DebtManager.sol:292" + } + ], + "types": { + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/deployments/mainnet/DebtManager.json b/deployments/mainnet/DebtManager.json index 15fb993cb..1838215db 100644 --- a/deployments/mainnet/DebtManager.json +++ b/deployments/mainnet/DebtManager.json @@ -1,5 +1,5 @@ { - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "abi": [ { "anonymous": false, @@ -244,6 +244,69 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract Market", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetHealthFactor", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "deposit", + "type": "bool" + } + ], + "name": "leverage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "receiveFlashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -277,14 +340,77 @@ "type": "uint256" } ], - "name": "fixedRoll", + "name": "rollFixed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "initialize", + "inputs": [ + { + "internalType": "contract Market", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayMaturity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMaturity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxRepayAssets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxBorrowAssets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "percentage", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct Permit", + "name": "p", + "type": "tuple" + } + ], + "name": "rollFixed", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -298,21 +424,21 @@ }, { "internalType": "uint256", - "name": "principal", + "name": "repayMaturity", "type": "uint256" }, { "internalType": "uint256", - "name": "targetHealthFactor", + "name": "maxRepayAssets", "type": "uint256" }, { - "internalType": "bool", - "name": "deposit", - "type": "bool" + "internalType": "uint256", + "name": "percentage", + "type": "uint256" } ], - "name": "leverage", + "name": "rollFixedToFloating", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -320,27 +446,59 @@ { "inputs": [ { - "internalType": "contract ERC20[]", - "name": "", - "type": "address[]" + "internalType": "contract Market", + "name": "market", + "type": "address" }, { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" + "internalType": "uint256", + "name": "repayMaturity", + "type": "uint256" }, { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" + "internalType": "uint256", + "name": "maxRepayAssets", + "type": "uint256" }, { - "internalType": "bytes", - "name": "userData", - "type": "bytes" + "internalType": "uint256", + "name": "percentage", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct Permit", + "name": "p", + "type": "tuple" } ], - "name": "receiveFlashLoan", + "name": "rollFixedToFloating", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -354,12 +512,12 @@ }, { "internalType": "uint256", - "name": "repayMaturity", + "name": "borrowMaturity", "type": "uint256" }, { "internalType": "uint256", - "name": "maxRepayAssets", + "name": "maxBorrowAssets", "type": "uint256" }, { @@ -368,7 +526,7 @@ "type": "uint256" } ], - "name": "rollFixedToFloating", + "name": "rollFloatingToFixed", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -394,6 +552,38 @@ "internalType": "uint256", "name": "percentage", "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct Permit", + "name": "p", + "type": "tuple" } ], "name": "rollFloatingToFixed", @@ -423,137 +613,137 @@ "type": "constructor" } ], - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "receipt": { "to": null, "from": "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a", - "contractAddress": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", - "transactionIndex": 77, - "gasUsed": "736433", - "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000004000010000000000000000000000000002000000080000000000000000201000000000004010100008000008000002000000000000002100000000000000000010000000000000000004000000000002020040800000000000000000000000800000000000000000000080000000000000000000010080000000000000a00000830000010000200000440000000400000000004000000000000000000000000010002020000000100000010000040000000002000400000000000000000000000010200000000000000100208000000000200000000000000000000100000000", - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2", - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "contractAddress": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", + "transactionIndex": 68, + "gasUsed": "736500", + "logsBloom": "0x00000000000000000000004000000000400000000000000000000002000000000000010000000000000000000000000002000000080000000000000000200000000000004010100008000008000002000000000000022000000010000000000012000000000000000004000000000002020040800000010000000000000000000000000000000000000080000000000000000000010080000000000000800000030000010000200000440000000400000000000000000000000000000020000010002020000000100000000000040000000002000400040000000000000000000010200000000000000100008000000000200000000400000000000100000000", + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e", + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "logs": [ { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000006df3686f372a74280437d118de7ae38ce97462f8" + "0x000000000000000000000000fe0c5abf52e3e3076f3cb7f6323c7c1c91f54b74" ], "data": "0x", - "logIndex": 163, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 156, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x000000000000000000000000c4d4500326981eacd020e20a81b1c479c161c7ef" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 164, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 157, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x000000000000000000000000163538e22f4d38c1eb21b79939f3d2ee274198ff" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 165, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 158, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x000000000000000000000000660e2fc185a9ffe722af253329ceaad4c9f6f928" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 166, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 159, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x0000000000000000000000008644c0fded361d1920e068ba4b09996e26729435" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 167, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 160, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x0000000000000000000000003843c41da1d7909c86fad51c47b9a97cf62a29e1" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 168, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 161, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", - "logIndex": 169, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 162, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003866ea62494597a5edea4a97f9429f82b9d7ca34", - "logIndex": 170, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 163, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" } ], - "blockNumber": 17393571, - "cumulativeGasUsed": "6963078", + "blockNumber": 17429816, + "cumulativeGasUsed": "6026466", "status": 1, "byzantium": true }, "args": [ - "0x6DF3686f372A74280437D118dE7Ae38cE97462f8", + "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74", "0x3866eA62494597A5EDeA4A97f9429f82b9d7Ca34", "0x8129fc1c" ], "numDeployments": 1, - "solcInputHash": "03a03f60daa39b8c260cc231d959b34a", + "solcInputHash": "c17dde40789793494d592271c7649423", "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", @@ -561,7 +751,7 @@ "methodName": "initialize", "args": [] }, - "implementation": "0x6DF3686f372A74280437D118dE7Ae38cE97462f8", + "implementation": "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74", "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", diff --git a/deployments/mainnet/DebtManager_Implementation.json b/deployments/mainnet/DebtManager_Implementation.json index 9d40f0661..e432f79b5 100644 --- a/deployments/mainnet/DebtManager_Implementation.json +++ b/deployments/mainnet/DebtManager_Implementation.json @@ -1,5 +1,5 @@ { - "address": "0x6DF3686f372A74280437D118dE7Ae38cE97462f8", + "address": "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74", "abi": [ { "inputs": [ @@ -137,6 +137,69 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract Market", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "targetHealthFactor", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "deposit", + "type": "bool" + } + ], + "name": "leverage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20[]", + "name": "", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "receiveFlashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -170,14 +233,77 @@ "type": "uint256" } ], - "name": "fixedRoll", + "name": "rollFixed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [], - "name": "initialize", + "inputs": [ + { + "internalType": "contract Market", + "name": "market", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayMaturity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowMaturity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxRepayAssets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxBorrowAssets", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "percentage", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct Permit", + "name": "p", + "type": "tuple" + } + ], + "name": "rollFixed", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -191,21 +317,21 @@ }, { "internalType": "uint256", - "name": "principal", + "name": "repayMaturity", "type": "uint256" }, { "internalType": "uint256", - "name": "targetHealthFactor", + "name": "maxRepayAssets", "type": "uint256" }, { - "internalType": "bool", - "name": "deposit", - "type": "bool" + "internalType": "uint256", + "name": "percentage", + "type": "uint256" } ], - "name": "leverage", + "name": "rollFixedToFloating", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -213,27 +339,59 @@ { "inputs": [ { - "internalType": "contract ERC20[]", - "name": "", - "type": "address[]" + "internalType": "contract Market", + "name": "market", + "type": "address" }, { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" + "internalType": "uint256", + "name": "repayMaturity", + "type": "uint256" }, { - "internalType": "uint256[]", - "name": "", - "type": "uint256[]" + "internalType": "uint256", + "name": "maxRepayAssets", + "type": "uint256" }, { - "internalType": "bytes", - "name": "userData", - "type": "bytes" + "internalType": "uint256", + "name": "percentage", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct Permit", + "name": "p", + "type": "tuple" } ], - "name": "receiveFlashLoan", + "name": "rollFixedToFloating", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -247,12 +405,12 @@ }, { "internalType": "uint256", - "name": "repayMaturity", + "name": "borrowMaturity", "type": "uint256" }, { "internalType": "uint256", - "name": "maxRepayAssets", + "name": "maxBorrowAssets", "type": "uint256" }, { @@ -261,7 +419,7 @@ "type": "uint256" } ], - "name": "rollFixedToFloating", + "name": "rollFloatingToFixed", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -287,6 +445,38 @@ "internalType": "uint256", "name": "percentage", "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "internalType": "struct Permit", + "name": "p", + "type": "tuple" } ], "name": "rollFloatingToFixed", @@ -295,32 +485,32 @@ "type": "function" } ], - "transactionHash": "0xdf88035e4ea2fd7ba99f922002f31d95d9a725a8abf155cede3ae92b50e6c300", + "transactionHash": "0x63933d9c3bf6ec88a69bb410108f694dc5b3d514706ba51845341c3fba7d24db", "receipt": { "to": null, "from": "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a", - "contractAddress": "0x6DF3686f372A74280437D118dE7Ae38cE97462f8", - "transactionIndex": 79, - "gasUsed": "2911186", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000080000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xe3d700783ebf30d1dd96c19977b1c9d5ede0fd302f01346efadf9a9dc7587c1b", - "transactionHash": "0xdf88035e4ea2fd7ba99f922002f31d95d9a725a8abf155cede3ae92b50e6c300", + "contractAddress": "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74", + "transactionIndex": 83, + "gasUsed": "3112455", + "logsBloom": "0x00000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000100000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe018af33fb6df3db4dd1f05e7fd823cce2786cc78ec8b0565a7fe8378ddf027c", + "transactionHash": "0x63933d9c3bf6ec88a69bb410108f694dc5b3d514706ba51845341c3fba7d24db", "logs": [ { - "transactionIndex": 79, - "blockNumber": 17393570, - "transactionHash": "0xdf88035e4ea2fd7ba99f922002f31d95d9a725a8abf155cede3ae92b50e6c300", - "address": "0x6DF3686f372A74280437D118dE7Ae38cE97462f8", + "transactionIndex": 83, + "blockNumber": 17429815, + "transactionHash": "0x63933d9c3bf6ec88a69bb410108f694dc5b3d514706ba51845341c3fba7d24db", + "address": "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000ff", - "logIndex": 259, - "blockHash": "0xe3d700783ebf30d1dd96c19977b1c9d5ede0fd302f01346efadf9a9dc7587c1b" + "logIndex": 212, + "blockHash": "0xe018af33fb6df3db4dd1f05e7fd823cce2786cc78ec8b0565a7fe8378ddf027c" } ], - "blockNumber": 17393570, - "cumulativeGasUsed": "12206855", + "blockNumber": 17429815, + "cumulativeGasUsed": "11396926", "status": 1, "byzantium": true }, @@ -329,10 +519,10 @@ "0xBA12222222228d8Ba445958a75a0704d566BF2C8" ], "numDeployments": 1, - "solcInputHash": "03a03f60daa39b8c260cc231d959b34a", - "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"auditor_\",\"type\":\"address\"},{\"internalType\":\"contract IBalancerVault\",\"name\":\"balancerVault_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"Disagreement\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidOperation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MarketNotListed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"auditor\",\"outputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"availableLiquidity\",\"outputs\":[{\"components\":[{\"internalType\":\"contract ERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"liquidity\",\"type\":\"uint256\"}],\"internalType\":\"struct DebtManager.AvailableAsset[]\",\"name\":\"availableAssets\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"balancerVault\",\"outputs\":[{\"internalType\":\"contract IBalancerVault\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"deleverage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRepayAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"fixedRoll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"targetHealthFactor\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"deposit\",\"type\":\"bool\"}],\"name\":\"leverage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ERC20[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"userData\",\"type\":\"bytes\"}],\"name\":\"receiveFlashLoan\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRepayAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"rollFixedToFloating\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"borrowMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"rollFloatingToFixed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address)\":{\"details\":\"The Market must be listed by the Auditor in order to be valid for approval.\",\"params\":{\"market\":\"The Market to spend the contract's balance.\"}},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"deleverage(address,uint256,uint256,uint256)\":{\"params\":{\"market\":\"The Market to deleverage the position out.\",\"maturity\":\"The maturity of the fixed pool that the position is being deleveraged out of, `0` if floating.\",\"maxAssets\":\"Max amount of fixed debt that the sender is willing to accept.\",\"percentage\":\"The percentage of the borrow that will be repaid, represented with 18 decimals.\"}},\"fixedRoll(address,uint256,uint256,uint256,uint256,uint256)\":{\"params\":{\"borrowMaturity\":\"The maturity of the fixed pool that the position is being rolled to.\",\"market\":\"The Market to roll the position in.\",\"maxBorrowAssets\":\"Max amount of debt that the sender is willing to accept to be borrowed.\",\"maxRepayAssets\":\"Max amount of debt that the account is willing to accept to be repaid.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\",\"repayMaturity\":\"The maturity of the fixed pool that the position is being rolled from.\"}},\"initialize()\":{\"details\":\"can only be called once.\"},\"leverage(address,uint256,uint256,bool)\":{\"params\":{\"deposit\":\"True if the principal is being deposited, false if the principal is already deposited.\",\"market\":\"The Market to leverage the position in.\",\"principal\":\"The amount of assets to deposit or deposited.\",\"targetHealthFactor\":\"The desired target health factor that the account will be leveraged to.\"}},\"receiveFlashLoan(address[],uint256[],uint256[],bytes)\":{\"details\":\"Only the Balancer Vault contract is allowed to call this function.\",\"params\":{\"userData\":\"Additional data provided by the borrower for the flash loan.\"}},\"rollFixedToFloating(address,uint256,uint256,uint256)\":{\"params\":{\"market\":\"The Market to roll the position in.\",\"maxRepayAssets\":\"Max amount of debt that the account is willing to accept to be repaid.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\",\"repayMaturity\":\"The maturity of the fixed pool that the position is being rolled from.\"}},\"rollFloatingToFixed(address,uint256,uint256,uint256)\":{\"params\":{\"borrowMaturity\":\"The maturity of the fixed pool that the position is being rolled to.\",\"market\":\"The Market to roll the position in.\",\"maxBorrowAssets\":\"Max amount of debt that the sender is willing to accept to be borrowed.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\"}}},\"stateVariables\":{\"auditor\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"balancerVault\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"DebtManager\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"approve(address)\":{\"notice\":\"Approves the Market to spend the contract's balance of the underlying asset.\"},\"auditor()\":{\"notice\":\"Auditor contract that lists the markets that can be leveraged.\"},\"availableLiquidity()\":{\"notice\":\"Returns Balancer Vault's available liquidity of each enabled underlying asset.\"},\"balancerVault()\":{\"notice\":\"Balancer's vault contract that is used to take flash loans.\"},\"deleverage(address,uint256,uint256,uint256)\":{\"notice\":\"Deleverages the position of `msg.sender` a certain `percentage` by taking a flash loan from Balancer's vault to repay the borrow.\"},\"fixedRoll(address,uint256,uint256,uint256,uint256,uint256)\":{\"notice\":\"Rolls a percentage of the fixed position of `msg.sender` to another fixed pool.\"},\"initialize()\":{\"notice\":\"Initializes the contract.\"},\"leverage(address,uint256,uint256,bool)\":{\"notice\":\"Leverages the floating position of `msg.sender` to match `targetHealthFactor` by taking a flash loan from Balancer's vault.\"},\"receiveFlashLoan(address[],uint256[],uint256[],bytes)\":{\"notice\":\"Callback function called by the Balancer Vault contract when a flash loan is initiated.\"},\"rollFixedToFloating(address,uint256,uint256,uint256)\":{\"notice\":\"Rolls a percentage of the fixed position of `msg.sender` to a floating position.\"},\"rollFloatingToFixed(address,uint256,uint256,uint256)\":{\"notice\":\"Rolls a percentage of the floating position of `msg.sender` to a fixed position.\"}},\"notice\":\"Contract for efficient debt management of accounts interacting with Exactly Protocol.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/DebtManager.sol\":\"DebtManager\"},\"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/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 { Market, ERC20, ERC4626, FixedLib, Disagreement } from \\\"../Market.sol\\\";\\nimport { Auditor, 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 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 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\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IBalancerVault balancerVault_) {\\n auditor = auditor_;\\n balancerVault = balancerVault_;\\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++) {\\n markets[i].asset().safeApprove(address(markets[i]), type(uint256).max);\\n }\\n }\\n\\n /// @notice Leverages the floating position of `msg.sender` to match `targetHealthFactor` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param principal The amount of assets to deposit or deposited.\\n /// @param targetHealthFactor The desired target health factor that the account will be leveraged to.\\n /// @param deposit True if the principal is being deposited, false if the principal is already deposited.\\n function leverage(Market market, uint256 principal, uint256 targetHealthFactor, bool deposit) external {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls = new bytes[](2);\\n ERC20 asset = market.asset();\\n\\n if (deposit) asset.safeTransferFrom(msg.sender, address(this), principal);\\n\\n (uint256 adjustFactor, , , , ) = auditor.markets(market);\\n uint256 factor = adjustFactor.mulWadDown(adjustFactor).divWadDown(targetHealthFactor);\\n tokens[0] = asset;\\n amounts[0] = principal.mulWadDown(factor).divWadDown(1e18 - factor);\\n calls[0] = abi.encodeCall(ERC4626.deposit, (amounts[0] + (deposit ? principal : 0), msg.sender));\\n calls[1] = abi.encodeCall(Market.borrow, (amounts[0], address(balancerVault), msg.sender));\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, abi.encode(market, calls));\\n }\\n\\n /// @notice Deleverages the position of `msg.sender` a certain `percentage` by taking a flash loan from\\n /// Balancer's vault to repay the borrow.\\n /// @param market The Market to deleverage the position out.\\n /// @param maturity The maturity of the fixed pool that the position is being deleveraged out of, `0` if floating.\\n /// @param maxAssets Max amount of fixed debt that the sender is willing to accept.\\n /// @param percentage The percentage of the borrow that will be repaid, represented with 18 decimals.\\n function deleverage(Market market, uint256 maturity, uint256 maxAssets, uint256 percentage) external {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls = new bytes[](2);\\n tokens[0] = market.asset();\\n\\n if (maturity == 0) {\\n (, , uint256 floatingBorrowShares) = market.accounts(msg.sender);\\n amounts[0] = market.previewRefund(floatingBorrowShares.mulWadDown(percentage));\\n calls[0] = abi.encodeCall(Market.repay, (amounts[0], msg.sender));\\n } else {\\n uint256 positionAssets;\\n (amounts[0], positionAssets) = repayAtMaturityAssets(market, maturity, percentage);\\n calls[0] = abi.encodeCall(Market.repayAtMaturity, (maturity, positionAssets, maxAssets, msg.sender));\\n }\\n calls[1] = abi.encodeCall(Market.withdraw, (amounts[0], address(balancerVault), msg.sender));\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, abi.encode(market, calls));\\n }\\n\\n /// @notice Rolls a percentage of the floating position of `msg.sender` 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 ) external {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls;\\n RollVars memory r;\\n tokens[0] = market.asset();\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, msg.sender);\\n (, , uint256 floatingBorrowShares) = market.accounts(msg.sender);\\n r.repayAssets = market.previewRefund(\\n percentage < 1e18 ? floatingBorrowShares.mulWadDown(percentage) : floatingBorrowShares\\n );\\n r.loopCount = r.repayAssets.mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n\\n amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.repay,\\n (r.i == 0 ? amounts[0] : r.repayAssets / r.loopCount, msg.sender)\\n );\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n r.i + 1 == r.loopCount ? amounts[0] : r.repayAssets / r.loopCount,\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n msg.sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, abi.encode(market, calls));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, msg.sender);\\n if (maxBorrowAssets < newPrincipal + newFee - r.principal - r.fee) revert Disagreement();\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `msg.sender` 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 ) external {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls;\\n RollVars memory r;\\n tokens[0] = market.asset();\\n\\n (, , uint256 floatingBorrowShares) = market.accounts(msg.sender);\\n r.principal = market.previewRefund(floatingBorrowShares);\\n (uint256 repayAssets, uint256 positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n r.loopCount = repayAssets.mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n positionAssets = positionAssets / r.loopCount;\\n\\n amounts[0] = repayAssets.mulDivUp(1, r.loopCount);\\n calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.repayAtMaturity,\\n (repayMaturity, positionAssets, type(uint256).max, msg.sender)\\n );\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.borrow,\\n (amounts[0], r.i + 1 == r.loopCount ? address(balancerVault) : address(this), msg.sender)\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n balancerVault.flashLoan(address(this), tokens, amounts, abi.encode(market, calls));\\n (, , floatingBorrowShares) = market.accounts(msg.sender);\\n if (maxRepayAssets < market.previewRefund(floatingBorrowShares) - r.principal) revert Disagreement();\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `msg.sender` 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 fixedRoll(\\n Market market,\\n uint256 repayMaturity,\\n uint256 borrowMaturity,\\n uint256 maxRepayAssets,\\n uint256 maxBorrowAssets,\\n uint256 percentage\\n ) external {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls;\\n RollVars memory r;\\n tokens[0] = market.asset();\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, msg.sender);\\n (r.repayAssets, r.positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n\\n r.loopCount = r.repayAssets.mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n if (r.loopCount > 1 && repayMaturity == borrowMaturity) revert InvalidOperation();\\n\\n amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n r.positionAssets = r.positionAssets / r.loopCount;\\n calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.repayAtMaturity,\\n (repayMaturity, r.positionAssets, type(uint256).max, msg.sender)\\n );\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n amounts[0],\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n msg.sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, abi.encode(market, calls));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, msg.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 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, msg.sender);\\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 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 assert(msg.sender == address(balancerVault));\\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 Returns Balancer Vault's available liquidity of each enabled underlying asset.\\n function availableLiquidity() external view returns (AvailableAsset[] memory availableAssets) {\\n uint256 marketsCount = auditor.allMarkets().length;\\n availableAssets = new AvailableAsset[](marketsCount);\\n\\n for (uint256 i = 0; i < marketsCount; i++) {\\n ERC20 asset = auditor.marketList(i).asset();\\n availableAssets[i] = AvailableAsset({ asset: asset, liquidity: asset.balanceOf(address(balancerVault)) });\\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) external {\\n (, , , bool isListed, ) = auditor.markets(market);\\n if (!isListed) revert MarketNotListed();\\n\\n market.asset().safeApprove(address(market), type(uint256).max);\\n }\\n\\n struct AvailableAsset {\\n ERC20 asset;\\n uint256 liquidity;\\n }\\n}\\n\\nerror InvalidOperation();\\n\\nstruct RollVars {\\n uint256 positionAssets;\\n uint256 repayAssets;\\n uint256 callIndex;\\n uint256 loopCount;\\n uint256 principal;\\n uint256 fee;\\n uint256 i;\\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\",\"keccak256\":\"0x01320e22efcebc8cc581cc68f52544b28c4a9227dacfbc3b8c29671f6f914210\",\"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": "0x60c06040523480156200001157600080fd5b5060405162003513380380620035138339810160408190526200003491620000dd565b6001600160a01b03808316608052811660a0526200005162000059565b50506200011c565b600054610100900460ff16156200006f57600080fd5b60005460ff9081161015620000c2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6001600160a01b0381168114620000da57600080fd5b50565b60008060408385031215620000f157600080fd5b8251620000fe81620000c4565b60208401519092506200011181620000c4565b809150509250929050565b60805160a051613346620001cd6000396000818160b301528181610356015281816105830152818161063a01528181610a0b01528181610bfe01528181610ca8015281816110e801528181611334015281816113eb0152818161173001528181611cc901528181611d4301528181611ef901528181612319015261239301526000818161011f0152818161152b015281816116370152818161184e01528181611b000152611e1401526133466000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c8063743753591161007157806374375359146101545780638129fc1c14610169578063912019c914610171578063daea85c514610184578063f04f270714610197578063fad6cf0f146101aa57600080fd5b8063158274a5146100ae57806333195347146100f25780633e256402146101075780633ec045a61461011a57806340c714ce14610141575b600080fd5b6100d57f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b610105610100366004612a47565b6101bd565b005b610105610115366004612a93565b61080f565b6100d57f000000000000000000000000000000000000000000000000000000000000000081565b61010561014f366004612a93565b610e5e565b61015c611525565b6040516100e99190612ace565b6101056117e4565b61010561017f366004612b34565b6119e8565b610105610192366004612b7e565b611df2565b6101056101a5366004612cf1565b611eee565b6101056101b8366004612a93565b611fa5565b604080516001808252818301909252600091602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337019050509050606061020c6129f5565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561024a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026e9190612dfc565b8360008151811061028157610281612e19565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018a9052336024820152908b169063d2681a0b906044016040805180830381865afa1580156102da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fe9190612e2f565b60a083015260808201526103138a8a87612432565b8252602082015282516103d690600190859060009061033457610334612e19565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa1580156103a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ca9190612e53565b60208401519190612725565b6060820181905260011080156103eb57508789145b1561040957604051631cc6a69960e11b815260040160405180910390fd5b6060810151602082015161041f91600190612725565b8460008151811061043257610432612e19565b60209081029190910101526060810151815161044e9190612e82565b81526060810151610460906002612ea4565b67ffffffffffffffff81111561047857610478612ba2565b6040519080825280602002602001820160405280156104ab57816020015b60608152602001906001900390816104965790505b50600060c083015291505b80606001518160c001511015610638578051604051602481018b90526044810191909152600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b17905282018051849161052482612ebb565b90528151811061053657610536612e19565b6020026020010181905250878460008151811061055557610555612e19565b602002602001015160001983606001518460c0015160016105769190612ed4565b1461058157306105a3565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b17905282018051849161060b82612ebb565b90528151811061061d5761061d612e19565b602090810291909101015260c08101805160010190526104b6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3085878e8760405160200161067d929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016106ab9493929190612fa9565b600060405180830381600087803b1580156106c557600080fd5b505af11580156106d9573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038d169063d2681a0b906044016040805180830381865afa15801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190612e2f565b915091508260a00151836080015160001961076b9190613045565b6107759190613045565b8810610783576000196107a1565b60a08301516080840151610797908a612ed4565b6107a19190612ed4565b6107ab8284612ed4565b11806107e3575060808301516107c390600019613045565b89106107d1576000196107e0565b60808301516107e0908a612ed4565b82115b1561080157604051632c1b6b4160e21b815260040160405180910390fd5b505050505050505050505050565b604080516001808252818301909252600091602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337019050509050606061085e6129f5565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561089c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c09190612dfc565b836000815181106108d3576108d3612e19565b6001600160a01b039283166020918202929092010152604051632f2e037160e11b81523360048201526000918a1690635e5c06e290602401606060405180830381865afa158015610928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094c9190613058565b60405163023effef60e51b8152600481018290529093506001600160a01b038c1692506347dffde09150602401602060405180830381865afa158015610996573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ba9190612e53565b60808301526000806109cd8b8b8a612432565b91509150610a876001876000815181106109e9576109e9612e19565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015610a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7f9190612e53565b849190612725565b60608501819052610a989082612e82565b9050610ab460018560600151846127259092919063ffffffff16565b87600081518110610ac757610ac7612e19565b60209081029190910101526060840151610ae2906002612ea4565b67ffffffffffffffff811115610afa57610afa612ba2565b604051908082528060200260200182016040528015610b2d57816020015b6060815260200190600190039081610b185790505b50600060c086015294505b83606001518460c001511015610ca657604051602481018b905260448101829052600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b179052850180518791610ba382612ebb565b905281518110610bb557610bb5612e19565b602002602001018190525086600081518110610bd357610bd3612e19565b602002602001015184606001518560c001516001610bf19190612ed4565b14610bfc5730610c1e565b7f00000000000000000000000000000000000000000000000000000000000000005b60405160248101929092526001600160a01b0316604482015233606482015260840160408051601f198184030181529181526020820180516001600160e01b0316633545906160e21b179052850180518791610c7982612ebb565b905281518110610c8b57610c8b612e19565b602090810291909101015260c0840180516001019052610b38565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e30888a8f8a604051602001610ceb929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401610d199493929190612fa9565b600060405180830381600087803b158015610d3357600080fd5b505af1158015610d47573d6000803e3d6000fd5b5050604051632f2e037160e11b81523360048201526001600160a01b038e169250635e5c06e29150602401606060405180830381865afa158015610d8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db39190613058565b608087015160405163023effef60e51b81526004810183905291965092506001600160a01b038e1691506347dffde090602401602060405180830381865afa158015610e03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e279190612e53565b610e319190613045565b891015610e5157604051632c1b6b4160e21b815260040160405180910390fd5b5050505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090506060610ead6129f5565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0f9190612dfc565b83600081518110610f2257610f22612e19565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018990523360248201529089169063d2681a0b906044016040805180830381865afa158015610f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9f9190612e2f565b60a08301526080820152604051632f2e037160e11b81523360048201526000906001600160a01b038a1690635e5c06e290602401606060405180830381865afa158015610ff0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110149190613058565b92505050886001600160a01b03166347dffde0670de0b6b3a7640000881061103c5782611046565b6110468389612753565b6040518263ffffffff1660e01b815260040161106491815260200190565b602060405180830381865afa158015611081573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a59190612e53565b8260200181815250506111686001856000815181106110c6576110c6612e19565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015611138573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115c9190612e53565b60208501519190612725565b60608301819052602083015161118091600190612725565b8560008151811061119357611193612e19565b602090810291909101015260608201516111ae906002612ea4565b67ffffffffffffffff8111156111c6576111c6612ba2565b6040519080825280602002602001820160405280156111f957816020015b60608152602001906001900390816111e45790505b50600060c084015292505b81606001518260c0015110156113e95760c08201511561123757816060015182602001516112329190612e82565b611253565b8460008151811061124a5761124a612e19565b60200260200101515b604051602481019190915233604482015260640160408051601f198184030181529181526020820180516001600160e01b031663acb7081560e01b1790528301805185916112a082612ebb565b9052815181106112b2576112b2612e19565b60200260200101819052508782606001518360c0015160016112d49190612ed4565b146112f257826060015183602001516112ed9190612e82565b61130e565b8560008151811061130557611305612e19565b60200260200101515b60001984606001518560c0015160016113279190612ed4565b146113325730611354565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b1790528301805185916113bc82612ebb565b9052815181106113ce576113ce612e19565b602090810291909101015260c0820180516001019052611204565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3086888d8860405160200161142e929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161145c9493929190612fa9565b600060405180830381600087803b15801561147657600080fd5b505af115801561148a573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038c169063d2681a0b906044016040805180830381865afa1580156114dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115019190612e2f565b915091508360a001518460800151828461151b9190612ed4565b610e279190613045565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611587573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115af9190810190613086565b5190508067ffffffffffffffff8111156115cb576115cb612ba2565b60405190808252806020026020018201604052801561161057816020015b60408051808201909152600080825260208201528152602001906001900390816115e95790505b50915060005b818110156117df576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa158015611686573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116aa9190612dfc565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170b9190612dfc565b6040805180820182526001600160a01b0380841680835292516370a0823160e01b81527f00000000000000000000000000000000000000000000000000000000000000009091166004820152929350916020830191906370a0823190602401602060405180830381865afa158015611787573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ab9190612e53565b8152508483815181106117c0576117c0612e19565b60200260200101819052505080806117d790612ebb565b915050611616565b505090565b600054610100900460ff16158080156118045750600054600160ff909116105b8061181e5750303b15801561181e575060005460ff166001145b61182757600080fd5b6000805460ff19166001179055801561184a576000805461ff0019166101001790555b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156118aa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118d29190810190613086565b905060005b815181101561199d5761198b8282815181106118f5576118f5612e19565b602002602001015160001984848151811061191257611912612e19565b60200260200101516001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061197b9190612dfc565b6001600160a01b03169190612771565b8061199581612ebb565b9150506118d7565b505080156119e5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081611a465790505090506000876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac19190612dfc565b90508415611ade57611ade6001600160a01b03821633308a6127c0565b604051638e8f294b60e01b81526001600160a01b0389811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6d919061312b565b505050506001600160801b031690506000611b9b88611b95848561275390919063ffffffff16565b90612814565b90508285600081518110611bb157611bb1612e19565b6001600160a01b0390921660209283029190910190910152611be8611bde82670de0b6b3a7640000613045565b611b958b84612753565b86600081518110611bfb57611bfb612e19565b60200260200101818152505086611c13576000611c15565b885b86600081518110611c2857611c28612e19565b6020026020010151611c3a9190612ed4565b604051602481019190915233604482015260640160408051601f198184030181529190526020810180516001600160e01b0316636e553f6560e01b17905284518590600090611c8b57611c8b612e19565b602002602001018190525085600081518110611ca957611ca9612e19565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316633545906160e21b179052845185906001908110611d3657611d36612e19565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3087898e89604051602001611d86929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401611db49493929190612fa9565b600060405180830381600087803b158015611dce57600080fd5b505af1158015611de2573d6000803e3d6000fd5b5050505050505050505050505050565b604051638e8f294b60e01b81526001600160a01b0382811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611e5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e81919061312b565b50935050505080611ea5576040516334b04fe360e11b815260040160405180910390fd5b611eea82600019846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611957573d6000803e3d6000fd5b5050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611f2657611f266131a5565b60008082806020019051810190611f3d91906131bb565b9150915060005b8151811015611f9c57611f93828281518110611f6257611f62612e19565b602002602001015160405180602001604052806000815250856001600160a01b03166128299092919063ffffffff16565b50600101611f44565b50505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081612003579050509050866001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612058573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207c9190612dfc565b8260008151811061208f5761208f612e19565b60200260200101906001600160a01b031690816001600160a01b0316815250508560000361224a57604051632f2e037160e11b81523360048201526000906001600160a01b03891690635e5c06e290602401606060405180830381865afa1580156120fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121229190613058565b925050506001600160a01b0388166347dffde061213f8388612753565b6040518263ffffffff1660e01b815260040161215d91815260200190565b602060405180830381865afa15801561217a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219e9190612e53565b846000815181106121b1576121b1612e19565b602002602001018181525050836000815181106121d0576121d0612e19565b6020026020010151336040516024016121fc9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529190526020810180516001600160e01b031663acb7081560e01b1790528251839060009061223957612239612e19565b6020026020010181905250506122e6565b6000612257888887612432565b8560008151811061226a5761226a612e19565b602090810291909101019190915260405160248101899052604481018290526064810188905233608482015290915060a40160408051601f198184030181529190526020810180516001600160e01b0316633c6f317f60e01b179052825183906000906122d9576122d9612e19565b6020026020010181905250505b826000815181106122f9576122f9612e19565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316632d182be560e21b17905281518290600190811061238657612386612e19565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3084868b866040516020016123d6929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016124049493929190612fa9565b600060405180830381600087803b15801561241e57600080fd5b505af1158015610e51573d6000803e3d6000fd5b600080612452604051806040016040528060008152602001600081525090565b60405163d2681a0b60e01b8152600481018690523360248201526001600160a01b0387169063d2681a0b906044016040805180830381865afa15801561249c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c09190612e2f565b60208301528152670de0b6b3a764000084106124ec57602081015181516124e79190612ed4565b612507565b602081015181516125079161250091612ed4565b8590612753565b91508442101561268f5761253c6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018790526001600160a01b03881690634e7c505990602401608060405180830381865afa158015612581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a591906132be565b60608501819052604085019190915260208401919091529082526125e8906125cd9042613045565b60608301516125dc9089613045565b60408401519190612840565b816040018181516125f99190613045565b905250600061267961260b848661285f565b60000151896001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561264d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126719190612e53565b8491906128af565b5090506126868185613045565b9450505061271c565b61270f866001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f49190612e53565b6126fe8742613045565b6127089190612ea4565b8390612753565b6127199083612ed4565b92505b50935093915050565b82820281151584158583048514171661273d57600080fd5b6001826001830304018115150290509392505050565b60006127688383670de0b6b3a7640000612840565b90505b92915050565b600060405163095ea7b360e01b6000528360045282602452602060006044600080895af13d15601f3d11600160005114161716915060006060528060405250806127ba57600080fd5b50505050565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d116001600051141617169150600060605280604052508061280d57600080fd5b5050505050565b600061276883670de0b6b3a764000084612840565b606061283884846000856128f6565b949350505050565b82820281151584158583048514171661285857600080fd5b0492915050565b6040805180820190915260008082526020820152825160208401516000916128939161288b9082612ed4565b859190612840565b80855290506128a28184613045565b6020850152509192915050565b60008060006128bd8661297f565b9050801561271c576128de6128d2868361299e565b60408801519083612840565b92506128ea8385612753565b91506127198284613045565b60608247101561290557600080fd5b600080866001600160a01b0316858760405161292191906132f4565b60006040518083038185875af1925050503d806000811461295e576040519150601f19603f3d011682016040523d82523d6000602084013e612963565b606091505b5091509150612974878383876129b4565b979650505050505050565b8051602082015160009190612994828261299e565b6128389083613045565b60008183106129ad5781612768565b5090919050565b606083156129e05782516000036129d9576001600160a01b0385163b6129d957600080fd5b5081612838565b61283883838151156100a95781518083602001fd5b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03811681146119e557600080fd5b60008060008060008060c08789031215612a6057600080fd5b8635612a6b81612a32565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b60008060008060808587031215612aa957600080fd5b8435612ab481612a32565b966020860135965060408601359560600135945092505050565b602080825282518282018190526000919060409081850190868401855b82811015612b1957815180516001600160a01b03168552860151868501529284019290850190600101612aeb565b5091979650505050505050565b80151581146119e557600080fd5b60008060008060808587031215612b4a57600080fd5b8435612b5581612a32565b935060208501359250604085013591506060850135612b7381612b26565b939692955090935050565b600060208284031215612b9057600080fd5b8135612b9b81612a32565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612be157612be1612ba2565b604052919050565b600067ffffffffffffffff821115612c0357612c03612ba2565b5060051b60200190565b600082601f830112612c1e57600080fd5b81356020612c33612c2e83612be9565b612bb8565b82815260059290921b84018101918181019086841115612c5257600080fd5b8286015b84811015612c6d5780358352918301918301612c56565b509695505050505050565b600067ffffffffffffffff821115612c9257612c92612ba2565b50601f01601f191660200190565b600082601f830112612cb157600080fd5b8135612cbf612c2e82612c78565b818152846020838601011115612cd457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612d0757600080fd5b843567ffffffffffffffff80821115612d1f57600080fd5b818701915087601f830112612d3357600080fd5b81356020612d43612c2e83612be9565b82815260059290921b8401810191818101908b841115612d6257600080fd5b948201945b83861015612d89578535612d7a81612a32565b82529482019490820190612d67565b98505088013592505080821115612d9f57600080fd5b612dab88838901612c0d565b94506040870135915080821115612dc157600080fd5b612dcd88838901612c0d565b93506060870135915080821115612de357600080fd5b50612df087828801612ca0565b91505092959194509250565b600060208284031215612e0e57600080fd5b8151612b9b81612a32565b634e487b7160e01b600052603260045260246000fd5b60008060408385031215612e4257600080fd5b505080516020909101519092909150565b600060208284031215612e6557600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082612e9f57634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761276b5761276b612e6c565b600060018201612ecd57612ecd612e6c565b5060010190565b8082018082111561276b5761276b612e6c565b60005b83811015612f02578181015183820152602001612eea565b50506000910152565b60008151808452612f23816020860160208601612ee7565b601f01601f19169290920160200192915050565b60006040820160018060a01b0385168352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015612f9b57605f19888703018452612f89868351612f0b565b95509284019290840190600101612f6d565b509398975050505050505050565b6001600160a01b0385811682526080602080840182905286519184018290526000928782019290919060a0860190855b81811015612ff7578551851683529483019491830191600101612fd9565b5050858103604087015287518082529082019350915080870160005b8381101561302f57815185529382019390820190600101613013565b5050505082810360608401526129748185612f0b565b8181038181111561276b5761276b612e6c565b60008060006060848603121561306d57600080fd5b8351925060208401519150604084015190509250925092565b6000602080838503121561309957600080fd5b825167ffffffffffffffff8111156130b057600080fd5b8301601f810185136130c157600080fd5b80516130cf612c2e82612be9565b81815260059190911b820183019083810190878311156130ee57600080fd5b928401925b8284101561297457835161310681612a32565b825292840192908401906130f3565b805160ff8116811461312657600080fd5b919050565b600080600080600060a0868803121561314357600080fd5b85516001600160801b038116811461315a57600080fd5b945061316860208701613115565b935061317660408701613115565b9250606086015161318681612b26565b608087015190925061319781612a32565b809150509295509295909350565b634e487b7160e01b600052600160045260246000fd5b60008060408084860312156131cf57600080fd5b83516131da81612a32565b8093505060208085015167ffffffffffffffff808211156131fa57600080fd5b818701915087601f83011261320e57600080fd5b815161321c612c2e82612be9565b81815260059190911b8301840190848101908a83111561323b57600080fd5b8585015b838110156132ac578051858111156132575760008081fd5b8601603f81018d136132695760008081fd5b87810151613279612c2e82612c78565b8181528e8b83850101111561328e5760008081fd5b61329d828b83018d8601612ee7565b8552505091860191860161323f565b50809750505050505050509250929050565b600080600080608085870312156132d457600080fd5b505082516020840151604085015160609095015191969095509092509050565b60008251613306818460208701612ee7565b919091019291505056fea2646970667358221220e0f1ae525678d5c77c1167f738b59b8b2e8df0e89b25752b40026139344dfa4f64736f6c63430008110033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a95760003560e01c8063743753591161007157806374375359146101545780638129fc1c14610169578063912019c914610171578063daea85c514610184578063f04f270714610197578063fad6cf0f146101aa57600080fd5b8063158274a5146100ae57806333195347146100f25780633e256402146101075780633ec045a61461011a57806340c714ce14610141575b600080fd5b6100d57f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b610105610100366004612a47565b6101bd565b005b610105610115366004612a93565b61080f565b6100d57f000000000000000000000000000000000000000000000000000000000000000081565b61010561014f366004612a93565b610e5e565b61015c611525565b6040516100e99190612ace565b6101056117e4565b61010561017f366004612b34565b6119e8565b610105610192366004612b7e565b611df2565b6101056101a5366004612cf1565b611eee565b6101056101b8366004612a93565b611fa5565b604080516001808252818301909252600091602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337019050509050606061020c6129f5565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561024a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061026e9190612dfc565b8360008151811061028157610281612e19565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018a9052336024820152908b169063d2681a0b906044016040805180830381865afa1580156102da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102fe9190612e2f565b60a083015260808201526103138a8a87612432565b8252602082015282516103d690600190859060009061033457610334612e19565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa1580156103a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ca9190612e53565b60208401519190612725565b6060820181905260011080156103eb57508789145b1561040957604051631cc6a69960e11b815260040160405180910390fd5b6060810151602082015161041f91600190612725565b8460008151811061043257610432612e19565b60209081029190910101526060810151815161044e9190612e82565b81526060810151610460906002612ea4565b67ffffffffffffffff81111561047857610478612ba2565b6040519080825280602002602001820160405280156104ab57816020015b60608152602001906001900390816104965790505b50600060c083015291505b80606001518160c001511015610638578051604051602481018b90526044810191909152600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b17905282018051849161052482612ebb565b90528151811061053657610536612e19565b6020026020010181905250878460008151811061055557610555612e19565b602002602001015160001983606001518460c0015160016105769190612ed4565b1461058157306105a3565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b17905282018051849161060b82612ebb565b90528151811061061d5761061d612e19565b602090810291909101015260c08101805160010190526104b6565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3085878e8760405160200161067d929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016106ab9493929190612fa9565b600060405180830381600087803b1580156106c557600080fd5b505af11580156106d9573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038d169063d2681a0b906044016040805180830381865afa15801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190612e2f565b915091508260a00151836080015160001961076b9190613045565b6107759190613045565b8810610783576000196107a1565b60a08301516080840151610797908a612ed4565b6107a19190612ed4565b6107ab8284612ed4565b11806107e3575060808301516107c390600019613045565b89106107d1576000196107e0565b60808301516107e0908a612ed4565b82115b1561080157604051632c1b6b4160e21b815260040160405180910390fd5b505050505050505050505050565b604080516001808252818301909252600091602080830190803683375050604080516001808252818301909252929350600092915060208083019080368337019050509050606061085e6129f5565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561089c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c09190612dfc565b836000815181106108d3576108d3612e19565b6001600160a01b039283166020918202929092010152604051632f2e037160e11b81523360048201526000918a1690635e5c06e290602401606060405180830381865afa158015610928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094c9190613058565b60405163023effef60e51b8152600481018290529093506001600160a01b038c1692506347dffde09150602401602060405180830381865afa158015610996573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ba9190612e53565b60808301526000806109cd8b8b8a612432565b91509150610a876001876000815181106109e9576109e9612e19565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015610a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7f9190612e53565b849190612725565b60608501819052610a989082612e82565b9050610ab460018560600151846127259092919063ffffffff16565b87600081518110610ac757610ac7612e19565b60209081029190910101526060840151610ae2906002612ea4565b67ffffffffffffffff811115610afa57610afa612ba2565b604051908082528060200260200182016040528015610b2d57816020015b6060815260200190600190039081610b185790505b50600060c086015294505b83606001518460c001511015610ca657604051602481018b905260448101829052600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b179052850180518791610ba382612ebb565b905281518110610bb557610bb5612e19565b602002602001018190525086600081518110610bd357610bd3612e19565b602002602001015184606001518560c001516001610bf19190612ed4565b14610bfc5730610c1e565b7f00000000000000000000000000000000000000000000000000000000000000005b60405160248101929092526001600160a01b0316604482015233606482015260840160408051601f198184030181529181526020820180516001600160e01b0316633545906160e21b179052850180518791610c7982612ebb565b905281518110610c8b57610c8b612e19565b602090810291909101015260c0840180516001019052610b38565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e30888a8f8a604051602001610ceb929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401610d199493929190612fa9565b600060405180830381600087803b158015610d3357600080fd5b505af1158015610d47573d6000803e3d6000fd5b5050604051632f2e037160e11b81523360048201526001600160a01b038e169250635e5c06e29150602401606060405180830381865afa158015610d8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db39190613058565b608087015160405163023effef60e51b81526004810183905291965092506001600160a01b038e1691506347dffde090602401602060405180830381865afa158015610e03573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e279190612e53565b610e319190613045565b891015610e5157604051632c1b6b4160e21b815260040160405180910390fd5b5050505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090506060610ead6129f5565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0f9190612dfc565b83600081518110610f2257610f22612e19565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018990523360248201529089169063d2681a0b906044016040805180830381865afa158015610f7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9f9190612e2f565b60a08301526080820152604051632f2e037160e11b81523360048201526000906001600160a01b038a1690635e5c06e290602401606060405180830381865afa158015610ff0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110149190613058565b92505050886001600160a01b03166347dffde0670de0b6b3a7640000881061103c5782611046565b6110468389612753565b6040518263ffffffff1660e01b815260040161106491815260200190565b602060405180830381865afa158015611081573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a59190612e53565b8260200181815250506111686001856000815181106110c6576110c6612e19565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015611138573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061115c9190612e53565b60208501519190612725565b60608301819052602083015161118091600190612725565b8560008151811061119357611193612e19565b602090810291909101015260608201516111ae906002612ea4565b67ffffffffffffffff8111156111c6576111c6612ba2565b6040519080825280602002602001820160405280156111f957816020015b60608152602001906001900390816111e45790505b50600060c084015292505b81606001518260c0015110156113e95760c08201511561123757816060015182602001516112329190612e82565b611253565b8460008151811061124a5761124a612e19565b60200260200101515b604051602481019190915233604482015260640160408051601f198184030181529181526020820180516001600160e01b031663acb7081560e01b1790528301805185916112a082612ebb565b9052815181106112b2576112b2612e19565b60200260200101819052508782606001518360c0015160016112d49190612ed4565b146112f257826060015183602001516112ed9190612e82565b61130e565b8560008151811061130557611305612e19565b60200260200101515b60001984606001518560c0015160016113279190612ed4565b146113325730611354565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b1790528301805185916113bc82612ebb565b9052815181106113ce576113ce612e19565b602090810291909101015260c0820180516001019052611204565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3086888d8860405160200161142e929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161145c9493929190612fa9565b600060405180830381600087803b15801561147657600080fd5b505af115801561148a573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038c169063d2681a0b906044016040805180830381865afa1580156114dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115019190612e2f565b915091508360a001518460800151828461151b9190612ed4565b610e279190613045565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611587573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115af9190810190613086565b5190508067ffffffffffffffff8111156115cb576115cb612ba2565b60405190808252806020026020018201604052801561161057816020015b60408051808201909152600080825260208201528152602001906001900390816115e95790505b50915060005b818110156117df576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa158015611686573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116aa9190612dfc565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170b9190612dfc565b6040805180820182526001600160a01b0380841680835292516370a0823160e01b81527f00000000000000000000000000000000000000000000000000000000000000009091166004820152929350916020830191906370a0823190602401602060405180830381865afa158015611787573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ab9190612e53565b8152508483815181106117c0576117c0612e19565b60200260200101819052505080806117d790612ebb565b915050611616565b505090565b600054610100900460ff16158080156118045750600054600160ff909116105b8061181e5750303b15801561181e575060005460ff166001145b61182757600080fd5b6000805460ff19166001179055801561184a576000805461ff0019166101001790555b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156118aa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118d29190810190613086565b905060005b815181101561199d5761198b8282815181106118f5576118f5612e19565b602002602001015160001984848151811061191257611912612e19565b60200260200101516001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611957573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061197b9190612dfc565b6001600160a01b03169190612771565b8061199581612ebb565b9150506118d7565b505080156119e5576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081611a465790505090506000876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac19190612dfc565b90508415611ade57611ade6001600160a01b03821633308a6127c0565b604051638e8f294b60e01b81526001600160a01b0389811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6d919061312b565b505050506001600160801b031690506000611b9b88611b95848561275390919063ffffffff16565b90612814565b90508285600081518110611bb157611bb1612e19565b6001600160a01b0390921660209283029190910190910152611be8611bde82670de0b6b3a7640000613045565b611b958b84612753565b86600081518110611bfb57611bfb612e19565b60200260200101818152505086611c13576000611c15565b885b86600081518110611c2857611c28612e19565b6020026020010151611c3a9190612ed4565b604051602481019190915233604482015260640160408051601f198184030181529190526020810180516001600160e01b0316636e553f6560e01b17905284518590600090611c8b57611c8b612e19565b602002602001018190525085600081518110611ca957611ca9612e19565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316633545906160e21b179052845185906001908110611d3657611d36612e19565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3087898e89604051602001611d86929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b8152600401611db49493929190612fa9565b600060405180830381600087803b158015611dce57600080fd5b505af1158015611de2573d6000803e3d6000fd5b5050505050505050505050505050565b604051638e8f294b60e01b81526001600160a01b0382811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611e5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e81919061312b565b50935050505080611ea5576040516334b04fe360e11b815260040160405180910390fd5b611eea82600019846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611957573d6000803e3d6000fd5b5050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611f2657611f266131a5565b60008082806020019051810190611f3d91906131bb565b9150915060005b8151811015611f9c57611f93828281518110611f6257611f62612e19565b602002602001015160405180602001604052806000815250856001600160a01b03166128299092919063ffffffff16565b50600101611f44565b50505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081612003579050509050866001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612058573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207c9190612dfc565b8260008151811061208f5761208f612e19565b60200260200101906001600160a01b031690816001600160a01b0316815250508560000361224a57604051632f2e037160e11b81523360048201526000906001600160a01b03891690635e5c06e290602401606060405180830381865afa1580156120fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121229190613058565b925050506001600160a01b0388166347dffde061213f8388612753565b6040518263ffffffff1660e01b815260040161215d91815260200190565b602060405180830381865afa15801561217a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219e9190612e53565b846000815181106121b1576121b1612e19565b602002602001018181525050836000815181106121d0576121d0612e19565b6020026020010151336040516024016121fc9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529190526020810180516001600160e01b031663acb7081560e01b1790528251839060009061223957612239612e19565b6020026020010181905250506122e6565b6000612257888887612432565b8560008151811061226a5761226a612e19565b602090810291909101019190915260405160248101899052604481018290526064810188905233608482015290915060a40160408051601f198184030181529190526020810180516001600160e01b0316633c6f317f60e01b179052825183906000906122d9576122d9612e19565b6020026020010181905250505b826000815181106122f9576122f9612e19565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316632d182be560e21b17905281518290600190811061238657612386612e19565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3084868b866040516020016123d6929190612f37565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016124049493929190612fa9565b600060405180830381600087803b15801561241e57600080fd5b505af1158015610e51573d6000803e3d6000fd5b600080612452604051806040016040528060008152602001600081525090565b60405163d2681a0b60e01b8152600481018690523360248201526001600160a01b0387169063d2681a0b906044016040805180830381865afa15801561249c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c09190612e2f565b60208301528152670de0b6b3a764000084106124ec57602081015181516124e79190612ed4565b612507565b602081015181516125079161250091612ed4565b8590612753565b91508442101561268f5761253c6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018790526001600160a01b03881690634e7c505990602401608060405180830381865afa158015612581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125a591906132be565b60608501819052604085019190915260208401919091529082526125e8906125cd9042613045565b60608301516125dc9089613045565b60408401519190612840565b816040018181516125f99190613045565b905250600061267961260b848661285f565b60000151896001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561264d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126719190612e53565b8491906128af565b5090506126868185613045565b9450505061271c565b61270f866001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f49190612e53565b6126fe8742613045565b6127089190612ea4565b8390612753565b6127199083612ed4565b92505b50935093915050565b82820281151584158583048514171661273d57600080fd5b6001826001830304018115150290509392505050565b60006127688383670de0b6b3a7640000612840565b90505b92915050565b600060405163095ea7b360e01b6000528360045282602452602060006044600080895af13d15601f3d11600160005114161716915060006060528060405250806127ba57600080fd5b50505050565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d116001600051141617169150600060605280604052508061280d57600080fd5b5050505050565b600061276883670de0b6b3a764000084612840565b606061283884846000856128f6565b949350505050565b82820281151584158583048514171661285857600080fd5b0492915050565b6040805180820190915260008082526020820152825160208401516000916128939161288b9082612ed4565b859190612840565b80855290506128a28184613045565b6020850152509192915050565b60008060006128bd8661297f565b9050801561271c576128de6128d2868361299e565b60408801519083612840565b92506128ea8385612753565b91506127198284613045565b60608247101561290557600080fd5b600080866001600160a01b0316858760405161292191906132f4565b60006040518083038185875af1925050503d806000811461295e576040519150601f19603f3d011682016040523d82523d6000602084013e612963565b606091505b5091509150612974878383876129b4565b979650505050505050565b8051602082015160009190612994828261299e565b6128389083613045565b60008183106129ad5781612768565b5090919050565b606083156129e05782516000036129d9576001600160a01b0385163b6129d957600080fd5b5081612838565b61283883838151156100a95781518083602001fd5b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b03811681146119e557600080fd5b60008060008060008060c08789031215612a6057600080fd5b8635612a6b81612a32565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b60008060008060808587031215612aa957600080fd5b8435612ab481612a32565b966020860135965060408601359560600135945092505050565b602080825282518282018190526000919060409081850190868401855b82811015612b1957815180516001600160a01b03168552860151868501529284019290850190600101612aeb565b5091979650505050505050565b80151581146119e557600080fd5b60008060008060808587031215612b4a57600080fd5b8435612b5581612a32565b935060208501359250604085013591506060850135612b7381612b26565b939692955090935050565b600060208284031215612b9057600080fd5b8135612b9b81612a32565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612be157612be1612ba2565b604052919050565b600067ffffffffffffffff821115612c0357612c03612ba2565b5060051b60200190565b600082601f830112612c1e57600080fd5b81356020612c33612c2e83612be9565b612bb8565b82815260059290921b84018101918181019086841115612c5257600080fd5b8286015b84811015612c6d5780358352918301918301612c56565b509695505050505050565b600067ffffffffffffffff821115612c9257612c92612ba2565b50601f01601f191660200190565b600082601f830112612cb157600080fd5b8135612cbf612c2e82612c78565b818152846020838601011115612cd457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612d0757600080fd5b843567ffffffffffffffff80821115612d1f57600080fd5b818701915087601f830112612d3357600080fd5b81356020612d43612c2e83612be9565b82815260059290921b8401810191818101908b841115612d6257600080fd5b948201945b83861015612d89578535612d7a81612a32565b82529482019490820190612d67565b98505088013592505080821115612d9f57600080fd5b612dab88838901612c0d565b94506040870135915080821115612dc157600080fd5b612dcd88838901612c0d565b93506060870135915080821115612de357600080fd5b50612df087828801612ca0565b91505092959194509250565b600060208284031215612e0e57600080fd5b8151612b9b81612a32565b634e487b7160e01b600052603260045260246000fd5b60008060408385031215612e4257600080fd5b505080516020909101519092909150565b600060208284031215612e6557600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082612e9f57634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761276b5761276b612e6c565b600060018201612ecd57612ecd612e6c565b5060010190565b8082018082111561276b5761276b612e6c565b60005b83811015612f02578181015183820152602001612eea565b50506000910152565b60008151808452612f23816020860160208601612ee7565b601f01601f19169290920160200192915050565b60006040820160018060a01b0385168352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015612f9b57605f19888703018452612f89868351612f0b565b95509284019290840190600101612f6d565b509398975050505050505050565b6001600160a01b0385811682526080602080840182905286519184018290526000928782019290919060a0860190855b81811015612ff7578551851683529483019491830191600101612fd9565b5050858103604087015287518082529082019350915080870160005b8381101561302f57815185529382019390820190600101613013565b5050505082810360608401526129748185612f0b565b8181038181111561276b5761276b612e6c565b60008060006060848603121561306d57600080fd5b8351925060208401519150604084015190509250925092565b6000602080838503121561309957600080fd5b825167ffffffffffffffff8111156130b057600080fd5b8301601f810185136130c157600080fd5b80516130cf612c2e82612be9565b81815260059190911b820183019083810190878311156130ee57600080fd5b928401925b8284101561297457835161310681612a32565b825292840192908401906130f3565b805160ff8116811461312657600080fd5b919050565b600080600080600060a0868803121561314357600080fd5b85516001600160801b038116811461315a57600080fd5b945061316860208701613115565b935061317660408701613115565b9250606086015161318681612b26565b608087015190925061319781612a32565b809150509295509295909350565b634e487b7160e01b600052600160045260246000fd5b60008060408084860312156131cf57600080fd5b83516131da81612a32565b8093505060208085015167ffffffffffffffff808211156131fa57600080fd5b818701915087601f83011261320e57600080fd5b815161321c612c2e82612be9565b81815260059190911b8301840190848101908a83111561323b57600080fd5b8585015b838110156132ac578051858111156132575760008081fd5b8601603f81018d136132695760008081fd5b87810151613279612c2e82612c78565b8181528e8b83850101111561328e5760008081fd5b61329d828b83018d8601612ee7565b8552505091860191860161323f565b50809750505050505050509250929050565b600080600080608085870312156132d457600080fd5b505082516020840151604085015160609095015191969095509092509050565b60008251613306818460208701612ee7565b919091019291505056fea2646970667358221220e0f1ae525678d5c77c1167f738b59b8b2e8df0e89b25752b40026139344dfa4f64736f6c63430008110033", + "solcInputHash": "1d150c43eaec84155a253efe8f389af9", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"auditor_\",\"type\":\"address\"},{\"internalType\":\"contract IBalancerVault\",\"name\":\"balancerVault_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"Disagreement\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidOperation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MarketNotListed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"auditor\",\"outputs\":[{\"internalType\":\"contract Auditor\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"availableLiquidity\",\"outputs\":[{\"components\":[{\"internalType\":\"contract ERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"liquidity\",\"type\":\"uint256\"}],\"internalType\":\"struct DebtManager.AvailableAsset[]\",\"name\":\"availableAssets\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"balancerVault\",\"outputs\":[{\"internalType\":\"contract IBalancerVault\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"maturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"deleverage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"principal\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"targetHealthFactor\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"deposit\",\"type\":\"bool\"}],\"name\":\"leverage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract ERC20[]\",\"name\":\"\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256[]\",\"name\":\"\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes\",\"name\":\"userData\",\"type\":\"bytes\"}],\"name\":\"receiveFlashLoan\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRepayAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"rollFixed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"borrowMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRepayAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct Permit\",\"name\":\"p\",\"type\":\"tuple\"}],\"name\":\"rollFixed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRepayAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"rollFixedToFloating\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"repayMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRepayAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct Permit\",\"name\":\"p\",\"type\":\"tuple\"}],\"name\":\"rollFixedToFloating\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"borrowMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"}],\"name\":\"rollFloatingToFixed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract Market\",\"name\":\"market\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"borrowMaturity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxBorrowAssets\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"percentage\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"internalType\":\"struct Permit\",\"name\":\"p\",\"type\":\"tuple\"}],\"name\":\"rollFloatingToFixed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address)\":{\"details\":\"The Market must be listed by the Auditor in order to be valid for approval.\",\"params\":{\"market\":\"The Market to spend the contract's balance.\"}},\"constructor\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor\"},\"deleverage(address,uint256,uint256,uint256)\":{\"params\":{\"market\":\"The Market to deleverage the position out.\",\"maturity\":\"The maturity of the fixed pool that the position is being deleveraged out of, `0` if floating.\",\"maxAssets\":\"Max amount of fixed debt that the sender is willing to accept.\",\"percentage\":\"The percentage of the borrow that will be repaid, represented with 18 decimals.\"}},\"initialize()\":{\"details\":\"can only be called once.\"},\"leverage(address,uint256,uint256,bool)\":{\"params\":{\"deposit\":\"True if the principal is being deposited, false if the principal is already deposited.\",\"market\":\"The Market to leverage the position in.\",\"principal\":\"The amount of assets to deposit or deposited.\",\"targetHealthFactor\":\"The desired target health factor that the account will be leveraged to.\"}},\"receiveFlashLoan(address[],uint256[],uint256[],bytes)\":{\"details\":\"Only the Balancer Vault contract is allowed to call this function.\",\"params\":{\"userData\":\"Additional data provided by the borrower for the flash loan.\"}},\"rollFixed(address,uint256,uint256,uint256,uint256,uint256)\":{\"params\":{\"borrowMaturity\":\"The maturity of the fixed pool that the position is being rolled to.\",\"market\":\"The Market to roll the position in.\",\"maxBorrowAssets\":\"Max amount of debt that the sender is willing to accept to be borrowed.\",\"maxRepayAssets\":\"Max amount of debt that the account is willing to accept to be repaid.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\",\"repayMaturity\":\"The maturity of the fixed pool that the position is being rolled from.\"}},\"rollFixed(address,uint256,uint256,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))\":{\"params\":{\"borrowMaturity\":\"The maturity of the fixed pool that the position is being rolled to.\",\"market\":\"The Market to roll the position in.\",\"maxBorrowAssets\":\"Max amount of debt that the sender is willing to accept to be borrowed.\",\"maxRepayAssets\":\"Max amount of debt that the account is willing to accept to be repaid.\",\"p\":\"Arguments for the permit call to `market` on behalf of `permit.account`.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\",\"repayMaturity\":\"The maturity of the fixed pool that the position is being rolled from.\"}},\"rollFixedToFloating(address,uint256,uint256,uint256)\":{\"params\":{\"market\":\"The Market to roll the position in.\",\"maxRepayAssets\":\"Max amount of debt that the account is willing to accept to be repaid.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\",\"repayMaturity\":\"The maturity of the fixed pool that the position is being rolled from.\"}},\"rollFixedToFloating(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))\":{\"params\":{\"market\":\"The Market to roll the position in.\",\"maxRepayAssets\":\"Max amount of debt that the account is willing to accept to be repaid.\",\"p\":\"Arguments for the permit call to `market` on behalf of `permit.account`.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\",\"repayMaturity\":\"The maturity of the fixed pool that the position is being rolled from.\"}},\"rollFloatingToFixed(address,uint256,uint256,uint256)\":{\"params\":{\"borrowMaturity\":\"The maturity of the fixed pool that the position is being rolled to.\",\"market\":\"The Market to roll the position in.\",\"maxBorrowAssets\":\"Max amount of debt that the sender is willing to accept to be borrowed.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\"}},\"rollFloatingToFixed(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))\":{\"params\":{\"borrowMaturity\":\"The maturity of the fixed pool that the position is being rolled to.\",\"market\":\"The Market to roll the position in.\",\"maxBorrowAssets\":\"Max amount of debt that the sender is willing to accept to be borrowed.\",\"p\":\"Arguments for the permit call to `market` on behalf of `permit.account`.\",\"percentage\":\"The percentage of the position that will be rolled, represented with 18 decimals.\"}}},\"stateVariables\":{\"auditor\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"},\"balancerVault\":{\"custom:oz-upgrades-unsafe-allow\":\"state-variable-immutable\"}},\"title\":\"DebtManager\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"approve(address)\":{\"notice\":\"Approves the Market to spend the contract's balance of the underlying asset.\"},\"auditor()\":{\"notice\":\"Auditor contract that lists the markets that can be leveraged.\"},\"availableLiquidity()\":{\"notice\":\"Returns Balancer Vault's available liquidity of each enabled underlying asset.\"},\"balancerVault()\":{\"notice\":\"Balancer's vault contract that is used to take flash loans.\"},\"deleverage(address,uint256,uint256,uint256)\":{\"notice\":\"Deleverages the position of `msg.sender` a certain `percentage` by taking a flash loan from Balancer's vault to repay the borrow.\"},\"initialize()\":{\"notice\":\"Initializes the contract.\"},\"leverage(address,uint256,uint256,bool)\":{\"notice\":\"Leverages the floating position of `msg.sender` to match `targetHealthFactor` by taking a flash loan from Balancer's vault.\"},\"receiveFlashLoan(address[],uint256[],uint256[],bytes)\":{\"notice\":\"Callback function called by the Balancer Vault contract when a flash loan is initiated.\"},\"rollFixed(address,uint256,uint256,uint256,uint256,uint256)\":{\"notice\":\"Rolls a percentage of the fixed position of `msg.sender` to another fixed pool.\"},\"rollFixed(address,uint256,uint256,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))\":{\"notice\":\"Rolls a percentage of the fixed position of `msg.sender` to another fixed pool after calling `market.permit`.\"},\"rollFixedToFloating(address,uint256,uint256,uint256)\":{\"notice\":\"Rolls a percentage of the fixed position of `msg.sender` to a floating position.\"},\"rollFixedToFloating(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))\":{\"notice\":\"Rolls a percentage of the fixed position of `msg.sender` to a floating position after calling `market.permit`.\"},\"rollFloatingToFixed(address,uint256,uint256,uint256)\":{\"notice\":\"Rolls a percentage of the floating position of `msg.sender` to a fixed position.\"},\"rollFloatingToFixed(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))\":{\"notice\":\"Rolls a percentage of the floating position of `msg.sender` to a fixed position after calling `market.permit`.\"}},\"notice\":\"Contract for efficient debt management of accounts interacting with Exactly Protocol.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/periphery/DebtManager.sol\":\"DebtManager\"},\"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/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 { Market, ERC20, ERC4626, FixedLib, Disagreement } from \\\"../Market.sol\\\";\\nimport { Auditor, 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 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 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\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor(Auditor auditor_, IBalancerVault balancerVault_) {\\n auditor = auditor_;\\n balancerVault = balancerVault_;\\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++) {\\n markets[i].asset().safeApprove(address(markets[i]), type(uint256).max);\\n }\\n }\\n\\n /// @notice Leverages the floating position of `msg.sender` to match `targetHealthFactor` by taking a flash loan\\n /// from Balancer's vault.\\n /// @param market The Market to leverage the position in.\\n /// @param principal The amount of assets to deposit or deposited.\\n /// @param targetHealthFactor The desired target health factor that the account will be leveraged to.\\n /// @param deposit True if the principal is being deposited, false if the principal is already deposited.\\n function leverage(Market market, uint256 principal, uint256 targetHealthFactor, bool deposit) external {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls = new bytes[](2);\\n ERC20 asset = market.asset();\\n\\n if (deposit) asset.safeTransferFrom(msg.sender, address(this), principal);\\n\\n (uint256 adjustFactor, , , , ) = auditor.markets(market);\\n uint256 factor = adjustFactor.mulWadDown(adjustFactor).divWadDown(targetHealthFactor);\\n tokens[0] = asset;\\n amounts[0] = principal.mulWadDown(factor).divWadDown(1e18 - factor);\\n calls[0] = abi.encodeCall(ERC4626.deposit, (amounts[0] + (deposit ? principal : 0), msg.sender));\\n calls[1] = abi.encodeCall(Market.borrow, (amounts[0], address(balancerVault), msg.sender));\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, call(abi.encode(market, calls)));\\n }\\n\\n /// @notice Deleverages the position of `msg.sender` a certain `percentage` by taking a flash loan from\\n /// Balancer's vault to repay the borrow.\\n /// @param market The Market to deleverage the position out.\\n /// @param maturity The maturity of the fixed pool that the position is being deleveraged out of, `0` if floating.\\n /// @param maxAssets Max amount of fixed debt that the sender is willing to accept.\\n /// @param percentage The percentage of the borrow that will be repaid, represented with 18 decimals.\\n function deleverage(Market market, uint256 maturity, uint256 maxAssets, uint256 percentage) external {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls = new bytes[](2);\\n tokens[0] = market.asset();\\n\\n if (maturity == 0) {\\n (, , uint256 floatingBorrowShares) = market.accounts(msg.sender);\\n amounts[0] = market.previewRefund(floatingBorrowShares.mulWadDown(percentage));\\n calls[0] = abi.encodeCall(Market.repay, (amounts[0], msg.sender));\\n } else {\\n uint256 positionAssets;\\n (amounts[0], positionAssets) = repayAtMaturityAssets(market, maturity, percentage);\\n calls[0] = abi.encodeCall(Market.repayAtMaturity, (maturity, positionAssets, maxAssets, msg.sender));\\n }\\n calls[1] = abi.encodeCall(Market.withdraw, (amounts[0], address(balancerVault), msg.sender));\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, call(abi.encode(market, calls)));\\n }\\n\\n /// @notice Rolls a percentage of the floating position of `msg.sender` 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 {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls;\\n RollVars memory r;\\n tokens[0] = market.asset();\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, msg.sender);\\n (, , uint256 floatingBorrowShares) = market.accounts(msg.sender);\\n r.repayAssets = market.previewRefund(\\n percentage < 1e18 ? floatingBorrowShares.mulWadDown(percentage) : floatingBorrowShares\\n );\\n r.loopCount = r.repayAssets.mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n\\n amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.repay,\\n (r.i == 0 ? amounts[0] : r.repayAssets / r.loopCount, msg.sender)\\n );\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n r.i + 1 == r.loopCount ? amounts[0] : r.repayAssets / r.loopCount,\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n msg.sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, call(abi.encode(market, calls)));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, msg.sender);\\n if (maxBorrowAssets < newPrincipal + newFee - r.principal - r.fee) revert Disagreement();\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `msg.sender` 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 {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls;\\n RollVars memory r;\\n tokens[0] = market.asset();\\n\\n {\\n (, , uint256 floatingBorrowShares) = market.accounts(msg.sender);\\n r.principal = market.previewRefund(floatingBorrowShares);\\n }\\n (uint256 repayAssets, uint256 positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n r.loopCount = repayAssets.mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n positionAssets = positionAssets / r.loopCount;\\n\\n amounts[0] = repayAssets.mulDivUp(1, r.loopCount);\\n calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.repayAtMaturity,\\n (repayMaturity, positionAssets, type(uint256).max, msg.sender)\\n );\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.borrow,\\n (amounts[0], r.i + 1 == r.loopCount ? address(balancerVault) : address(this), msg.sender)\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n balancerVault.flashLoan(address(this), tokens, amounts, call(abi.encode(market, calls)));\\n {\\n (, , uint256 floatingBorrowShares) = market.accounts(msg.sender);\\n if (maxRepayAssets < market.previewRefund(floatingBorrowShares) - r.principal) revert Disagreement();\\n }\\n }\\n\\n /// @notice Rolls a percentage of the fixed position of `msg.sender` 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 {\\n uint256[] memory amounts = new uint256[](1);\\n ERC20[] memory tokens = new ERC20[](1);\\n bytes[] memory calls;\\n RollVars memory r;\\n tokens[0] = market.asset();\\n\\n (r.principal, r.fee) = market.fixedBorrowPositions(borrowMaturity, msg.sender);\\n (r.repayAssets, r.positionAssets) = repayAtMaturityAssets(market, repayMaturity, percentage);\\n\\n r.loopCount = r.repayAssets.mulDivUp(1, tokens[0].balanceOf(address(balancerVault)));\\n if (r.loopCount > 1 && repayMaturity == borrowMaturity) revert InvalidOperation();\\n\\n amounts[0] = r.repayAssets.mulDivUp(1, r.loopCount);\\n r.positionAssets = r.positionAssets / r.loopCount;\\n calls = new bytes[](2 * r.loopCount);\\n for (r.i = 0; r.i < r.loopCount; ) {\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.repayAtMaturity,\\n (repayMaturity, r.positionAssets, type(uint256).max, msg.sender)\\n );\\n calls[r.callIndex++] = abi.encodeCall(\\n Market.borrowAtMaturity,\\n (\\n borrowMaturity,\\n amounts[0],\\n type(uint256).max,\\n r.i + 1 == r.loopCount ? address(balancerVault) : address(this),\\n msg.sender\\n )\\n );\\n unchecked {\\n ++r.i;\\n }\\n }\\n\\n balancerVault.flashLoan(address(this), tokens, amounts, call(abi.encode(market, calls)));\\n (uint256 newPrincipal, uint256 newFee) = market.fixedBorrowPositions(borrowMaturity, msg.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 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, msg.sender);\\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 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 Calls `token.permit` on behalf of `permit.account`.\\n /// @param token The `ERC20` to call `permit`.\\n /// @param p Arguments for the permit call.\\n modifier permit(\\n ERC20 token,\\n uint256 assets,\\n Permit calldata p\\n ) {\\n token.permit(p.account, address(this), assets, p.deadline, p.v, p.r, p.s);\\n _;\\n }\\n\\n /// @notice Rolls a percentage of the floating position of `msg.sender` 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 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 Rolls a percentage of the fixed position of `msg.sender` 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 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 fixed position of `msg.sender` 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 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 Returns Balancer Vault's available liquidity of each enabled underlying asset.\\n function availableLiquidity() external view returns (AvailableAsset[] memory availableAssets) {\\n uint256 marketsCount = auditor.allMarkets().length;\\n availableAssets = new AvailableAsset[](marketsCount);\\n\\n for (uint256 i = 0; i < marketsCount; i++) {\\n ERC20 asset = auditor.marketList(i).asset();\\n availableAssets[i] = AvailableAsset({ asset: asset, liquidity: asset.balanceOf(address(balancerVault)) });\\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) external {\\n (, , , bool isListed, ) = auditor.markets(market);\\n if (!isListed) revert MarketNotListed();\\n\\n market.asset().safeApprove(address(market), type(uint256).max);\\n }\\n\\n struct AvailableAsset {\\n ERC20 asset;\\n uint256 liquidity;\\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 RollVars {\\n uint256 positionAssets;\\n uint256 repayAssets;\\n uint256 callIndex;\\n uint256 loopCount;\\n uint256 principal;\\n uint256 fee;\\n uint256 i;\\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\",\"keccak256\":\"0x99c3d592ec90f717b653aedd0729f3ffafe54042383fbd051cb42d128e9eccc6\",\"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": "0x60c06040523480156200001157600080fd5b50604051620038b7380380620038b78339810160408190526200003491620000dd565b6001600160a01b03808316608052811660a0526200005162000059565b50506200011c565b600054610100900460ff16156200006f57600080fd5b60005460ff9081161015620000c2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6001600160a01b0381168114620000da57600080fd5b50565b60008060408385031215620000f157600080fd5b8251620000fe81620000c4565b60208401519092506200011181620000c4565b809150509250929050565b60805160a0516136ea620001cd6000396000818160f4015281816103d0015281816105fd015281816106b401528181610a9601528181610c8901528181610d330152818161116a015281816113b60152818161146d015281816117a601528181611d3f01528181611db9015281816120b0015281816125980152612612015260008181610160015281816115a1015281816116ad015281816118c401528181611b760152611f2801526136ea6000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063912019c91161008c578063e4a3434c11610066578063e4a3434c146101eb578063f04f2707146101fe578063f3e3c11114610211578063fad6cf0f1461022457600080fd5b8063912019c9146101b2578063cc7e37d9146101c5578063daea85c5146101d857600080fd5b80633ec045a6116100c85780633ec045a61461015b57806340c714ce1461018257806374375359146101955780638129fc1c146101aa57600080fd5b8063158274a5146100ef57806320ba6def146101335780633e25640214610148575b600080fd5b6101167f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b610146610141366004612cba565b610237565b005b610146610156366004612d06565b610899565b6101167f000000000000000000000000000000000000000000000000000000000000000081565b610146610190366004612d06565b610ee0565b61019d61159b565b60405161012a9190612d41565b61014661185a565b6101466101c0366004612da7565b611a5e565b6101466101d3366004612e09565b611e5c565b6101466101e6366004612e5d565b611f06565b6101466101f9366004612e09565b612002565b61014661020c366004612fd0565b6120a2565b61014661021f3660046130db565b612176565b610146610232366004612d06565b612224565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090506060610286612c68565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e89190613142565b836000815181106102fb576102fb61315f565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018a9052336024820152908b169063d2681a0b906044016040805180830381865afa158015610354573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103789190613175565b60a0830152608082015261038d8a8a876126a5565b8252602082015282516104509060019085906000906103ae576103ae61315f565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015610420573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104449190613199565b60208401519190612998565b60608201819052600110801561046557508789145b1561048357604051631cc6a69960e11b815260040160405180910390fd5b6060810151602082015161049991600190612998565b846000815181106104ac576104ac61315f565b6020908102919091010152606081015181516104c891906131c8565b815260608101516104da9060026131ea565b67ffffffffffffffff8111156104f2576104f2612e81565b60405190808252806020026020018201604052801561052557816020015b60608152602001906001900390816105105790505b50600060c083015291505b80606001518160c0015110156106b2578051604051602481018b90526044810191909152600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b17905282018051849161059e82613201565b9052815181106105b0576105b061315f565b602002602001018190525087846000815181106105cf576105cf61315f565b602002602001015160001983606001518460c0015160016105f0919061321a565b146105fb573061061d565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b17905282018051849161068582613201565b9052815181106106975761069761315f565b602090810291909101015260c0810180516001019052610530565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3085876107168f886040516020016106fa92919061327d565b6040516020818303038152906040528051602082012060015590565b6040518563ffffffff1660e01b815260040161073594939291906132ef565b600060405180830381600087803b15801561074f57600080fd5b505af1158015610763573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038d169063d2681a0b906044016040805180830381865afa1580156107b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107da9190613175565b915091508260a0015183608001516000196107f5919061338b565b6107ff919061338b565b881061080d5760001961082b565b60a08301516080840151610821908a61321a565b61082b919061321a565b610835828461321a565b118061086d5750608083015161084d9060001961338b565b891061085b5760001961086a565b608083015161086a908a61321a565b82115b1561088b57604051632c1b6b4160e21b815260040160405180910390fd5b505050505050505050505050565b60408051600180825281830190925260009160208083019080368337505060408051600180825281830190925292935060009291506020808301908036833701905050905060606108e8612c68565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610926573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094a9190613142565b8360008151811061095d5761095d61315f565b6001600160a01b039283166020918202929092010152604051632f2e037160e11b81523360048201526000918a1690635e5c06e290602401606060405180830381865afa1580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d6919061339e565b60405163023effef60e51b8152600481018290529093506001600160a01b038c1692506347dffde09150602401602060405180830381865afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a449190613199565b608083015250600080610a588a8a896126a5565b91509150610b12600186600081518110610a7457610a7461315f565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015610ae6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0a9190613199565b849190612998565b60608401819052610b2390826131c8565b9050610b3f60018460600151846129989092919063ffffffff16565b86600081518110610b5257610b5261315f565b60209081029190910101526060830151610b6d9060026131ea565b67ffffffffffffffff811115610b8557610b85612e81565b604051908082528060200260200182016040528015610bb857816020015b6060815260200190600190039081610ba35790505b50600060c085015293505b82606001518360c001511015610d3157604051602481018a905260448101829052600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b179052840180518691610c2e82613201565b905281518110610c4057610c4061315f565b602002602001018190525085600081518110610c5e57610c5e61315f565b602002602001015183606001518460c001516001610c7c919061321a565b14610c875730610ca9565b7f00000000000000000000000000000000000000000000000000000000000000005b60405160248101929092526001600160a01b0316604482015233606482015260840160408051601f198184030181529181526020820180516001600160e01b0316633545906160e21b179052840180518691610d0482613201565b905281518110610d1657610d1661315f565b602090810291909101015260c0830180516001019052610bc3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e308789610d798f8a6040516020016106fa92919061327d565b6040518563ffffffff1660e01b8152600401610d9894939291906132ef565b600060405180830381600087803b158015610db257600080fd5b505af1158015610dc6573d6000803e3d6000fd5b5050604051632f2e037160e11b8152336004820152600092506001600160a01b038d169150635e5c06e290602401606060405180830381865afa158015610e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e35919061339e565b608087015160405163023effef60e51b81526004810183905291945092506001600160a01b038e1691506347dffde090602401602060405180830381865afa158015610e85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea99190613199565b610eb3919061338b565b891015610ed357604051632c1b6b4160e21b815260040160405180910390fd5b5050505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090506060610f2f612c68565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f919190613142565b83600081518110610fa457610fa461315f565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018990523360248201529089169063d2681a0b906044016040805180830381865afa158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110219190613175565b60a08301526080820152604051632f2e037160e11b81523360048201526000906001600160a01b038a1690635e5c06e290602401606060405180830381865afa158015611072573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611096919061339e565b92505050886001600160a01b03166347dffde0670de0b6b3a764000088106110be57826110c8565b6110c883896129c6565b6040518263ffffffff1660e01b81526004016110e691815260200190565b602060405180830381865afa158015611103573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111279190613199565b8260200181815250506111ea6001856000815181106111485761114861315f565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa1580156111ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111de9190613199565b60208501519190612998565b60608301819052602083015161120291600190612998565b856000815181106112155761121561315f565b602090810291909101015260608201516112309060026131ea565b67ffffffffffffffff81111561124857611248612e81565b60405190808252806020026020018201604052801561127b57816020015b60608152602001906001900390816112665790505b50600060c084015292505b81606001518260c00151101561146b5760c0820151156112b957816060015182602001516112b491906131c8565b6112d5565b846000815181106112cc576112cc61315f565b60200260200101515b604051602481019190915233604482015260640160408051601f198184030181529181526020820180516001600160e01b031663acb7081560e01b17905283018051859161132282613201565b9052815181106113345761133461315f565b60200260200101819052508782606001518360c001516001611356919061321a565b14611374578260600151836020015161136f91906131c8565b611390565b856000815181106113875761138761315f565b60200260200101515b60001984606001518560c0015160016113a9919061321a565b146113b457306113d6565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b17905283018051859161143e82613201565b9052815181106114505761145061315f565b602090810291909101015260c0820180516001019052611286565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3086886114b38e896040516020016106fa92919061327d565b6040518563ffffffff1660e01b81526004016114d294939291906132ef565b600060405180830381600087803b1580156114ec57600080fd5b505af1158015611500573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038c169063d2681a0b906044016040805180830381865afa158015611553573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115779190613175565b915091508360a0015184608001518284611591919061321a565b610ea9919061338b565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156115fd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261162591908101906133cc565b5190508067ffffffffffffffff81111561164157611641612e81565b60405190808252806020026020018201604052801561168657816020015b604080518082019091526000808252602082015281526020019060019003908161165f5790505b50915060005b81811015611855576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa1580156116fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117209190613142565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117819190613142565b6040805180820182526001600160a01b0380841680835292516370a0823160e01b81527f00000000000000000000000000000000000000000000000000000000000000009091166004820152929350916020830191906370a0823190602401602060405180830381865afa1580156117fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118219190613199565b8152508483815181106118365761183661315f565b602002602001018190525050808061184d90613201565b91505061168c565b505090565b600054610100900460ff161580801561187a5750600054600160ff909116105b806118945750303b158015611894575060005460ff166001145b61189d57600080fd5b6000805460ff1916600117905580156118c0576000805461ff0019166101001790555b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611920573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261194891908101906133cc565b905060005b8151811015611a1357611a0182828151811061196b5761196b61315f565b60200260200101516000198484815181106119885761198861315f565b60200260200101516001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f19190613142565b6001600160a01b031691906129e4565b80611a0b81613201565b91505061194d565b50508015611a5b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081611abc5790505090506000876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b379190613142565b90508415611b5457611b546001600160a01b03821633308a612a33565b604051638e8f294b60e01b81526001600160a01b0389811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611bbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be3919061346a565b505050506001600160801b031690506000611c1188611c0b84856129c690919063ffffffff16565b90612a87565b90508285600081518110611c2757611c2761315f565b6001600160a01b0390921660209283029190910190910152611c5e611c5482670de0b6b3a764000061338b565b611c0b8b846129c6565b86600081518110611c7157611c7161315f565b60200260200101818152505086611c89576000611c8b565b885b86600081518110611c9e57611c9e61315f565b6020026020010151611cb0919061321a565b604051602481019190915233604482015260640160408051601f198184030181529190526020810180516001600160e01b0316636e553f6560e01b17905284518590600090611d0157611d0161315f565b602002602001018190525085600081518110611d1f57611d1f61315f565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316633545906160e21b179052845185906001908110611dac57611dac61315f565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e308789611dff8f8a6040516020016106fa92919061327d565b6040518563ffffffff1660e01b8152600401611e1e94939291906132ef565b600060405180830381600087803b158015611e3857600080fd5b505af1158015611e4c573d6000803e3d6000fd5b5050505050505050505050505050565b8483826001600160a01b03831663d505accf611e7b6020840184612e5d565b30856020860135611e9260608801604089016134eb565b876060013588608001356040518863ffffffff1660e01b8152600401611ebe9796959493929190613508565b600060405180830381600087803b158015611ed857600080fd5b505af1158015611eec573d6000803e3d6000fd5b50505050611efc88888888610ee0565b5050505050505050565b604051638e8f294b60e01b81526001600160a01b0382811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f95919061346a565b50935050505080611fb9576040516334b04fe360e11b815260040160405180910390fd5b611ffe82600019846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cd573d6000803e3d6000fd5b5050565b8483826001600160a01b03831663d505accf6120216020840184612e5d565b3085602086013561203860608801604089016134eb565b876060013588608001356040518863ffffffff1660e01b81526004016120649796959493929190613508565b600060405180830381600087803b15801561207e57600080fd5b505af1158015612092573d6000803e3d6000fd5b50505050611efc88888888610899565b600154336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156120dc57508015155b80156120ed57508151602083012081145b6120f9576120f9613549565b6000600181905582518190612117908501602090810190860161355f565b9150915060005b8151811015611efc5761216d82828151811061213c5761213c61315f565b602002602001015160405180602001604052806000815250856001600160a01b0316612a9c9092919063ffffffff16565b5060010161211e565b8683826001600160a01b03831663d505accf6121956020840184612e5d565b308560208601356121ac60608801604089016134eb565b876060013588608001356040518863ffffffff1660e01b81526004016121d89796959493929190613508565b600060405180830381600087803b1580156121f257600080fd5b505af1158015612206573d6000803e3d6000fd5b505050506122188a8a8a8a8a8a610237565b50505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081612282579050509050866001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122fb9190613142565b8260008151811061230e5761230e61315f565b60200260200101906001600160a01b031690816001600160a01b031681525050856000036124c957604051632f2e037160e11b81523360048201526000906001600160a01b03891690635e5c06e290602401606060405180830381865afa15801561237d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a1919061339e565b925050506001600160a01b0388166347dffde06123be83886129c6565b6040518263ffffffff1660e01b81526004016123dc91815260200190565b602060405180830381865afa1580156123f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241d9190613199565b846000815181106124305761243061315f565b6020026020010181815250508360008151811061244f5761244f61315f565b60200260200101513360405160240161247b9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529190526020810180516001600160e01b031663acb7081560e01b179052825183906000906124b8576124b861315f565b602002602001018190525050612565565b60006124d68888876126a5565b856000815181106124e9576124e961315f565b602090810291909101019190915260405160248101899052604481018290526064810188905233608482015290915060a40160408051601f198184030181529190526020810180516001600160e01b0316633c6f317f60e01b179052825183906000906125585761255861315f565b6020026020010181905250505b826000815181106125785761257861315f565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316632d182be560e21b1790528151829060019081106126055761260561315f565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3084866126588c876040516020016106fa92919061327d565b6040518563ffffffff1660e01b815260040161267794939291906132ef565b600060405180830381600087803b15801561269157600080fd5b505af1158015610ed3573d6000803e3d6000fd5b6000806126c5604051806040016040528060008152602001600081525090565b60405163d2681a0b60e01b8152600481018690523360248201526001600160a01b0387169063d2681a0b906044016040805180830381865afa15801561270f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127339190613175565b60208301528152670de0b6b3a7640000841061275f576020810151815161275a919061321a565b61277a565b6020810151815161277a916127739161321a565b85906129c6565b915084421015612902576127af6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018790526001600160a01b03881690634e7c505990602401608060405180830381865afa1580156127f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128189190613662565b606085018190526040850191909152602084019190915290825261285b90612840904261338b565b606083015161284f908961338b565b60408401519190612ab3565b8160400181815161286c919061338b565b90525060006128ec61287e8486612ad2565b60000151896001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e49190613199565b849190612b22565b5090506128f9818561338b565b9450505061298f565b612982866001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612943573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129679190613199565b612971874261338b565b61297b91906131ea565b83906129c6565b61298c908361321a565b92505b50935093915050565b8282028115158415858304851417166129b057600080fd5b6001826001830304018115150290509392505050565b60006129db8383670de0b6b3a7640000612ab3565b90505b92915050565b600060405163095ea7b360e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080612a2d57600080fd5b50505050565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d1160016000511416171691506000606052806040525080612a8057600080fd5b5050505050565b60006129db83670de0b6b3a764000084612ab3565b6060612aab8484600085612b69565b949350505050565b828202811515841585830485141716612acb57600080fd5b0492915050565b604080518082019091526000808252602082015282516020840151600091612b0691612afe908261321a565b859190612ab3565b8085529050612b15818461338b565b6020850152509192915050565b6000806000612b3086612bf2565b9050801561298f57612b51612b458683612c11565b60408801519083612ab3565b9250612b5d83856129c6565b915061298c828461338b565b606082471015612b7857600080fd5b600080866001600160a01b03168587604051612b949190613698565b60006040518083038185875af1925050503d8060008114612bd1576040519150601f19603f3d011682016040523d82523d6000602084013e612bd6565b606091505b5091509150612be787838387612c27565b979650505050505050565b8051602082015160009190612c078282612c11565b612aab908361338b565b6000818310612c2057816129db565b5090919050565b60608315612c53578251600003612c4c576001600160a01b0385163b612c4c57600080fd5b5081612aab565b612aab83838151156100ea5781518083602001fd5b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114611a5b57600080fd5b60008060008060008060c08789031215612cd357600080fd5b8635612cde81612ca5565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b60008060008060808587031215612d1c57600080fd5b8435612d2781612ca5565b966020860135965060408601359560600135945092505050565b602080825282518282018190526000919060409081850190868401855b82811015612d8c57815180516001600160a01b03168552860151868501529284019290850190600101612d5e565b5091979650505050505050565b8015158114611a5b57600080fd5b60008060008060808587031215612dbd57600080fd5b8435612dc881612ca5565b935060208501359250604085013591506060850135612de681612d99565b939692955090935050565b600060a08284031215612e0357600080fd5b50919050565b60008060008060006101208688031215612e2257600080fd5b8535612e2d81612ca5565b9450602086013593506040860135925060608601359150612e518760808801612df1565b90509295509295909350565b600060208284031215612e6f57600080fd5b8135612e7a81612ca5565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612ec057612ec0612e81565b604052919050565b600067ffffffffffffffff821115612ee257612ee2612e81565b5060051b60200190565b600082601f830112612efd57600080fd5b81356020612f12612f0d83612ec8565b612e97565b82815260059290921b84018101918181019086841115612f3157600080fd5b8286015b84811015612f4c5780358352918301918301612f35565b509695505050505050565b600067ffffffffffffffff821115612f7157612f71612e81565b50601f01601f191660200190565b600082601f830112612f9057600080fd5b8135612f9e612f0d82612f57565b818152846020838601011115612fb357600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612fe657600080fd5b843567ffffffffffffffff80821115612ffe57600080fd5b818701915087601f83011261301257600080fd5b81356020613022612f0d83612ec8565b82815260059290921b8401810191818101908b84111561304157600080fd5b948201945b8386101561306857853561305981612ca5565b82529482019490820190613046565b9850508801359250508082111561307e57600080fd5b61308a88838901612eec565b945060408701359150808211156130a057600080fd5b6130ac88838901612eec565b935060608701359150808211156130c257600080fd5b506130cf87828801612f7f565b91505092959194509250565b6000806000806000806000610160888a0312156130f757600080fd5b873561310281612ca5565b96506020880135955060408801359450606088013593506080880135925060a088013591506131348960c08a01612df1565b905092959891949750929550565b60006020828403121561315457600080fd5b8151612e7a81612ca5565b634e487b7160e01b600052603260045260246000fd5b6000806040838503121561318857600080fd5b505080516020909101519092909150565b6000602082840312156131ab57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000826131e557634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176129de576129de6131b2565b600060018201613213576132136131b2565b5060010190565b808201808211156129de576129de6131b2565b60005b83811015613248578181015183820152602001613230565b50506000910152565b6000815180845261326981602086016020860161322d565b601f01601f19169290920160200192915050565b60006040820160018060a01b0385168352602060408185015281855180845260608601915060608160051b870101935082870160005b828110156132e157605f198887030184526132cf868351613251565b955092840192908401906001016132b3565b509398975050505050505050565b6001600160a01b0385811682526080602080840182905286519184018290526000928782019290919060a0860190855b8181101561333d57855185168352948301949183019160010161331f565b5050858103604087015287518082529082019350915080870160005b8381101561337557815185529382019390820190600101613359565b505050508281036060840152612be78185613251565b818103818111156129de576129de6131b2565b6000806000606084860312156133b357600080fd5b8351925060208401519150604084015190509250925092565b600060208083850312156133df57600080fd5b825167ffffffffffffffff8111156133f657600080fd5b8301601f8101851361340757600080fd5b8051613415612f0d82612ec8565b81815260059190911b8201830190838101908783111561343457600080fd5b928401925b82841015612be757835161344c81612ca5565b82529284019290840190613439565b60ff81168114611a5b57600080fd5b600080600080600060a0868803121561348257600080fd5b85516001600160801b038116811461349957600080fd5b60208701519095506134aa8161345b565b60408701519094506134bb8161345b565b60608701519093506134cc81612d99565b60808701519092506134dd81612ca5565b809150509295509295909350565b6000602082840312156134fd57600080fd5b8135612e7a8161345b565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b634e487b7160e01b600052600160045260246000fd5b600080604080848603121561357357600080fd5b835161357e81612ca5565b8093505060208085015167ffffffffffffffff8082111561359e57600080fd5b818701915087601f8301126135b257600080fd5b81516135c0612f0d82612ec8565b81815260059190911b8301840190848101908a8311156135df57600080fd5b8585015b83811015613650578051858111156135fb5760008081fd5b8601603f81018d1361360d5760008081fd5b8781015161361d612f0d82612f57565b8181528e8b8385010111156136325760008081fd5b613641828b83018d860161322d565b855250509186019186016135e3565b50809750505050505050509250929050565b6000806000806080858703121561367857600080fd5b505082516020840151604085015160609095015191969095509092509050565b600082516136aa81846020870161322d565b919091019291505056fea26469706673582212205b8af7cdf1ab05f84e235026d3ac5798d4996351f7ba9a2f425aaebdbcceca1f64736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063912019c91161008c578063e4a3434c11610066578063e4a3434c146101eb578063f04f2707146101fe578063f3e3c11114610211578063fad6cf0f1461022457600080fd5b8063912019c9146101b2578063cc7e37d9146101c5578063daea85c5146101d857600080fd5b80633ec045a6116100c85780633ec045a61461015b57806340c714ce1461018257806374375359146101955780638129fc1c146101aa57600080fd5b8063158274a5146100ef57806320ba6def146101335780633e25640214610148575b600080fd5b6101167f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b610146610141366004612cba565b610237565b005b610146610156366004612d06565b610899565b6101167f000000000000000000000000000000000000000000000000000000000000000081565b610146610190366004612d06565b610ee0565b61019d61159b565b60405161012a9190612d41565b61014661185a565b6101466101c0366004612da7565b611a5e565b6101466101d3366004612e09565b611e5c565b6101466101e6366004612e5d565b611f06565b6101466101f9366004612e09565b612002565b61014661020c366004612fd0565b6120a2565b61014661021f3660046130db565b612176565b610146610232366004612d06565b612224565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090506060610286612c68565b896001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e89190613142565b836000815181106102fb576102fb61315f565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018a9052336024820152908b169063d2681a0b906044016040805180830381865afa158015610354573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103789190613175565b60a0830152608082015261038d8a8a876126a5565b8252602082015282516104509060019085906000906103ae576103ae61315f565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015610420573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104449190613199565b60208401519190612998565b60608201819052600110801561046557508789145b1561048357604051631cc6a69960e11b815260040160405180910390fd5b6060810151602082015161049991600190612998565b846000815181106104ac576104ac61315f565b6020908102919091010152606081015181516104c891906131c8565b815260608101516104da9060026131ea565b67ffffffffffffffff8111156104f2576104f2612e81565b60405190808252806020026020018201604052801561052557816020015b60608152602001906001900390816105105790505b50600060c083015291505b80606001518160c0015110156106b2578051604051602481018b90526044810191909152600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b17905282018051849161059e82613201565b9052815181106105b0576105b061315f565b602002602001018190525087846000815181106105cf576105cf61315f565b602002602001015160001983606001518460c0015160016105f0919061321a565b146105fb573061061d565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b17905282018051849161068582613201565b9052815181106106975761069761315f565b602090810291909101015260c0810180516001019052610530565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3085876107168f886040516020016106fa92919061327d565b6040516020818303038152906040528051602082012060015590565b6040518563ffffffff1660e01b815260040161073594939291906132ef565b600060405180830381600087803b15801561074f57600080fd5b505af1158015610763573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038d169063d2681a0b906044016040805180830381865afa1580156107b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107da9190613175565b915091508260a0015183608001516000196107f5919061338b565b6107ff919061338b565b881061080d5760001961082b565b60a08301516080840151610821908a61321a565b61082b919061321a565b610835828461321a565b118061086d5750608083015161084d9060001961338b565b891061085b5760001961086a565b608083015161086a908a61321a565b82115b1561088b57604051632c1b6b4160e21b815260040160405180910390fd5b505050505050505050505050565b60408051600180825281830190925260009160208083019080368337505060408051600180825281830190925292935060009291506020808301908036833701905050905060606108e8612c68565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610926573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094a9190613142565b8360008151811061095d5761095d61315f565b6001600160a01b039283166020918202929092010152604051632f2e037160e11b81523360048201526000918a1690635e5c06e290602401606060405180830381865afa1580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d6919061339e565b60405163023effef60e51b8152600481018290529093506001600160a01b038c1692506347dffde09150602401602060405180830381865afa158015610a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a449190613199565b608083015250600080610a588a8a896126a5565b91509150610b12600186600081518110610a7457610a7461315f565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa158015610ae6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0a9190613199565b849190612998565b60608401819052610b2390826131c8565b9050610b3f60018460600151846129989092919063ffffffff16565b86600081518110610b5257610b5261315f565b60209081029190910101526060830151610b6d9060026131ea565b67ffffffffffffffff811115610b8557610b85612e81565b604051908082528060200260200182016040528015610bb857816020015b6060815260200190600190039081610ba35790505b50600060c085015293505b82606001518360c001511015610d3157604051602481018a905260448101829052600019606482015233608482015260a40160408051601f198184030181529181526020820180516001600160e01b0316633c6f317f60e01b179052840180518691610c2e82613201565b905281518110610c4057610c4061315f565b602002602001018190525085600081518110610c5e57610c5e61315f565b602002602001015183606001518460c001516001610c7c919061321a565b14610c875730610ca9565b7f00000000000000000000000000000000000000000000000000000000000000005b60405160248101929092526001600160a01b0316604482015233606482015260840160408051601f198184030181529181526020820180516001600160e01b0316633545906160e21b179052840180518691610d0482613201565b905281518110610d1657610d1661315f565b602090810291909101015260c0830180516001019052610bc3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e308789610d798f8a6040516020016106fa92919061327d565b6040518563ffffffff1660e01b8152600401610d9894939291906132ef565b600060405180830381600087803b158015610db257600080fd5b505af1158015610dc6573d6000803e3d6000fd5b5050604051632f2e037160e11b8152336004820152600092506001600160a01b038d169150635e5c06e290602401606060405180830381865afa158015610e11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e35919061339e565b608087015160405163023effef60e51b81526004810183905291945092506001600160a01b038e1691506347dffde090602401602060405180830381865afa158015610e85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea99190613199565b610eb3919061338b565b891015610ed357604051632c1b6b4160e21b815260040160405180910390fd5b5050505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090506060610f2f612c68565b876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f919190613142565b83600081518110610fa457610fa461315f565b6001600160a01b03928316602091820292909201015260405163d2681a0b60e01b8152600481018990523360248201529089169063d2681a0b906044016040805180830381865afa158015610ffd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110219190613175565b60a08301526080820152604051632f2e037160e11b81523360048201526000906001600160a01b038a1690635e5c06e290602401606060405180830381865afa158015611072573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611096919061339e565b92505050886001600160a01b03166347dffde0670de0b6b3a764000088106110be57826110c8565b6110c883896129c6565b6040518263ffffffff1660e01b81526004016110e691815260200190565b602060405180830381865afa158015611103573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111279190613199565b8260200181815250506111ea6001856000815181106111485761114861315f565b60209081029190910101516040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152909116906370a0823190602401602060405180830381865afa1580156111ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111de9190613199565b60208501519190612998565b60608301819052602083015161120291600190612998565b856000815181106112155761121561315f565b602090810291909101015260608201516112309060026131ea565b67ffffffffffffffff81111561124857611248612e81565b60405190808252806020026020018201604052801561127b57816020015b60608152602001906001900390816112665790505b50600060c084015292505b81606001518260c00151101561146b5760c0820151156112b957816060015182602001516112b491906131c8565b6112d5565b846000815181106112cc576112cc61315f565b60200260200101515b604051602481019190915233604482015260640160408051601f198184030181529181526020820180516001600160e01b031663acb7081560e01b17905283018051859161132282613201565b9052815181106113345761133461315f565b60200260200101819052508782606001518360c001516001611356919061321a565b14611374578260600151836020015161136f91906131c8565b611390565b856000815181106113875761138761315f565b60200260200101515b60001984606001518560c0015160016113a9919061321a565b146113b457306113d6565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516024810194909452604484019290925260648301526001600160a01b031660848201523360a482015260c40160408051601f198184030181529181526020820180516001600160e01b0316630d2dcf3160e11b17905283018051859161143e82613201565b9052815181106114505761145061315f565b602090810291909101015260c0820180516001019052611286565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3086886114b38e896040516020016106fa92919061327d565b6040518563ffffffff1660e01b81526004016114d294939291906132ef565b600060405180830381600087803b1580156114ec57600080fd5b505af1158015611500573d6000803e3d6000fd5b505060405163d2681a0b60e01b8152600481018b9052336024820152600092508291506001600160a01b038c169063d2681a0b906044016040805180830381865afa158015611553573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115779190613175565b915091508360a0015184608001518284611591919061321a565b610ea9919061338b565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156115fd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261162591908101906133cc565b5190508067ffffffffffffffff81111561164157611641612e81565b60405190808252806020026020018201604052801561168657816020015b604080518082019091526000808252602082015281526020019060019003908161165f5790505b50915060005b81811015611855576040516308cae55b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063232b956c90602401602060405180830381865afa1580156116fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117209190613142565b6001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561175d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117819190613142565b6040805180820182526001600160a01b0380841680835292516370a0823160e01b81527f00000000000000000000000000000000000000000000000000000000000000009091166004820152929350916020830191906370a0823190602401602060405180830381865afa1580156117fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118219190613199565b8152508483815181106118365761183661315f565b602002602001018190525050808061184d90613201565b91505061168c565b505090565b600054610100900460ff161580801561187a5750600054600160ff909116105b806118945750303b158015611894575060005460ff166001145b61189d57600080fd5b6000805460ff1916600117905580156118c0576000805461ff0019166101001790555b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663375a7cba6040518163ffffffff1660e01b8152600401600060405180830381865afa158015611920573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261194891908101906133cc565b905060005b8151811015611a1357611a0182828151811061196b5761196b61315f565b60200260200101516000198484815181106119885761198861315f565b60200260200101516001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f19190613142565b6001600160a01b031691906129e4565b80611a0b81613201565b91505061194d565b50508015611a5b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081611abc5790505090506000876001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611b13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b379190613142565b90508415611b5457611b546001600160a01b03821633308a612a33565b604051638e8f294b60e01b81526001600160a01b0389811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611bbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be3919061346a565b505050506001600160801b031690506000611c1188611c0b84856129c690919063ffffffff16565b90612a87565b90508285600081518110611c2757611c2761315f565b6001600160a01b0390921660209283029190910190910152611c5e611c5482670de0b6b3a764000061338b565b611c0b8b846129c6565b86600081518110611c7157611c7161315f565b60200260200101818152505086611c89576000611c8b565b885b86600081518110611c9e57611c9e61315f565b6020026020010151611cb0919061321a565b604051602481019190915233604482015260640160408051601f198184030181529190526020810180516001600160e01b0316636e553f6560e01b17905284518590600090611d0157611d0161315f565b602002602001018190525085600081518110611d1f57611d1f61315f565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316633545906160e21b179052845185906001908110611dac57611dac61315f565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e308789611dff8f8a6040516020016106fa92919061327d565b6040518563ffffffff1660e01b8152600401611e1e94939291906132ef565b600060405180830381600087803b158015611e3857600080fd5b505af1158015611e4c573d6000803e3d6000fd5b5050505050505050505050505050565b8483826001600160a01b03831663d505accf611e7b6020840184612e5d565b30856020860135611e9260608801604089016134eb565b876060013588608001356040518863ffffffff1660e01b8152600401611ebe9796959493929190613508565b600060405180830381600087803b158015611ed857600080fd5b505af1158015611eec573d6000803e3d6000fd5b50505050611efc88888888610ee0565b5050505050505050565b604051638e8f294b60e01b81526001600160a01b0382811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638e8f294b9060240160a060405180830381865afa158015611f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f95919061346a565b50935050505080611fb9576040516334b04fe360e11b815260040160405180910390fd5b611ffe82600019846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119cd573d6000803e3d6000fd5b5050565b8483826001600160a01b03831663d505accf6120216020840184612e5d565b3085602086013561203860608801604089016134eb565b876060013588608001356040518863ffffffff1660e01b81526004016120649796959493929190613508565b600060405180830381600087803b15801561207e57600080fd5b505af1158015612092573d6000803e3d6000fd5b50505050611efc88888888610899565b600154336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480156120dc57508015155b80156120ed57508151602083012081145b6120f9576120f9613549565b6000600181905582518190612117908501602090810190860161355f565b9150915060005b8151811015611efc5761216d82828151811061213c5761213c61315f565b602002602001015160405180602001604052806000815250856001600160a01b0316612a9c9092919063ffffffff16565b5060010161211e565b8683826001600160a01b03831663d505accf6121956020840184612e5d565b308560208601356121ac60608801604089016134eb565b876060013588608001356040518863ffffffff1660e01b81526004016121d89796959493929190613508565b600060405180830381600087803b1580156121f257600080fd5b505af1158015612206573d6000803e3d6000fd5b505050506122188a8a8a8a8a8a610237565b50505050505050505050565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683375050604080516002808252606082019092529293506000929150602082015b6060815260200190600190039081612282579050509050866001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122fb9190613142565b8260008151811061230e5761230e61315f565b60200260200101906001600160a01b031690816001600160a01b031681525050856000036124c957604051632f2e037160e11b81523360048201526000906001600160a01b03891690635e5c06e290602401606060405180830381865afa15801561237d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a1919061339e565b925050506001600160a01b0388166347dffde06123be83886129c6565b6040518263ffffffff1660e01b81526004016123dc91815260200190565b602060405180830381865afa1580156123f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241d9190613199565b846000815181106124305761243061315f565b6020026020010181815250508360008151811061244f5761244f61315f565b60200260200101513360405160240161247b9291909182526001600160a01b0316602082015260400190565b60408051601f198184030181529190526020810180516001600160e01b031663acb7081560e01b179052825183906000906124b8576124b861315f565b602002602001018190525050612565565b60006124d68888876126a5565b856000815181106124e9576124e961315f565b602090810291909101019190915260405160248101899052604481018290526064810188905233608482015290915060a40160408051601f198184030181529190526020810180516001600160e01b0316633c6f317f60e01b179052825183906000906125585761255861315f565b6020026020010181905250505b826000815181106125785761257861315f565b602090810291909101015160405160248101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016604482015233606482015260840160408051601f198184030181529190526020810180516001600160e01b0316632d182be560e21b1790528151829060019081106126055761260561315f565b60200260200101819052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316635c38449e3084866126588c876040516020016106fa92919061327d565b6040518563ffffffff1660e01b815260040161267794939291906132ef565b600060405180830381600087803b15801561269157600080fd5b505af1158015610ed3573d6000803e3d6000fd5b6000806126c5604051806040016040528060008152602001600081525090565b60405163d2681a0b60e01b8152600481018690523360248201526001600160a01b0387169063d2681a0b906044016040805180830381865afa15801561270f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127339190613175565b60208301528152670de0b6b3a7640000841061275f576020810151815161275a919061321a565b61277a565b6020810151815161277a916127739161321a565b85906129c6565b915084421015612902576127af6040518060800160405280600081526020016000815260200160008152602001600081525090565b604051634e7c505960e01b8152600481018790526001600160a01b03881690634e7c505990602401608060405180830381865afa1580156127f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128189190613662565b606085018190526040850191909152602084019190915290825261285b90612840904261338b565b606083015161284f908961338b565b60408401519190612ab3565b8160400181815161286c919061338b565b90525060006128ec61287e8486612ad2565b60000151896001600160a01b031663a1e8f02b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e49190613199565b849190612b22565b5090506128f9818561338b565b9450505061298f565b612982866001600160a01b031663d6b7494f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612943573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129679190613199565b612971874261338b565b61297b91906131ea565b83906129c6565b61298c908361321a565b92505b50935093915050565b8282028115158415858304851417166129b057600080fd5b6001826001830304018115150290509392505050565b60006129db8383670de0b6b3a7640000612ab3565b90505b92915050565b600060405163095ea7b360e01b6000528360045282602452602060006044600080895af13d15601f3d1160016000511416171691506000606052806040525080612a2d57600080fd5b50505050565b60006040516323b872dd60e01b6000528460045283602452826044526020600060646000808a5af13d15601f3d1160016000511416171691506000606052806040525080612a8057600080fd5b5050505050565b60006129db83670de0b6b3a764000084612ab3565b6060612aab8484600085612b69565b949350505050565b828202811515841585830485141716612acb57600080fd5b0492915050565b604080518082019091526000808252602082015282516020840151600091612b0691612afe908261321a565b859190612ab3565b8085529050612b15818461338b565b6020850152509192915050565b6000806000612b3086612bf2565b9050801561298f57612b51612b458683612c11565b60408801519083612ab3565b9250612b5d83856129c6565b915061298c828461338b565b606082471015612b7857600080fd5b600080866001600160a01b03168587604051612b949190613698565b60006040518083038185875af1925050503d8060008114612bd1576040519150601f19603f3d011682016040523d82523d6000602084013e612bd6565b606091505b5091509150612be787838387612c27565b979650505050505050565b8051602082015160009190612c078282612c11565b612aab908361338b565b6000818310612c2057816129db565b5090919050565b60608315612c53578251600003612c4c576001600160a01b0385163b612c4c57600080fd5b5081612aab565b612aab83838151156100ea5781518083602001fd5b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6001600160a01b0381168114611a5b57600080fd5b60008060008060008060c08789031215612cd357600080fd5b8635612cde81612ca5565b9860208801359850604088013597606081013597506080810135965060a00135945092505050565b60008060008060808587031215612d1c57600080fd5b8435612d2781612ca5565b966020860135965060408601359560600135945092505050565b602080825282518282018190526000919060409081850190868401855b82811015612d8c57815180516001600160a01b03168552860151868501529284019290850190600101612d5e565b5091979650505050505050565b8015158114611a5b57600080fd5b60008060008060808587031215612dbd57600080fd5b8435612dc881612ca5565b935060208501359250604085013591506060850135612de681612d99565b939692955090935050565b600060a08284031215612e0357600080fd5b50919050565b60008060008060006101208688031215612e2257600080fd5b8535612e2d81612ca5565b9450602086013593506040860135925060608601359150612e518760808801612df1565b90509295509295909350565b600060208284031215612e6f57600080fd5b8135612e7a81612ca5565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612ec057612ec0612e81565b604052919050565b600067ffffffffffffffff821115612ee257612ee2612e81565b5060051b60200190565b600082601f830112612efd57600080fd5b81356020612f12612f0d83612ec8565b612e97565b82815260059290921b84018101918181019086841115612f3157600080fd5b8286015b84811015612f4c5780358352918301918301612f35565b509695505050505050565b600067ffffffffffffffff821115612f7157612f71612e81565b50601f01601f191660200190565b600082601f830112612f9057600080fd5b8135612f9e612f0d82612f57565b818152846020838601011115612fb357600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612fe657600080fd5b843567ffffffffffffffff80821115612ffe57600080fd5b818701915087601f83011261301257600080fd5b81356020613022612f0d83612ec8565b82815260059290921b8401810191818101908b84111561304157600080fd5b948201945b8386101561306857853561305981612ca5565b82529482019490820190613046565b9850508801359250508082111561307e57600080fd5b61308a88838901612eec565b945060408701359150808211156130a057600080fd5b6130ac88838901612eec565b935060608701359150808211156130c257600080fd5b506130cf87828801612f7f565b91505092959194509250565b6000806000806000806000610160888a0312156130f757600080fd5b873561310281612ca5565b96506020880135955060408801359450606088013593506080880135925060a088013591506131348960c08a01612df1565b905092959891949750929550565b60006020828403121561315457600080fd5b8151612e7a81612ca5565b634e487b7160e01b600052603260045260246000fd5b6000806040838503121561318857600080fd5b505080516020909101519092909150565b6000602082840312156131ab57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000826131e557634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176129de576129de6131b2565b600060018201613213576132136131b2565b5060010190565b808201808211156129de576129de6131b2565b60005b83811015613248578181015183820152602001613230565b50506000910152565b6000815180845261326981602086016020860161322d565b601f01601f19169290920160200192915050565b60006040820160018060a01b0385168352602060408185015281855180845260608601915060608160051b870101935082870160005b828110156132e157605f198887030184526132cf868351613251565b955092840192908401906001016132b3565b509398975050505050505050565b6001600160a01b0385811682526080602080840182905286519184018290526000928782019290919060a0860190855b8181101561333d57855185168352948301949183019160010161331f565b5050858103604087015287518082529082019350915080870160005b8381101561337557815185529382019390820190600101613359565b505050508281036060840152612be78185613251565b818103818111156129de576129de6131b2565b6000806000606084860312156133b357600080fd5b8351925060208401519150604084015190509250925092565b600060208083850312156133df57600080fd5b825167ffffffffffffffff8111156133f657600080fd5b8301601f8101851361340757600080fd5b8051613415612f0d82612ec8565b81815260059190911b8201830190838101908783111561343457600080fd5b928401925b82841015612be757835161344c81612ca5565b82529284019290840190613439565b60ff81168114611a5b57600080fd5b600080600080600060a0868803121561348257600080fd5b85516001600160801b038116811461349957600080fd5b60208701519095506134aa8161345b565b60408701519094506134bb8161345b565b60608701519093506134cc81612d99565b60808701519092506134dd81612ca5565b809150509295509295909350565b6000602082840312156134fd57600080fd5b8135612e7a8161345b565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b634e487b7160e01b600052600160045260246000fd5b600080604080848603121561357357600080fd5b835161357e81612ca5565b8093505060208085015167ffffffffffffffff8082111561359e57600080fd5b818701915087601f8301126135b257600080fd5b81516135c0612f0d82612ec8565b81815260059190911b8301840190848101908a8311156135df57600080fd5b8585015b83811015613650578051858111156135fb5760008081fd5b8601603f81018d1361360d5760008081fd5b8781015161361d612f0d82612f57565b8181528e8b8385010111156136325760008081fd5b613641828b83018d860161322d565b855250509186019186016135e3565b50809750505050505050509250929050565b6000806000806080858703121561367857600080fd5b505082516020840151604085015160609095015191969095509092509050565b600082516136aa81846020870161322d565b919091019291505056fea26469706673582212205b8af7cdf1ab05f84e235026d3ac5798d4996351f7ba9a2f425aaebdbcceca1f64736f6c63430008110033", "devdoc": { "kind": "dev", "methods": { @@ -353,16 +543,6 @@ "percentage": "The percentage of the borrow that will be repaid, represented with 18 decimals." } }, - "fixedRoll(address,uint256,uint256,uint256,uint256,uint256)": { - "params": { - "borrowMaturity": "The maturity of the fixed pool that the position is being rolled to.", - "market": "The Market to roll the position in.", - "maxBorrowAssets": "Max amount of debt that the sender is willing to accept to be borrowed.", - "maxRepayAssets": "Max amount of debt that the account is willing to accept to be repaid.", - "percentage": "The percentage of the position that will be rolled, represented with 18 decimals.", - "repayMaturity": "The maturity of the fixed pool that the position is being rolled from." - } - }, "initialize()": { "details": "can only be called once." }, @@ -380,6 +560,27 @@ "userData": "Additional data provided by the borrower for the flash loan." } }, + "rollFixed(address,uint256,uint256,uint256,uint256,uint256)": { + "params": { + "borrowMaturity": "The maturity of the fixed pool that the position is being rolled to.", + "market": "The Market to roll the position in.", + "maxBorrowAssets": "Max amount of debt that the sender is willing to accept to be borrowed.", + "maxRepayAssets": "Max amount of debt that the account is willing to accept to be repaid.", + "percentage": "The percentage of the position that will be rolled, represented with 18 decimals.", + "repayMaturity": "The maturity of the fixed pool that the position is being rolled from." + } + }, + "rollFixed(address,uint256,uint256,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))": { + "params": { + "borrowMaturity": "The maturity of the fixed pool that the position is being rolled to.", + "market": "The Market to roll the position in.", + "maxBorrowAssets": "Max amount of debt that the sender is willing to accept to be borrowed.", + "maxRepayAssets": "Max amount of debt that the account is willing to accept to be repaid.", + "p": "Arguments for the permit call to `market` on behalf of `permit.account`.", + "percentage": "The percentage of the position that will be rolled, represented with 18 decimals.", + "repayMaturity": "The maturity of the fixed pool that the position is being rolled from." + } + }, "rollFixedToFloating(address,uint256,uint256,uint256)": { "params": { "market": "The Market to roll the position in.", @@ -388,6 +589,15 @@ "repayMaturity": "The maturity of the fixed pool that the position is being rolled from." } }, + "rollFixedToFloating(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))": { + "params": { + "market": "The Market to roll the position in.", + "maxRepayAssets": "Max amount of debt that the account is willing to accept to be repaid.", + "p": "Arguments for the permit call to `market` on behalf of `permit.account`.", + "percentage": "The percentage of the position that will be rolled, represented with 18 decimals.", + "repayMaturity": "The maturity of the fixed pool that the position is being rolled from." + } + }, "rollFloatingToFixed(address,uint256,uint256,uint256)": { "params": { "borrowMaturity": "The maturity of the fixed pool that the position is being rolled to.", @@ -395,6 +605,15 @@ "maxBorrowAssets": "Max amount of debt that the sender is willing to accept to be borrowed.", "percentage": "The percentage of the position that will be rolled, represented with 18 decimals." } + }, + "rollFloatingToFixed(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))": { + "params": { + "borrowMaturity": "The maturity of the fixed pool that the position is being rolled to.", + "market": "The Market to roll the position in.", + "maxBorrowAssets": "Max amount of debt that the sender is willing to accept to be borrowed.", + "p": "Arguments for the permit call to `market` on behalf of `permit.account`.", + "percentage": "The percentage of the position that will be rolled, represented with 18 decimals." + } } }, "stateVariables": { @@ -426,9 +645,6 @@ "deleverage(address,uint256,uint256,uint256)": { "notice": "Deleverages the position of `msg.sender` a certain `percentage` by taking a flash loan from Balancer's vault to repay the borrow." }, - "fixedRoll(address,uint256,uint256,uint256,uint256,uint256)": { - "notice": "Rolls a percentage of the fixed position of `msg.sender` to another fixed pool." - }, "initialize()": { "notice": "Initializes the contract." }, @@ -438,11 +654,23 @@ "receiveFlashLoan(address[],uint256[],uint256[],bytes)": { "notice": "Callback function called by the Balancer Vault contract when a flash loan is initiated." }, + "rollFixed(address,uint256,uint256,uint256,uint256,uint256)": { + "notice": "Rolls a percentage of the fixed position of `msg.sender` to another fixed pool." + }, + "rollFixed(address,uint256,uint256,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))": { + "notice": "Rolls a percentage of the fixed position of `msg.sender` to another fixed pool after calling `market.permit`." + }, "rollFixedToFloating(address,uint256,uint256,uint256)": { "notice": "Rolls a percentage of the fixed position of `msg.sender` to a floating position." }, + "rollFixedToFloating(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))": { + "notice": "Rolls a percentage of the fixed position of `msg.sender` to a floating position after calling `market.permit`." + }, "rollFloatingToFixed(address,uint256,uint256,uint256)": { "notice": "Rolls a percentage of the floating position of `msg.sender` to a fixed position." + }, + "rollFloatingToFixed(address,uint256,uint256,uint256,(address,uint256,uint8,bytes32,bytes32))": { + "notice": "Rolls a percentage of the floating position of `msg.sender` to a fixed position after calling `market.permit`." } }, "notice": "Contract for efficient debt management of accounts interacting with Exactly Protocol.", @@ -465,6 +693,14 @@ "offset": 1, "slot": "0", "type": "t_bool" + }, + { + "astId": 12931, + "contract": "contracts/periphery/DebtManager.sol:DebtManager", + "label": "callHash", + "offset": 0, + "slot": "1", + "type": "t_bytes32" } ], "types": { @@ -473,6 +709,11 @@ "label": "bool", "numberOfBytes": "1" }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, "t_uint8": { "encoding": "inplace", "label": "uint8", diff --git a/deployments/mainnet/DebtManager_Proxy.json b/deployments/mainnet/DebtManager_Proxy.json index bd580aa65..48c25f850 100644 --- a/deployments/mainnet/DebtManager_Proxy.json +++ b/deployments/mainnet/DebtManager_Proxy.json @@ -1,5 +1,5 @@ { - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "abi": [ { "inputs": [ @@ -146,137 +146,137 @@ "type": "receive" } ], - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "receipt": { "to": null, "from": "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a", - "contractAddress": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", - "transactionIndex": 77, - "gasUsed": "736433", - "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000004000010000000000000000000000000002000000080000000000000000201000000000004010100008000008000002000000000000002100000000000000000010000000000000000004000000000002020040800000000000000000000000800000000000000000000080000000000000000000010080000000000000a00000830000010000200000440000000400000000004000000000000000000000000010002020000000100000010000040000000002000400000000000000000000000010200000000000000100208000000000200000000000000000000100000000", - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2", - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "contractAddress": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", + "transactionIndex": 68, + "gasUsed": "736500", + "logsBloom": "0x00000000000000000000004000000000400000000000000000000002000000000000010000000000000000000000000002000000080000000000000000200000000000004010100008000008000002000000000000022000000010000000000012000000000000000004000000000002020040800000010000000000000000000000000000000000000080000000000000000000010080000000000000800000030000010000200000440000000400000000000000000000000000000020000010002020000000100000000000040000000002000400040000000000000000000010200000000000000100008000000000200000000400000000000100000000", + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e", + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "logs": [ { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "topics": [ "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", - "0x0000000000000000000000006df3686f372a74280437d118de7ae38ce97462f8" + "0x000000000000000000000000fe0c5abf52e3e3076f3cb7f6323c7c1c91f54b74" ], "data": "0x", - "logIndex": 163, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 156, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x000000000000000000000000c4d4500326981eacd020e20a81b1c479c161c7ef" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 164, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 157, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x000000000000000000000000163538e22f4d38c1eb21b79939f3d2ee274198ff" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 165, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 158, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x000000000000000000000000660e2fc185a9ffe722af253329ceaad4c9f6f928" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 166, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 159, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x0000000000000000000000008644c0fded361d1920e068ba4b09996e26729435" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 167, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 160, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", "address": "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0", "topics": [ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", - "0x000000000000000000000000323ef62d6ddbd2a971d347299bb68e212af702f0", + "0x00000000000000000000000028f3d029da71d9d53ffff921d5ab6e41c3ffddb3", "0x0000000000000000000000003843c41da1d7909c86fad51c47b9a97cf62a29e1" ], "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "logIndex": 168, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 161, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "topics": [ "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" ], "data": "0x0000000000000000000000000000000000000000000000000000000000000001", - "logIndex": 169, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 162, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" }, { - "transactionIndex": 77, - "blockNumber": 17393571, - "transactionHash": "0xcbfb973c5e777c2dd55795e5e1a255c251d02868d866f8a0435d0850e93dcc20", - "address": "0x323Ef62D6DdBD2A971d347299bB68E212AF702f0", + "transactionIndex": 68, + "blockNumber": 17429816, + "transactionHash": "0xc3dc226051dcb5d4a070da2a2c66a905fda8cfb750943bfd6a67affb7ddbc574", + "address": "0x28f3D029Da71d9d53Ffff921D5AB6e41C3FfDDB3", "topics": [ "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000003866ea62494597a5edea4a97f9429f82b9d7ca34", - "logIndex": 170, - "blockHash": "0xd151de3713c8e737b59a021c8ea194283c14f67dd6ff8acae752f3bc73a733f2" + "logIndex": 163, + "blockHash": "0x8bbcda03c571808b5bb87e801ac795c55c79e66b6fac58e26d1f24a7ae51406e" } ], - "blockNumber": 17393571, - "cumulativeGasUsed": "6963078", + "blockNumber": 17429816, + "cumulativeGasUsed": "6026466", "status": 1, "byzantium": true }, "args": [ - "0x6DF3686f372A74280437D118dE7Ae38cE97462f8", + "0xfE0c5ABF52E3e3076f3CB7F6323C7C1c91F54b74", "0x3866eA62494597A5EDeA4A97f9429f82b9d7Ca34", "0x8129fc1c" ], "numDeployments": 1, - "solcInputHash": "03a03f60daa39b8c260cc231d959b34a", + "solcInputHash": "c17dde40789793494d592271c7649423", "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",