From 5aea29af543955cb4f79f03d13778a7b0473dbf1 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Tue, 3 Jan 2023 16:38:25 +0100 Subject: [PATCH] Artifacts deployed to mainnet in v2.0.0 --- artifacts/.chainId | 1 + artifacts/AssetPool.json | 1090 ++++++ artifacts/BatchedPhasedEscrow.json | 373 ++ artifacts/CoveragePool.json | 692 ++++ artifacts/CoveragePoolBeneficiary.json | 193 + artifacts/RewardsPool.json | 323 ++ artifacts/UnderwriterToken.json | 1111 ++++++ .../1f648bbc62fc09e530210f2d58cb219e.json | 198 + .../b466ba551e3f54d5eed446f39b17a223.json | 197 + deployments/mainnet/.chainId | 1 + deployments/mainnet/AssetPool.json | 1090 ++++++ deployments/mainnet/BatchedPhasedEscrow.json | 373 ++ deployments/mainnet/CoveragePool.json | 692 ++++ .../mainnet/CoveragePoolBeneficiary.json | 193 + deployments/mainnet/RewardsPool.json | 323 ++ deployments/mainnet/UnderwriterToken.json | 1111 ++++++ .../1f648bbc62fc09e530210f2d58cb219e.json | 198 + .../b466ba551e3f54d5eed446f39b17a223.json | 197 + export.json | 3287 +++++++++++++++++ 19 files changed, 11643 insertions(+) create mode 100644 artifacts/.chainId create mode 100644 artifacts/AssetPool.json create mode 100644 artifacts/BatchedPhasedEscrow.json create mode 100644 artifacts/CoveragePool.json create mode 100644 artifacts/CoveragePoolBeneficiary.json create mode 100644 artifacts/RewardsPool.json create mode 100644 artifacts/UnderwriterToken.json create mode 100644 artifacts/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json create mode 100644 artifacts/solcInputs/b466ba551e3f54d5eed446f39b17a223.json create mode 100644 deployments/mainnet/.chainId create mode 100644 deployments/mainnet/AssetPool.json create mode 100644 deployments/mainnet/BatchedPhasedEscrow.json create mode 100644 deployments/mainnet/CoveragePool.json create mode 100644 deployments/mainnet/CoveragePoolBeneficiary.json create mode 100644 deployments/mainnet/RewardsPool.json create mode 100644 deployments/mainnet/UnderwriterToken.json create mode 100644 deployments/mainnet/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json create mode 100644 deployments/mainnet/solcInputs/b466ba551e3f54d5eed446f39b17a223.json create mode 100644 export.json diff --git a/artifacts/.chainId b/artifacts/.chainId new file mode 100644 index 00000000..56a6051c --- /dev/null +++ b/artifacts/.chainId @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/artifacts/AssetPool.json b/artifacts/AssetPool.json new file mode 100644 index 00000000..a9c3d19c --- /dev/null +++ b/artifacts/AssetPool.json @@ -0,0 +1,1090 @@ +{ + "address": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ICollateralToken", + "name": "_collateralToken", + "type": "address" + }, + { + "internalType": "contract UnderwriterToken", + "name": "_underwriterToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardsManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newAssetPool", + "type": "address" + } + ], + "name": "ApprovedAssetPoolUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "collateralAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "AssetPoolUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "cancelledAssetPool", + "type": "address" + } + ], + "name": "CancelledAssetPoolUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "CoverageClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "Deposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalDelay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalDelayUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalDelay", + "type": "uint256" + } + ], + "name": "WithdrawalDelayUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalTimeout", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalTimeoutUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalTimeout", + "type": "uint256" + } + ], + "name": "WithdrawalTimeoutUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "approveNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newWithdrawalDelay", + "type": "uint256" + } + ], + "name": "beginWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newWithdrawalTimeout", + "type": "uint256" + } + ], + "name": "beginWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cancelNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "contract ICollateralToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underwriter", + "type": "address" + } + ], + "name": "completeWithdrawal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minAmountToMint", + "type": "uint256" + } + ], + "name": "depositWithMin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getRemainingWithdrawalDelayUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRemainingWithdrawalTimeoutUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "grantShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "initiateWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "newAssetPool", + "outputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newWithdrawalDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newWithdrawalTimeout", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingWithdrawal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsPool", + "outputs": [ + { + "internalType": "contract RewardsPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underwriterToken", + "outputs": [ + { + "internalType": "contract UnderwriterToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "upgradeToNewAssetPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalDelayChangeInitiated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalGovernanceDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "withdrawalInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalTimeout", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalTimeoutChangeInitiated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "transactionIndex": 71, + "gasUsed": "4745721", + "logsBloom": "0x08000000000000000000000000000000000020000000000000800000000000000000000800000000000010000000000000020400000000000000000000000400000000000000000000000000004000000001000000000000000000000000000000000000020000000000010000000800000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020800000000200000000000000000000000000000000000000000000000000400000000800000000000000000000000020000000000000000000000000000000000000000000000000000000008000000800", + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f", + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "logs": [ + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 98, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 99, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 100, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "topics": [ + "0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 101, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + } + ], + "blockNumber": 16327114, + "cumulativeGasUsed": "8956336", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "0x123694886DBf5Ac94DDA07135349534536D14cAf" + ], + "numDeployments": 1, + "solcInputHash": "b466ba551e3f54d5eed446f39b17a223", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ICollateralToken\",\"name\":\"_collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract UnderwriterToken\",\"name\":\"_underwriterToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardsManager\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAssetPool\",\"type\":\"address\"}],\"name\":\"ApprovedAssetPoolUpgrade\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"AssetPoolUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"cancelledAssetPool\",\"type\":\"address\"}],\"name\":\"CancelledAssetPoolUpgrade\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"CoverageClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"Deposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalDelayUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"WithdrawalDelayUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalInitiated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalTimeout\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalTimeoutUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalTimeout\",\"type\":\"uint256\"}],\"name\":\"WithdrawalTimeoutUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IAssetPoolUpgrade\",\"name\":\"_newAssetPool\",\"type\":\"address\"}],\"name\":\"approveNewAssetPoolUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newWithdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newWithdrawalTimeout\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cancelNewAssetPoolUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateralToken\",\"outputs\":[{\"internalType\":\"contract ICollateralToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"}],\"name\":\"completeWithdrawal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToDeposit\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToDeposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minAmountToMint\",\"type\":\"uint256\"}],\"name\":\"depositWithMin\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRemainingWithdrawalDelayUpdateTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRemainingWithdrawalTimeoutUpdateTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"grantShares\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"initiateWithdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newAssetPool\",\"outputs\":[{\"internalType\":\"contract IAssetPoolUpgrade\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newWithdrawalDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newWithdrawalTimeout\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pendingWithdrawal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rewardsPool\",\"outputs\":[{\"internalType\":\"contract RewardsPool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underwriterToken\",\"outputs\":[{\"internalType\":\"contract UnderwriterToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_newAssetPool\",\"type\":\"address\"}],\"name\":\"upgradeToNewAssetPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalDelayChangeInitiated\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalGovernanceDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"withdrawalInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalTimeout\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalTimeoutChangeInitiated\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"beginWithdrawalDelayUpdate(uint256)\":{\"params\":{\"_newWithdrawalDelay\":\"The new value of withdrawal delay\"}},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"params\":{\"_newWithdrawalTimeout\":\"The new value of the withdrawal timeout\"}},\"completeWithdrawal(address)\":{\"returns\":{\"_0\":\"The amount of collateral withdrawn\"}},\"deposit(uint256)\":{\"details\":\"Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.\",\"params\":{\"amountToDeposit\":\"Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1\"},\"returns\":{\"_0\":\"The amount of minted underwriter tokens\"}},\"depositWithMin(uint256,uint256)\":{\"details\":\"Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.\",\"params\":{\"amountToDeposit\":\"Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1\",\"minAmountToMint\":\"Underwriter minimal tokens amount that a user expects to receive in exchange for the deposited collateral tokens\"},\"returns\":{\"_0\":\"The amount of minted underwriter tokens\"}},\"getRemainingWithdrawalDelayUpdateTime()\":{\"returns\":{\"_0\":\"The time left until withdrawal delay update can be finalized\"}},\"getRemainingWithdrawalTimeoutUpdateTime()\":{\"returns\":{\"_0\":\"The time left until withdrawal timeout update can be finalized\"}},\"grantShares(address,uint256)\":{\"details\":\"Can be called only by the contract owner.\",\"params\":{\"covAmount\":\"Amount of the underwriter tokens which should be minted\",\"recipient\":\"Address of the underwriter tokens recipient\"}},\"initiateWithdrawal(uint256)\":{\"details\":\"Before calling this function, underwriter token needs to have the required amount accepted to transfer to the asset pool.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"details\":\"This function is a shortcut for approve + deposit.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"totalValue()\":{\"returns\":{\"_0\":\"The total value of asset pool in collateral token.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgradeToNewAssetPool(uint256,address)\":{\"params\":{\"_newAssetPool\":\"New Asset Pool address to check validity with the one that was approved by the governance\",\"covAmount\":\"Amount of underwriter tokens used to calculate collateral tokens which are transferred to a new asset pool\"}},\"withdrawalGovernanceDelay()\":{\"returns\":{\"_0\":\"The withdrawal governance delay in seconds\"}}},\"title\":\"Asset Pool\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"approveNewAssetPoolUpgrade(address)\":{\"notice\":\"Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay.\"},\"beginWithdrawalDelayUpdate(uint256)\":{\"notice\":\"Lets the contract owner to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible.\"},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"notice\":\"Lets the contract owner to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value.\"},\"cancelNewAssetPoolUpgrade()\":{\"notice\":\"Allows governance to cancel already approved new asset pool in case of some misconfiguration.\"},\"claim(address,uint256)\":{\"notice\":\"Allows the coverage pool to demand coverage from the asset hold by this pool and send it to the provided recipient address.\"},\"completeWithdrawal(address)\":{\"notice\":\"Completes the previously initiated withdrawal for the underwriter. Anyone can complete the withdrawal for the underwriter. The withdrawal has to be completed before the withdrawal timeout elapses. Otherwise, the withdrawal has to be initiated again and the underwriter has to wait for the entire withdrawal delay again before being able to complete the withdrawal.\"},\"deposit(uint256)\":{\"notice\":\"Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts.\"},\"depositWithMin(uint256,uint256)\":{\"notice\":\"Accepts the given amount of collateral token as a deposit and mints at least a minAmountToMint underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts.\"},\"finalizeWithdrawalDelayUpdate()\":{\"notice\":\"Lets the contract owner to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass.\"},\"finalizeWithdrawalTimeoutUpdate()\":{\"notice\":\"Lets the contract owner to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass.\"},\"getRemainingWithdrawalDelayUpdateTime()\":{\"notice\":\"Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal delay update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum.\"},\"getRemainingWithdrawalTimeoutUpdateTime()\":{\"notice\":\"Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal timeout update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum.\"},\"grantShares(address,uint256)\":{\"notice\":\"Grants pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes.\"},\"initiateWithdrawal(uint256)\":{\"notice\":\"Initiates the withdrawal of collateral and rewards from the pool. Must be followed with completeWithdrawal call after the withdrawal delay passes. Accepts the amount of underwriter tokens representing the share of the pool that should be withdrawn. Can be called multiple times increasing the pool share to withdraw and resetting the withdrawal initiated timestamp for each call. Can be called with 0 covAmount to reset the withdrawal initiated timestamp if the underwriter has a pending withdrawal. In practice 0 covAmount should be used only to initiate the withdrawal again in case one did not complete the withdrawal before the withdrawal timeout elapsed.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts. Optional data in extraData may include a minimal amount of underwriter tokens expected to be minted for a depositor. There are cases when an amount of minted tokens matters for a depositor, as tokens might be used in third party exchanges.\"},\"totalValue()\":{\"notice\":\"Returns the current collateral token balance of the asset pool plus the reward amount (in collateral token) earned by the asset pool and not yet withdrawn to the asset pool.\"},\"upgradeToNewAssetPool(uint256,address)\":{\"notice\":\"Transfers collateral tokens to a new Asset Pool which previously was approved by the governance. Upgrade does not have to obey withdrawal delay. Old underwriter tokens are burned in favor of new tokens minted in a new Asset Pool. New tokens are sent directly to the underwriter from a new Asset Pool.\"},\"withdrawalDelay()\":{\"notice\":\"The time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim.\"},\"withdrawalGovernanceDelay()\":{\"notice\":\"The time it takes to initiate and complete the withdrawal from the pool plus 2 days to make a decision. This governance delay should be used for all changes directly affecting underwriter positions. This time is a minimum and the governance may choose to wait longer before finalizing the update.\"},\"withdrawalTimeout()\":{\"notice\":\"The time the underwriter has after the withdrawal delay passed to complete the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim. After the withdrawal timeout elapses, tokens stay in the pool and the underwriter has to initiate the withdrawal again and wait for the full withdrawal delay to complete the withdrawal.\"}},\"notice\":\"Asset pool is a component of a Coverage Pool. Asset Pool accepts a single ERC20 token as collateral, and returns an underwriter token. For example, an asset pool might accept deposits in KEEP in return for covKEEP underwriter tokens. Underwriter tokens represent an ownership share in the underlying collateral of the Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens as a deposit. It means that the total supply of the collateral token can not be greater than 2^96-1 or, if that supply is greater, it is acceptable that not all tokens can be deposited into the pool.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/AssetPool.sol\":\"AssetPool\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 /**\\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 / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xd0a917e32d1251a9b2f1dea15e932815d5382e64e6b0a18104664a6cc774cd70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"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\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./IVotesHistory.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\n/// @title Checkpoints\\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\\n/// delegation. This implementation supports token supply up to 2^96 - 1.\\n/// This contract keeps a history (checkpoints) of each account's vote\\n/// power. Vote power can be delegated either by calling the {delegate}\\n/// function directly, or by providing a signature to be used with\\n/// {delegateBySig}. Voting power can be publicly queried through\\n/// {getVotes} and {getPastVotes}.\\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\\n/// @dev This contract is upgrade-safe.\\nabstract contract Checkpoints is IVotesHistory {\\n struct Checkpoint {\\n uint32 fromBlock;\\n uint96 votes;\\n }\\n\\n // slither-disable-next-line uninitialized-state\\n mapping(address => address) internal _delegates;\\n mapping(address => uint128[]) internal _checkpoints;\\n uint128[] internal _totalSupplyCheckpoints;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n /// @notice Emitted when an account changes their delegate.\\n event DelegateChanged(\\n address indexed delegator,\\n address indexed fromDelegate,\\n address indexed toDelegate\\n );\\n\\n /// @notice Emitted when a balance or delegate change results in changes\\n /// to an account's voting power.\\n event DelegateVotesChanged(\\n address indexed delegate,\\n uint256 previousBalance,\\n uint256 newBalance\\n );\\n\\n function checkpoints(address account, uint32 pos)\\n public\\n view\\n virtual\\n returns (Checkpoint memory checkpoint)\\n {\\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\\n _checkpoints[account][pos]\\n );\\n checkpoint = Checkpoint(fromBlock, votes);\\n }\\n\\n /// @notice Get number of checkpoints for `account`.\\n function numCheckpoints(address account)\\n public\\n view\\n virtual\\n returns (uint32)\\n {\\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\\n }\\n\\n /// @notice Get the address `account` is currently delegating to.\\n function delegates(address account) public view virtual returns (address) {\\n return _delegates[account];\\n }\\n\\n /// @notice Gets the current votes balance for `account`.\\n /// @param account The address to get votes balance\\n /// @return The number of current votes for `account`\\n function getVotes(address account) public view returns (uint96) {\\n uint256 pos = _checkpoints[account].length;\\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\\n }\\n\\n /// @notice Determine the prior number of votes for an account as of\\n /// a block number.\\n /// @dev Block number must be a finalized block or else this function will\\n /// revert to prevent misinformation.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_checkpoints[account], blockNumber);\\n }\\n\\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\\n /// Note, this value is the sum of all balances, but it is NOT the\\n /// sum of all the delegated votes!\\n /// @param blockNumber The block number to get the total supply at\\n /// @dev `blockNumber` must have been already mined\\n function getPastTotalSupply(uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\\n }\\n\\n /// @notice Change delegation for `delegator` to `delegatee`.\\n // slither-disable-next-line dead-code\\n function delegate(address delegator, address delegatee) internal virtual;\\n\\n /// @notice Moves voting power from one delegate to another\\n /// @param src Address of old delegate\\n /// @param dst Address of new delegate\\n /// @param amount Voting power amount to transfer between delegates\\n function moveVotingPower(\\n address src,\\n address dst,\\n uint256 amount\\n ) internal {\\n if (src != dst && amount > 0) {\\n if (src != address(0)) {\\n // https://github.com/crytic/slither/issues/960\\n // slither-disable-next-line variable-scope\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[src],\\n subtract,\\n amount\\n );\\n emit DelegateVotesChanged(src, oldWeight, newWeight);\\n }\\n\\n if (dst != address(0)) {\\n // https://github.com/crytic/slither/issues/959\\n // slither-disable-next-line uninitialized-local\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[dst],\\n add,\\n amount\\n );\\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\\n }\\n }\\n }\\n\\n /// @notice Writes a new checkpoint based on operating last stored value\\n /// with a `delta`. Usually, said operation is the `add` or\\n /// `subtract` functions from this contract, but more complex\\n /// functions can be passed as parameters.\\n /// @param ckpts The checkpoints array to use\\n /// @param op The function to apply over the last value and the `delta`\\n /// @param delta Variation with respect to last stored value to be used\\n /// for new checkpoint\\n function writeCheckpoint(\\n uint128[] storage ckpts,\\n function(uint256, uint256) view returns (uint256) op,\\n uint256 delta\\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\\n uint256 pos = ckpts.length;\\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\\n newWeight = op(oldWeight, delta);\\n\\n if (pos > 0) {\\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\\n // slither-disable-next-line incorrect-equality\\n if (fromBlock == block.number) {\\n ckpts[pos - 1] = encodeCheckpoint(\\n fromBlock,\\n SafeCastUpgradeable.toUint96(newWeight)\\n );\\n return (oldWeight, newWeight);\\n }\\n }\\n\\n ckpts.push(\\n encodeCheckpoint(\\n SafeCastUpgradeable.toUint32(block.number),\\n SafeCastUpgradeable.toUint96(newWeight)\\n )\\n );\\n }\\n\\n /// @notice Lookup a value in a list of (sorted) checkpoints.\\n /// @param ckpts The checkpoints array to use\\n /// @param blockNumber Block number when we want to get the checkpoint at\\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\\n internal\\n view\\n returns (uint96)\\n {\\n // We run a binary search to look for the earliest checkpoint taken\\n // after `blockNumber`. During the loop, the index of the wanted\\n // checkpoint remains in the range [low-1, high). With each iteration,\\n // either `low` or `high` is moved towards the middle of the range to\\n // maintain the invariant.\\n // - If the middle checkpoint is after `blockNumber`,\\n // we look in [low, mid)\\n // - If the middle checkpoint is before or equal to `blockNumber`,\\n // we look in [mid+1, high)\\n // Once we reach a single value (when low == high), we've found the\\n // right checkpoint at the index high-1, if not out of bounds (in that\\n // case we're looking too far in the past and the result is 0).\\n // Note that if the latest checkpoint available is exactly for\\n // `blockNumber`, we end up with an index that is past the end of the\\n // array, so we technically don't find a checkpoint after\\n // `blockNumber`, but it works out the same.\\n require(blockNumber < block.number, \\\"Block not yet determined\\\");\\n\\n uint256 high = ckpts.length;\\n uint256 low = 0;\\n while (low < high) {\\n uint256 mid = MathUpgradeable.average(low, high);\\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\\n if (midBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\\n }\\n\\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\\n // slither-disable-next-line dead-code\\n function maxSupply() internal view virtual returns (uint96) {\\n return type(uint96).max;\\n }\\n\\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\\n /// checkpoint.\\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\\n /// remaining 96 bits.\\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\\n internal\\n pure\\n returns (uint128)\\n {\\n return (uint128(blockNumber) << 96) | uint128(value);\\n }\\n\\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\\n function decodeBlockNumber(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32)\\n {\\n return uint32(bytes4(bytes16(checkpoint)));\\n }\\n\\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\\n return uint96(checkpoint);\\n }\\n\\n /// @notice Decodes a block number and voting value from a `uint128`\\n /// `checkpoint`.\\n function decodeCheckpoint(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32 blockNumber, uint96 value)\\n {\\n blockNumber = decodeBlockNumber(checkpoint);\\n value = decodeValue(checkpoint);\\n }\\n\\n // slither-disable-next-line dead-code\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n // slither-disable-next-line dead-code\\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n}\\n\",\"keccak256\":\"0x67b28349e88afe7440c43df93ba5de56873d850a25147161e4469731750efb16\",\"license\":\"GPL-3.0-or-later\"},\"@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\ninterface IVotesHistory {\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n\\n function getPastTotalSupply(uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x535e87cf4c2e9a9439d99cf0918f013965fa6c4ddfbab07ff6ca4b195c8edc9f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/AssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./interfaces/IAssetPool.sol\\\";\\nimport \\\"./interfaces/IAssetPoolUpgrade.sol\\\";\\nimport \\\"./interfaces/ICollateralToken.sol\\\";\\nimport \\\"./RewardsPool.sol\\\";\\nimport \\\"./UnderwriterToken.sol\\\";\\nimport \\\"./GovernanceUtils.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Asset Pool\\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\\n/// accepts a single ERC20 token as collateral, and returns an\\n/// underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\\n/// as a deposit. It means that the total supply of the collateral token\\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\\n/// acceptable that not all tokens can be deposited into the pool.\\ncontract AssetPool is Ownable, IAssetPool {\\n using SafeERC20 for ICollateralToken;\\n using SafeERC20 for UnderwriterToken;\\n\\n ICollateralToken public immutable collateralToken;\\n UnderwriterToken public immutable underwriterToken;\\n\\n RewardsPool public immutable rewardsPool;\\n\\n IAssetPoolUpgrade public newAssetPool;\\n\\n /// @notice The time it takes the underwriter to withdraw their collateral\\n /// and rewards from the pool. This is the time that needs to pass\\n /// between initiating and completing the withdrawal. During that\\n /// time, underwriter is still earning rewards and their share of\\n /// the pool is still a subject of a possible coverage claim.\\n uint256 public withdrawalDelay = 21 days;\\n uint256 public newWithdrawalDelay;\\n uint256 public withdrawalDelayChangeInitiated;\\n\\n /// @notice The time the underwriter has after the withdrawal delay passed\\n /// to complete the withdrawal. During that time, underwriter is\\n /// still earning rewards and their share of the pool is still\\n /// a subject of a possible coverage claim.\\n /// After the withdrawal timeout elapses, tokens stay in the pool\\n /// and the underwriter has to initiate the withdrawal again and\\n /// wait for the full withdrawal delay to complete the withdrawal.\\n uint256 public withdrawalTimeout = 2 days;\\n uint256 public newWithdrawalTimeout;\\n uint256 public withdrawalTimeoutChangeInitiated;\\n\\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\\n mapping(address => uint256) public pendingWithdrawal;\\n\\n event Deposited(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount\\n );\\n\\n event CoverageClaimed(\\n address indexed recipient,\\n uint256 amount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalInitiated(\\n address indexed underwriter,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n event WithdrawalCompleted(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event ApprovedAssetPoolUpgrade(address newAssetPool);\\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\\n event AssetPoolUpgraded(\\n address indexed underwriter,\\n uint256 collateralAmount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalDelayUpdateStarted(\\n uint256 withdrawalDelay,\\n uint256 timestamp\\n );\\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\\n event WithdrawalTimeoutUpdateStarted(\\n uint256 withdrawalTimeout,\\n uint256 timestamp\\n );\\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\\n\\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\\n /// if the change was not yet initiated.\\n /// @param changeInitiatedTimestamp The timestamp at which the change has\\n /// been initiated\\n modifier onlyAfterWithdrawalGovernanceDelay(\\n uint256 changeInitiatedTimestamp\\n ) {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - changeInitiatedTimestamp >=\\n withdrawalGovernanceDelay(),\\n \\\"Governance delay has not elapsed\\\"\\n );\\n _;\\n }\\n\\n constructor(\\n ICollateralToken _collateralToken,\\n UnderwriterToken _underwriterToken,\\n address rewardsManager\\n ) {\\n collateralToken = _collateralToken;\\n underwriterToken = _underwriterToken;\\n\\n rewardsPool = new RewardsPool(\\n _collateralToken,\\n address(this),\\n rewardsManager\\n );\\n\\n initGovernance(_collateralToken);\\n }\\n\\n /// @dev Overwrite to empty if collateral token used by the AssetPool\\n /// does not support DAO checkpoints. Used for tests with KEEP token.\\n function initGovernance(ICollateralToken _collateralToken)\\n internal\\n virtual\\n {\\n _collateralToken.delegate(address(this));\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// Optional data in extraData may include a minimal amount of\\n /// underwriter tokens expected to be minted for a depositor. There\\n /// are cases when an amount of minted tokens matters for a\\n /// depositor, as tokens might be used in third party exchanges.\\n /// @dev This function is a shortcut for approve + deposit.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external {\\n require(\\n amount + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n require(msg.sender == token, \\\"Only token caller allowed\\\");\\n require(\\n token == address(collateralToken),\\n \\\"Unsupported collateral token\\\"\\n );\\n\\n uint256 toMint = _calculateTokensToMint(amount);\\n if (extraData.length != 0) {\\n require(extraData.length == 32, \\\"Unexpected data length\\\");\\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n }\\n\\n _deposit(from, amount, toMint);\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal to\\n /// 2^96-1\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amountToDeposit)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership. The amount locked in the pool after accepting\\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\\n /// function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal\\n /// to 2^96-1\\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\\n /// expects to receive in exchange for the deposited\\n /// collateral tokens\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the\\n /// pool. Must be followed with completeWithdrawal call after the\\n /// withdrawal delay passes. Accepts the amount of underwriter\\n /// tokens representing the share of the pool that should be\\n /// withdrawn. Can be called multiple times increasing the pool share\\n /// to withdraw and resetting the withdrawal initiated timestamp for\\n /// each call. Can be called with 0 covAmount to reset the\\n /// withdrawal initiated timestamp if the underwriter has a pending\\n /// withdrawal. In practice 0 covAmount should be used only to\\n /// initiate the withdrawal again in case one did not complete the\\n /// withdrawal before the withdrawal timeout elapsed.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external override {\\n uint256 pending = pendingWithdrawal[msg.sender];\\n require(\\n covAmount > 0 || pending > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n pending += covAmount;\\n pendingWithdrawal[msg.sender] = pending;\\n /* solhint-disable not-rely-on-time */\\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\\n\\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\\n /* solhint-enable not-rely-on-time */\\n\\n if (covAmount > 0) {\\n underwriterToken.safeTransferFrom(\\n msg.sender,\\n address(this),\\n covAmount\\n );\\n }\\n }\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter. Anyone can complete the withdrawal for the\\n /// underwriter. The withdrawal has to be completed before the\\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\\n /// be initiated again and the underwriter has to wait for the\\n /// entire withdrawal delay again before being able to complete\\n /// the withdrawal.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter)\\n external\\n override\\n returns (uint256)\\n {\\n /* solhint-disable not-rely-on-time */\\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\\n require(initiatedAt > 0, \\\"No withdrawal initiated for the underwriter\\\");\\n\\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\\n require(\\n withdrawalDelayEndTimestamp < block.timestamp,\\n \\\"Withdrawal delay has not elapsed\\\"\\n );\\n\\n require(\\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\\n \\\"Withdrawal timeout elapsed\\\"\\n );\\n\\n uint256 covAmount = pendingWithdrawal[underwriter];\\n uint256 covSupply = underwriterToken.totalSupply();\\n delete withdrawalInitiatedTimestamp[underwriter];\\n delete pendingWithdrawal[underwriter];\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\\n\\n emit WithdrawalCompleted(\\n underwriter,\\n amountToWithdraw,\\n covAmount,\\n block.timestamp\\n );\\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\\n\\n /* solhint-enable not-rely-on-time */\\n underwriterToken.burn(covAmount);\\n\\n return amountToWithdraw;\\n }\\n\\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\\n /// was approved by the governance. Upgrade does not have to obey\\n /// withdrawal delay.\\n /// Old underwriter tokens are burned in favor of new tokens minted\\n /// in a new Asset Pool. New tokens are sent directly to the\\n /// underwriter from a new Asset Pool.\\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\\n /// tokens which are transferred to a new asset pool\\n /// @param _newAssetPool New Asset Pool address to check validity with the one\\n /// that was approved by the governance\\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\\n external\\n {\\n /* solhint-disable not-rely-on-time */\\n require(\\n address(newAssetPool) != address(0),\\n \\\"New asset pool must be assigned\\\"\\n );\\n\\n require(\\n address(newAssetPool) == _newAssetPool,\\n \\\"Addresses of a new asset pool must match\\\"\\n );\\n\\n require(\\n covAmount > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\\n covSupply;\\n\\n collateralToken.safeApprove(\\n address(newAssetPool),\\n collateralToTransfer\\n );\\n // old underwriter tokens are burned in favor of new minted in a new\\n // asset pool\\n underwriterToken.burnFrom(msg.sender, covAmount);\\n // collateralToTransfer will be sent to a new AssetPool and new\\n // underwriter tokens will be minted and transferred back to the underwriter\\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\\n\\n emit AssetPoolUpgraded(\\n msg.sender,\\n collateralToTransfer,\\n covAmount,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Allows governance to set a new asset pool so the underwriters\\n /// can move their collateral tokens to a new asset pool without\\n /// having to wait for the withdrawal delay.\\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\\n external\\n onlyOwner\\n {\\n require(\\n address(_newAssetPool) != address(0),\\n \\\"New asset pool can't be zero address\\\"\\n );\\n\\n newAssetPool = _newAssetPool;\\n\\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\\n }\\n\\n /// @notice Allows governance to cancel already approved new asset pool\\n /// in case of some misconfiguration.\\n function cancelNewAssetPoolUpgrade() external onlyOwner {\\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\\n\\n newAssetPool = IAssetPoolUpgrade(address(0));\\n }\\n\\n /// @notice Allows the coverage pool to demand coverage from the asset hold\\n /// by this pool and send it to the provided recipient address.\\n function claim(address recipient, uint256 amount) external onlyOwner {\\n emit CoverageClaimed(recipient, amount, block.timestamp);\\n rewardsPool.withdraw();\\n require(\\n amount <= collateralToken.balanceOf(address(this)),\\n \\\"Amount to seize exceeds the pool balance\\\"\\n );\\n collateralToken.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal delay\\n /// parameter value. Withdrawal delay is the time it takes the\\n /// underwriter to withdraw their collateral and rewards from the\\n /// pool. This is the time that needs to pass between initiating and\\n /// completing the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalDelayUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal delay value should be but it should\\n /// be long enough so that the possibility of having free-riding\\n /// underwriters escaping from a potential coverage claim by\\n /// withdrawing their positions from the pool is negligible.\\n /// @param _newWithdrawalDelay The new value of withdrawal delay\\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\\n external\\n onlyOwner\\n {\\n newWithdrawalDelay = _newWithdrawalDelay;\\n withdrawalDelayChangeInitiated = block.timestamp;\\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// delay parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalDelayUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalDelayUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\\n {\\n withdrawalDelay = newWithdrawalDelay;\\n emit WithdrawalDelayUpdated(withdrawalDelay);\\n newWithdrawalDelay = 0;\\n withdrawalDelayChangeInitiated = 0;\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\\n /// parameter value. The withdrawal timeout is the time the\\n /// underwriter has - after the withdrawal delay passed - to\\n /// complete the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal timeout value should be but it should\\n /// be short enough so that the time of free-riding by being able to\\n /// immediately escape from the claim is minimal and long enough so\\n /// that honest underwriters have a possibility to finalize the\\n /// withdrawal. It is all about the right proportions with\\n /// a relation to withdrawal delay value.\\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\\n external\\n onlyOwner\\n {\\n newWithdrawalTimeout = _newWithdrawalTimeout;\\n withdrawalTimeoutChangeInitiated = block.timestamp;\\n emit WithdrawalTimeoutUpdateStarted(\\n _newWithdrawalTimeout,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// timeout parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalTimeoutUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\\n {\\n withdrawalTimeout = newWithdrawalTimeout;\\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\\n newWithdrawalTimeout = 0;\\n withdrawalTimeoutChangeInitiated = 0;\\n }\\n\\n /// @notice Grants pool shares by minting a given amount of the underwriter\\n /// tokens for the recipient address. In result, the recipient\\n /// obtains part of the pool ownership without depositing any\\n /// collateral tokens. Shares are usually granted for notifiers\\n /// reporting about various contract state changes.\\n /// @dev Can be called only by the contract owner.\\n /// @param recipient Address of the underwriter tokens recipient\\n /// @param covAmount Amount of the underwriter tokens which should be minted\\n function grantShares(address recipient, uint256 covAmount)\\n external\\n onlyOwner\\n {\\n rewardsPool.withdraw();\\n underwriterToken.mint(recipient, covAmount);\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal delay update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal delay update can be finalized\\n function getRemainingWithdrawalDelayUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalDelayChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal timeout update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal timeout update can be finalized\\n function getRemainingWithdrawalTimeoutUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalTimeoutChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the current collateral token balance of the asset pool\\n /// plus the reward amount (in collateral token) earned by the asset\\n /// pool and not yet withdrawn to the asset pool.\\n /// @return The total value of asset pool in collateral token.\\n function totalValue() public view returns (uint256) {\\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\\n }\\n\\n /// @notice The time it takes to initiate and complete the withdrawal from\\n /// the pool plus 2 days to make a decision. This governance delay\\n /// should be used for all changes directly affecting underwriter\\n /// positions. This time is a minimum and the governance may choose\\n /// to wait longer before finalizing the update.\\n /// @return The withdrawal governance delay in seconds\\n function withdrawalGovernanceDelay() public view returns (uint256) {\\n return withdrawalDelay + withdrawalTimeout + 2 days;\\n }\\n\\n /// @dev Calculates underwriter tokens to mint.\\n function _calculateTokensToMint(uint256 amountToDeposit)\\n internal\\n returns (uint256)\\n {\\n rewardsPool.withdraw();\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n if (covSupply == 0) {\\n return amountToDeposit;\\n }\\n\\n return (amountToDeposit * covSupply) / collateralBalance;\\n }\\n\\n function _deposit(\\n address depositor,\\n uint256 amountToDeposit,\\n uint256 amountToMint\\n ) internal {\\n require(depositor != address(this), \\\"Self-deposit not allowed\\\");\\n\\n require(\\n amountToMint > 0,\\n \\\"Minted tokens amount must be greater than 0\\\"\\n );\\n\\n emit Deposited(depositor, amountToDeposit, amountToMint);\\n\\n underwriterToken.mint(depositor, amountToMint);\\n collateralToken.safeTransferFrom(\\n depositor,\\n address(this),\\n amountToDeposit\\n );\\n }\\n}\\n\",\"keccak256\":\"0x41be5f1b06ae8b9b722c642030127cce94f571b63c4a782b155f5f42e5d61ccc\",\"license\":\"MIT\"},\"contracts/GovernanceUtils.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nlibrary GovernanceUtils {\\n /// @notice Gets the time remaining until the governable parameter update\\n /// can be committed.\\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\\n /// @param delay Governance delay.\\n /// @return Remaining time in seconds.\\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\\n internal\\n view\\n returns (uint256)\\n {\\n require(changeTimestamp > 0, \\\"Change not initiated\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n uint256 elapsed = block.timestamp - changeTimestamp;\\n if (elapsed >= delay) {\\n return 0;\\n } else {\\n return delay - elapsed;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x991d317527b08149a0e263c4c951e5969b29d48fd3aa64b2807de70fc766fd91\",\"license\":\"MIT\"},\"contracts/RewardsPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Rewards Pool\\n/// @notice RewardsPool accepts a single reward token and releases it to the\\n/// AssetPool over time in one week reward intervals. The owner of this\\n/// contract is the reward distribution address funding it with reward\\n/// tokens.\\ncontract RewardsPool is Ownable {\\n using SafeERC20 for IERC20;\\n\\n uint256 public constant DURATION = 7 days;\\n\\n IERC20 public immutable rewardToken;\\n address public immutable assetPool;\\n\\n // timestamp of the current reward interval end or the timestamp of the\\n // last interval end in case a new reward interval has not been allocated\\n uint256 public intervalFinish = 0;\\n // rate per second with which reward tokens are unlocked\\n uint256 public rewardRate = 0;\\n // amount of rewards accumulated and not yet withdrawn from the previous\\n // reward interval(s)\\n uint256 public rewardAccumulated = 0;\\n // the last time information in this contract was updated\\n uint256 public lastUpdateTime = 0;\\n\\n event RewardToppedUp(uint256 amount);\\n event RewardWithdrawn(uint256 amount);\\n\\n constructor(\\n IERC20 _rewardToken,\\n address _assetPool,\\n address owner\\n ) {\\n rewardToken = _rewardToken;\\n // slither-disable-next-line missing-zero-check\\n assetPool = _assetPool;\\n transferOwnership(owner);\\n }\\n\\n /// @notice Transfers the provided reward amount into RewardsPool and\\n /// creates a new, one-week reward interval starting from now.\\n /// Reward tokens from the previous reward interval that unlocked\\n /// over the time will be available for withdrawal immediately.\\n /// Reward tokens from the previous interval that has not been yet\\n /// unlocked, are added to the new interval being created.\\n /// @dev This function can be called only by the owner given that it creates\\n /// a new interval with one week length, starting from now.\\n function topUpReward(uint256 reward) external onlyOwner {\\n rewardAccumulated = earned();\\n\\n /* solhint-disable not-rely-on-time */\\n if (block.timestamp >= intervalFinish) {\\n // see https://github.com/crytic/slither/issues/844\\n // slither-disable-next-line divide-before-multiply\\n rewardRate = reward / DURATION;\\n } else {\\n uint256 remaining = intervalFinish - block.timestamp;\\n uint256 leftover = remaining * rewardRate;\\n rewardRate = (reward + leftover) / DURATION;\\n }\\n intervalFinish = block.timestamp + DURATION;\\n lastUpdateTime = block.timestamp;\\n /* solhint-enable avoid-low-level-calls */\\n\\n emit RewardToppedUp(reward);\\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\\n function withdraw() external {\\n uint256 amount = earned();\\n rewardAccumulated = 0;\\n lastUpdateTime = lastTimeRewardApplicable();\\n emit RewardWithdrawn(amount);\\n rewardToken.safeTransfer(assetPool, amount);\\n }\\n\\n /// @notice Returns the amount of earned and not yet withdrawn reward\\n /// tokens.\\n function earned() public view returns (uint256) {\\n return\\n rewardAccumulated +\\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\\n }\\n\\n /// @notice Returns the timestamp at which a reward was last time applicable.\\n /// When reward interval is pending, returns current block's\\n /// timestamp. If the last reward interval ended and no other reward\\n /// interval had been allocated, returns the last reward interval's\\n /// end timestamp.\\n function lastTimeRewardApplicable() public view returns (uint256) {\\n return Math.min(block.timestamp, intervalFinish);\\n }\\n}\\n\",\"keccak256\":\"0xe56e8c35bbafad758cc66473f113ea9fd3ffa9c44c6139fc3196dbbead2a4054\",\"license\":\"MIT\"},\"contracts/UnderwriterToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\\";\\n\\n/// @title UnderwriterToken\\n/// @notice Underwriter tokens represent an ownership share in the underlying\\n/// collateral of the asset-specific pool. Underwriter tokens are minted\\n/// when a user deposits ERC20 tokens into asset-specific pool and they\\n/// are burned when a user exits the position. Underwriter tokens\\n/// natively support meta transactions. Users can authorize a transfer\\n/// of their underwriter tokens with a signature conforming EIP712\\n/// standard instead of an on-chain transaction from their address.\\n/// Anyone can submit this signature on the user's behalf by calling the\\n/// permit function, as specified in EIP2612 standard, paying gas fees,\\n/// and possibly performing other actions in the same transaction.\\n// slither-disable-next-line missing-inheritance\\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\\n /// @notice The EIP-712 typehash for the delegation struct used by\\n /// `delegateBySig`.\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\n \\\"Delegation(address delegatee,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n constructor(string memory _name, string memory _symbol)\\n ERC20WithPermit(_name, _symbol)\\n {}\\n\\n /// @notice Delegates votes from signatory to `delegatee`\\n /// @param delegatee The address to delegate votes to\\n /// @param deadline The time at which to expire the signature\\n /// @param v The recovery byte of the signature\\n /// @param r Half of the ECDSA signature pair\\n /// @param s Half of the ECDSA signature pair\\n function delegateBySig(\\n address signatory,\\n address delegatee,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Delegation expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n DELEGATION_TYPEHASH,\\n delegatee,\\n nonce[signatory]++,\\n deadline\\n )\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == signatory,\\n \\\"Invalid signature\\\"\\n );\\n\\n return delegate(signatory, delegatee);\\n }\\n\\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) public virtual {\\n return delegate(msg.sender, delegatee);\\n }\\n\\n /// @notice Moves voting power when tokens are minted, burned or transferred.\\n /// @dev Overrides the empty function from the parent contract.\\n /// @param from The address that loses tokens and voting power\\n /// @param to The address that gains tokens and voting power\\n /// @param amount The amount of tokens and voting power that is transferred\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal override {\\n // When minting:\\n if (from == address(0)) {\\n // Does not allow to mint more than uint96 can fit. Otherwise, the\\n // Checkpoint might not fit the balance.\\n require(\\n totalSupply + amount <= maxSupply(),\\n \\\"Maximum total supply exceeded\\\"\\n );\\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\\n }\\n\\n // When burning:\\n if (to == address(0)) {\\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\\n }\\n\\n moveVotingPower(delegates(from), delegates(to), amount);\\n }\\n\\n /// @notice Delegate votes from `delegator` to `delegatee`.\\n /// @param delegator The address to delegate votes from\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegator, address delegatee) internal override {\\n address currentDelegate = delegates(delegator);\\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\\n _delegates[delegator] = delegatee;\\n\\n emit DelegateChanged(delegator, currentDelegate, delegatee);\\n\\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\\n }\\n}\\n\",\"keccak256\":\"0x73aa9781275a0e35c0c80873bfbb3b4b42692fa56f785a3eb4bf0471fb3c277d\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool interface\\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\\n/// an underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool.\\ninterface IAssetPool {\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amount) external returns (uint256);\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n returns (uint256);\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external;\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x5b4f1ad0d424a3de30a85a0ef1639c556073bc2eb58dc493b84c3d39a4c01847\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPoolUpgrade.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool upgrade interface\\n/// @notice Interface that has to be implemented by an Asset Pool accepting\\n/// upgrades from another asset pool.\\ninterface IAssetPoolUpgrade {\\n /// @notice Accepts the given underwriter with collateral tokens amount as a\\n /// deposit. In exchange new underwriter tokens will be calculated,\\n /// minted and then transferred back to the underwriter.\\n function depositFor(address underwriter, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0xcba05501e84b0c914619e2df9e30a6013254440013783f28deed9fc6698c58bd\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/// @title Collateral Token interface\\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\\n/// as a deposit token by underwriters. Collateral token positions of\\n/// underwriters can be affected when the Risk Manager claims coverage.\\n/// Collateral token needs to support DAO checkpoints and let to\\n/// retrieve past number of votes for the given address so that\\n/// Coverage Pool underwriters can participate in token holder DAO.\\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\ninterface ICollateralToken is IERC20 {\\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) external;\\n\\n /// @notice Determine the prior number of DAO votes for an account as of\\n /// a block number.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x7eee350d9c04b671643621258db266b65f46eea752acd7183f0bccac0eb1e233\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60e0604052621baf806002556202a3006005553480156200001f57600080fd5b5060405162005ca938038062005ca9833981810160405281019062000045919062000397565b62000065620000596200015760201b60201c565b6200015f60201b60201c565b8273ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050823082604051620000de9062000295565b620000ec939291906200046f565b604051809103906000f08015801562000109573d6000803e3d6000fd5b5073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250506200014e836200022360201b60201c565b505050620004c9565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8073ffffffffffffffffffffffffffffffffffffffff16635c19a95c306040518263ffffffff1660e01b81526004016200025e9190620004ac565b600060405180830381600087803b1580156200027957600080fd5b505af11580156200028e573d6000803e3d6000fd5b5050505050565b61180a806200449f83390190565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620002d582620002a8565b9050919050565b6000620002e982620002c8565b9050919050565b620002fb81620002dc565b81146200030757600080fd5b50565b6000815190506200031b81620002f0565b92915050565b60006200032e82620002c8565b9050919050565b620003408162000321565b81146200034c57600080fd5b50565b600081519050620003608162000335565b92915050565b6200037181620002c8565b81146200037d57600080fd5b50565b600081519050620003918162000366565b92915050565b600080600060608486031215620003b357620003b2620002a3565b5b6000620003c3868287016200030a565b9350506020620003d6868287016200034f565b9250506040620003e98682870162000380565b9150509250925092565b6000819050919050565b60006200041e620004186200041284620002a8565b620003f3565b620002a8565b9050919050565b60006200043282620003fd565b9050919050565b6000620004468262000425565b9050919050565b620004588162000439565b82525050565b6200046981620002c8565b82525050565b60006060820190506200048660008301866200044d565b6200049560208301856200045e565b620004a460408301846200045e565b949350505050565b6000602082019050620004c360008301846200045e565b92915050565b60805160a05160c051613efe620005a1600039600081816105d801528181610efb015281816114c6015281816117f501528181611bd601528181611f08015261219d01526000818161089f01528181610dd5015281816110e0015281816117cf01528181611b3601528181611d8b01528181611f880152818161221f01526124a2015260008181610f7d0152818161109a015281816112a10152818161154601528181611636015281816116800152818161189301528181611c5801528181611d45015281816122c101526125350152613efe6000f3fe608060405234801561001057600080fd5b50600436106101fb5760003560e01c8063715018a61161011a578063aad3ec96116100ad578063cc5398041161007c578063cc53980414610546578063d4c3eea014610564578063f2fde38b14610582578063fca555621461059e578063ff603d22146105ba576101fb565b8063aad3ec96146104d2578063b2016bd4146104ee578063b6b55f251461050c578063c2ef0dd61461053c576101fb565b80639ac9e7e5116100e95780639ac9e7e51461044a578063a6a56fa314610466578063a7ab696114610484578063a84f0f3f146104a2576101fb565b8063715018a6146103e85780638b4bcc4a146103f25780638da5cb5b146104105780638f4ffcb11461042e576101fb565b80632d2545e71161019257806347a5cfdb1161016157806347a5cfdb1461034e57806369da62f41461036c5780636c51741c146103885780636dbaf9ee146103b8576101fb565b80632d2545e7146102d65780633366b20b146102f45780633642110d146103125780634265117014610330576101fb565b80630964c95b116101ce5780630964c95b1461026457806312edde5e1461029457806315245857146102b05780632828fdb1146102ba576101fb565b80630359fea9146102005780630535f3bd1461021e57806307e039301461023c578063092b7eb51461025a575b600080fd5b6102086105d6565b6040516102159190612b43565b60405180910390f35b6102266105fa565b6040516102339190612b77565b60405180910390f35b610244610600565b6040516102519190612b77565b60405180910390f35b610262610606565b005b61027e60048036038101906102799190612bda565b6106fe565b60405161028b9190612b77565b60405180910390f35b6102ae60048036038101906102a99190612c33565b610716565b005b6102b86108e9565b005b6102d460048036038101906102cf9190612c33565b6109e1565b005b6102de610a33565b6040516102eb9190612b77565b60405180910390f35b6102fc610a58565b6040516103099190612c81565b60405180910390f35b61031a610a7e565b6040516103279190612b77565b60405180910390f35b610338610a98565b6040516103459190612b77565b60405180910390f35b610356610a9e565b6040516103639190612b77565b60405180910390f35b61038660048036038101906103819190612cda565b610aa4565b005b6103a2600480360381019061039d9190612d07565b610b97565b6040516103af9190612b77565b60405180910390f35b6103d260048036038101906103cd9190612bda565b610c61565b6040516103df9190612b77565b60405180910390f35b6103f0611177565b005b6103fa61118b565b6040516104079190612b77565b60405180910390f35b6104186111a5565b6040516104259190612d56565b60405180910390f35b61044860048036038101906104439190612dd6565b6111ce565b005b610464600480360381019061045f9190612c33565b6113f6565b005b61046e611448565b60405161047b9190612b77565b60405180910390f35b61048c61144e565b6040516104999190612b77565b60405180910390f35b6104bc60048036038101906104b79190612bda565b611454565b6040516104c99190612b77565b60405180910390f35b6104ec60048036038101906104e79190612e5e565b61146c565b005b6104f661167e565b6040516105039190612ebf565b60405180910390f35b61052660048036038101906105219190612c33565b6116a2565b6040516105339190612b77565b60405180910390f35b610544611728565b005b61054e6117cd565b60405161055b9190612efb565b60405180910390f35b61056c6117f1565b6040516105799190612b77565b60405180910390f35b61059c60048036038101906105979190612bda565b611949565b005b6105b860048036038101906105b39190612f16565b6119cd565b005b6105d460048036038101906105cf9190612e5e565b611efe565b005b7f000000000000000000000000000000000000000000000000000000000000000081565b60035481565b60065481565b61060e612017565b60045460008111610654576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064b90612fb3565b60405180910390fd5b61065c610a33565b81426106689190613002565b10156106a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a090613082565b60405180910390fd5b6003546002819055507fb34b8e54226bc5e8f4a9d846e344e0c42d09eeb1c79798df7ce7460c16071e2d6002546040516106e39190612b77565b60405180910390a16000600381905550600060048190555050565b60096020528060005260406000206000915090505481565b6000600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008211806107695750600081115b6107a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079f90613114565b60405180910390fd5b81816107b49190613134565b905080600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555042600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401824260405161088692919061318a565b60405180910390a260008211156108e5576108e43330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b5b5050565b6108f1612017565b60075460008111610937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092e90612fb3565b60405180910390fd5b61093f610a33565b814261094b9190613002565b101561098c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098390613082565b60405180910390fd5b6006546005819055507f9598c02e95262720ac8491c6255a4e2cfdabfb1595e7db4075699a286c0e51786005546040516109c69190612b77565b60405180910390a16000600681905550600060078190555050565b6109e9612017565b80600681905550426007819055507fea7f37aef8286a6784bab40be2b2b8d865d3a302ebaa9554a93393f0af4991be8142604051610a2892919061318a565b60405180910390a150565b60006202a300600554600254610a499190613134565b610a539190613134565b905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610a93600754610a8e610a33565b61211e565b905090565b60055481565b60045481565b610aac612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1390613225565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f798c873acf96c84f872a0ba8ab09b2eda82566b35ec01de0053dddc703294bd581604051610b8c9190612d56565b60405180910390a150565b60006bffffffffffffffffffffffff8016610bb06117f1565b84610bbb9190613134565b1115610bfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf390613291565b60405180910390fd5b6000610c0784612199565b905080831115610c4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4390613323565b60405180910390fd5b610c5733858361239e565b8091505092915050565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111610ce9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce0906133b5565b60405180910390fd5b600060025482610cf99190613134565b9050428110610d3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3490613421565b60405180910390fd5b4260055482610d4c9190613134565b1015610d8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d849061348d565b60405180910390fd5b6000600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3957600080fd5b505afa158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7191906134c2565b9050600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090557f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f6157600080fd5b505af1158015610f75573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610fd49190612d56565b60206040518083038186803b158015610fec57600080fd5b505afa158015611000573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102491906134c2565b9050600082828561103591906134ef565b61103f9190613578565b90508773ffffffffffffffffffffffffffffffffffffffff167fabed221d0c46913d6cc666ed64634168e3f1cc2638e31c6bdae1cba0b3681e4682864260405161108b939291906135a9565b60405180910390a26110de88827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b81526004016111379190612b77565b600060405180830381600087803b15801561115157600080fd5b505af1158015611165573d6000803e3d6000fd5b50505050809650505050505050919050565b61117f612017565b6111896000612605565b565b60006111a060045461119b610a33565b61211e565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6bffffffffffffffffffffffff80166111e56117f1565b856111f09190613134565b1115611231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122890613291565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461129f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112969061362c565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132490613698565b60405180910390fd5b600061133885612199565b9050600083839050146113e3576020838390501461138b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138290613704565b60405180910390fd5b6000838381019061139c9190612c33565b9050818111156113e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d890613323565b60405180910390fd5b505b6113ee86868361239e565b505050505050565b6113fe612017565b80600381905550426004819055507fad53a24a52f2d7f29240a9dbf89503d658764ecda61f09dc6fc99f8384b40a51814260405161143d92919061318a565b60405180910390a150565b60075481565b60025481565b60086020528060005260406000206000915090505481565b611474612017565b8173ffffffffffffffffffffffffffffffffffffffff167f954df0664683c9ae1eee78683930912208efdac997b3c0454ac72a9262e4e37c82426040516114bc92919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561152c57600080fd5b505af1158015611540573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161159d9190612d56565b60206040518083038186803b1580156115b557600080fd5b505afa1580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed91906134c2565b81111561162f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162690613796565b60405180910390fd5b61167a82827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b5050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006bffffffffffffffffffffffff80166116bb6117f1565b836116c69190613134565b1115611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe90613291565b60405180910390fd5b600061171283612199565b905061171f33848361239e565b80915050919050565b611730612017565b7fc5b126eaad8719040f9f4a97c3fee33e39511a07b0c7506940708ea84da3cbb5600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516117819190612d56565b60405180910390a16000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d6f192626040518163ffffffff1660e01b815260040160206040518083038186803b15801561185957600080fd5b505afa15801561186d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189191906134c2565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016118ea9190612d56565b60206040518083038186803b15801561190257600080fd5b505afa158015611916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193a91906134c2565b6119449190613134565b905090565b611951612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b890613828565b60405180910390fd5b6119ca81612605565b50565b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5690613894565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611aef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae690613926565b60405180910390fd5b60008211611b32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2990613114565b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b9a57600080fd5b505afa158015611bae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd291906134c2565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611c3c57600080fd5b505af1158015611c50573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611caf9190612d56565b60206040518083038186803b158015611cc757600080fd5b505afa158015611cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cff91906134c2565b90506000828286611d1091906134ef565b611d1a9190613578565b9050611d89600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166126c99092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166379cc679033876040518363ffffffff1660e01b8152600401611de4929190613946565b600060405180830381600087803b158015611dfe57600080fd5b505af1158015611e12573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632f4f21e233836040518363ffffffff1660e01b8152600401611e73929190613946565b600060405180830381600087803b158015611e8d57600080fd5b505af1158015611ea1573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167f52a02543e8a884453eaf1c2c5bec12d4f9e7ad29faa4ce468387ea34cef9a911828742604051611eef939291906135a9565b60405180910390a25050505050565b611f06612017565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401611fe1929190613946565b600060405180830381600087803b158015611ffb57600080fd5b505af115801561200f573d6000803e3d6000fd5b505050505050565b61201f612827565b73ffffffffffffffffffffffffffffffffffffffff1661203d6111a5565b73ffffffffffffffffffffffffffffffffffffffff1614612093576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208a906139bb565b60405180910390fd5b565b612118846323b872dd60e01b8585856040516024016120b6939291906139db565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b50505050565b6000808311612162576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161215990612fb3565b60405180910390fd5b600083426121709190613002565b9050828110612183576000915050612193565b808361218f9190613002565b9150505b92915050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561220357600080fd5b505af1158015612217573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561228357600080fd5b505afa158015612297573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122bb91906134c2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016123189190612d56565b60206040518083038186803b15801561233057600080fd5b505afa158015612344573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236891906134c2565b9050600082141561237d578392505050612399565b80828561238a91906134ef565b6123949190613578565b925050505b919050565b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561240d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240490613a5e565b60405180910390fd5b60008111612450576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161244790613af0565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff167f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca838360405161249892919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1984836040518363ffffffff1660e01b81526004016124fb929190613946565b600060405180830381600087803b15801561251557600080fd5b505af1158015612529573d6000803e3d6000fd5b5050505061257a8330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b505050565b6126008363a9059cbb60e01b848460405160240161259e929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000811480612762575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b8152600401612710929190613b10565b60206040518083038186803b15801561272857600080fd5b505afa15801561273c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276091906134c2565b145b6127a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161279890613bab565b60405180910390fd5b6128228363095ea7b360e01b84846040516024016127c0929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b600033905090565b6000612891826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166128f69092919063ffffffff16565b90506000815111156128f157808060200190518101906128b19190613c03565b6128f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128e790613ca2565b60405180910390fd5b5b505050565b6060612905848460008561290e565b90509392505050565b606082471015612953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294a90613d34565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161297c9190613dce565b60006040518083038185875af1925050503d80600081146129b9576040519150601f19603f3d011682016040523d82523d6000602084013e6129be565b606091505b50915091506129cf878383876129db565b92505050949350505050565b60608315612a3e57600083511415612a36576129f685612a51565b612a35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2c90613e31565b60405180910390fd5b5b829050612a49565b612a488383612a74565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115612a875781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612abb9190613ea6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000612b09612b04612aff84612ac4565b612ae4565b612ac4565b9050919050565b6000612b1b82612aee565b9050919050565b6000612b2d82612b10565b9050919050565b612b3d81612b22565b82525050565b6000602082019050612b586000830184612b34565b92915050565b6000819050919050565b612b7181612b5e565b82525050565b6000602082019050612b8c6000830184612b68565b92915050565b600080fd5b600080fd5b6000612ba782612ac4565b9050919050565b612bb781612b9c565b8114612bc257600080fd5b50565b600081359050612bd481612bae565b92915050565b600060208284031215612bf057612bef612b92565b5b6000612bfe84828501612bc5565b91505092915050565b612c1081612b5e565b8114612c1b57600080fd5b50565b600081359050612c2d81612c07565b92915050565b600060208284031215612c4957612c48612b92565b5b6000612c5784828501612c1e565b91505092915050565b6000612c6b82612b10565b9050919050565b612c7b81612c60565b82525050565b6000602082019050612c966000830184612c72565b92915050565b6000612ca782612b9c565b9050919050565b612cb781612c9c565b8114612cc257600080fd5b50565b600081359050612cd481612cae565b92915050565b600060208284031215612cf057612cef612b92565b5b6000612cfe84828501612cc5565b91505092915050565b60008060408385031215612d1e57612d1d612b92565b5b6000612d2c85828601612c1e565b9250506020612d3d85828601612c1e565b9150509250929050565b612d5081612b9c565b82525050565b6000602082019050612d6b6000830184612d47565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112612d9657612d95612d71565b5b8235905067ffffffffffffffff811115612db357612db2612d76565b5b602083019150836001820283011115612dcf57612dce612d7b565b5b9250929050565b600080600080600060808688031215612df257612df1612b92565b5b6000612e0088828901612bc5565b9550506020612e1188828901612c1e565b9450506040612e2288828901612bc5565b935050606086013567ffffffffffffffff811115612e4357612e42612b97565b5b612e4f88828901612d80565b92509250509295509295909350565b60008060408385031215612e7557612e74612b92565b5b6000612e8385828601612bc5565b9250506020612e9485828601612c1e565b9150509250929050565b6000612ea982612b10565b9050919050565b612eb981612e9e565b82525050565b6000602082019050612ed46000830184612eb0565b92915050565b6000612ee582612b10565b9050919050565b612ef581612eda565b82525050565b6000602082019050612f106000830184612eec565b92915050565b60008060408385031215612f2d57612f2c612b92565b5b6000612f3b85828601612c1e565b9250506020612f4c85828601612bc5565b9150509250929050565b600082825260208201905092915050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b6000612f9d601483612f56565b9150612fa882612f67565b602082019050919050565b60006020820190508181036000830152612fcc81612f90565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061300d82612b5e565b915061301883612b5e565b92508282101561302b5761302a612fd3565b5b828203905092915050565b7f476f7665726e616e63652064656c617920686173206e6f7420656c6170736564600082015250565b600061306c602083612f56565b915061307782613036565b602082019050919050565b6000602082019050818103600083015261309b8161305f565b9050919050565b7f556e64657277726974657220746f6b656e20616d6f756e74206d75737420626560008201527f2067726561746572207468616e20300000000000000000000000000000000000602082015250565b60006130fe602f83612f56565b9150613109826130a2565b604082019050919050565b6000602082019050818103600083015261312d816130f1565b9050919050565b600061313f82612b5e565b915061314a83612b5e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561317f5761317e612fd3565b5b828201905092915050565b600060408201905061319f6000830185612b68565b6131ac6020830184612b68565b9392505050565b7f4e657720617373657420706f6f6c2063616e2774206265207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061320f602483612f56565b915061321a826131b3565b604082019050919050565b6000602082019050818103600083015261323e81613202565b9050919050565b7f506f6f6c20636170616369747920657863656564656400000000000000000000600082015250565b600061327b601683612f56565b915061328682613245565b602082019050919050565b600060208201905081810360008301526132aa8161326e565b9050919050565b7f416d6f756e7420746f206d696e7420697320736d616c6c6572207468616e207460008201527f6865207265717569726564206d696e696d756d00000000000000000000000000602082015250565b600061330d603383612f56565b9150613318826132b1565b604082019050919050565b6000602082019050818103600083015261333c81613300565b9050919050565b7f4e6f207769746864726177616c20696e6974696174656420666f72207468652060008201527f756e646572777269746572000000000000000000000000000000000000000000602082015250565b600061339f602b83612f56565b91506133aa82613343565b604082019050919050565b600060208201905081810360008301526133ce81613392565b9050919050565b7f5769746864726177616c2064656c617920686173206e6f7420656c6170736564600082015250565b600061340b602083612f56565b9150613416826133d5565b602082019050919050565b6000602082019050818103600083015261343a816133fe565b9050919050565b7f5769746864726177616c2074696d656f757420656c6170736564000000000000600082015250565b6000613477601a83612f56565b915061348282613441565b602082019050919050565b600060208201905081810360008301526134a68161346a565b9050919050565b6000815190506134bc81612c07565b92915050565b6000602082840312156134d8576134d7612b92565b5b60006134e6848285016134ad565b91505092915050565b60006134fa82612b5e565b915061350583612b5e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561353e5761353d612fd3565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061358382612b5e565b915061358e83612b5e565b92508261359e5761359d613549565b5b828204905092915050565b60006060820190506135be6000830186612b68565b6135cb6020830185612b68565b6135d86040830184612b68565b949350505050565b7f4f6e6c7920746f6b656e2063616c6c657220616c6c6f77656400000000000000600082015250565b6000613616601983612f56565b9150613621826135e0565b602082019050919050565b6000602082019050818103600083015261364581613609565b9050919050565b7f556e737570706f7274656420636f6c6c61746572616c20746f6b656e00000000600082015250565b6000613682601c83612f56565b915061368d8261364c565b602082019050919050565b600060208201905081810360008301526136b181613675565b9050919050565b7f556e65787065637465642064617461206c656e67746800000000000000000000600082015250565b60006136ee601683612f56565b91506136f9826136b8565b602082019050919050565b6000602082019050818103600083015261371d816136e1565b9050919050565b7f416d6f756e7420746f207365697a6520657863656564732074686520706f6f6c60008201527f2062616c616e6365000000000000000000000000000000000000000000000000602082015250565b6000613780602883612f56565b915061378b82613724565b604082019050919050565b600060208201905081810360008301526137af81613773565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613812602683612f56565b915061381d826137b6565b604082019050919050565b6000602082019050818103600083015261384181613805565b9050919050565b7f4e657720617373657420706f6f6c206d7573742062652061737369676e656400600082015250565b600061387e601f83612f56565b915061388982613848565b602082019050919050565b600060208201905081810360008301526138ad81613871565b9050919050565b7f416464726573736573206f662061206e657720617373657420706f6f6c206d7560008201527f7374206d61746368000000000000000000000000000000000000000000000000602082015250565b6000613910602883612f56565b915061391b826138b4565b604082019050919050565b6000602082019050818103600083015261393f81613903565b9050919050565b600060408201905061395b6000830185612d47565b6139686020830184612b68565b9392505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006139a5602083612f56565b91506139b08261396f565b602082019050919050565b600060208201905081810360008301526139d481613998565b9050919050565b60006060820190506139f06000830186612d47565b6139fd6020830185612d47565b613a0a6040830184612b68565b949350505050565b7f53656c662d6465706f736974206e6f7420616c6c6f7765640000000000000000600082015250565b6000613a48601883612f56565b9150613a5382613a12565b602082019050919050565b60006020820190508181036000830152613a7781613a3b565b9050919050565b7f4d696e74656420746f6b656e7320616d6f756e74206d7573742062652067726560008201527f61746572207468616e2030000000000000000000000000000000000000000000602082015250565b6000613ada602b83612f56565b9150613ae582613a7e565b604082019050919050565b60006020820190508181036000830152613b0981613acd565b9050919050565b6000604082019050613b256000830185612d47565b613b326020830184612d47565b9392505050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000613b95603683612f56565b9150613ba082613b39565b604082019050919050565b60006020820190508181036000830152613bc481613b88565b9050919050565b60008115159050919050565b613be081613bcb565b8114613beb57600080fd5b50565b600081519050613bfd81613bd7565b92915050565b600060208284031215613c1957613c18612b92565b5b6000613c2784828501613bee565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000613c8c602a83612f56565b9150613c9782613c30565b604082019050919050565b60006020820190508181036000830152613cbb81613c7f565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000613d1e602683612f56565b9150613d2982613cc2565b604082019050919050565b60006020820190508181036000830152613d4d81613d11565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015613d88578082015181840152602081019050613d6d565b83811115613d97576000848401525b50505050565b6000613da882613d54565b613db28185613d5f565b9350613dc2818560208601613d6a565b80840191505092915050565b6000613dda8284613d9d565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000613e1b601d83612f56565b9150613e2682613de5565b602082019050919050565b60006020820190508181036000830152613e4a81613e0e565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000613e7882613e51565b613e828185612f56565b9350613e92818560208601613d6a565b613e9b81613e5c565b840191505092915050565b60006020820190508181036000830152613ec08184613e6d565b90509291505056fea26469706673582212206a2ec90cc79772da4ef337390a89355334ec5a1da50a012e1cd808863f30122d64736f6c6343000809003360c060405260006001556000600255600060035560006004553480156200002557600080fd5b506040516200180a3803806200180a83398181016040528101906200004b9190620003b9565b6200006b6200005f620000ed60201b60201c565b620000f560201b60201c565b8273ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050620000e481620001b960201b60201c565b50505062000530565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b620001c96200025060201b60201c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156200023c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000233906200049c565b60405180910390fd5b6200024d81620000f560201b60201c565b50565b62000260620000ed60201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1662000286620002e160201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1614620002df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620002d6906200050e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200033c826200030f565b9050919050565b600062000350826200032f565b9050919050565b620003628162000343565b81146200036e57600080fd5b50565b600081519050620003828162000357565b92915050565b62000393816200032f565b81146200039f57600080fd5b50565b600081519050620003b38162000388565b92915050565b600080600060608486031215620003d557620003d46200030a565b5b6000620003e58682870162000371565b9350506020620003f886828701620003a2565b92505060406200040b86828701620003a2565b9150509250925092565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006200048460268362000415565b9150620004918262000426565b604082019050919050565b60006020820190508181036000830152620004b78162000475565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000620004f660208362000415565b91506200050382620004be565b602082019050919050565b600060208201905081810360008301526200052981620004e7565b9050919050565b60805160a05161129f6200056b6000396000818161039301526104130152600081816103420152818161043501526105a0015261129f6000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c806380faa57d1161008c578063c910d95011610066578063c910d950146101f1578063d6f192621461020f578063f2fde38b1461022d578063f7c618c114610249576100ea565b806380faa57d146101975780638da5cb5b146101b5578063c8f33c91146101d3576100ea565b80633ccfd60b116100c85780633ccfd60b146101475780636e9a204b14610151578063715018a61461016f5780637b0a47ee14610179576100ea565b80630e807056146100ef5780631be052891461010b5780632ec939f914610129575b600080fd5b61010960048036038101906101049190610b04565b610267565b005b61011361038a565b6040516101209190610b40565b60405180910390f35b610131610391565b60405161013e9190610b9c565b60405180910390f35b61014f6103b5565b005b61015961047c565b6040516101669190610b40565b60405180910390f35b610177610482565b005b610181610496565b60405161018e9190610b40565b60405180910390f35b61019f61049c565b6040516101ac9190610b40565b60405180910390f35b6101bd6104af565b6040516101ca9190610b9c565b60405180910390f35b6101db6104d8565b6040516101e89190610b40565b60405180910390f35b6101f96104de565b6040516102069190610b40565b60405180910390f35b6102176104e4565b6040516102249190610b40565b60405180910390f35b61024760048036038101906102429190610be3565b61051a565b005b61025161059e565b60405161025e9190610c6f565b60405180910390f35b61026f6105c2565b6102776104e4565b60038190555060015442106102a05762093a80816102959190610ce8565b6002819055506102e7565b6000426001546102b09190610d19565b90506000600254826102c29190610d4d565b905062093a8081846102d49190610da7565b6102de9190610ce8565b60028190555050505b62093a80426102f69190610da7565b600181905550426004819055507fb32714d475c9d2f568d4ff24e88d0056b93256b5a04fbdb53a57f26bb765fbed816040516103329190610b40565b60405180910390a16103873330837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610640909392919063ffffffff16565b50565b62093a8081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006103bf6104e4565b905060006003819055506103d161049c565b6004819055507f150a6ec0e6f4e9ddcaaaa1674f157d91165a42d60653016f87a9fc870a39f050816040516104069190610b40565b60405180910390a16104797f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106c99092919063ffffffff16565b50565b60035481565b61048a6105c2565b610494600061074f565b565b60025481565b60006104aa42600154610813565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b60015481565b60006002546004546104f461049c565b6104fe9190610d19565b6105089190610d4d565b6003546105159190610da7565b905090565b6105226105c2565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610592576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058990610e80565b60405180910390fd5b61059b8161074f565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6105ca61082c565b73ffffffffffffffffffffffffffffffffffffffff166105e86104af565b73ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063590610eec565b60405180910390fd5b565b6106c3846323b872dd60e01b85858560405160240161066193929190610f0c565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b50505050565b61074a8363a9059cbb60e01b84846040516024016106e8929190610f43565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183106108225781610824565b825b905092915050565b600033905090565b6000610896826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108fb9092919063ffffffff16565b90506000815111156108f657808060200190518101906108b69190610fa4565b6108f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ec90611043565b60405180910390fd5b5b505050565b606061090a8484600085610913565b90509392505050565b606082471015610958576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094f906110d5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610981919061116f565b60006040518083038185875af1925050503d80600081146109be576040519150601f19603f3d011682016040523d82523d6000602084013e6109c3565b606091505b50915091506109d4878383876109e0565b92505050949350505050565b60608315610a4357600083511415610a3b576109fb85610a56565b610a3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a31906111d2565b60405180910390fd5b5b829050610a4e565b610a4d8383610a79565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610a8c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac09190611247565b60405180910390fd5b600080fd5b6000819050919050565b610ae181610ace565b8114610aec57600080fd5b50565b600081359050610afe81610ad8565b92915050565b600060208284031215610b1a57610b19610ac9565b5b6000610b2884828501610aef565b91505092915050565b610b3a81610ace565b82525050565b6000602082019050610b556000830184610b31565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8682610b5b565b9050919050565b610b9681610b7b565b82525050565b6000602082019050610bb16000830184610b8d565b92915050565b610bc081610b7b565b8114610bcb57600080fd5b50565b600081359050610bdd81610bb7565b92915050565b600060208284031215610bf957610bf8610ac9565b5b6000610c0784828501610bce565b91505092915050565b6000819050919050565b6000610c35610c30610c2b84610b5b565b610c10565b610b5b565b9050919050565b6000610c4782610c1a565b9050919050565b6000610c5982610c3c565b9050919050565b610c6981610c4e565b82525050565b6000602082019050610c846000830184610c60565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610cf382610ace565b9150610cfe83610ace565b925082610d0e57610d0d610c8a565b5b828204905092915050565b6000610d2482610ace565b9150610d2f83610ace565b925082821015610d4257610d41610cb9565b5b828203905092915050565b6000610d5882610ace565b9150610d6383610ace565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610d9c57610d9b610cb9565b5b828202905092915050565b6000610db282610ace565b9150610dbd83610ace565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610df257610df1610cb9565b5b828201905092915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610e6a602683610dfd565b9150610e7582610e0e565b604082019050919050565b60006020820190508181036000830152610e9981610e5d565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610ed6602083610dfd565b9150610ee182610ea0565b602082019050919050565b60006020820190508181036000830152610f0581610ec9565b9050919050565b6000606082019050610f216000830186610b8d565b610f2e6020830185610b8d565b610f3b6040830184610b31565b949350505050565b6000604082019050610f586000830185610b8d565b610f656020830184610b31565b9392505050565b60008115159050919050565b610f8181610f6c565b8114610f8c57600080fd5b50565b600081519050610f9e81610f78565b92915050565b600060208284031215610fba57610fb9610ac9565b5b6000610fc884828501610f8f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061102d602a83610dfd565b915061103882610fd1565b604082019050919050565b6000602082019050818103600083015261105c81611020565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006110bf602683610dfd565b91506110ca82611063565b604082019050919050565b600060208201905081810360008301526110ee816110b2565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561112957808201518184015260208101905061110e565b83811115611138576000848401525b50505050565b6000611149826110f5565b6111538185611100565b935061116381856020860161110b565b80840191505092915050565b600061117b828461113e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b60006111bc601d83610dfd565b91506111c782611186565b602082019050919050565b600060208201905081810360008301526111eb816111af565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000611219826111f2565b6112238185610dfd565b935061123381856020860161110b565b61123c816111fd565b840191505092915050565b60006020820190508181036000830152611261818461120e565b90509291505056fea2646970667358221220c5bae390803cc3f1622719d99fad44d96dace0eca188c3ba7313821ca78e23e664736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c8063715018a61161011a578063aad3ec96116100ad578063cc5398041161007c578063cc53980414610546578063d4c3eea014610564578063f2fde38b14610582578063fca555621461059e578063ff603d22146105ba576101fb565b8063aad3ec96146104d2578063b2016bd4146104ee578063b6b55f251461050c578063c2ef0dd61461053c576101fb565b80639ac9e7e5116100e95780639ac9e7e51461044a578063a6a56fa314610466578063a7ab696114610484578063a84f0f3f146104a2576101fb565b8063715018a6146103e85780638b4bcc4a146103f25780638da5cb5b146104105780638f4ffcb11461042e576101fb565b80632d2545e71161019257806347a5cfdb1161016157806347a5cfdb1461034e57806369da62f41461036c5780636c51741c146103885780636dbaf9ee146103b8576101fb565b80632d2545e7146102d65780633366b20b146102f45780633642110d146103125780634265117014610330576101fb565b80630964c95b116101ce5780630964c95b1461026457806312edde5e1461029457806315245857146102b05780632828fdb1146102ba576101fb565b80630359fea9146102005780630535f3bd1461021e57806307e039301461023c578063092b7eb51461025a575b600080fd5b6102086105d6565b6040516102159190612b43565b60405180910390f35b6102266105fa565b6040516102339190612b77565b60405180910390f35b610244610600565b6040516102519190612b77565b60405180910390f35b610262610606565b005b61027e60048036038101906102799190612bda565b6106fe565b60405161028b9190612b77565b60405180910390f35b6102ae60048036038101906102a99190612c33565b610716565b005b6102b86108e9565b005b6102d460048036038101906102cf9190612c33565b6109e1565b005b6102de610a33565b6040516102eb9190612b77565b60405180910390f35b6102fc610a58565b6040516103099190612c81565b60405180910390f35b61031a610a7e565b6040516103279190612b77565b60405180910390f35b610338610a98565b6040516103459190612b77565b60405180910390f35b610356610a9e565b6040516103639190612b77565b60405180910390f35b61038660048036038101906103819190612cda565b610aa4565b005b6103a2600480360381019061039d9190612d07565b610b97565b6040516103af9190612b77565b60405180910390f35b6103d260048036038101906103cd9190612bda565b610c61565b6040516103df9190612b77565b60405180910390f35b6103f0611177565b005b6103fa61118b565b6040516104079190612b77565b60405180910390f35b6104186111a5565b6040516104259190612d56565b60405180910390f35b61044860048036038101906104439190612dd6565b6111ce565b005b610464600480360381019061045f9190612c33565b6113f6565b005b61046e611448565b60405161047b9190612b77565b60405180910390f35b61048c61144e565b6040516104999190612b77565b60405180910390f35b6104bc60048036038101906104b79190612bda565b611454565b6040516104c99190612b77565b60405180910390f35b6104ec60048036038101906104e79190612e5e565b61146c565b005b6104f661167e565b6040516105039190612ebf565b60405180910390f35b61052660048036038101906105219190612c33565b6116a2565b6040516105339190612b77565b60405180910390f35b610544611728565b005b61054e6117cd565b60405161055b9190612efb565b60405180910390f35b61056c6117f1565b6040516105799190612b77565b60405180910390f35b61059c60048036038101906105979190612bda565b611949565b005b6105b860048036038101906105b39190612f16565b6119cd565b005b6105d460048036038101906105cf9190612e5e565b611efe565b005b7f000000000000000000000000000000000000000000000000000000000000000081565b60035481565b60065481565b61060e612017565b60045460008111610654576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064b90612fb3565b60405180910390fd5b61065c610a33565b81426106689190613002565b10156106a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a090613082565b60405180910390fd5b6003546002819055507fb34b8e54226bc5e8f4a9d846e344e0c42d09eeb1c79798df7ce7460c16071e2d6002546040516106e39190612b77565b60405180910390a16000600381905550600060048190555050565b60096020528060005260406000206000915090505481565b6000600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008211806107695750600081115b6107a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079f90613114565b60405180910390fd5b81816107b49190613134565b905080600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555042600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401824260405161088692919061318a565b60405180910390a260008211156108e5576108e43330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b5b5050565b6108f1612017565b60075460008111610937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092e90612fb3565b60405180910390fd5b61093f610a33565b814261094b9190613002565b101561098c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098390613082565b60405180910390fd5b6006546005819055507f9598c02e95262720ac8491c6255a4e2cfdabfb1595e7db4075699a286c0e51786005546040516109c69190612b77565b60405180910390a16000600681905550600060078190555050565b6109e9612017565b80600681905550426007819055507fea7f37aef8286a6784bab40be2b2b8d865d3a302ebaa9554a93393f0af4991be8142604051610a2892919061318a565b60405180910390a150565b60006202a300600554600254610a499190613134565b610a539190613134565b905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610a93600754610a8e610a33565b61211e565b905090565b60055481565b60045481565b610aac612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1390613225565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f798c873acf96c84f872a0ba8ab09b2eda82566b35ec01de0053dddc703294bd581604051610b8c9190612d56565b60405180910390a150565b60006bffffffffffffffffffffffff8016610bb06117f1565b84610bbb9190613134565b1115610bfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf390613291565b60405180910390fd5b6000610c0784612199565b905080831115610c4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4390613323565b60405180910390fd5b610c5733858361239e565b8091505092915050565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111610ce9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce0906133b5565b60405180910390fd5b600060025482610cf99190613134565b9050428110610d3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3490613421565b60405180910390fd5b4260055482610d4c9190613134565b1015610d8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d849061348d565b60405180910390fd5b6000600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3957600080fd5b505afa158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7191906134c2565b9050600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090557f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f6157600080fd5b505af1158015610f75573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610fd49190612d56565b60206040518083038186803b158015610fec57600080fd5b505afa158015611000573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102491906134c2565b9050600082828561103591906134ef565b61103f9190613578565b90508773ffffffffffffffffffffffffffffffffffffffff167fabed221d0c46913d6cc666ed64634168e3f1cc2638e31c6bdae1cba0b3681e4682864260405161108b939291906135a9565b60405180910390a26110de88827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b81526004016111379190612b77565b600060405180830381600087803b15801561115157600080fd5b505af1158015611165573d6000803e3d6000fd5b50505050809650505050505050919050565b61117f612017565b6111896000612605565b565b60006111a060045461119b610a33565b61211e565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6bffffffffffffffffffffffff80166111e56117f1565b856111f09190613134565b1115611231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122890613291565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461129f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112969061362c565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132490613698565b60405180910390fd5b600061133885612199565b9050600083839050146113e3576020838390501461138b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138290613704565b60405180910390fd5b6000838381019061139c9190612c33565b9050818111156113e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d890613323565b60405180910390fd5b505b6113ee86868361239e565b505050505050565b6113fe612017565b80600381905550426004819055507fad53a24a52f2d7f29240a9dbf89503d658764ecda61f09dc6fc99f8384b40a51814260405161143d92919061318a565b60405180910390a150565b60075481565b60025481565b60086020528060005260406000206000915090505481565b611474612017565b8173ffffffffffffffffffffffffffffffffffffffff167f954df0664683c9ae1eee78683930912208efdac997b3c0454ac72a9262e4e37c82426040516114bc92919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561152c57600080fd5b505af1158015611540573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161159d9190612d56565b60206040518083038186803b1580156115b557600080fd5b505afa1580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed91906134c2565b81111561162f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162690613796565b60405180910390fd5b61167a82827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b5050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006bffffffffffffffffffffffff80166116bb6117f1565b836116c69190613134565b1115611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe90613291565b60405180910390fd5b600061171283612199565b905061171f33848361239e565b80915050919050565b611730612017565b7fc5b126eaad8719040f9f4a97c3fee33e39511a07b0c7506940708ea84da3cbb5600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516117819190612d56565b60405180910390a16000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d6f192626040518163ffffffff1660e01b815260040160206040518083038186803b15801561185957600080fd5b505afa15801561186d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189191906134c2565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016118ea9190612d56565b60206040518083038186803b15801561190257600080fd5b505afa158015611916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193a91906134c2565b6119449190613134565b905090565b611951612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b890613828565b60405180910390fd5b6119ca81612605565b50565b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5690613894565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611aef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae690613926565b60405180910390fd5b60008211611b32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2990613114565b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b9a57600080fd5b505afa158015611bae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd291906134c2565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611c3c57600080fd5b505af1158015611c50573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611caf9190612d56565b60206040518083038186803b158015611cc757600080fd5b505afa158015611cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cff91906134c2565b90506000828286611d1091906134ef565b611d1a9190613578565b9050611d89600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166126c99092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166379cc679033876040518363ffffffff1660e01b8152600401611de4929190613946565b600060405180830381600087803b158015611dfe57600080fd5b505af1158015611e12573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632f4f21e233836040518363ffffffff1660e01b8152600401611e73929190613946565b600060405180830381600087803b158015611e8d57600080fd5b505af1158015611ea1573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167f52a02543e8a884453eaf1c2c5bec12d4f9e7ad29faa4ce468387ea34cef9a911828742604051611eef939291906135a9565b60405180910390a25050505050565b611f06612017565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401611fe1929190613946565b600060405180830381600087803b158015611ffb57600080fd5b505af115801561200f573d6000803e3d6000fd5b505050505050565b61201f612827565b73ffffffffffffffffffffffffffffffffffffffff1661203d6111a5565b73ffffffffffffffffffffffffffffffffffffffff1614612093576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208a906139bb565b60405180910390fd5b565b612118846323b872dd60e01b8585856040516024016120b6939291906139db565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b50505050565b6000808311612162576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161215990612fb3565b60405180910390fd5b600083426121709190613002565b9050828110612183576000915050612193565b808361218f9190613002565b9150505b92915050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561220357600080fd5b505af1158015612217573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561228357600080fd5b505afa158015612297573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122bb91906134c2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016123189190612d56565b60206040518083038186803b15801561233057600080fd5b505afa158015612344573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236891906134c2565b9050600082141561237d578392505050612399565b80828561238a91906134ef565b6123949190613578565b925050505b919050565b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561240d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240490613a5e565b60405180910390fd5b60008111612450576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161244790613af0565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff167f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca838360405161249892919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1984836040518363ffffffff1660e01b81526004016124fb929190613946565b600060405180830381600087803b15801561251557600080fd5b505af1158015612529573d6000803e3d6000fd5b5050505061257a8330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b505050565b6126008363a9059cbb60e01b848460405160240161259e929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000811480612762575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b8152600401612710929190613b10565b60206040518083038186803b15801561272857600080fd5b505afa15801561273c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276091906134c2565b145b6127a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161279890613bab565b60405180910390fd5b6128228363095ea7b360e01b84846040516024016127c0929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b600033905090565b6000612891826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166128f69092919063ffffffff16565b90506000815111156128f157808060200190518101906128b19190613c03565b6128f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128e790613ca2565b60405180910390fd5b5b505050565b6060612905848460008561290e565b90509392505050565b606082471015612953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294a90613d34565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161297c9190613dce565b60006040518083038185875af1925050503d80600081146129b9576040519150601f19603f3d011682016040523d82523d6000602084013e6129be565b606091505b50915091506129cf878383876129db565b92505050949350505050565b60608315612a3e57600083511415612a36576129f685612a51565b612a35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2c90613e31565b60405180910390fd5b5b829050612a49565b612a488383612a74565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115612a875781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612abb9190613ea6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000612b09612b04612aff84612ac4565b612ae4565b612ac4565b9050919050565b6000612b1b82612aee565b9050919050565b6000612b2d82612b10565b9050919050565b612b3d81612b22565b82525050565b6000602082019050612b586000830184612b34565b92915050565b6000819050919050565b612b7181612b5e565b82525050565b6000602082019050612b8c6000830184612b68565b92915050565b600080fd5b600080fd5b6000612ba782612ac4565b9050919050565b612bb781612b9c565b8114612bc257600080fd5b50565b600081359050612bd481612bae565b92915050565b600060208284031215612bf057612bef612b92565b5b6000612bfe84828501612bc5565b91505092915050565b612c1081612b5e565b8114612c1b57600080fd5b50565b600081359050612c2d81612c07565b92915050565b600060208284031215612c4957612c48612b92565b5b6000612c5784828501612c1e565b91505092915050565b6000612c6b82612b10565b9050919050565b612c7b81612c60565b82525050565b6000602082019050612c966000830184612c72565b92915050565b6000612ca782612b9c565b9050919050565b612cb781612c9c565b8114612cc257600080fd5b50565b600081359050612cd481612cae565b92915050565b600060208284031215612cf057612cef612b92565b5b6000612cfe84828501612cc5565b91505092915050565b60008060408385031215612d1e57612d1d612b92565b5b6000612d2c85828601612c1e565b9250506020612d3d85828601612c1e565b9150509250929050565b612d5081612b9c565b82525050565b6000602082019050612d6b6000830184612d47565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112612d9657612d95612d71565b5b8235905067ffffffffffffffff811115612db357612db2612d76565b5b602083019150836001820283011115612dcf57612dce612d7b565b5b9250929050565b600080600080600060808688031215612df257612df1612b92565b5b6000612e0088828901612bc5565b9550506020612e1188828901612c1e565b9450506040612e2288828901612bc5565b935050606086013567ffffffffffffffff811115612e4357612e42612b97565b5b612e4f88828901612d80565b92509250509295509295909350565b60008060408385031215612e7557612e74612b92565b5b6000612e8385828601612bc5565b9250506020612e9485828601612c1e565b9150509250929050565b6000612ea982612b10565b9050919050565b612eb981612e9e565b82525050565b6000602082019050612ed46000830184612eb0565b92915050565b6000612ee582612b10565b9050919050565b612ef581612eda565b82525050565b6000602082019050612f106000830184612eec565b92915050565b60008060408385031215612f2d57612f2c612b92565b5b6000612f3b85828601612c1e565b9250506020612f4c85828601612bc5565b9150509250929050565b600082825260208201905092915050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b6000612f9d601483612f56565b9150612fa882612f67565b602082019050919050565b60006020820190508181036000830152612fcc81612f90565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061300d82612b5e565b915061301883612b5e565b92508282101561302b5761302a612fd3565b5b828203905092915050565b7f476f7665726e616e63652064656c617920686173206e6f7420656c6170736564600082015250565b600061306c602083612f56565b915061307782613036565b602082019050919050565b6000602082019050818103600083015261309b8161305f565b9050919050565b7f556e64657277726974657220746f6b656e20616d6f756e74206d75737420626560008201527f2067726561746572207468616e20300000000000000000000000000000000000602082015250565b60006130fe602f83612f56565b9150613109826130a2565b604082019050919050565b6000602082019050818103600083015261312d816130f1565b9050919050565b600061313f82612b5e565b915061314a83612b5e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561317f5761317e612fd3565b5b828201905092915050565b600060408201905061319f6000830185612b68565b6131ac6020830184612b68565b9392505050565b7f4e657720617373657420706f6f6c2063616e2774206265207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061320f602483612f56565b915061321a826131b3565b604082019050919050565b6000602082019050818103600083015261323e81613202565b9050919050565b7f506f6f6c20636170616369747920657863656564656400000000000000000000600082015250565b600061327b601683612f56565b915061328682613245565b602082019050919050565b600060208201905081810360008301526132aa8161326e565b9050919050565b7f416d6f756e7420746f206d696e7420697320736d616c6c6572207468616e207460008201527f6865207265717569726564206d696e696d756d00000000000000000000000000602082015250565b600061330d603383612f56565b9150613318826132b1565b604082019050919050565b6000602082019050818103600083015261333c81613300565b9050919050565b7f4e6f207769746864726177616c20696e6974696174656420666f72207468652060008201527f756e646572777269746572000000000000000000000000000000000000000000602082015250565b600061339f602b83612f56565b91506133aa82613343565b604082019050919050565b600060208201905081810360008301526133ce81613392565b9050919050565b7f5769746864726177616c2064656c617920686173206e6f7420656c6170736564600082015250565b600061340b602083612f56565b9150613416826133d5565b602082019050919050565b6000602082019050818103600083015261343a816133fe565b9050919050565b7f5769746864726177616c2074696d656f757420656c6170736564000000000000600082015250565b6000613477601a83612f56565b915061348282613441565b602082019050919050565b600060208201905081810360008301526134a68161346a565b9050919050565b6000815190506134bc81612c07565b92915050565b6000602082840312156134d8576134d7612b92565b5b60006134e6848285016134ad565b91505092915050565b60006134fa82612b5e565b915061350583612b5e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561353e5761353d612fd3565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061358382612b5e565b915061358e83612b5e565b92508261359e5761359d613549565b5b828204905092915050565b60006060820190506135be6000830186612b68565b6135cb6020830185612b68565b6135d86040830184612b68565b949350505050565b7f4f6e6c7920746f6b656e2063616c6c657220616c6c6f77656400000000000000600082015250565b6000613616601983612f56565b9150613621826135e0565b602082019050919050565b6000602082019050818103600083015261364581613609565b9050919050565b7f556e737570706f7274656420636f6c6c61746572616c20746f6b656e00000000600082015250565b6000613682601c83612f56565b915061368d8261364c565b602082019050919050565b600060208201905081810360008301526136b181613675565b9050919050565b7f556e65787065637465642064617461206c656e67746800000000000000000000600082015250565b60006136ee601683612f56565b91506136f9826136b8565b602082019050919050565b6000602082019050818103600083015261371d816136e1565b9050919050565b7f416d6f756e7420746f207365697a6520657863656564732074686520706f6f6c60008201527f2062616c616e6365000000000000000000000000000000000000000000000000602082015250565b6000613780602883612f56565b915061378b82613724565b604082019050919050565b600060208201905081810360008301526137af81613773565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613812602683612f56565b915061381d826137b6565b604082019050919050565b6000602082019050818103600083015261384181613805565b9050919050565b7f4e657720617373657420706f6f6c206d7573742062652061737369676e656400600082015250565b600061387e601f83612f56565b915061388982613848565b602082019050919050565b600060208201905081810360008301526138ad81613871565b9050919050565b7f416464726573736573206f662061206e657720617373657420706f6f6c206d7560008201527f7374206d61746368000000000000000000000000000000000000000000000000602082015250565b6000613910602883612f56565b915061391b826138b4565b604082019050919050565b6000602082019050818103600083015261393f81613903565b9050919050565b600060408201905061395b6000830185612d47565b6139686020830184612b68565b9392505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006139a5602083612f56565b91506139b08261396f565b602082019050919050565b600060208201905081810360008301526139d481613998565b9050919050565b60006060820190506139f06000830186612d47565b6139fd6020830185612d47565b613a0a6040830184612b68565b949350505050565b7f53656c662d6465706f736974206e6f7420616c6c6f7765640000000000000000600082015250565b6000613a48601883612f56565b9150613a5382613a12565b602082019050919050565b60006020820190508181036000830152613a7781613a3b565b9050919050565b7f4d696e74656420746f6b656e7320616d6f756e74206d7573742062652067726560008201527f61746572207468616e2030000000000000000000000000000000000000000000602082015250565b6000613ada602b83612f56565b9150613ae582613a7e565b604082019050919050565b60006020820190508181036000830152613b0981613acd565b9050919050565b6000604082019050613b256000830185612d47565b613b326020830184612d47565b9392505050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000613b95603683612f56565b9150613ba082613b39565b604082019050919050565b60006020820190508181036000830152613bc481613b88565b9050919050565b60008115159050919050565b613be081613bcb565b8114613beb57600080fd5b50565b600081519050613bfd81613bd7565b92915050565b600060208284031215613c1957613c18612b92565b5b6000613c2784828501613bee565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000613c8c602a83612f56565b9150613c9782613c30565b604082019050919050565b60006020820190508181036000830152613cbb81613c7f565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000613d1e602683612f56565b9150613d2982613cc2565b604082019050919050565b60006020820190508181036000830152613d4d81613d11565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015613d88578082015181840152602081019050613d6d565b83811115613d97576000848401525b50505050565b6000613da882613d54565b613db28185613d5f565b9350613dc2818560208601613d6a565b80840191505092915050565b6000613dda8284613d9d565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000613e1b601d83612f56565b9150613e2682613de5565b602082019050919050565b60006020820190508181036000830152613e4a81613e0e565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000613e7882613e51565b613e828185612f56565b9350613e92818560208601613d6a565b613e9b81613e5c565b840191505092915050565b60006020820190508181036000830152613ec08184613e6d565b90509291505056fea26469706673582212206a2ec90cc79772da4ef337390a89355334ec5a1da50a012e1cd808863f30122d64736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "beginWithdrawalDelayUpdate(uint256)": { + "params": { + "_newWithdrawalDelay": "The new value of withdrawal delay" + } + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "params": { + "_newWithdrawalTimeout": "The new value of the withdrawal timeout" + } + }, + "completeWithdrawal(address)": { + "returns": { + "_0": "The amount of collateral withdrawn" + } + }, + "deposit(uint256)": { + "details": "Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.", + "params": { + "amountToDeposit": "Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1" + }, + "returns": { + "_0": "The amount of minted underwriter tokens" + } + }, + "depositWithMin(uint256,uint256)": { + "details": "Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.", + "params": { + "amountToDeposit": "Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1", + "minAmountToMint": "Underwriter minimal tokens amount that a user expects to receive in exchange for the deposited collateral tokens" + }, + "returns": { + "_0": "The amount of minted underwriter tokens" + } + }, + "getRemainingWithdrawalDelayUpdateTime()": { + "returns": { + "_0": "The time left until withdrawal delay update can be finalized" + } + }, + "getRemainingWithdrawalTimeoutUpdateTime()": { + "returns": { + "_0": "The time left until withdrawal timeout update can be finalized" + } + }, + "grantShares(address,uint256)": { + "details": "Can be called only by the contract owner.", + "params": { + "covAmount": "Amount of the underwriter tokens which should be minted", + "recipient": "Address of the underwriter tokens recipient" + } + }, + "initiateWithdrawal(uint256)": { + "details": "Before calling this function, underwriter token needs to have the required amount accepted to transfer to the asset pool." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "receiveApproval(address,uint256,address,bytes)": { + "details": "This function is a shortcut for approve + deposit." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "totalValue()": { + "returns": { + "_0": "The total value of asset pool in collateral token." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "upgradeToNewAssetPool(uint256,address)": { + "params": { + "_newAssetPool": "New Asset Pool address to check validity with the one that was approved by the governance", + "covAmount": "Amount of underwriter tokens used to calculate collateral tokens which are transferred to a new asset pool" + } + }, + "withdrawalGovernanceDelay()": { + "returns": { + "_0": "The withdrawal governance delay in seconds" + } + } + }, + "title": "Asset Pool", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "approveNewAssetPoolUpgrade(address)": { + "notice": "Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay." + }, + "beginWithdrawalDelayUpdate(uint256)": { + "notice": "Lets the contract owner to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible." + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "notice": "Lets the contract owner to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value." + }, + "cancelNewAssetPoolUpgrade()": { + "notice": "Allows governance to cancel already approved new asset pool in case of some misconfiguration." + }, + "claim(address,uint256)": { + "notice": "Allows the coverage pool to demand coverage from the asset hold by this pool and send it to the provided recipient address." + }, + "completeWithdrawal(address)": { + "notice": "Completes the previously initiated withdrawal for the underwriter. Anyone can complete the withdrawal for the underwriter. The withdrawal has to be completed before the withdrawal timeout elapses. Otherwise, the withdrawal has to be initiated again and the underwriter has to wait for the entire withdrawal delay again before being able to complete the withdrawal." + }, + "deposit(uint256)": { + "notice": "Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts." + }, + "depositWithMin(uint256,uint256)": { + "notice": "Accepts the given amount of collateral token as a deposit and mints at least a minAmountToMint underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts." + }, + "finalizeWithdrawalDelayUpdate()": { + "notice": "Lets the contract owner to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass." + }, + "finalizeWithdrawalTimeoutUpdate()": { + "notice": "Lets the contract owner to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass." + }, + "getRemainingWithdrawalDelayUpdateTime()": { + "notice": "Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal delay update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum." + }, + "getRemainingWithdrawalTimeoutUpdateTime()": { + "notice": "Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal timeout update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum." + }, + "grantShares(address,uint256)": { + "notice": "Grants pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes." + }, + "initiateWithdrawal(uint256)": { + "notice": "Initiates the withdrawal of collateral and rewards from the pool. Must be followed with completeWithdrawal call after the withdrawal delay passes. Accepts the amount of underwriter tokens representing the share of the pool that should be withdrawn. Can be called multiple times increasing the pool share to withdraw and resetting the withdrawal initiated timestamp for each call. Can be called with 0 covAmount to reset the withdrawal initiated timestamp if the underwriter has a pending withdrawal. In practice 0 covAmount should be used only to initiate the withdrawal again in case one did not complete the withdrawal before the withdrawal timeout elapsed." + }, + "receiveApproval(address,uint256,address,bytes)": { + "notice": "Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts. Optional data in extraData may include a minimal amount of underwriter tokens expected to be minted for a depositor. There are cases when an amount of minted tokens matters for a depositor, as tokens might be used in third party exchanges." + }, + "totalValue()": { + "notice": "Returns the current collateral token balance of the asset pool plus the reward amount (in collateral token) earned by the asset pool and not yet withdrawn to the asset pool." + }, + "upgradeToNewAssetPool(uint256,address)": { + "notice": "Transfers collateral tokens to a new Asset Pool which previously was approved by the governance. Upgrade does not have to obey withdrawal delay. Old underwriter tokens are burned in favor of new tokens minted in a new Asset Pool. New tokens are sent directly to the underwriter from a new Asset Pool." + }, + "withdrawalDelay()": { + "notice": "The time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim." + }, + "withdrawalGovernanceDelay()": { + "notice": "The time it takes to initiate and complete the withdrawal from the pool plus 2 days to make a decision. This governance delay should be used for all changes directly affecting underwriter positions. This time is a minimum and the governance may choose to wait longer before finalizing the update." + }, + "withdrawalTimeout()": { + "notice": "The time the underwriter has after the withdrawal delay passed to complete the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim. After the withdrawal timeout elapses, tokens stay in the pool and the underwriter has to initiate the withdrawal again and wait for the full withdrawal delay to complete the withdrawal." + } + }, + "notice": "Asset pool is a component of a Coverage Pool. Asset Pool accepts a single ERC20 token as collateral, and returns an underwriter token. For example, an asset pool might accept deposits in KEEP in return for covKEEP underwriter tokens. Underwriter tokens represent an ownership share in the underlying collateral of the Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens as a deposit. It means that the total supply of the collateral token can not be greater than 2^96-1 or, if that supply is greater, it is acceptable that not all tokens can be deposited into the pool.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 5629, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "newAssetPool", + "offset": 0, + "slot": "1", + "type": "t_contract(IAssetPoolUpgrade)10558" + }, + { + "astId": 5633, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalDelay", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 5635, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "newWithdrawalDelay", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 5637, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalDelayChangeInitiated", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 5641, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalTimeout", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 5643, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "newWithdrawalTimeout", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 5645, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalTimeoutChangeInitiated", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 5649, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalInitiatedTimestamp", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 5653, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "pendingWithdrawal", + "offset": 0, + "slot": "9", + "type": "t_mapping(t_address,t_uint256)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_contract(IAssetPoolUpgrade)10558": { + "encoding": "inplace", + "label": "contract IAssetPoolUpgrade", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/artifacts/BatchedPhasedEscrow.json b/artifacts/BatchedPhasedEscrow.json new file mode 100644 index 00000000..9311ca64 --- /dev/null +++ b/artifacts/BatchedPhasedEscrow.json @@ -0,0 +1,373 @@ +{ + "address": "0xa96AD7889ef29D4978e00B0cB31cD41F77bFD8A6", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "beneficiary", + "type": "address" + } + ], + "name": "BeneficiaryApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldDrawee", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newDrawee", + "type": "address" + } + ], + "name": "DraweeRoleTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensWithdrawn", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract", + "name": "_beneficiary", + "type": "address" + } + ], + "name": "approveBeneficiary", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract[]", + "name": "beneficiaries", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "batchedWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "drawee", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract", + "name": "_beneficiary", + "type": "address" + } + ], + "name": "isBeneficiaryApproved", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newDrawee", + "type": "address" + } + ], + "name": "setDrawee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x0d0e587cc0652ec111ae9d92db0ff1f92d2952cd0a6362263e37dd9ff55721b9", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0xa96AD7889ef29D4978e00B0cB31cD41F77bFD8A6", + "transactionIndex": 90, + "gasUsed": "1661630", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000800000000000000000000000000000000000402000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x5271f05403ff0f6054c6896a5344ff57cebaf1a1a50c19d82fc5f8983a2256a7", + "transactionHash": "0x0d0e587cc0652ec111ae9d92db0ff1f92d2952cd0a6362263e37dd9ff55721b9", + "logs": [ + { + "transactionIndex": 90, + "blockNumber": 16327124, + "transactionHash": "0x0d0e587cc0652ec111ae9d92db0ff1f92d2952cd0a6362263e37dd9ff55721b9", + "address": "0xa96AD7889ef29D4978e00B0cB31cD41F77bFD8A6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 177, + "blockHash": "0x5271f05403ff0f6054c6896a5344ff57cebaf1a1a50c19d82fc5f8983a2256a7" + } + ], + "blockNumber": 16327124, + "cumulativeGasUsed": "10257008", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5" + ], + "numDeployments": 1, + "solcInputHash": "1f648bbc62fc09e530210f2d58cb219e", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"}],\"name\":\"BeneficiaryApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldDrawee\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newDrawee\",\"type\":\"address\"}],\"name\":\"DraweeRoleTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokensWithdrawn\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IBeneficiaryContract\",\"name\":\"_beneficiary\",\"type\":\"address\"}],\"name\":\"approveBeneficiary\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IBeneficiaryContract[]\",\"name\":\"beneficiaries\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"batchedWithdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"drawee\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IBeneficiaryContract\",\"name\":\"_beneficiary\",\"type\":\"address\"}],\"name\":\"isBeneficiaryApproved\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newDrawee\",\"type\":\"address\"}],\"name\":\"setDrawee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"BatchedPhasedEscrow\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"approveBeneficiary(address)\":{\"notice\":\"Approves the provided address as a beneficiary of tokens held by the escrow. Can be called only by escrow owner.\"},\"batchedWithdraw(address[],uint256[])\":{\"notice\":\"Withdraws tokens from escrow to selected beneficiaries, transferring to each beneficiary the amount of tokens specified as a parameter. Only beneficiaries previously approved by escrow owner can receive funds.\"},\"isBeneficiaryApproved(address)\":{\"notice\":\"Returns `true` if the given address has been approved as a beneficiary of the escrow, `false` otherwise.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Funds the escrow by transferring all of the approved tokens to the escrow.\"},\"setDrawee(address)\":{\"notice\":\"Transfers the role of drawee to another address. Can be called only by the contract owner.\"}},\"notice\":\"A token holder contract allowing contract owner to approve a set of beneficiaries of tokens held by the contract, to appoint a separate drawee role, and allowing that drawee to withdraw tokens to approved beneficiaries in phases.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/BatchedPhasedEscrow.sol\":\"BatchedPhasedEscrow\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/BatchedPhasedEscrow.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Batched Phased Escrow Beneficiary\\n/// @notice Interface expected from contracts receiving tokens from the\\n/// BatchedPhasedEscrow.\\ninterface IBeneficiaryContract {\\n function __escrowSentTokens(uint256 amount) external;\\n}\\n\\n/// @title BatchedPhasedEscrow\\n/// @notice A token holder contract allowing contract owner to approve a set of\\n/// beneficiaries of tokens held by the contract, to appoint a separate\\n/// drawee role, and allowing that drawee to withdraw tokens to approved\\n/// beneficiaries in phases.\\ncontract BatchedPhasedEscrow is Ownable {\\n using SafeERC20 for IERC20;\\n\\n event BeneficiaryApproved(address beneficiary);\\n event TokensWithdrawn(address beneficiary, uint256 amount);\\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\\n\\n IERC20 public token;\\n address public drawee;\\n mapping(address => bool) private approvedBeneficiaries;\\n\\n modifier onlyDrawee() {\\n require(drawee == msg.sender, \\\"Caller is not the drawee\\\");\\n _;\\n }\\n\\n constructor(IERC20 _token) {\\n token = _token;\\n drawee = msg.sender;\\n }\\n\\n /// @notice Approves the provided address as a beneficiary of tokens held by\\n /// the escrow. Can be called only by escrow owner.\\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\\n external\\n onlyOwner\\n {\\n address beneficiaryAddress = address(_beneficiary);\\n require(\\n beneficiaryAddress != address(0),\\n \\\"Beneficiary can not be zero address\\\"\\n );\\n approvedBeneficiaries[beneficiaryAddress] = true;\\n emit BeneficiaryApproved(beneficiaryAddress);\\n }\\n\\n /// @notice Returns `true` if the given address has been approved as a\\n /// beneficiary of the escrow, `false` otherwise.\\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\\n public\\n view\\n returns (bool)\\n {\\n return approvedBeneficiaries[address(_beneficiary)];\\n }\\n\\n /// @notice Transfers the role of drawee to another address. Can be called\\n /// only by the contract owner.\\n function setDrawee(address newDrawee) external onlyOwner {\\n require(newDrawee != address(0), \\\"New drawee can not be zero address\\\");\\n emit DraweeRoleTransferred(drawee, newDrawee);\\n drawee = newDrawee;\\n }\\n\\n /// @notice Funds the escrow by transferring all of the approved tokens\\n /// to the escrow.\\n function receiveApproval(\\n address _from,\\n uint256 _value,\\n address _token,\\n bytes memory\\n ) external {\\n require(IERC20(_token) == token, \\\"Unsupported token\\\");\\n token.safeTransferFrom(_from, address(this), _value);\\n }\\n\\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\\n /// transferring to each beneficiary the amount of tokens specified\\n /// as a parameter. Only beneficiaries previously approved by escrow\\n /// owner can receive funds.\\n function batchedWithdraw(\\n IBeneficiaryContract[] memory beneficiaries,\\n uint256[] memory amounts\\n ) external onlyDrawee {\\n require(\\n beneficiaries.length == amounts.length,\\n \\\"Mismatched arrays length\\\"\\n );\\n\\n for (uint256 i = 0; i < beneficiaries.length; i++) {\\n IBeneficiaryContract beneficiary = beneficiaries[i];\\n require(\\n isBeneficiaryApproved(beneficiary),\\n \\\"Beneficiary was not approved\\\"\\n );\\n withdraw(beneficiary, amounts[i]);\\n }\\n }\\n\\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\\n private\\n {\\n emit TokensWithdrawn(address(beneficiary), amount);\\n token.safeTransfer(address(beneficiary), amount);\\n // slither-disable-next-line calls-loop\\n beneficiary.__escrowSentTokens(amount);\\n }\\n}\\n\",\"keccak256\":\"0xd1ed7b9149ea0672c94e22812ca723751c2be7546b1d23ffb12d9595a14a8f50\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060405162001e3e38038062001e3e83398181016040528101906200003791906200022a565b620000576200004b620000e060201b60201c565b620000e860201b60201c565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506200025c565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001de82620001b1565b9050919050565b6000620001f282620001d1565b9050919050565b6200020481620001e5565b81146200021057600080fd5b50565b6000815190506200022481620001f9565b92915050565b600060208284031215620002435762000242620001ac565b5b6000620002538482850162000213565b91505092915050565b611bd2806200026c6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063ba07075011610066578063ba0707501461011f578063d6d0aa411461013b578063f2fde38b14610159578063f70cb38e14610175578063fc0c546a146101a55761009e565b8063431714c3146100a3578063715018a6146100bf5780638da5cb5b146100c95780638f4ffcb1146100e7578063a1c9b08014610103575b600080fd5b6100bd60048036038101906100b89190610e1d565b6101c3565b005b6100c76102d3565b005b6100d16102e7565b6040516100de9190610e59565b60405180910390f35b61010160048036038101906100fc919061101c565b610310565b005b61011d6004803603810190610118919061122a565b6103f5565b005b610139600480360381019061013491906112a2565b610579565b005b610143610690565b6040516101509190610e59565b60405180910390f35b610173600480360381019061016e91906112a2565b6106b6565b005b61018f600480360381019061018a9190610e1d565b61073a565b60405161019c91906112ea565b60405180910390f35b6101ad610790565b6040516101ba9190611364565b60405180910390f35b6101cb6107b6565b6000819050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023790611402565b60405180910390fd5b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fae756b0a5bd1fbe0871906ac484a39752d357561ca291b46f52c068408c39a96816040516102c79190610e59565b60405180910390a15050565b6102db6107b6565b6102e56000610834565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146103a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103979061146e565b60405180910390fd5b6103ef843085600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108f8909392919063ffffffff16565b50505050565b3373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610485576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047c906114da565b60405180910390fd5b80518251146104c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c090611546565b60405180910390fd5b60005b82518110156105745760008382815181106104ea576104e9611566565b5b602002602001015190506104fd8161073a565b61053c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610533906115e1565b60405180910390fd5b6105608184848151811061055357610552611566565b5b6020026020010151610981565b50808061056c90611630565b9150506104cc565b505050565b6105816107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156105f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e8906116eb565b60405180910390fd5b7f2cd645351aa758b6871e153e13b27063dc3eefbf1a8acc38b31486f099cb7510600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168260405161064492919061170b565b60405180910390a180600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106be6107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561072e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610725906117a6565b60405180910390fd5b61073781610834565b50565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6107be610a76565b73ffffffffffffffffffffffffffffffffffffffff166107dc6102e7565b73ffffffffffffffffffffffffffffffffffffffff1614610832576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082990611812565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61097b846323b872dd60e01b85858560405160240161091993929190611841565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b50505050565b7f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b82826040516109b2929190611878565b60405180910390a1610a078282600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b459092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff16634a5f5456826040518263ffffffff1660e01b8152600401610a4091906118a1565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b505050505050565b600033905090565b6000610ae0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610bcb9092919063ffffffff16565b9050600081511115610b405780806020019051810190610b0091906118e8565b610b3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3690611987565b60405180910390fd5b5b505050565b610bc68363a9059cbb60e01b8484604051602401610b64929190611878565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b505050565b6060610bda8484600085610be3565b90509392505050565b606082471015610c28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1f90611a19565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610c519190611ab3565b60006040518083038185875af1925050503d8060008114610c8e576040519150601f19603f3d011682016040523d82523d6000602084013e610c93565b606091505b5091509150610ca487838387610cb0565b92505050949350505050565b60608315610d1357600083511415610d0b57610ccb85610d26565b610d0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0190611b16565b60405180910390fd5b5b829050610d1e565b610d1d8383610d49565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610d5c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d909190611b7a565b60405180910390fd5b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610dd882610dad565b9050919050565b6000610dea82610dcd565b9050919050565b610dfa81610ddf565b8114610e0557600080fd5b50565b600081359050610e1781610df1565b92915050565b600060208284031215610e3357610e32610da3565b5b6000610e4184828501610e08565b91505092915050565b610e5381610dcd565b82525050565b6000602082019050610e6e6000830184610e4a565b92915050565b610e7d81610dcd565b8114610e8857600080fd5b50565b600081359050610e9a81610e74565b92915050565b6000819050919050565b610eb381610ea0565b8114610ebe57600080fd5b50565b600081359050610ed081610eaa565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610f2982610ee0565b810181811067ffffffffffffffff82111715610f4857610f47610ef1565b5b80604052505050565b6000610f5b610d99565b9050610f678282610f20565b919050565b600067ffffffffffffffff821115610f8757610f86610ef1565b5b610f9082610ee0565b9050602081019050919050565b82818337600083830152505050565b6000610fbf610fba84610f6c565b610f51565b905082815260208101848484011115610fdb57610fda610edb565b5b610fe6848285610f9d565b509392505050565b600082601f83011261100357611002610ed6565b5b8135611013848260208601610fac565b91505092915050565b6000806000806080858703121561103657611035610da3565b5b600061104487828801610e8b565b945050602061105587828801610ec1565b935050604061106687828801610e8b565b925050606085013567ffffffffffffffff81111561108757611086610da8565b5b61109387828801610fee565b91505092959194509250565b600067ffffffffffffffff8211156110ba576110b9610ef1565b5b602082029050602081019050919050565b600080fd5b60006110e36110de8461109f565b610f51565b90508083825260208201905060208402830185811115611106576111056110cb565b5b835b8181101561112f578061111b8882610e08565b845260208401935050602081019050611108565b5050509392505050565b600082601f83011261114e5761114d610ed6565b5b813561115e8482602086016110d0565b91505092915050565b600067ffffffffffffffff82111561118257611181610ef1565b5b602082029050602081019050919050565b60006111a66111a184611167565b610f51565b905080838252602082019050602084028301858111156111c9576111c86110cb565b5b835b818110156111f257806111de8882610ec1565b8452602084019350506020810190506111cb565b5050509392505050565b600082601f83011261121157611210610ed6565b5b8135611221848260208601611193565b91505092915050565b6000806040838503121561124157611240610da3565b5b600083013567ffffffffffffffff81111561125f5761125e610da8565b5b61126b85828601611139565b925050602083013567ffffffffffffffff81111561128c5761128b610da8565b5b611298858286016111fc565b9150509250929050565b6000602082840312156112b8576112b7610da3565b5b60006112c684828501610e8b565b91505092915050565b60008115159050919050565b6112e4816112cf565b82525050565b60006020820190506112ff60008301846112db565b92915050565b6000819050919050565b600061132a61132561132084610dad565b611305565b610dad565b9050919050565b600061133c8261130f565b9050919050565b600061134e82611331565b9050919050565b61135e81611343565b82525050565b60006020820190506113796000830184611355565b92915050565b600082825260208201905092915050565b7f42656e65666963696172792063616e206e6f74206265207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006113ec60238361137f565b91506113f782611390565b604082019050919050565b6000602082019050818103600083015261141b816113df565b9050919050565b7f556e737570706f7274656420746f6b656e000000000000000000000000000000600082015250565b600061145860118361137f565b915061146382611422565b602082019050919050565b600060208201905081810360008301526114878161144b565b9050919050565b7f43616c6c6572206973206e6f7420746865206472617765650000000000000000600082015250565b60006114c460188361137f565b91506114cf8261148e565b602082019050919050565b600060208201905081810360008301526114f3816114b7565b9050919050565b7f4d69736d61746368656420617272617973206c656e6774680000000000000000600082015250565b600061153060188361137f565b915061153b826114fa565b602082019050919050565b6000602082019050818103600083015261155f81611523565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f42656e656669636961727920776173206e6f7420617070726f76656400000000600082015250565b60006115cb601c8361137f565b91506115d682611595565b602082019050919050565b600060208201905081810360008301526115fa816115be565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061163b82610ea0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561166e5761166d611601565b5b600182019050919050565b7f4e6577206472617765652063616e206e6f74206265207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006116d560228361137f565b91506116e082611679565b604082019050919050565b60006020820190508181036000830152611704816116c8565b9050919050565b60006040820190506117206000830185610e4a565b61172d6020830184610e4a565b9392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061179060268361137f565b915061179b82611734565b604082019050919050565b600060208201905081810360008301526117bf81611783565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006117fc60208361137f565b9150611807826117c6565b602082019050919050565b6000602082019050818103600083015261182b816117ef565b9050919050565b61183b81610ea0565b82525050565b60006060820190506118566000830186610e4a565b6118636020830185610e4a565b6118706040830184611832565b949350505050565b600060408201905061188d6000830185610e4a565b61189a6020830184611832565b9392505050565b60006020820190506118b66000830184611832565b92915050565b6118c5816112cf565b81146118d057600080fd5b50565b6000815190506118e2816118bc565b92915050565b6000602082840312156118fe576118fd610da3565b5b600061190c848285016118d3565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000611971602a8361137f565b915061197c82611915565b604082019050919050565b600060208201905081810360008301526119a081611964565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000611a0360268361137f565b9150611a0e826119a7565b604082019050919050565b60006020820190508181036000830152611a32816119f6565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015611a6d578082015181840152602081019050611a52565b83811115611a7c576000848401525b50505050565b6000611a8d82611a39565b611a978185611a44565b9350611aa7818560208601611a4f565b80840191505092915050565b6000611abf8284611a82565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000611b00601d8361137f565b9150611b0b82611aca565b602082019050919050565b60006020820190508181036000830152611b2f81611af3565b9050919050565b600081519050919050565b6000611b4c82611b36565b611b56818561137f565b9350611b66818560208601611a4f565b611b6f81610ee0565b840191505092915050565b60006020820190508181036000830152611b948184611b41565b90509291505056fea2646970667358221220e866eaf732d163a6a7078656998c3165d0dec06cf5a3aff327d7470ab2fc616f64736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063ba07075011610066578063ba0707501461011f578063d6d0aa411461013b578063f2fde38b14610159578063f70cb38e14610175578063fc0c546a146101a55761009e565b8063431714c3146100a3578063715018a6146100bf5780638da5cb5b146100c95780638f4ffcb1146100e7578063a1c9b08014610103575b600080fd5b6100bd60048036038101906100b89190610e1d565b6101c3565b005b6100c76102d3565b005b6100d16102e7565b6040516100de9190610e59565b60405180910390f35b61010160048036038101906100fc919061101c565b610310565b005b61011d6004803603810190610118919061122a565b6103f5565b005b610139600480360381019061013491906112a2565b610579565b005b610143610690565b6040516101509190610e59565b60405180910390f35b610173600480360381019061016e91906112a2565b6106b6565b005b61018f600480360381019061018a9190610e1d565b61073a565b60405161019c91906112ea565b60405180910390f35b6101ad610790565b6040516101ba9190611364565b60405180910390f35b6101cb6107b6565b6000819050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023790611402565b60405180910390fd5b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fae756b0a5bd1fbe0871906ac484a39752d357561ca291b46f52c068408c39a96816040516102c79190610e59565b60405180910390a15050565b6102db6107b6565b6102e56000610834565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146103a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103979061146e565b60405180910390fd5b6103ef843085600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108f8909392919063ffffffff16565b50505050565b3373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610485576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047c906114da565b60405180910390fd5b80518251146104c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c090611546565b60405180910390fd5b60005b82518110156105745760008382815181106104ea576104e9611566565b5b602002602001015190506104fd8161073a565b61053c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610533906115e1565b60405180910390fd5b6105608184848151811061055357610552611566565b5b6020026020010151610981565b50808061056c90611630565b9150506104cc565b505050565b6105816107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156105f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e8906116eb565b60405180910390fd5b7f2cd645351aa758b6871e153e13b27063dc3eefbf1a8acc38b31486f099cb7510600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168260405161064492919061170b565b60405180910390a180600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106be6107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561072e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610725906117a6565b60405180910390fd5b61073781610834565b50565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6107be610a76565b73ffffffffffffffffffffffffffffffffffffffff166107dc6102e7565b73ffffffffffffffffffffffffffffffffffffffff1614610832576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082990611812565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61097b846323b872dd60e01b85858560405160240161091993929190611841565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b50505050565b7f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b82826040516109b2929190611878565b60405180910390a1610a078282600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b459092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff16634a5f5456826040518263ffffffff1660e01b8152600401610a4091906118a1565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b505050505050565b600033905090565b6000610ae0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610bcb9092919063ffffffff16565b9050600081511115610b405780806020019051810190610b0091906118e8565b610b3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3690611987565b60405180910390fd5b5b505050565b610bc68363a9059cbb60e01b8484604051602401610b64929190611878565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b505050565b6060610bda8484600085610be3565b90509392505050565b606082471015610c28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1f90611a19565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610c519190611ab3565b60006040518083038185875af1925050503d8060008114610c8e576040519150601f19603f3d011682016040523d82523d6000602084013e610c93565b606091505b5091509150610ca487838387610cb0565b92505050949350505050565b60608315610d1357600083511415610d0b57610ccb85610d26565b610d0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0190611b16565b60405180910390fd5b5b829050610d1e565b610d1d8383610d49565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610d5c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d909190611b7a565b60405180910390fd5b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610dd882610dad565b9050919050565b6000610dea82610dcd565b9050919050565b610dfa81610ddf565b8114610e0557600080fd5b50565b600081359050610e1781610df1565b92915050565b600060208284031215610e3357610e32610da3565b5b6000610e4184828501610e08565b91505092915050565b610e5381610dcd565b82525050565b6000602082019050610e6e6000830184610e4a565b92915050565b610e7d81610dcd565b8114610e8857600080fd5b50565b600081359050610e9a81610e74565b92915050565b6000819050919050565b610eb381610ea0565b8114610ebe57600080fd5b50565b600081359050610ed081610eaa565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610f2982610ee0565b810181811067ffffffffffffffff82111715610f4857610f47610ef1565b5b80604052505050565b6000610f5b610d99565b9050610f678282610f20565b919050565b600067ffffffffffffffff821115610f8757610f86610ef1565b5b610f9082610ee0565b9050602081019050919050565b82818337600083830152505050565b6000610fbf610fba84610f6c565b610f51565b905082815260208101848484011115610fdb57610fda610edb565b5b610fe6848285610f9d565b509392505050565b600082601f83011261100357611002610ed6565b5b8135611013848260208601610fac565b91505092915050565b6000806000806080858703121561103657611035610da3565b5b600061104487828801610e8b565b945050602061105587828801610ec1565b935050604061106687828801610e8b565b925050606085013567ffffffffffffffff81111561108757611086610da8565b5b61109387828801610fee565b91505092959194509250565b600067ffffffffffffffff8211156110ba576110b9610ef1565b5b602082029050602081019050919050565b600080fd5b60006110e36110de8461109f565b610f51565b90508083825260208201905060208402830185811115611106576111056110cb565b5b835b8181101561112f578061111b8882610e08565b845260208401935050602081019050611108565b5050509392505050565b600082601f83011261114e5761114d610ed6565b5b813561115e8482602086016110d0565b91505092915050565b600067ffffffffffffffff82111561118257611181610ef1565b5b602082029050602081019050919050565b60006111a66111a184611167565b610f51565b905080838252602082019050602084028301858111156111c9576111c86110cb565b5b835b818110156111f257806111de8882610ec1565b8452602084019350506020810190506111cb565b5050509392505050565b600082601f83011261121157611210610ed6565b5b8135611221848260208601611193565b91505092915050565b6000806040838503121561124157611240610da3565b5b600083013567ffffffffffffffff81111561125f5761125e610da8565b5b61126b85828601611139565b925050602083013567ffffffffffffffff81111561128c5761128b610da8565b5b611298858286016111fc565b9150509250929050565b6000602082840312156112b8576112b7610da3565b5b60006112c684828501610e8b565b91505092915050565b60008115159050919050565b6112e4816112cf565b82525050565b60006020820190506112ff60008301846112db565b92915050565b6000819050919050565b600061132a61132561132084610dad565b611305565b610dad565b9050919050565b600061133c8261130f565b9050919050565b600061134e82611331565b9050919050565b61135e81611343565b82525050565b60006020820190506113796000830184611355565b92915050565b600082825260208201905092915050565b7f42656e65666963696172792063616e206e6f74206265207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006113ec60238361137f565b91506113f782611390565b604082019050919050565b6000602082019050818103600083015261141b816113df565b9050919050565b7f556e737570706f7274656420746f6b656e000000000000000000000000000000600082015250565b600061145860118361137f565b915061146382611422565b602082019050919050565b600060208201905081810360008301526114878161144b565b9050919050565b7f43616c6c6572206973206e6f7420746865206472617765650000000000000000600082015250565b60006114c460188361137f565b91506114cf8261148e565b602082019050919050565b600060208201905081810360008301526114f3816114b7565b9050919050565b7f4d69736d61746368656420617272617973206c656e6774680000000000000000600082015250565b600061153060188361137f565b915061153b826114fa565b602082019050919050565b6000602082019050818103600083015261155f81611523565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f42656e656669636961727920776173206e6f7420617070726f76656400000000600082015250565b60006115cb601c8361137f565b91506115d682611595565b602082019050919050565b600060208201905081810360008301526115fa816115be565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061163b82610ea0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561166e5761166d611601565b5b600182019050919050565b7f4e6577206472617765652063616e206e6f74206265207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006116d560228361137f565b91506116e082611679565b604082019050919050565b60006020820190508181036000830152611704816116c8565b9050919050565b60006040820190506117206000830185610e4a565b61172d6020830184610e4a565b9392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061179060268361137f565b915061179b82611734565b604082019050919050565b600060208201905081810360008301526117bf81611783565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006117fc60208361137f565b9150611807826117c6565b602082019050919050565b6000602082019050818103600083015261182b816117ef565b9050919050565b61183b81610ea0565b82525050565b60006060820190506118566000830186610e4a565b6118636020830185610e4a565b6118706040830184611832565b949350505050565b600060408201905061188d6000830185610e4a565b61189a6020830184611832565b9392505050565b60006020820190506118b66000830184611832565b92915050565b6118c5816112cf565b81146118d057600080fd5b50565b6000815190506118e2816118bc565b92915050565b6000602082840312156118fe576118fd610da3565b5b600061190c848285016118d3565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000611971602a8361137f565b915061197c82611915565b604082019050919050565b600060208201905081810360008301526119a081611964565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000611a0360268361137f565b9150611a0e826119a7565b604082019050919050565b60006020820190508181036000830152611a32816119f6565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015611a6d578082015181840152602081019050611a52565b83811115611a7c576000848401525b50505050565b6000611a8d82611a39565b611a978185611a44565b9350611aa7818560208601611a4f565b80840191505092915050565b6000611abf8284611a82565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000611b00601d8361137f565b9150611b0b82611aca565b602082019050919050565b60006020820190508181036000830152611b2f81611af3565b9050919050565b600081519050919050565b6000611b4c82611b36565b611b56818561137f565b9350611b66818560208601611a4f565b611b6f81610ee0565b840191505092915050565b60006020820190508181036000830152611b948184611b41565b90509291505056fea2646970667358221220e866eaf732d163a6a7078656998c3165d0dec06cf5a3aff327d7470ab2fc616f64736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "BatchedPhasedEscrow", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "approveBeneficiary(address)": { + "notice": "Approves the provided address as a beneficiary of tokens held by the escrow. Can be called only by escrow owner." + }, + "batchedWithdraw(address[],uint256[])": { + "notice": "Withdraws tokens from escrow to selected beneficiaries, transferring to each beneficiary the amount of tokens specified as a parameter. Only beneficiaries previously approved by escrow owner can receive funds." + }, + "isBeneficiaryApproved(address)": { + "notice": "Returns `true` if the given address has been approved as a beneficiary of the escrow, `false` otherwise." + }, + "receiveApproval(address,uint256,address,bytes)": { + "notice": "Funds the escrow by transferring all of the approved tokens to the escrow." + }, + "setDrawee(address)": { + "notice": "Transfers the role of drawee to another address. Can be called only by the contract owner." + } + }, + "notice": "A token holder contract allowing contract owner to approve a set of beneficiaries of tokens held by the contract, to appoint a separate drawee role, and allowing that drawee to withdraw tokens to approved beneficiaries in phases.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 7479, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "token", + "offset": 0, + "slot": "1", + "type": "t_contract(IERC20)671" + }, + { + "astId": 7481, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "drawee", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 7485, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "approvedBeneficiaries", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_bool)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IERC20)671": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + } + } + } +} \ No newline at end of file diff --git a/artifacts/CoveragePool.json b/artifacts/CoveragePool.json new file mode 100644 index 00000000..7857fddf --- /dev/null +++ b/artifacts/CoveragePool.json @@ -0,0 +1,692 @@ +{ + "address": "0x7D7B622C07f216d99eFc3EfB9Cf71872F46D811A", + "abi": [ + { + "inputs": [ + { + "internalType": "contract AssetPool", + "name": "_assetPool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerApprovalCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerApprovalStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerUnapproved", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "portionToSeize", + "type": "uint256" + } + ], + "name": "amountToSeize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "approveFirstRiskManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "approveNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "approvedRiskManagers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "assetPool", + "outputs": [ + { + "internalType": "contract AssetPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "beginRiskManagerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newWithdrawalDelay", + "type": "uint256" + } + ], + "name": "beginWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newWithdrawalTimeout", + "type": "uint256" + } + ], + "name": "beginWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "contract ICollateralToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "finalizeRiskManagerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "firstRiskManagerApproved", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "getRemainingRiskManagerApprovalTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "grantAssetPoolShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "riskManagerApprovalTimestamps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountToSeize", + "type": "uint256" + } + ], + "name": "seizeAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "portionToSeize", + "type": "uint256" + } + ], + "name": "seizePortion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "unapproveRiskManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underwriterToken", + "outputs": [ + { + "internalType": "contract UnderwriterToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x1e59f22dcdfd1aaed6b0eacc5bf8b4ff69552a813fa12ff6c8ae72a462d0f434", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x7D7B622C07f216d99eFc3EfB9Cf71872F46D811A", + "transactionIndex": 79, + "gasUsed": "2140640", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000004000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000010000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3d4c6d85742f5a15b38a53d4eb9e47911401718ba2e49ac50dc580581588614f", + "transactionHash": "0x1e59f22dcdfd1aaed6b0eacc5bf8b4ff69552a813fa12ff6c8ae72a462d0f434", + "logs": [ + { + "transactionIndex": 79, + "blockNumber": 16327120, + "transactionHash": "0x1e59f22dcdfd1aaed6b0eacc5bf8b4ff69552a813fa12ff6c8ae72a462d0f434", + "address": "0x7D7B622C07f216d99eFc3EfB9Cf71872F46D811A", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 180, + "blockHash": "0x3d4c6d85742f5a15b38a53d4eb9e47911401718ba2e49ac50dc580581588614f" + } + ], + "blockNumber": 16327120, + "cumulativeGasUsed": "9586576", + "status": 1, + "byzantium": true + }, + "args": [ + "0x21b86FDC93F23fD52022A283828dF8E808D28D5D" + ], + "numDeployments": 1, + "solcInputHash": "1f648bbc62fc09e530210f2d58cb219e", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract AssetPool\",\"name\":\"_assetPool\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"RiskManagerApprovalCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"RiskManagerApprovalStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"RiskManagerUnapproved\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"portionToSeize\",\"type\":\"uint256\"}],\"name\":\"amountToSeize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"approveFirstRiskManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IAssetPoolUpgrade\",\"name\":\"_newAssetPool\",\"type\":\"address\"}],\"name\":\"approveNewAssetPoolUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"approvedRiskManagers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"assetPool\",\"outputs\":[{\"internalType\":\"contract AssetPool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"beginRiskManagerApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newWithdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newWithdrawalTimeout\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateralToken\",\"outputs\":[{\"internalType\":\"contract ICollateralToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"finalizeRiskManagerApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"firstRiskManagerApproved\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"getRemainingRiskManagerApprovalTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"grantAssetPoolShares\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"riskManagerApprovalTimestamps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountToSeize\",\"type\":\"uint256\"}],\"name\":\"seizeAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"portionToSeize\",\"type\":\"uint256\"}],\"name\":\"seizePortion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"unapproveRiskManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underwriterToken\",\"outputs\":[{\"internalType\":\"contract UnderwriterToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Coverage pool contract is owned by the governance. Coverage pool is the owner of the asset pool contract.\",\"kind\":\"dev\",\"methods\":{\"amountToSeize(uint256)\":{\"params\":{\"portionToSeize\":\"Portion of the pool to seize in the range (0, 1] multiplied by FLOATING_POINT_DIVISOR\"}},\"approveFirstRiskManager(address)\":{\"details\":\"Can be called only by the contract owner. Can be called only once. Does not require any further calls to any functions.\",\"params\":{\"riskManager\":\"Risk manager that will be approved\"}},\"approveNewAssetPoolUpgrade(address)\":{\"params\":{\"_newAssetPool\":\"New asset pool\"}},\"beginRiskManagerApproval(address)\":{\"details\":\"Can be called only by the contract owner and only when the first risk manager is already approved. For a risk manager to be approved, a call to `finalizeRiskManagerApproval` must follow (after a governance delay).\",\"params\":{\"riskManager\":\"Risk manager that will be approved\"}},\"beginWithdrawalDelayUpdate(uint256)\":{\"params\":{\"newWithdrawalDelay\":\"The new value of withdrawal delay\"}},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"params\":{\"newWithdrawalTimeout\":\"The new value of the withdrawal timeout\"}},\"finalizeRiskManagerApproval(address)\":{\"details\":\"Can be called only by the contract owner. Must be preceded with a call to beginRiskManagerApproval and a governance delay must elapse.\",\"params\":{\"riskManager\":\"Risk manager that will be approved\"}},\"getPastVotes(address,uint256)\":{\"params\":{\"account\":\"The underwriter address to check\",\"blockNumber\":\"The block number to get the vote balance at\"},\"returns\":{\"_0\":\"The number of votes the underwriter had as of the given block\"}},\"getRemainingRiskManagerApprovalTime(address)\":{\"params\":{\"riskManager\":\"Risk manager in the process of approval\"},\"returns\":{\"_0\":\"Remaining time in seconds.\"}},\"grantAssetPoolShares(address,uint256)\":{\"details\":\"Can be called only by an approved risk manager.\",\"params\":{\"covAmount\":\"Amount of the underwriter tokens which should be minted\",\"recipient\":\"Address of the underwriter tokens recipient\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"seizeAmount(address,uint256)\":{\"params\":{\"amountToSeize\":\"Amount to be seized from the pool\",\"recipient\":\"Address that will receive the pool's seized funds\"}},\"seizePortion(address,uint256)\":{\"details\":\"`portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR` for calculation precision purposes. Further calculations in this function will need to take this divisor into account.\",\"params\":{\"portionToSeize\":\"Portion of the pool to seize in the range (0, 1] multiplied by `FLOATING_POINT_DIVISOR`\",\"recipient\":\"Address that will receive the pool's seized funds\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unapproveRiskManager(address)\":{\"details\":\"Can be called only by the contract owner.\",\"params\":{\"riskManager\":\"Risk manager that will be unapproved\"}}},\"title\":\"Coverage Pool\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"amountToSeize(uint256)\":{\"notice\":\"Calculates amount of tokens to be seized from the coverage pool.\"},\"approveFirstRiskManager(address)\":{\"notice\":\"Approves the first risk manager\"},\"approveNewAssetPoolUpgrade(address)\":{\"notice\":\"Approves upgradeability to the new asset pool. Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay.\"},\"beginRiskManagerApproval(address)\":{\"notice\":\"Begins risk manager approval process.\"},\"beginWithdrawalDelayUpdate(uint256)\":{\"notice\":\"Lets the governance to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible.\"},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"notice\":\"Lets the governance to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value.\"},\"finalizeRiskManagerApproval(address)\":{\"notice\":\"Finalizes risk manager approval process.\"},\"finalizeWithdrawalDelayUpdate()\":{\"notice\":\"Lets the governance to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass.\"},\"finalizeWithdrawalTimeoutUpdate()\":{\"notice\":\"Lets the governance to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass.\"},\"getPastVotes(address,uint256)\":{\"notice\":\"Determine the prior number of DAO votes for the given coverage pool underwriter.\"},\"getRemainingRiskManagerApprovalTime(address)\":{\"notice\":\"Returns the time remaining until the risk manager approval process can be finalized\"},\"grantAssetPoolShares(address,uint256)\":{\"notice\":\"Grants asset pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes.\"},\"seizeAmount(address,uint256)\":{\"notice\":\"Seizes funds from the coverage pool and sends them to the `recipient`.\"},\"seizePortion(address,uint256)\":{\"notice\":\"Seizes funds from the coverage pool and sends them to the `recipient`.\"},\"unapproveRiskManager(address)\":{\"notice\":\"Unapproves an already approved risk manager or cancels the approval process of a risk manager (the latter happens if called between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`). The change takes effect immediately.\"}},\"notice\":\"A contract that manages a single asset pool. Handles approving and unapproving of risk managers and allows them to seize funds from the asset pool if they are approved.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/CoveragePool.sol\":\"CoveragePool\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 /**\\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 / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xd0a917e32d1251a9b2f1dea15e932815d5382e64e6b0a18104664a6cc774cd70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"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\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./IVotesHistory.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\n/// @title Checkpoints\\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\\n/// delegation. This implementation supports token supply up to 2^96 - 1.\\n/// This contract keeps a history (checkpoints) of each account's vote\\n/// power. Vote power can be delegated either by calling the {delegate}\\n/// function directly, or by providing a signature to be used with\\n/// {delegateBySig}. Voting power can be publicly queried through\\n/// {getVotes} and {getPastVotes}.\\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\\n/// @dev This contract is upgrade-safe.\\nabstract contract Checkpoints is IVotesHistory {\\n struct Checkpoint {\\n uint32 fromBlock;\\n uint96 votes;\\n }\\n\\n // slither-disable-next-line uninitialized-state\\n mapping(address => address) internal _delegates;\\n mapping(address => uint128[]) internal _checkpoints;\\n uint128[] internal _totalSupplyCheckpoints;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n /// @notice Emitted when an account changes their delegate.\\n event DelegateChanged(\\n address indexed delegator,\\n address indexed fromDelegate,\\n address indexed toDelegate\\n );\\n\\n /// @notice Emitted when a balance or delegate change results in changes\\n /// to an account's voting power.\\n event DelegateVotesChanged(\\n address indexed delegate,\\n uint256 previousBalance,\\n uint256 newBalance\\n );\\n\\n function checkpoints(address account, uint32 pos)\\n public\\n view\\n virtual\\n returns (Checkpoint memory checkpoint)\\n {\\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\\n _checkpoints[account][pos]\\n );\\n checkpoint = Checkpoint(fromBlock, votes);\\n }\\n\\n /// @notice Get number of checkpoints for `account`.\\n function numCheckpoints(address account)\\n public\\n view\\n virtual\\n returns (uint32)\\n {\\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\\n }\\n\\n /// @notice Get the address `account` is currently delegating to.\\n function delegates(address account) public view virtual returns (address) {\\n return _delegates[account];\\n }\\n\\n /// @notice Gets the current votes balance for `account`.\\n /// @param account The address to get votes balance\\n /// @return The number of current votes for `account`\\n function getVotes(address account) public view returns (uint96) {\\n uint256 pos = _checkpoints[account].length;\\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\\n }\\n\\n /// @notice Determine the prior number of votes for an account as of\\n /// a block number.\\n /// @dev Block number must be a finalized block or else this function will\\n /// revert to prevent misinformation.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_checkpoints[account], blockNumber);\\n }\\n\\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\\n /// Note, this value is the sum of all balances, but it is NOT the\\n /// sum of all the delegated votes!\\n /// @param blockNumber The block number to get the total supply at\\n /// @dev `blockNumber` must have been already mined\\n function getPastTotalSupply(uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\\n }\\n\\n /// @notice Change delegation for `delegator` to `delegatee`.\\n // slither-disable-next-line dead-code\\n function delegate(address delegator, address delegatee) internal virtual;\\n\\n /// @notice Moves voting power from one delegate to another\\n /// @param src Address of old delegate\\n /// @param dst Address of new delegate\\n /// @param amount Voting power amount to transfer between delegates\\n function moveVotingPower(\\n address src,\\n address dst,\\n uint256 amount\\n ) internal {\\n if (src != dst && amount > 0) {\\n if (src != address(0)) {\\n // https://github.com/crytic/slither/issues/960\\n // slither-disable-next-line variable-scope\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[src],\\n subtract,\\n amount\\n );\\n emit DelegateVotesChanged(src, oldWeight, newWeight);\\n }\\n\\n if (dst != address(0)) {\\n // https://github.com/crytic/slither/issues/959\\n // slither-disable-next-line uninitialized-local\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[dst],\\n add,\\n amount\\n );\\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\\n }\\n }\\n }\\n\\n /// @notice Writes a new checkpoint based on operating last stored value\\n /// with a `delta`. Usually, said operation is the `add` or\\n /// `subtract` functions from this contract, but more complex\\n /// functions can be passed as parameters.\\n /// @param ckpts The checkpoints array to use\\n /// @param op The function to apply over the last value and the `delta`\\n /// @param delta Variation with respect to last stored value to be used\\n /// for new checkpoint\\n function writeCheckpoint(\\n uint128[] storage ckpts,\\n function(uint256, uint256) view returns (uint256) op,\\n uint256 delta\\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\\n uint256 pos = ckpts.length;\\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\\n newWeight = op(oldWeight, delta);\\n\\n if (pos > 0) {\\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\\n // slither-disable-next-line incorrect-equality\\n if (fromBlock == block.number) {\\n ckpts[pos - 1] = encodeCheckpoint(\\n fromBlock,\\n SafeCastUpgradeable.toUint96(newWeight)\\n );\\n return (oldWeight, newWeight);\\n }\\n }\\n\\n ckpts.push(\\n encodeCheckpoint(\\n SafeCastUpgradeable.toUint32(block.number),\\n SafeCastUpgradeable.toUint96(newWeight)\\n )\\n );\\n }\\n\\n /// @notice Lookup a value in a list of (sorted) checkpoints.\\n /// @param ckpts The checkpoints array to use\\n /// @param blockNumber Block number when we want to get the checkpoint at\\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\\n internal\\n view\\n returns (uint96)\\n {\\n // We run a binary search to look for the earliest checkpoint taken\\n // after `blockNumber`. During the loop, the index of the wanted\\n // checkpoint remains in the range [low-1, high). With each iteration,\\n // either `low` or `high` is moved towards the middle of the range to\\n // maintain the invariant.\\n // - If the middle checkpoint is after `blockNumber`,\\n // we look in [low, mid)\\n // - If the middle checkpoint is before or equal to `blockNumber`,\\n // we look in [mid+1, high)\\n // Once we reach a single value (when low == high), we've found the\\n // right checkpoint at the index high-1, if not out of bounds (in that\\n // case we're looking too far in the past and the result is 0).\\n // Note that if the latest checkpoint available is exactly for\\n // `blockNumber`, we end up with an index that is past the end of the\\n // array, so we technically don't find a checkpoint after\\n // `blockNumber`, but it works out the same.\\n require(blockNumber < block.number, \\\"Block not yet determined\\\");\\n\\n uint256 high = ckpts.length;\\n uint256 low = 0;\\n while (low < high) {\\n uint256 mid = MathUpgradeable.average(low, high);\\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\\n if (midBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\\n }\\n\\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\\n // slither-disable-next-line dead-code\\n function maxSupply() internal view virtual returns (uint96) {\\n return type(uint96).max;\\n }\\n\\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\\n /// checkpoint.\\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\\n /// remaining 96 bits.\\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\\n internal\\n pure\\n returns (uint128)\\n {\\n return (uint128(blockNumber) << 96) | uint128(value);\\n }\\n\\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\\n function decodeBlockNumber(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32)\\n {\\n return uint32(bytes4(bytes16(checkpoint)));\\n }\\n\\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\\n return uint96(checkpoint);\\n }\\n\\n /// @notice Decodes a block number and voting value from a `uint128`\\n /// `checkpoint`.\\n function decodeCheckpoint(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32 blockNumber, uint96 value)\\n {\\n blockNumber = decodeBlockNumber(checkpoint);\\n value = decodeValue(checkpoint);\\n }\\n\\n // slither-disable-next-line dead-code\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n // slither-disable-next-line dead-code\\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n}\\n\",\"keccak256\":\"0x67b28349e88afe7440c43df93ba5de56873d850a25147161e4469731750efb16\",\"license\":\"GPL-3.0-or-later\"},\"@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\ninterface IVotesHistory {\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n\\n function getPastTotalSupply(uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x535e87cf4c2e9a9439d99cf0918f013965fa6c4ddfbab07ff6ca4b195c8edc9f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/AssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./interfaces/IAssetPool.sol\\\";\\nimport \\\"./interfaces/IAssetPoolUpgrade.sol\\\";\\nimport \\\"./interfaces/ICollateralToken.sol\\\";\\nimport \\\"./RewardsPool.sol\\\";\\nimport \\\"./UnderwriterToken.sol\\\";\\nimport \\\"./GovernanceUtils.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Asset Pool\\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\\n/// accepts a single ERC20 token as collateral, and returns an\\n/// underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\\n/// as a deposit. It means that the total supply of the collateral token\\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\\n/// acceptable that not all tokens can be deposited into the pool.\\ncontract AssetPool is Ownable, IAssetPool {\\n using SafeERC20 for ICollateralToken;\\n using SafeERC20 for UnderwriterToken;\\n\\n ICollateralToken public immutable collateralToken;\\n UnderwriterToken public immutable underwriterToken;\\n\\n RewardsPool public immutable rewardsPool;\\n\\n IAssetPoolUpgrade public newAssetPool;\\n\\n /// @notice The time it takes the underwriter to withdraw their collateral\\n /// and rewards from the pool. This is the time that needs to pass\\n /// between initiating and completing the withdrawal. During that\\n /// time, underwriter is still earning rewards and their share of\\n /// the pool is still a subject of a possible coverage claim.\\n uint256 public withdrawalDelay = 21 days;\\n uint256 public newWithdrawalDelay;\\n uint256 public withdrawalDelayChangeInitiated;\\n\\n /// @notice The time the underwriter has after the withdrawal delay passed\\n /// to complete the withdrawal. During that time, underwriter is\\n /// still earning rewards and their share of the pool is still\\n /// a subject of a possible coverage claim.\\n /// After the withdrawal timeout elapses, tokens stay in the pool\\n /// and the underwriter has to initiate the withdrawal again and\\n /// wait for the full withdrawal delay to complete the withdrawal.\\n uint256 public withdrawalTimeout = 2 days;\\n uint256 public newWithdrawalTimeout;\\n uint256 public withdrawalTimeoutChangeInitiated;\\n\\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\\n mapping(address => uint256) public pendingWithdrawal;\\n\\n event Deposited(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount\\n );\\n\\n event CoverageClaimed(\\n address indexed recipient,\\n uint256 amount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalInitiated(\\n address indexed underwriter,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n event WithdrawalCompleted(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event ApprovedAssetPoolUpgrade(address newAssetPool);\\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\\n event AssetPoolUpgraded(\\n address indexed underwriter,\\n uint256 collateralAmount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalDelayUpdateStarted(\\n uint256 withdrawalDelay,\\n uint256 timestamp\\n );\\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\\n event WithdrawalTimeoutUpdateStarted(\\n uint256 withdrawalTimeout,\\n uint256 timestamp\\n );\\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\\n\\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\\n /// if the change was not yet initiated.\\n /// @param changeInitiatedTimestamp The timestamp at which the change has\\n /// been initiated\\n modifier onlyAfterWithdrawalGovernanceDelay(\\n uint256 changeInitiatedTimestamp\\n ) {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - changeInitiatedTimestamp >=\\n withdrawalGovernanceDelay(),\\n \\\"Governance delay has not elapsed\\\"\\n );\\n _;\\n }\\n\\n constructor(\\n ICollateralToken _collateralToken,\\n UnderwriterToken _underwriterToken,\\n address rewardsManager\\n ) {\\n collateralToken = _collateralToken;\\n underwriterToken = _underwriterToken;\\n\\n rewardsPool = new RewardsPool(\\n _collateralToken,\\n address(this),\\n rewardsManager\\n );\\n\\n initGovernance(_collateralToken);\\n }\\n\\n /// @dev Overwrite to empty if collateral token used by the AssetPool\\n /// does not support DAO checkpoints. Used for tests with KEEP token.\\n function initGovernance(ICollateralToken _collateralToken)\\n internal\\n virtual\\n {\\n _collateralToken.delegate(address(this));\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// Optional data in extraData may include a minimal amount of\\n /// underwriter tokens expected to be minted for a depositor. There\\n /// are cases when an amount of minted tokens matters for a\\n /// depositor, as tokens might be used in third party exchanges.\\n /// @dev This function is a shortcut for approve + deposit.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external {\\n require(\\n amount + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n require(msg.sender == token, \\\"Only token caller allowed\\\");\\n require(\\n token == address(collateralToken),\\n \\\"Unsupported collateral token\\\"\\n );\\n\\n uint256 toMint = _calculateTokensToMint(amount);\\n if (extraData.length != 0) {\\n require(extraData.length == 32, \\\"Unexpected data length\\\");\\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n }\\n\\n _deposit(from, amount, toMint);\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal to\\n /// 2^96-1\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amountToDeposit)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership. The amount locked in the pool after accepting\\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\\n /// function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal\\n /// to 2^96-1\\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\\n /// expects to receive in exchange for the deposited\\n /// collateral tokens\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the\\n /// pool. Must be followed with completeWithdrawal call after the\\n /// withdrawal delay passes. Accepts the amount of underwriter\\n /// tokens representing the share of the pool that should be\\n /// withdrawn. Can be called multiple times increasing the pool share\\n /// to withdraw and resetting the withdrawal initiated timestamp for\\n /// each call. Can be called with 0 covAmount to reset the\\n /// withdrawal initiated timestamp if the underwriter has a pending\\n /// withdrawal. In practice 0 covAmount should be used only to\\n /// initiate the withdrawal again in case one did not complete the\\n /// withdrawal before the withdrawal timeout elapsed.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external override {\\n uint256 pending = pendingWithdrawal[msg.sender];\\n require(\\n covAmount > 0 || pending > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n pending += covAmount;\\n pendingWithdrawal[msg.sender] = pending;\\n /* solhint-disable not-rely-on-time */\\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\\n\\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\\n /* solhint-enable not-rely-on-time */\\n\\n if (covAmount > 0) {\\n underwriterToken.safeTransferFrom(\\n msg.sender,\\n address(this),\\n covAmount\\n );\\n }\\n }\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter. Anyone can complete the withdrawal for the\\n /// underwriter. The withdrawal has to be completed before the\\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\\n /// be initiated again and the underwriter has to wait for the\\n /// entire withdrawal delay again before being able to complete\\n /// the withdrawal.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter)\\n external\\n override\\n returns (uint256)\\n {\\n /* solhint-disable not-rely-on-time */\\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\\n require(initiatedAt > 0, \\\"No withdrawal initiated for the underwriter\\\");\\n\\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\\n require(\\n withdrawalDelayEndTimestamp < block.timestamp,\\n \\\"Withdrawal delay has not elapsed\\\"\\n );\\n\\n require(\\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\\n \\\"Withdrawal timeout elapsed\\\"\\n );\\n\\n uint256 covAmount = pendingWithdrawal[underwriter];\\n uint256 covSupply = underwriterToken.totalSupply();\\n delete withdrawalInitiatedTimestamp[underwriter];\\n delete pendingWithdrawal[underwriter];\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\\n\\n emit WithdrawalCompleted(\\n underwriter,\\n amountToWithdraw,\\n covAmount,\\n block.timestamp\\n );\\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\\n\\n /* solhint-enable not-rely-on-time */\\n underwriterToken.burn(covAmount);\\n\\n return amountToWithdraw;\\n }\\n\\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\\n /// was approved by the governance. Upgrade does not have to obey\\n /// withdrawal delay.\\n /// Old underwriter tokens are burned in favor of new tokens minted\\n /// in a new Asset Pool. New tokens are sent directly to the\\n /// underwriter from a new Asset Pool.\\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\\n /// tokens which are transferred to a new asset pool\\n /// @param _newAssetPool New Asset Pool address to check validity with the one\\n /// that was approved by the governance\\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\\n external\\n {\\n /* solhint-disable not-rely-on-time */\\n require(\\n address(newAssetPool) != address(0),\\n \\\"New asset pool must be assigned\\\"\\n );\\n\\n require(\\n address(newAssetPool) == _newAssetPool,\\n \\\"Addresses of a new asset pool must match\\\"\\n );\\n\\n require(\\n covAmount > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\\n covSupply;\\n\\n collateralToken.safeApprove(\\n address(newAssetPool),\\n collateralToTransfer\\n );\\n // old underwriter tokens are burned in favor of new minted in a new\\n // asset pool\\n underwriterToken.burnFrom(msg.sender, covAmount);\\n // collateralToTransfer will be sent to a new AssetPool and new\\n // underwriter tokens will be minted and transferred back to the underwriter\\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\\n\\n emit AssetPoolUpgraded(\\n msg.sender,\\n collateralToTransfer,\\n covAmount,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Allows governance to set a new asset pool so the underwriters\\n /// can move their collateral tokens to a new asset pool without\\n /// having to wait for the withdrawal delay.\\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\\n external\\n onlyOwner\\n {\\n require(\\n address(_newAssetPool) != address(0),\\n \\\"New asset pool can't be zero address\\\"\\n );\\n\\n newAssetPool = _newAssetPool;\\n\\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\\n }\\n\\n /// @notice Allows governance to cancel already approved new asset pool\\n /// in case of some misconfiguration.\\n function cancelNewAssetPoolUpgrade() external onlyOwner {\\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\\n\\n newAssetPool = IAssetPoolUpgrade(address(0));\\n }\\n\\n /// @notice Allows the coverage pool to demand coverage from the asset hold\\n /// by this pool and send it to the provided recipient address.\\n function claim(address recipient, uint256 amount) external onlyOwner {\\n emit CoverageClaimed(recipient, amount, block.timestamp);\\n rewardsPool.withdraw();\\n require(\\n amount <= collateralToken.balanceOf(address(this)),\\n \\\"Amount to seize exceeds the pool balance\\\"\\n );\\n collateralToken.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal delay\\n /// parameter value. Withdrawal delay is the time it takes the\\n /// underwriter to withdraw their collateral and rewards from the\\n /// pool. This is the time that needs to pass between initiating and\\n /// completing the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalDelayUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal delay value should be but it should\\n /// be long enough so that the possibility of having free-riding\\n /// underwriters escaping from a potential coverage claim by\\n /// withdrawing their positions from the pool is negligible.\\n /// @param _newWithdrawalDelay The new value of withdrawal delay\\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\\n external\\n onlyOwner\\n {\\n newWithdrawalDelay = _newWithdrawalDelay;\\n withdrawalDelayChangeInitiated = block.timestamp;\\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// delay parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalDelayUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalDelayUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\\n {\\n withdrawalDelay = newWithdrawalDelay;\\n emit WithdrawalDelayUpdated(withdrawalDelay);\\n newWithdrawalDelay = 0;\\n withdrawalDelayChangeInitiated = 0;\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\\n /// parameter value. The withdrawal timeout is the time the\\n /// underwriter has - after the withdrawal delay passed - to\\n /// complete the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal timeout value should be but it should\\n /// be short enough so that the time of free-riding by being able to\\n /// immediately escape from the claim is minimal and long enough so\\n /// that honest underwriters have a possibility to finalize the\\n /// withdrawal. It is all about the right proportions with\\n /// a relation to withdrawal delay value.\\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\\n external\\n onlyOwner\\n {\\n newWithdrawalTimeout = _newWithdrawalTimeout;\\n withdrawalTimeoutChangeInitiated = block.timestamp;\\n emit WithdrawalTimeoutUpdateStarted(\\n _newWithdrawalTimeout,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// timeout parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalTimeoutUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\\n {\\n withdrawalTimeout = newWithdrawalTimeout;\\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\\n newWithdrawalTimeout = 0;\\n withdrawalTimeoutChangeInitiated = 0;\\n }\\n\\n /// @notice Grants pool shares by minting a given amount of the underwriter\\n /// tokens for the recipient address. In result, the recipient\\n /// obtains part of the pool ownership without depositing any\\n /// collateral tokens. Shares are usually granted for notifiers\\n /// reporting about various contract state changes.\\n /// @dev Can be called only by the contract owner.\\n /// @param recipient Address of the underwriter tokens recipient\\n /// @param covAmount Amount of the underwriter tokens which should be minted\\n function grantShares(address recipient, uint256 covAmount)\\n external\\n onlyOwner\\n {\\n rewardsPool.withdraw();\\n underwriterToken.mint(recipient, covAmount);\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal delay update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal delay update can be finalized\\n function getRemainingWithdrawalDelayUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalDelayChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal timeout update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal timeout update can be finalized\\n function getRemainingWithdrawalTimeoutUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalTimeoutChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the current collateral token balance of the asset pool\\n /// plus the reward amount (in collateral token) earned by the asset\\n /// pool and not yet withdrawn to the asset pool.\\n /// @return The total value of asset pool in collateral token.\\n function totalValue() public view returns (uint256) {\\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\\n }\\n\\n /// @notice The time it takes to initiate and complete the withdrawal from\\n /// the pool plus 2 days to make a decision. This governance delay\\n /// should be used for all changes directly affecting underwriter\\n /// positions. This time is a minimum and the governance may choose\\n /// to wait longer before finalizing the update.\\n /// @return The withdrawal governance delay in seconds\\n function withdrawalGovernanceDelay() public view returns (uint256) {\\n return withdrawalDelay + withdrawalTimeout + 2 days;\\n }\\n\\n /// @dev Calculates underwriter tokens to mint.\\n function _calculateTokensToMint(uint256 amountToDeposit)\\n internal\\n returns (uint256)\\n {\\n rewardsPool.withdraw();\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n if (covSupply == 0) {\\n return amountToDeposit;\\n }\\n\\n return (amountToDeposit * covSupply) / collateralBalance;\\n }\\n\\n function _deposit(\\n address depositor,\\n uint256 amountToDeposit,\\n uint256 amountToMint\\n ) internal {\\n require(depositor != address(this), \\\"Self-deposit not allowed\\\");\\n\\n require(\\n amountToMint > 0,\\n \\\"Minted tokens amount must be greater than 0\\\"\\n );\\n\\n emit Deposited(depositor, amountToDeposit, amountToMint);\\n\\n underwriterToken.mint(depositor, amountToMint);\\n collateralToken.safeTransferFrom(\\n depositor,\\n address(this),\\n amountToDeposit\\n );\\n }\\n}\\n\",\"keccak256\":\"0x41be5f1b06ae8b9b722c642030127cce94f571b63c4a782b155f5f42e5d61ccc\",\"license\":\"MIT\"},\"contracts/CoveragePool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./interfaces/IAssetPoolUpgrade.sol\\\";\\nimport \\\"./interfaces/ICollateralToken.sol\\\";\\nimport \\\"./AssetPool.sol\\\";\\nimport \\\"./CoveragePoolConstants.sol\\\";\\nimport \\\"./GovernanceUtils.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Coverage Pool\\n/// @notice A contract that manages a single asset pool. Handles approving and\\n/// unapproving of risk managers and allows them to seize funds from the\\n/// asset pool if they are approved.\\n/// @dev Coverage pool contract is owned by the governance. Coverage pool is the\\n/// owner of the asset pool contract.\\ncontract CoveragePool is Ownable {\\n AssetPool public immutable assetPool;\\n ICollateralToken public immutable collateralToken;\\n UnderwriterToken public immutable underwriterToken;\\n\\n bool public firstRiskManagerApproved = false;\\n\\n // Currently approved risk managers\\n mapping(address => bool) public approvedRiskManagers;\\n // Timestamps of risk managers whose approvals have been initiated\\n mapping(address => uint256) public riskManagerApprovalTimestamps;\\n\\n event RiskManagerApprovalStarted(address riskManager, uint256 timestamp);\\n event RiskManagerApprovalCompleted(address riskManager, uint256 timestamp);\\n event RiskManagerUnapproved(address riskManager, uint256 timestamp);\\n\\n /// @notice Reverts if called by a risk manager that is not approved\\n modifier onlyApprovedRiskManager() {\\n require(approvedRiskManagers[msg.sender], \\\"Risk manager not approved\\\");\\n _;\\n }\\n\\n constructor(AssetPool _assetPool) {\\n assetPool = _assetPool;\\n collateralToken = _assetPool.collateralToken();\\n underwriterToken = _assetPool.underwriterToken();\\n }\\n\\n /// @notice Approves the first risk manager\\n /// @dev Can be called only by the contract owner. Can be called only once.\\n /// Does not require any further calls to any functions.\\n /// @param riskManager Risk manager that will be approved\\n function approveFirstRiskManager(address riskManager) external onlyOwner {\\n require(\\n !firstRiskManagerApproved,\\n \\\"The first risk manager was approved\\\"\\n );\\n approvedRiskManagers[riskManager] = true;\\n firstRiskManagerApproved = true;\\n }\\n\\n /// @notice Begins risk manager approval process.\\n /// @dev Can be called only by the contract owner and only when the first\\n /// risk manager is already approved. For a risk manager to be\\n /// approved, a call to `finalizeRiskManagerApproval` must follow\\n /// (after a governance delay).\\n /// @param riskManager Risk manager that will be approved\\n function beginRiskManagerApproval(address riskManager) external onlyOwner {\\n require(\\n firstRiskManagerApproved,\\n \\\"The first risk manager is not yet approved; Please use \\\"\\n \\\"approveFirstRiskManager instead\\\"\\n );\\n\\n require(\\n !approvedRiskManagers[riskManager],\\n \\\"Risk manager already approved\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n riskManagerApprovalTimestamps[riskManager] = block.timestamp;\\n /* solhint-disable-next-line not-rely-on-time */\\n emit RiskManagerApprovalStarted(riskManager, block.timestamp);\\n }\\n\\n /// @notice Finalizes risk manager approval process.\\n /// @dev Can be called only by the contract owner. Must be preceded with a\\n /// call to beginRiskManagerApproval and a governance delay must elapse.\\n /// @param riskManager Risk manager that will be approved\\n function finalizeRiskManagerApproval(address riskManager)\\n external\\n onlyOwner\\n {\\n require(\\n riskManagerApprovalTimestamps[riskManager] > 0,\\n \\\"Risk manager approval not initiated\\\"\\n );\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - riskManagerApprovalTimestamps[riskManager] >=\\n assetPool.withdrawalGovernanceDelay(),\\n \\\"Risk manager governance delay has not elapsed\\\"\\n );\\n approvedRiskManagers[riskManager] = true;\\n /* solhint-disable-next-line not-rely-on-time */\\n emit RiskManagerApprovalCompleted(riskManager, block.timestamp);\\n delete riskManagerApprovalTimestamps[riskManager];\\n }\\n\\n /// @notice Unapproves an already approved risk manager or cancels the\\n /// approval process of a risk manager (the latter happens if called\\n /// between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`).\\n /// The change takes effect immediately.\\n /// @dev Can be called only by the contract owner.\\n /// @param riskManager Risk manager that will be unapproved\\n function unapproveRiskManager(address riskManager) external onlyOwner {\\n require(\\n riskManagerApprovalTimestamps[riskManager] > 0 ||\\n approvedRiskManagers[riskManager],\\n \\\"Risk manager is neither approved nor with a pending approval\\\"\\n );\\n delete riskManagerApprovalTimestamps[riskManager];\\n delete approvedRiskManagers[riskManager];\\n /* solhint-disable-next-line not-rely-on-time */\\n emit RiskManagerUnapproved(riskManager, block.timestamp);\\n }\\n\\n /// @notice Approves upgradeability to the new asset pool.\\n /// Allows governance to set a new asset pool so the underwriters\\n /// can move their collateral tokens to a new asset pool without\\n /// having to wait for the withdrawal delay.\\n /// @param _newAssetPool New asset pool\\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\\n external\\n onlyOwner\\n {\\n assetPool.approveNewAssetPoolUpgrade(_newAssetPool);\\n }\\n\\n /// @notice Lets the governance to begin an update of withdrawal delay\\n /// parameter value. Withdrawal delay is the time it takes the\\n /// underwriter to withdraw their collateral and rewards from the\\n /// pool. This is the time that needs to pass between initiating and\\n /// completing the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalDelayUpdate after the required\\n /// governance delay passes. It is up to the governance to\\n /// decide what the withdrawal delay value should be but it should\\n /// be long enough so that the possibility of having free-riding\\n /// underwriters escaping from a potential coverage claim by\\n /// withdrawing their positions from the pool is negligible.\\n /// @param newWithdrawalDelay The new value of withdrawal delay\\n function beginWithdrawalDelayUpdate(uint256 newWithdrawalDelay)\\n external\\n onlyOwner\\n {\\n assetPool.beginWithdrawalDelayUpdate(newWithdrawalDelay);\\n }\\n\\n /// @notice Lets the governance to finalize an update of withdrawal\\n /// delay parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalDelayUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalDelayUpdate() external onlyOwner {\\n assetPool.finalizeWithdrawalDelayUpdate();\\n }\\n\\n /// @notice Lets the governance to begin an update of withdrawal timeout\\n /// parameter value. The withdrawal timeout is the time the\\n /// underwriter has - after the withdrawal delay passed - to\\n /// complete the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\\n /// governance delay passes. It is up to the governance to\\n /// decide what the withdrawal timeout value should be but it should\\n /// be short enough so that the time of free-riding by being able to\\n /// immediately escape from the claim is minimal and long enough so\\n /// that honest underwriters have a possibility to finalize the\\n /// withdrawal. It is all about the right proportions with\\n /// a relation to withdrawal delay value.\\n /// @param newWithdrawalTimeout The new value of the withdrawal timeout\\n function beginWithdrawalTimeoutUpdate(uint256 newWithdrawalTimeout)\\n external\\n onlyOwner\\n {\\n assetPool.beginWithdrawalTimeoutUpdate(newWithdrawalTimeout);\\n }\\n\\n /// @notice Lets the governance to finalize an update of withdrawal\\n /// timeout parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalTimeoutUpdate() external onlyOwner {\\n assetPool.finalizeWithdrawalTimeoutUpdate();\\n }\\n\\n /// @notice Seizes funds from the coverage pool and sends them to the\\n /// `recipient`.\\n /// @dev `portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR`\\n /// for calculation precision purposes. Further calculations in this\\n /// function will need to take this divisor into account.\\n /// @param recipient Address that will receive the pool's seized funds\\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\\n /// multiplied by `FLOATING_POINT_DIVISOR`\\n function seizePortion(address recipient, uint256 portionToSeize)\\n external\\n onlyApprovedRiskManager\\n {\\n require(\\n portionToSeize > 0 &&\\n portionToSeize <= CoveragePoolConstants.FLOATING_POINT_DIVISOR,\\n \\\"Portion to seize is not within the range (0, 1]\\\"\\n );\\n\\n assetPool.claim(recipient, amountToSeize(portionToSeize));\\n }\\n\\n /// @notice Seizes funds from the coverage pool and sends them to the\\n /// `recipient`.\\n /// @param recipient Address that will receive the pool's seized funds\\n /// @param amountToSeize Amount to be seized from the pool\\n // slither-disable-next-line shadowing-local\\n function seizeAmount(address recipient, uint256 amountToSeize)\\n external\\n onlyApprovedRiskManager\\n {\\n require(amountToSeize > 0, \\\"Amount to seize must be >0\\\");\\n\\n assetPool.claim(recipient, amountToSeize);\\n }\\n\\n /// @notice Grants asset pool shares by minting a given amount of the\\n /// underwriter tokens for the recipient address. In result, the\\n /// recipient obtains part of the pool ownership without depositing\\n /// any collateral tokens. Shares are usually granted for notifiers\\n /// reporting about various contract state changes.\\n /// @dev Can be called only by an approved risk manager.\\n /// @param recipient Address of the underwriter tokens recipient\\n /// @param covAmount Amount of the underwriter tokens which should be minted\\n function grantAssetPoolShares(address recipient, uint256 covAmount)\\n external\\n onlyApprovedRiskManager\\n {\\n assetPool.grantShares(recipient, covAmount);\\n }\\n\\n /// @notice Returns the time remaining until the risk manager approval\\n /// process can be finalized\\n /// @param riskManager Risk manager in the process of approval\\n /// @return Remaining time in seconds.\\n function getRemainingRiskManagerApprovalTime(address riskManager)\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n riskManagerApprovalTimestamps[riskManager],\\n assetPool.withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Determine the prior number of DAO votes for the given coverage\\n /// pool underwriter.\\n /// @param account The underwriter address to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the underwriter had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96)\\n {\\n uint96 underwriterVotes = underwriterToken.getPastVotes(\\n account,\\n blockNumber\\n );\\n uint96 underwriterTokenSupply = underwriterToken.getPastTotalSupply(\\n blockNumber\\n );\\n\\n if (underwriterTokenSupply == 0) {\\n return 0;\\n }\\n\\n uint96 covPoolVotes = collateralToken.getPastVotes(\\n address(assetPool),\\n blockNumber\\n );\\n\\n return\\n uint96(\\n (uint256(underwriterVotes) * covPoolVotes) /\\n underwriterTokenSupply\\n );\\n }\\n\\n /// @notice Calculates amount of tokens to be seized from the coverage pool.\\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\\n /// multiplied by FLOATING_POINT_DIVISOR\\n function amountToSeize(uint256 portionToSeize)\\n public\\n view\\n returns (uint256)\\n {\\n return\\n (collateralToken.balanceOf(address(assetPool)) * portionToSeize) /\\n CoveragePoolConstants.FLOATING_POINT_DIVISOR;\\n }\\n}\\n\",\"keccak256\":\"0x84ac20c2bdc5f1a66783ca7bd607e8042e8fda4c37c4ac33502dcbbc7fee9432\",\"license\":\"MIT\"},\"contracts/CoveragePoolConstants.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nlibrary CoveragePoolConstants {\\n // This divisor is for precision purposes only. We use this divisor around\\n // auction related code to get the precise values without rounding it down\\n // when dealing with floating numbers.\\n uint256 public constant FLOATING_POINT_DIVISOR = 1e18;\\n}\\n\",\"keccak256\":\"0x6762b84f1f678a93a7714dc1c91288f935255cf729569e1fa976d9172a4e3c6e\",\"license\":\"MIT\"},\"contracts/GovernanceUtils.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nlibrary GovernanceUtils {\\n /// @notice Gets the time remaining until the governable parameter update\\n /// can be committed.\\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\\n /// @param delay Governance delay.\\n /// @return Remaining time in seconds.\\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\\n internal\\n view\\n returns (uint256)\\n {\\n require(changeTimestamp > 0, \\\"Change not initiated\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n uint256 elapsed = block.timestamp - changeTimestamp;\\n if (elapsed >= delay) {\\n return 0;\\n } else {\\n return delay - elapsed;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x991d317527b08149a0e263c4c951e5969b29d48fd3aa64b2807de70fc766fd91\",\"license\":\"MIT\"},\"contracts/RewardsPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Rewards Pool\\n/// @notice RewardsPool accepts a single reward token and releases it to the\\n/// AssetPool over time in one week reward intervals. The owner of this\\n/// contract is the reward distribution address funding it with reward\\n/// tokens.\\ncontract RewardsPool is Ownable {\\n using SafeERC20 for IERC20;\\n\\n uint256 public constant DURATION = 7 days;\\n\\n IERC20 public immutable rewardToken;\\n address public immutable assetPool;\\n\\n // timestamp of the current reward interval end or the timestamp of the\\n // last interval end in case a new reward interval has not been allocated\\n uint256 public intervalFinish = 0;\\n // rate per second with which reward tokens are unlocked\\n uint256 public rewardRate = 0;\\n // amount of rewards accumulated and not yet withdrawn from the previous\\n // reward interval(s)\\n uint256 public rewardAccumulated = 0;\\n // the last time information in this contract was updated\\n uint256 public lastUpdateTime = 0;\\n\\n event RewardToppedUp(uint256 amount);\\n event RewardWithdrawn(uint256 amount);\\n\\n constructor(\\n IERC20 _rewardToken,\\n address _assetPool,\\n address owner\\n ) {\\n rewardToken = _rewardToken;\\n // slither-disable-next-line missing-zero-check\\n assetPool = _assetPool;\\n transferOwnership(owner);\\n }\\n\\n /// @notice Transfers the provided reward amount into RewardsPool and\\n /// creates a new, one-week reward interval starting from now.\\n /// Reward tokens from the previous reward interval that unlocked\\n /// over the time will be available for withdrawal immediately.\\n /// Reward tokens from the previous interval that has not been yet\\n /// unlocked, are added to the new interval being created.\\n /// @dev This function can be called only by the owner given that it creates\\n /// a new interval with one week length, starting from now.\\n function topUpReward(uint256 reward) external onlyOwner {\\n rewardAccumulated = earned();\\n\\n /* solhint-disable not-rely-on-time */\\n if (block.timestamp >= intervalFinish) {\\n // see https://github.com/crytic/slither/issues/844\\n // slither-disable-next-line divide-before-multiply\\n rewardRate = reward / DURATION;\\n } else {\\n uint256 remaining = intervalFinish - block.timestamp;\\n uint256 leftover = remaining * rewardRate;\\n rewardRate = (reward + leftover) / DURATION;\\n }\\n intervalFinish = block.timestamp + DURATION;\\n lastUpdateTime = block.timestamp;\\n /* solhint-enable avoid-low-level-calls */\\n\\n emit RewardToppedUp(reward);\\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\\n function withdraw() external {\\n uint256 amount = earned();\\n rewardAccumulated = 0;\\n lastUpdateTime = lastTimeRewardApplicable();\\n emit RewardWithdrawn(amount);\\n rewardToken.safeTransfer(assetPool, amount);\\n }\\n\\n /// @notice Returns the amount of earned and not yet withdrawn reward\\n /// tokens.\\n function earned() public view returns (uint256) {\\n return\\n rewardAccumulated +\\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\\n }\\n\\n /// @notice Returns the timestamp at which a reward was last time applicable.\\n /// When reward interval is pending, returns current block's\\n /// timestamp. If the last reward interval ended and no other reward\\n /// interval had been allocated, returns the last reward interval's\\n /// end timestamp.\\n function lastTimeRewardApplicable() public view returns (uint256) {\\n return Math.min(block.timestamp, intervalFinish);\\n }\\n}\\n\",\"keccak256\":\"0xe56e8c35bbafad758cc66473f113ea9fd3ffa9c44c6139fc3196dbbead2a4054\",\"license\":\"MIT\"},\"contracts/UnderwriterToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\\";\\n\\n/// @title UnderwriterToken\\n/// @notice Underwriter tokens represent an ownership share in the underlying\\n/// collateral of the asset-specific pool. Underwriter tokens are minted\\n/// when a user deposits ERC20 tokens into asset-specific pool and they\\n/// are burned when a user exits the position. Underwriter tokens\\n/// natively support meta transactions. Users can authorize a transfer\\n/// of their underwriter tokens with a signature conforming EIP712\\n/// standard instead of an on-chain transaction from their address.\\n/// Anyone can submit this signature on the user's behalf by calling the\\n/// permit function, as specified in EIP2612 standard, paying gas fees,\\n/// and possibly performing other actions in the same transaction.\\n// slither-disable-next-line missing-inheritance\\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\\n /// @notice The EIP-712 typehash for the delegation struct used by\\n /// `delegateBySig`.\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\n \\\"Delegation(address delegatee,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n constructor(string memory _name, string memory _symbol)\\n ERC20WithPermit(_name, _symbol)\\n {}\\n\\n /// @notice Delegates votes from signatory to `delegatee`\\n /// @param delegatee The address to delegate votes to\\n /// @param deadline The time at which to expire the signature\\n /// @param v The recovery byte of the signature\\n /// @param r Half of the ECDSA signature pair\\n /// @param s Half of the ECDSA signature pair\\n function delegateBySig(\\n address signatory,\\n address delegatee,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Delegation expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n DELEGATION_TYPEHASH,\\n delegatee,\\n nonce[signatory]++,\\n deadline\\n )\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == signatory,\\n \\\"Invalid signature\\\"\\n );\\n\\n return delegate(signatory, delegatee);\\n }\\n\\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) public virtual {\\n return delegate(msg.sender, delegatee);\\n }\\n\\n /// @notice Moves voting power when tokens are minted, burned or transferred.\\n /// @dev Overrides the empty function from the parent contract.\\n /// @param from The address that loses tokens and voting power\\n /// @param to The address that gains tokens and voting power\\n /// @param amount The amount of tokens and voting power that is transferred\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal override {\\n // When minting:\\n if (from == address(0)) {\\n // Does not allow to mint more than uint96 can fit. Otherwise, the\\n // Checkpoint might not fit the balance.\\n require(\\n totalSupply + amount <= maxSupply(),\\n \\\"Maximum total supply exceeded\\\"\\n );\\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\\n }\\n\\n // When burning:\\n if (to == address(0)) {\\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\\n }\\n\\n moveVotingPower(delegates(from), delegates(to), amount);\\n }\\n\\n /// @notice Delegate votes from `delegator` to `delegatee`.\\n /// @param delegator The address to delegate votes from\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegator, address delegatee) internal override {\\n address currentDelegate = delegates(delegator);\\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\\n _delegates[delegator] = delegatee;\\n\\n emit DelegateChanged(delegator, currentDelegate, delegatee);\\n\\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\\n }\\n}\\n\",\"keccak256\":\"0x73aa9781275a0e35c0c80873bfbb3b4b42692fa56f785a3eb4bf0471fb3c277d\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool interface\\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\\n/// an underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool.\\ninterface IAssetPool {\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amount) external returns (uint256);\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n returns (uint256);\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external;\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x5b4f1ad0d424a3de30a85a0ef1639c556073bc2eb58dc493b84c3d39a4c01847\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPoolUpgrade.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool upgrade interface\\n/// @notice Interface that has to be implemented by an Asset Pool accepting\\n/// upgrades from another asset pool.\\ninterface IAssetPoolUpgrade {\\n /// @notice Accepts the given underwriter with collateral tokens amount as a\\n /// deposit. In exchange new underwriter tokens will be calculated,\\n /// minted and then transferred back to the underwriter.\\n function depositFor(address underwriter, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0xcba05501e84b0c914619e2df9e30a6013254440013783f28deed9fc6698c58bd\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/// @title Collateral Token interface\\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\\n/// as a deposit token by underwriters. Collateral token positions of\\n/// underwriters can be affected when the Risk Manager claims coverage.\\n/// Collateral token needs to support DAO checkpoints and let to\\n/// retrieve past number of votes for the given address so that\\n/// Coverage Pool underwriters can participate in token holder DAO.\\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\ninterface ICollateralToken is IERC20 {\\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) external;\\n\\n /// @notice Determine the prior number of DAO votes for an account as of\\n /// a block number.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x7eee350d9c04b671643621258db266b65f46eea752acd7183f0bccac0eb1e233\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60e060405260008060146101000a81548160ff0219169083151502179055503480156200002b57600080fd5b5060405162002a4238038062002a42833981810160405281019062000051919062000360565b62000071620000656200021660201b60201c565b6200021e60201b60201c565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1663b2016bd46040518163ffffffff1660e01b815260040160206040518083038186803b158015620000ec57600080fd5b505afa15801562000101573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001279190620003d7565b73ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1663cc5398046040518163ffffffff1660e01b815260040160206040518083038186803b158015620001a157600080fd5b505afa158015620001b6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001dc91906200044e565b73ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250505062000480565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200031482620002e7565b9050919050565b6000620003288262000307565b9050919050565b6200033a816200031b565b81146200034657600080fd5b50565b6000815190506200035a816200032f565b92915050565b600060208284031215620003795762000378620002e2565b5b6000620003898482850162000349565b91505092915050565b60006200039f8262000307565b9050919050565b620003b18162000392565b8114620003bd57600080fd5b50565b600081519050620003d181620003a6565b92915050565b600060208284031215620003f057620003ef620002e2565b5b60006200040084828501620003c0565b91505092915050565b6000620004168262000307565b9050919050565b620004288162000409565b81146200043457600080fd5b50565b60008151905062000448816200041d565b92915050565b600060208284031215620004675762000466620002e2565b5b6000620004778482850162000437565b91505092915050565b60805160a05160c05161252262000520600039600081816108e40152818161099301526115b2015260008181610a6201528181610c7701526112ca015260008181610452015281816104dc01528181610566015281816106800152818161071101528181610a9e01528181610bc101528181610cb301528181610d6301528181610ee80152818161100b0152818161123c01526113bd01526125226000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c806376b6a1af116100c3578063c753e5801161007c578063c753e58014610363578063cc5398041461037f578063ccfbf30a1461039d578063e1e92fcf146103cd578063efec39a0146103fd578063f2fde38b1461041957610158565b806376b6a1af146102b757806384e1c564146102d35780638da5cb5b146102ef5780639ac9e7e51461030d578063b2016bd414610329578063bdceb0e21461034757610158565b806333f29dd01161011557806333f29dd0146101e55780633a46b1a814610201578063465b43e6146102315780635d6f5ddb1461026157806369da62f414610291578063715018a6146102ad57610158565b80630647cada1461015d578063092b7eb51461017b57806315245857146101855780632828fdb11461018f5780632b9d0579146101ab5780632ec939f9146101c7575b600080fd5b610165610435565b604051610172919061193d565b60405180910390f35b610183610448565b005b61018d6104d2565b005b6101a960048036038101906101a49190611993565b61055c565b005b6101c560048036038101906101c09190611a1e565b6105f2565b005b6101cf61070f565b6040516101dc9190611abd565b60405180910390f35b6101ff60048036038101906101fa9190611ad8565b610733565b005b61021b60048036038101906102169190611a1e565b6108df565b6040516102289190611b2c565b60405180910390f35b61024b60048036038101906102469190611ad8565b610b7a565b6040516102589190611b56565b60405180910390f35b61027b60048036038101906102769190611993565b610c69565b6040516102889190611b56565b60405180910390f35b6102ab60048036038101906102a69190611baf565b610d59565b005b6102b5610def565b005b6102d160048036038101906102cc9190611a1e565b610e03565b005b6102ed60048036038101906102e89190611ad8565b610f7f565b005b6102f7611209565b6040516103049190611beb565b60405180910390f35b61032760048036038101906103229190611993565b611232565b005b6103316112c8565b60405161033e9190611c27565b60405180910390f35b610361600480360381019061035c9190611a1e565b6112ec565b005b61037d60048036038101906103789190611ad8565b61144c565b005b6103876115b0565b6040516103949190611c63565b60405180910390f35b6103b760048036038101906103b29190611ad8565b6115d4565b6040516103c4919061193d565b60405180910390f35b6103e760048036038101906103e29190611ad8565b6115f4565b6040516103f49190611b56565b60405180910390f35b61041760048036038101906104129190611ad8565b61160c565b005b610433600480360381019061042e9190611ad8565b6116d9565b005b600060149054906101000a900460ff1681565b61045061175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663092b7eb56040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156104b857600080fd5b505af11580156104cc573d6000803e3d6000fd5b50505050565b6104da61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663152458576040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561054257600080fd5b505af1158015610556573d6000803e3d6000fd5b50505050565b61056461175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632828fdb1826040518263ffffffff1660e01b81526004016105bd9190611b56565b600060405180830381600087803b1580156105d757600080fd5b505af11580156105eb573d6000803e3d6000fd5b5050505050565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661067e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067590611cdb565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ff603d2283836040518363ffffffff1660e01b81526004016106d9929190611cfb565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b61073b61175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411806107d25750600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b610811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080890611d96565b60405180910390fd5b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690557f9bf9ec07f4d3e134e1a799a215cf4c47dbf1c427fe348f3c0d3994ef1c2e295781426040516108d4929190611cfb565b60405180910390a150565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a885856040518363ffffffff1660e01b815260040161093d929190611cfb565b60206040518083038186803b15801561095557600080fd5b505afa158015610969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098d9190611de2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16638e539e8c856040518263ffffffff1660e01b81526004016109ea9190611b56565b60206040518083038186803b158015610a0257600080fd5b505afa158015610a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3a9190611de2565b90506000816bffffffffffffffffffffffff161415610a5e57600092505050610b74565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a87f0000000000000000000000000000000000000000000000000000000000000000876040518363ffffffff1660e01b8152600401610adb929190611cfb565b60206040518083038186803b158015610af357600080fd5b505afa158015610b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b9190611de2565b9050816bffffffffffffffffffffffff16816bffffffffffffffffffffffff16846bffffffffffffffffffffffff16610b649190611e3e565b610b6e9190611ec7565b93505050505b92915050565b6000610c62600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020547f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2557600080fd5b505afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d9190611f0d565b6117db565b9050919050565b6000670de0b6b3a7640000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a082317f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b8152600401610cee9190611beb565b60206040518083038186803b158015610d0657600080fd5b505afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190611f0d565b610d489190611e3e565b610d529190611ec7565b9050919050565b610d6161175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166369da62f4826040518263ffffffff1660e01b8152600401610dba9190611f5b565b600060405180830381600087803b158015610dd457600080fd5b505af1158015610de8573d6000803e3d6000fd5b5050505050565b610df761175d565b610e016000611856565b565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610e8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8690611cdb565b60405180910390fd5b600081118015610ea75750670de0b6b3a76400008111155b610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd90611fe8565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683610f2c84610c69565b6040518363ffffffff1660e01b8152600401610f49929190611cfb565b600060405180830381600087803b158015610f6357600080fd5b505af1158015610f77573d6000803e3d6000fd5b505050505050565b610f8761175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411611009576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110009061207a565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b15801561106f57600080fd5b505afa158015611083573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a79190611f0d565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054426110f2919061209a565b1015611133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112a90612140565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f8499a35b7f2bbd8a5de334eed2665f0f7ea74bf1c4785bb3fb2c6a9b97fe1c5481426040516111bb929190611cfb565b60405180910390a1600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61123a61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16639ac9e7e5826040518263ffffffff1660e01b81526004016112939190611b56565b600060405180830381600087803b1580156112ad57600080fd5b505af11580156112c1573d6000803e3d6000fd5b5050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611378576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136f90611cdb565b60405180910390fd5b600081116113bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b2906121ac565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683836040518363ffffffff1660e01b8152600401611416929190611cfb565b600060405180830381600087803b15801561143057600080fd5b505af1158015611444573d6000803e3d6000fd5b505050505050565b61145461175d565b600060149054906101000a900460ff166114a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149a90612264565b60405180910390fd5b600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611530576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611527906122d0565b60405180910390fd5b42600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f981f6bdfdbe336d34d32ee17135d9517e6a5ffb574159f7ceaf02b3e2ed255b281426040516115a5929190611cfb565b60405180910390a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b60016020528060005260406000206000915054906101000a900460ff1681565b60026020528060005260406000206000915090505481565b61161461175d565b600060149054906101000a900460ff1615611664576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165b90612362565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600060146101000a81548160ff02191690831515021790555050565b6116e161175d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611751576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611748906123f4565b60405180910390fd5b61175a81611856565b50565b61176561191a565b73ffffffffffffffffffffffffffffffffffffffff16611783611209565b73ffffffffffffffffffffffffffffffffffffffff16146117d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d090612460565b60405180910390fd5b565b600080831161181f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611816906124cc565b60405180910390fd5b6000834261182d919061209a565b9050828110611840576000915050611850565b808361184c919061209a565b9150505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b60008115159050919050565b61193781611922565b82525050565b6000602082019050611952600083018461192e565b92915050565b600080fd5b6000819050919050565b6119708161195d565b811461197b57600080fd5b50565b60008135905061198d81611967565b92915050565b6000602082840312156119a9576119a8611958565b5b60006119b78482850161197e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119eb826119c0565b9050919050565b6119fb816119e0565b8114611a0657600080fd5b50565b600081359050611a18816119f2565b92915050565b60008060408385031215611a3557611a34611958565b5b6000611a4385828601611a09565b9250506020611a548582860161197e565b9150509250929050565b6000819050919050565b6000611a83611a7e611a79846119c0565b611a5e565b6119c0565b9050919050565b6000611a9582611a68565b9050919050565b6000611aa782611a8a565b9050919050565b611ab781611a9c565b82525050565b6000602082019050611ad26000830184611aae565b92915050565b600060208284031215611aee57611aed611958565b5b6000611afc84828501611a09565b91505092915050565b60006bffffffffffffffffffffffff82169050919050565b611b2681611b05565b82525050565b6000602082019050611b416000830184611b1d565b92915050565b611b508161195d565b82525050565b6000602082019050611b6b6000830184611b47565b92915050565b6000611b7c826119e0565b9050919050565b611b8c81611b71565b8114611b9757600080fd5b50565b600081359050611ba981611b83565b92915050565b600060208284031215611bc557611bc4611958565b5b6000611bd384828501611b9a565b91505092915050565b611be5816119e0565b82525050565b6000602082019050611c006000830184611bdc565b92915050565b6000611c1182611a8a565b9050919050565b611c2181611c06565b82525050565b6000602082019050611c3c6000830184611c18565b92915050565b6000611c4d82611a8a565b9050919050565b611c5d81611c42565b82525050565b6000602082019050611c786000830184611c54565b92915050565b600082825260208201905092915050565b7f5269736b206d616e61676572206e6f7420617070726f76656400000000000000600082015250565b6000611cc5601983611c7e565b9150611cd082611c8f565b602082019050919050565b60006020820190508181036000830152611cf481611cb8565b9050919050565b6000604082019050611d106000830185611bdc565b611d1d6020830184611b47565b9392505050565b7f5269736b206d616e61676572206973206e65697468657220617070726f76656460008201527f206e6f72207769746820612070656e64696e6720617070726f76616c00000000602082015250565b6000611d80603c83611c7e565b9150611d8b82611d24565b604082019050919050565b60006020820190508181036000830152611daf81611d73565b9050919050565b611dbf81611b05565b8114611dca57600080fd5b50565b600081519050611ddc81611db6565b92915050565b600060208284031215611df857611df7611958565b5b6000611e0684828501611dcd565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611e498261195d565b9150611e548361195d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611e8d57611e8c611e0f565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611ed28261195d565b9150611edd8361195d565b925082611eed57611eec611e98565b5b828204905092915050565b600081519050611f0781611967565b92915050565b600060208284031215611f2357611f22611958565b5b6000611f3184828501611ef8565b91505092915050565b6000611f4582611a8a565b9050919050565b611f5581611f3a565b82525050565b6000602082019050611f706000830184611f4c565b92915050565b7f506f7274696f6e20746f207365697a65206973206e6f742077697468696e207460008201527f68652072616e67652028302c20315d0000000000000000000000000000000000602082015250565b6000611fd2602f83611c7e565b9150611fdd82611f76565b604082019050919050565b6000602082019050818103600083015261200181611fc5565b9050919050565b7f5269736b206d616e6167657220617070726f76616c206e6f7420696e6974696160008201527f7465640000000000000000000000000000000000000000000000000000000000602082015250565b6000612064602383611c7e565b915061206f82612008565b604082019050919050565b6000602082019050818103600083015261209381612057565b9050919050565b60006120a58261195d565b91506120b08361195d565b9250828210156120c3576120c2611e0f565b5b828203905092915050565b7f5269736b206d616e6167657220676f7665726e616e63652064656c617920686160008201527f73206e6f7420656c617073656400000000000000000000000000000000000000602082015250565b600061212a602d83611c7e565b9150612135826120ce565b604082019050919050565b600060208201905081810360008301526121598161211d565b9050919050565b7f416d6f756e7420746f207365697a65206d757374206265203e30000000000000600082015250565b6000612196601a83611c7e565b91506121a182612160565b602082019050919050565b600060208201905081810360008301526121c581612189565b9050919050565b7f546865206669727374207269736b206d616e61676572206973206e6f7420796560008201527f7420617070726f7665643b20506c656173652075736520617070726f7665466960208201527f7273745269736b4d616e6167657220696e737465616400000000000000000000604082015250565b600061224e605683611c7e565b9150612259826121cc565b606082019050919050565b6000602082019050818103600083015261227d81612241565b9050919050565b7f5269736b206d616e6167657220616c726561647920617070726f766564000000600082015250565b60006122ba601d83611c7e565b91506122c582612284565b602082019050919050565b600060208201905081810360008301526122e9816122ad565b9050919050565b7f546865206669727374207269736b206d616e616765722077617320617070726f60008201527f7665640000000000000000000000000000000000000000000000000000000000602082015250565b600061234c602383611c7e565b9150612357826122f0565b604082019050919050565b6000602082019050818103600083015261237b8161233f565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006123de602683611c7e565b91506123e982612382565b604082019050919050565b6000602082019050818103600083015261240d816123d1565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061244a602083611c7e565b915061245582612414565b602082019050919050565b600060208201905081810360008301526124798161243d565b9050919050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b60006124b6601483611c7e565b91506124c182612480565b602082019050919050565b600060208201905081810360008301526124e5816124a9565b905091905056fea2646970667358221220ec205cb71546993cf5a2a6b6040e8c2992a7fa4c20445f6280393e2db7e83c8864736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101585760003560e01c806376b6a1af116100c3578063c753e5801161007c578063c753e58014610363578063cc5398041461037f578063ccfbf30a1461039d578063e1e92fcf146103cd578063efec39a0146103fd578063f2fde38b1461041957610158565b806376b6a1af146102b757806384e1c564146102d35780638da5cb5b146102ef5780639ac9e7e51461030d578063b2016bd414610329578063bdceb0e21461034757610158565b806333f29dd01161011557806333f29dd0146101e55780633a46b1a814610201578063465b43e6146102315780635d6f5ddb1461026157806369da62f414610291578063715018a6146102ad57610158565b80630647cada1461015d578063092b7eb51461017b57806315245857146101855780632828fdb11461018f5780632b9d0579146101ab5780632ec939f9146101c7575b600080fd5b610165610435565b604051610172919061193d565b60405180910390f35b610183610448565b005b61018d6104d2565b005b6101a960048036038101906101a49190611993565b61055c565b005b6101c560048036038101906101c09190611a1e565b6105f2565b005b6101cf61070f565b6040516101dc9190611abd565b60405180910390f35b6101ff60048036038101906101fa9190611ad8565b610733565b005b61021b60048036038101906102169190611a1e565b6108df565b6040516102289190611b2c565b60405180910390f35b61024b60048036038101906102469190611ad8565b610b7a565b6040516102589190611b56565b60405180910390f35b61027b60048036038101906102769190611993565b610c69565b6040516102889190611b56565b60405180910390f35b6102ab60048036038101906102a69190611baf565b610d59565b005b6102b5610def565b005b6102d160048036038101906102cc9190611a1e565b610e03565b005b6102ed60048036038101906102e89190611ad8565b610f7f565b005b6102f7611209565b6040516103049190611beb565b60405180910390f35b61032760048036038101906103229190611993565b611232565b005b6103316112c8565b60405161033e9190611c27565b60405180910390f35b610361600480360381019061035c9190611a1e565b6112ec565b005b61037d60048036038101906103789190611ad8565b61144c565b005b6103876115b0565b6040516103949190611c63565b60405180910390f35b6103b760048036038101906103b29190611ad8565b6115d4565b6040516103c4919061193d565b60405180910390f35b6103e760048036038101906103e29190611ad8565b6115f4565b6040516103f49190611b56565b60405180910390f35b61041760048036038101906104129190611ad8565b61160c565b005b610433600480360381019061042e9190611ad8565b6116d9565b005b600060149054906101000a900460ff1681565b61045061175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663092b7eb56040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156104b857600080fd5b505af11580156104cc573d6000803e3d6000fd5b50505050565b6104da61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663152458576040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561054257600080fd5b505af1158015610556573d6000803e3d6000fd5b50505050565b61056461175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632828fdb1826040518263ffffffff1660e01b81526004016105bd9190611b56565b600060405180830381600087803b1580156105d757600080fd5b505af11580156105eb573d6000803e3d6000fd5b5050505050565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661067e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067590611cdb565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ff603d2283836040518363ffffffff1660e01b81526004016106d9929190611cfb565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b61073b61175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411806107d25750600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b610811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080890611d96565b60405180910390fd5b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690557f9bf9ec07f4d3e134e1a799a215cf4c47dbf1c427fe348f3c0d3994ef1c2e295781426040516108d4929190611cfb565b60405180910390a150565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a885856040518363ffffffff1660e01b815260040161093d929190611cfb565b60206040518083038186803b15801561095557600080fd5b505afa158015610969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098d9190611de2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16638e539e8c856040518263ffffffff1660e01b81526004016109ea9190611b56565b60206040518083038186803b158015610a0257600080fd5b505afa158015610a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3a9190611de2565b90506000816bffffffffffffffffffffffff161415610a5e57600092505050610b74565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a87f0000000000000000000000000000000000000000000000000000000000000000876040518363ffffffff1660e01b8152600401610adb929190611cfb565b60206040518083038186803b158015610af357600080fd5b505afa158015610b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b9190611de2565b9050816bffffffffffffffffffffffff16816bffffffffffffffffffffffff16846bffffffffffffffffffffffff16610b649190611e3e565b610b6e9190611ec7565b93505050505b92915050565b6000610c62600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020547f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2557600080fd5b505afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d9190611f0d565b6117db565b9050919050565b6000670de0b6b3a7640000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a082317f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b8152600401610cee9190611beb565b60206040518083038186803b158015610d0657600080fd5b505afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190611f0d565b610d489190611e3e565b610d529190611ec7565b9050919050565b610d6161175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166369da62f4826040518263ffffffff1660e01b8152600401610dba9190611f5b565b600060405180830381600087803b158015610dd457600080fd5b505af1158015610de8573d6000803e3d6000fd5b5050505050565b610df761175d565b610e016000611856565b565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610e8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8690611cdb565b60405180910390fd5b600081118015610ea75750670de0b6b3a76400008111155b610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd90611fe8565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683610f2c84610c69565b6040518363ffffffff1660e01b8152600401610f49929190611cfb565b600060405180830381600087803b158015610f6357600080fd5b505af1158015610f77573d6000803e3d6000fd5b505050505050565b610f8761175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411611009576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110009061207a565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b15801561106f57600080fd5b505afa158015611083573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a79190611f0d565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054426110f2919061209a565b1015611133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112a90612140565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f8499a35b7f2bbd8a5de334eed2665f0f7ea74bf1c4785bb3fb2c6a9b97fe1c5481426040516111bb929190611cfb565b60405180910390a1600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61123a61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16639ac9e7e5826040518263ffffffff1660e01b81526004016112939190611b56565b600060405180830381600087803b1580156112ad57600080fd5b505af11580156112c1573d6000803e3d6000fd5b5050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611378576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136f90611cdb565b60405180910390fd5b600081116113bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b2906121ac565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683836040518363ffffffff1660e01b8152600401611416929190611cfb565b600060405180830381600087803b15801561143057600080fd5b505af1158015611444573d6000803e3d6000fd5b505050505050565b61145461175d565b600060149054906101000a900460ff166114a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149a90612264565b60405180910390fd5b600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611530576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611527906122d0565b60405180910390fd5b42600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f981f6bdfdbe336d34d32ee17135d9517e6a5ffb574159f7ceaf02b3e2ed255b281426040516115a5929190611cfb565b60405180910390a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b60016020528060005260406000206000915054906101000a900460ff1681565b60026020528060005260406000206000915090505481565b61161461175d565b600060149054906101000a900460ff1615611664576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165b90612362565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600060146101000a81548160ff02191690831515021790555050565b6116e161175d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611751576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611748906123f4565b60405180910390fd5b61175a81611856565b50565b61176561191a565b73ffffffffffffffffffffffffffffffffffffffff16611783611209565b73ffffffffffffffffffffffffffffffffffffffff16146117d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d090612460565b60405180910390fd5b565b600080831161181f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611816906124cc565b60405180910390fd5b6000834261182d919061209a565b9050828110611840576000915050611850565b808361184c919061209a565b9150505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b60008115159050919050565b61193781611922565b82525050565b6000602082019050611952600083018461192e565b92915050565b600080fd5b6000819050919050565b6119708161195d565b811461197b57600080fd5b50565b60008135905061198d81611967565b92915050565b6000602082840312156119a9576119a8611958565b5b60006119b78482850161197e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119eb826119c0565b9050919050565b6119fb816119e0565b8114611a0657600080fd5b50565b600081359050611a18816119f2565b92915050565b60008060408385031215611a3557611a34611958565b5b6000611a4385828601611a09565b9250506020611a548582860161197e565b9150509250929050565b6000819050919050565b6000611a83611a7e611a79846119c0565b611a5e565b6119c0565b9050919050565b6000611a9582611a68565b9050919050565b6000611aa782611a8a565b9050919050565b611ab781611a9c565b82525050565b6000602082019050611ad26000830184611aae565b92915050565b600060208284031215611aee57611aed611958565b5b6000611afc84828501611a09565b91505092915050565b60006bffffffffffffffffffffffff82169050919050565b611b2681611b05565b82525050565b6000602082019050611b416000830184611b1d565b92915050565b611b508161195d565b82525050565b6000602082019050611b6b6000830184611b47565b92915050565b6000611b7c826119e0565b9050919050565b611b8c81611b71565b8114611b9757600080fd5b50565b600081359050611ba981611b83565b92915050565b600060208284031215611bc557611bc4611958565b5b6000611bd384828501611b9a565b91505092915050565b611be5816119e0565b82525050565b6000602082019050611c006000830184611bdc565b92915050565b6000611c1182611a8a565b9050919050565b611c2181611c06565b82525050565b6000602082019050611c3c6000830184611c18565b92915050565b6000611c4d82611a8a565b9050919050565b611c5d81611c42565b82525050565b6000602082019050611c786000830184611c54565b92915050565b600082825260208201905092915050565b7f5269736b206d616e61676572206e6f7420617070726f76656400000000000000600082015250565b6000611cc5601983611c7e565b9150611cd082611c8f565b602082019050919050565b60006020820190508181036000830152611cf481611cb8565b9050919050565b6000604082019050611d106000830185611bdc565b611d1d6020830184611b47565b9392505050565b7f5269736b206d616e61676572206973206e65697468657220617070726f76656460008201527f206e6f72207769746820612070656e64696e6720617070726f76616c00000000602082015250565b6000611d80603c83611c7e565b9150611d8b82611d24565b604082019050919050565b60006020820190508181036000830152611daf81611d73565b9050919050565b611dbf81611b05565b8114611dca57600080fd5b50565b600081519050611ddc81611db6565b92915050565b600060208284031215611df857611df7611958565b5b6000611e0684828501611dcd565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611e498261195d565b9150611e548361195d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611e8d57611e8c611e0f565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611ed28261195d565b9150611edd8361195d565b925082611eed57611eec611e98565b5b828204905092915050565b600081519050611f0781611967565b92915050565b600060208284031215611f2357611f22611958565b5b6000611f3184828501611ef8565b91505092915050565b6000611f4582611a8a565b9050919050565b611f5581611f3a565b82525050565b6000602082019050611f706000830184611f4c565b92915050565b7f506f7274696f6e20746f207365697a65206973206e6f742077697468696e207460008201527f68652072616e67652028302c20315d0000000000000000000000000000000000602082015250565b6000611fd2602f83611c7e565b9150611fdd82611f76565b604082019050919050565b6000602082019050818103600083015261200181611fc5565b9050919050565b7f5269736b206d616e6167657220617070726f76616c206e6f7420696e6974696160008201527f7465640000000000000000000000000000000000000000000000000000000000602082015250565b6000612064602383611c7e565b915061206f82612008565b604082019050919050565b6000602082019050818103600083015261209381612057565b9050919050565b60006120a58261195d565b91506120b08361195d565b9250828210156120c3576120c2611e0f565b5b828203905092915050565b7f5269736b206d616e6167657220676f7665726e616e63652064656c617920686160008201527f73206e6f7420656c617073656400000000000000000000000000000000000000602082015250565b600061212a602d83611c7e565b9150612135826120ce565b604082019050919050565b600060208201905081810360008301526121598161211d565b9050919050565b7f416d6f756e7420746f207365697a65206d757374206265203e30000000000000600082015250565b6000612196601a83611c7e565b91506121a182612160565b602082019050919050565b600060208201905081810360008301526121c581612189565b9050919050565b7f546865206669727374207269736b206d616e61676572206973206e6f7420796560008201527f7420617070726f7665643b20506c656173652075736520617070726f7665466960208201527f7273745269736b4d616e6167657220696e737465616400000000000000000000604082015250565b600061224e605683611c7e565b9150612259826121cc565b606082019050919050565b6000602082019050818103600083015261227d81612241565b9050919050565b7f5269736b206d616e6167657220616c726561647920617070726f766564000000600082015250565b60006122ba601d83611c7e565b91506122c582612284565b602082019050919050565b600060208201905081810360008301526122e9816122ad565b9050919050565b7f546865206669727374207269736b206d616e616765722077617320617070726f60008201527f7665640000000000000000000000000000000000000000000000000000000000602082015250565b600061234c602383611c7e565b9150612357826122f0565b604082019050919050565b6000602082019050818103600083015261237b8161233f565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006123de602683611c7e565b91506123e982612382565b604082019050919050565b6000602082019050818103600083015261240d816123d1565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061244a602083611c7e565b915061245582612414565b602082019050919050565b600060208201905081810360008301526124798161243d565b9050919050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b60006124b6601483611c7e565b91506124c182612480565b602082019050919050565b600060208201905081810360008301526124e5816124a9565b905091905056fea2646970667358221220ec205cb71546993cf5a2a6b6040e8c2992a7fa4c20445f6280393e2db7e83c8864736f6c63430008090033", + "devdoc": { + "details": "Coverage pool contract is owned by the governance. Coverage pool is the owner of the asset pool contract.", + "kind": "dev", + "methods": { + "amountToSeize(uint256)": { + "params": { + "portionToSeize": "Portion of the pool to seize in the range (0, 1] multiplied by FLOATING_POINT_DIVISOR" + } + }, + "approveFirstRiskManager(address)": { + "details": "Can be called only by the contract owner. Can be called only once. Does not require any further calls to any functions.", + "params": { + "riskManager": "Risk manager that will be approved" + } + }, + "approveNewAssetPoolUpgrade(address)": { + "params": { + "_newAssetPool": "New asset pool" + } + }, + "beginRiskManagerApproval(address)": { + "details": "Can be called only by the contract owner and only when the first risk manager is already approved. For a risk manager to be approved, a call to `finalizeRiskManagerApproval` must follow (after a governance delay).", + "params": { + "riskManager": "Risk manager that will be approved" + } + }, + "beginWithdrawalDelayUpdate(uint256)": { + "params": { + "newWithdrawalDelay": "The new value of withdrawal delay" + } + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "params": { + "newWithdrawalTimeout": "The new value of the withdrawal timeout" + } + }, + "finalizeRiskManagerApproval(address)": { + "details": "Can be called only by the contract owner. Must be preceded with a call to beginRiskManagerApproval and a governance delay must elapse.", + "params": { + "riskManager": "Risk manager that will be approved" + } + }, + "getPastVotes(address,uint256)": { + "params": { + "account": "The underwriter address to check", + "blockNumber": "The block number to get the vote balance at" + }, + "returns": { + "_0": "The number of votes the underwriter had as of the given block" + } + }, + "getRemainingRiskManagerApprovalTime(address)": { + "params": { + "riskManager": "Risk manager in the process of approval" + }, + "returns": { + "_0": "Remaining time in seconds." + } + }, + "grantAssetPoolShares(address,uint256)": { + "details": "Can be called only by an approved risk manager.", + "params": { + "covAmount": "Amount of the underwriter tokens which should be minted", + "recipient": "Address of the underwriter tokens recipient" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "seizeAmount(address,uint256)": { + "params": { + "amountToSeize": "Amount to be seized from the pool", + "recipient": "Address that will receive the pool's seized funds" + } + }, + "seizePortion(address,uint256)": { + "details": "`portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR` for calculation precision purposes. Further calculations in this function will need to take this divisor into account.", + "params": { + "portionToSeize": "Portion of the pool to seize in the range (0, 1] multiplied by `FLOATING_POINT_DIVISOR`", + "recipient": "Address that will receive the pool's seized funds" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "unapproveRiskManager(address)": { + "details": "Can be called only by the contract owner.", + "params": { + "riskManager": "Risk manager that will be unapproved" + } + } + }, + "title": "Coverage Pool", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "amountToSeize(uint256)": { + "notice": "Calculates amount of tokens to be seized from the coverage pool." + }, + "approveFirstRiskManager(address)": { + "notice": "Approves the first risk manager" + }, + "approveNewAssetPoolUpgrade(address)": { + "notice": "Approves upgradeability to the new asset pool. Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay." + }, + "beginRiskManagerApproval(address)": { + "notice": "Begins risk manager approval process." + }, + "beginWithdrawalDelayUpdate(uint256)": { + "notice": "Lets the governance to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible." + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "notice": "Lets the governance to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value." + }, + "finalizeRiskManagerApproval(address)": { + "notice": "Finalizes risk manager approval process." + }, + "finalizeWithdrawalDelayUpdate()": { + "notice": "Lets the governance to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass." + }, + "finalizeWithdrawalTimeoutUpdate()": { + "notice": "Lets the governance to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass." + }, + "getPastVotes(address,uint256)": { + "notice": "Determine the prior number of DAO votes for the given coverage pool underwriter." + }, + "getRemainingRiskManagerApprovalTime(address)": { + "notice": "Returns the time remaining until the risk manager approval process can be finalized" + }, + "grantAssetPoolShares(address,uint256)": { + "notice": "Grants asset pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes." + }, + "seizeAmount(address,uint256)": { + "notice": "Seizes funds from the coverage pool and sends them to the `recipient`." + }, + "seizePortion(address,uint256)": { + "notice": "Seizes funds from the coverage pool and sends them to the `recipient`." + }, + "unapproveRiskManager(address)": { + "notice": "Unapproves an already approved risk manager or cancels the approval process of a risk manager (the latter happens if called between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`). The change takes effect immediately." + } + }, + "notice": "A contract that manages a single asset pool. Handles approving and unapproving of risk managers and allows them to seize funds from the asset pool if they are approved.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 7742, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "firstRiskManagerApproved", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 7746, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "approvedRiskManagers", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 7750, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "riskManagerApprovalTimestamps", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_uint256)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/artifacts/CoveragePoolBeneficiary.json b/artifacts/CoveragePoolBeneficiary.json new file mode 100644 index 00000000..538c3814 --- /dev/null +++ b/artifacts/CoveragePoolBeneficiary.json @@ -0,0 +1,193 @@ +{ + "address": "0xE8372cab8d06a607E374cC549d8F68648ef67263", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + }, + { + "internalType": "contract RewardsPool", + "name": "_rewards", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "__escrowSentTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewards", + "outputs": [ + { + "internalType": "contract RewardsPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x5951d8f75599e2c73b4e74143cfb332b547d9f23e7c53c07a1ba1f6dd1a72aa4", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0xE8372cab8d06a607E374cC549d8F68648ef67263", + "transactionIndex": 87, + "gasUsed": "950588", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000008000000000000000000000000000000000000000000000080000000000000000400000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800200000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x8fb3b4f85e35081ccca8048280fd9425afa2d92a91aea37193ef53d94f10a9ad", + "transactionHash": "0x5951d8f75599e2c73b4e74143cfb332b547d9f23e7c53c07a1ba1f6dd1a72aa4", + "logs": [ + { + "transactionIndex": 87, + "blockNumber": 16327130, + "transactionHash": "0x5951d8f75599e2c73b4e74143cfb332b547d9f23e7c53c07a1ba1f6dd1a72aa4", + "address": "0xE8372cab8d06a607E374cC549d8F68648ef67263", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 152, + "blockHash": "0x8fb3b4f85e35081ccca8048280fd9425afa2d92a91aea37193ef53d94f10a9ad" + } + ], + "blockNumber": 16327130, + "cumulativeGasUsed": "8431270", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "0xD4FD81D7a16320Ca029389a728327918bdc086b6" + ], + "numDeployments": 1, + "solcInputHash": "1f648bbc62fc09e530210f2d58cb219e", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"contract RewardsPool\",\"name\":\"_rewards\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"__escrowSentTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rewards\",\"outputs\":[{\"internalType\":\"contract RewardsPool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"CoveragePoolBeneficiary\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A beneficiary contract that can receive a withdrawal phase from a BatchedPhasedEscrow contract. It immediately transfers the received tokens on a designated RewardsPool contract.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/CoveragePoolBeneficiary.sol\":\"CoveragePoolBeneficiary\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"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/BatchedPhasedEscrow.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Batched Phased Escrow Beneficiary\\n/// @notice Interface expected from contracts receiving tokens from the\\n/// BatchedPhasedEscrow.\\ninterface IBeneficiaryContract {\\n function __escrowSentTokens(uint256 amount) external;\\n}\\n\\n/// @title BatchedPhasedEscrow\\n/// @notice A token holder contract allowing contract owner to approve a set of\\n/// beneficiaries of tokens held by the contract, to appoint a separate\\n/// drawee role, and allowing that drawee to withdraw tokens to approved\\n/// beneficiaries in phases.\\ncontract BatchedPhasedEscrow is Ownable {\\n using SafeERC20 for IERC20;\\n\\n event BeneficiaryApproved(address beneficiary);\\n event TokensWithdrawn(address beneficiary, uint256 amount);\\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\\n\\n IERC20 public token;\\n address public drawee;\\n mapping(address => bool) private approvedBeneficiaries;\\n\\n modifier onlyDrawee() {\\n require(drawee == msg.sender, \\\"Caller is not the drawee\\\");\\n _;\\n }\\n\\n constructor(IERC20 _token) {\\n token = _token;\\n drawee = msg.sender;\\n }\\n\\n /// @notice Approves the provided address as a beneficiary of tokens held by\\n /// the escrow. Can be called only by escrow owner.\\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\\n external\\n onlyOwner\\n {\\n address beneficiaryAddress = address(_beneficiary);\\n require(\\n beneficiaryAddress != address(0),\\n \\\"Beneficiary can not be zero address\\\"\\n );\\n approvedBeneficiaries[beneficiaryAddress] = true;\\n emit BeneficiaryApproved(beneficiaryAddress);\\n }\\n\\n /// @notice Returns `true` if the given address has been approved as a\\n /// beneficiary of the escrow, `false` otherwise.\\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\\n public\\n view\\n returns (bool)\\n {\\n return approvedBeneficiaries[address(_beneficiary)];\\n }\\n\\n /// @notice Transfers the role of drawee to another address. Can be called\\n /// only by the contract owner.\\n function setDrawee(address newDrawee) external onlyOwner {\\n require(newDrawee != address(0), \\\"New drawee can not be zero address\\\");\\n emit DraweeRoleTransferred(drawee, newDrawee);\\n drawee = newDrawee;\\n }\\n\\n /// @notice Funds the escrow by transferring all of the approved tokens\\n /// to the escrow.\\n function receiveApproval(\\n address _from,\\n uint256 _value,\\n address _token,\\n bytes memory\\n ) external {\\n require(IERC20(_token) == token, \\\"Unsupported token\\\");\\n token.safeTransferFrom(_from, address(this), _value);\\n }\\n\\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\\n /// transferring to each beneficiary the amount of tokens specified\\n /// as a parameter. Only beneficiaries previously approved by escrow\\n /// owner can receive funds.\\n function batchedWithdraw(\\n IBeneficiaryContract[] memory beneficiaries,\\n uint256[] memory amounts\\n ) external onlyDrawee {\\n require(\\n beneficiaries.length == amounts.length,\\n \\\"Mismatched arrays length\\\"\\n );\\n\\n for (uint256 i = 0; i < beneficiaries.length; i++) {\\n IBeneficiaryContract beneficiary = beneficiaries[i];\\n require(\\n isBeneficiaryApproved(beneficiary),\\n \\\"Beneficiary was not approved\\\"\\n );\\n withdraw(beneficiary, amounts[i]);\\n }\\n }\\n\\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\\n private\\n {\\n emit TokensWithdrawn(address(beneficiary), amount);\\n token.safeTransfer(address(beneficiary), amount);\\n // slither-disable-next-line calls-loop\\n beneficiary.__escrowSentTokens(amount);\\n }\\n}\\n\",\"keccak256\":\"0xd1ed7b9149ea0672c94e22812ca723751c2be7546b1d23ffb12d9595a14a8f50\",\"license\":\"MIT\"},\"contracts/CoveragePoolBeneficiary.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./RewardsPool.sol\\\";\\nimport \\\"./BatchedPhasedEscrow.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\n/// @title CoveragePoolBeneficiary\\n/// @notice A beneficiary contract that can receive a withdrawal phase from a\\n/// BatchedPhasedEscrow contract.\\n/// It immediately transfers the received tokens on a designated\\n/// RewardsPool contract.\\ncontract CoveragePoolBeneficiary is Ownable, IBeneficiaryContract {\\n using SafeERC20 for IERC20;\\n\\n IERC20 public immutable token;\\n RewardsPool public immutable rewards;\\n\\n constructor(IERC20 _token, RewardsPool _rewards) {\\n token = _token;\\n rewards = _rewards;\\n }\\n\\n function __escrowSentTokens(uint256 amount) external override onlyOwner {\\n token.safeApprove(address(rewards), amount);\\n rewards.topUpReward(amount);\\n }\\n}\\n\",\"keccak256\":\"0xff7a0970054716949a23c460b0b818d6d0a46ad0d7b53c1d9c8fcfefec124d8c\",\"license\":\"MIT\"},\"contracts/RewardsPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Rewards Pool\\n/// @notice RewardsPool accepts a single reward token and releases it to the\\n/// AssetPool over time in one week reward intervals. The owner of this\\n/// contract is the reward distribution address funding it with reward\\n/// tokens.\\ncontract RewardsPool is Ownable {\\n using SafeERC20 for IERC20;\\n\\n uint256 public constant DURATION = 7 days;\\n\\n IERC20 public immutable rewardToken;\\n address public immutable assetPool;\\n\\n // timestamp of the current reward interval end or the timestamp of the\\n // last interval end in case a new reward interval has not been allocated\\n uint256 public intervalFinish = 0;\\n // rate per second with which reward tokens are unlocked\\n uint256 public rewardRate = 0;\\n // amount of rewards accumulated and not yet withdrawn from the previous\\n // reward interval(s)\\n uint256 public rewardAccumulated = 0;\\n // the last time information in this contract was updated\\n uint256 public lastUpdateTime = 0;\\n\\n event RewardToppedUp(uint256 amount);\\n event RewardWithdrawn(uint256 amount);\\n\\n constructor(\\n IERC20 _rewardToken,\\n address _assetPool,\\n address owner\\n ) {\\n rewardToken = _rewardToken;\\n // slither-disable-next-line missing-zero-check\\n assetPool = _assetPool;\\n transferOwnership(owner);\\n }\\n\\n /// @notice Transfers the provided reward amount into RewardsPool and\\n /// creates a new, one-week reward interval starting from now.\\n /// Reward tokens from the previous reward interval that unlocked\\n /// over the time will be available for withdrawal immediately.\\n /// Reward tokens from the previous interval that has not been yet\\n /// unlocked, are added to the new interval being created.\\n /// @dev This function can be called only by the owner given that it creates\\n /// a new interval with one week length, starting from now.\\n function topUpReward(uint256 reward) external onlyOwner {\\n rewardAccumulated = earned();\\n\\n /* solhint-disable not-rely-on-time */\\n if (block.timestamp >= intervalFinish) {\\n // see https://github.com/crytic/slither/issues/844\\n // slither-disable-next-line divide-before-multiply\\n rewardRate = reward / DURATION;\\n } else {\\n uint256 remaining = intervalFinish - block.timestamp;\\n uint256 leftover = remaining * rewardRate;\\n rewardRate = (reward + leftover) / DURATION;\\n }\\n intervalFinish = block.timestamp + DURATION;\\n lastUpdateTime = block.timestamp;\\n /* solhint-enable avoid-low-level-calls */\\n\\n emit RewardToppedUp(reward);\\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\\n function withdraw() external {\\n uint256 amount = earned();\\n rewardAccumulated = 0;\\n lastUpdateTime = lastTimeRewardApplicable();\\n emit RewardWithdrawn(amount);\\n rewardToken.safeTransfer(assetPool, amount);\\n }\\n\\n /// @notice Returns the amount of earned and not yet withdrawn reward\\n /// tokens.\\n function earned() public view returns (uint256) {\\n return\\n rewardAccumulated +\\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\\n }\\n\\n /// @notice Returns the timestamp at which a reward was last time applicable.\\n /// When reward interval is pending, returns current block's\\n /// timestamp. If the last reward interval ended and no other reward\\n /// interval had been allocated, returns the last reward interval's\\n /// end timestamp.\\n function lastTimeRewardApplicable() public view returns (uint256) {\\n return Math.min(block.timestamp, intervalFinish);\\n }\\n}\\n\",\"keccak256\":\"0xe56e8c35bbafad758cc66473f113ea9fd3ffa9c44c6139fc3196dbbead2a4054\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b506040516200128738038062001287833981810160405281019062000037919062000256565b620000576200004b620000c760201b60201c565b620000cf60201b60201c565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff168152505050506200029d565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001c58262000198565b9050919050565b6000620001d982620001b8565b9050919050565b620001eb81620001cc565b8114620001f757600080fd5b50565b6000815190506200020b81620001e0565b92915050565b60006200021e82620001b8565b9050919050565b620002308162000211565b81146200023c57600080fd5b50565b600081519050620002508162000225565b92915050565b6000806040838503121562000270576200026f62000193565b5b60006200028085828601620001fa565b925050602062000293858286016200023f565b9150509250929050565b60805160a051610faf620002d86000396000818161011001528181610178015261024301526000818161013201526102eb0152610faf6000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80634a5f545614610067578063715018a6146100835780638da5cb5b1461008d5780639ec5a894146100ab578063f2fde38b146100c9578063fc0c546a146100e5575b600080fd5b610081600480360381019061007c9190610885565b610103565b005b61008b610204565b005b610095610218565b6040516100a291906108f3565b60405180910390f35b6100b3610241565b6040516100c0919061096d565b60405180910390f35b6100e360048036038101906100de91906109b4565b610265565b005b6100ed6102e9565b6040516100fa9190610a02565b60405180910390f35b61010b61030d565b6101767f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661038b9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630e807056826040518263ffffffff1660e01b81526004016101cf9190610a2c565b600060405180830381600087803b1580156101e957600080fd5b505af11580156101fd573d6000803e3d6000fd5b5050505050565b61020c61030d565b61021660006104e9565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b61026d61030d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156102dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d490610aca565b60405180910390fd5b6102e6816104e9565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6103156105ad565b73ffffffffffffffffffffffffffffffffffffffff16610333610218565b73ffffffffffffffffffffffffffffffffffffffff1614610389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038090610b36565b60405180910390fd5b565b6000811480610424575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b81526004016103d2929190610b56565b60206040518083038186803b1580156103ea57600080fd5b505afa1580156103fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104229190610b94565b145b610463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045a90610c33565b60405180910390fd5b6104e48363095ea7b360e01b8484604051602401610482929190610c53565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506105b5565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000610617826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661067c9092919063ffffffff16565b905060008151111561067757808060200190518101906106379190610cb4565b610676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066d90610d53565b60405180910390fd5b5b505050565b606061068b8484600085610694565b90509392505050565b6060824710156106d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d090610de5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516107029190610e7f565b60006040518083038185875af1925050503d806000811461073f576040519150601f19603f3d011682016040523d82523d6000602084013e610744565b606091505b509150915061075587838387610761565b92505050949350505050565b606083156107c4576000835114156107bc5761077c856107d7565b6107bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b290610ee2565b60405180910390fd5b5b8290506107cf565b6107ce83836107fa565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008251111561080d5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108419190610f57565b60405180910390fd5b600080fd5b6000819050919050565b6108628161084f565b811461086d57600080fd5b50565b60008135905061087f81610859565b92915050565b60006020828403121561089b5761089a61084a565b5b60006108a984828501610870565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108dd826108b2565b9050919050565b6108ed816108d2565b82525050565b600060208201905061090860008301846108e4565b92915050565b6000819050919050565b600061093361092e610929846108b2565b61090e565b6108b2565b9050919050565b600061094582610918565b9050919050565b60006109578261093a565b9050919050565b6109678161094c565b82525050565b6000602082019050610982600083018461095e565b92915050565b610991816108d2565b811461099c57600080fd5b50565b6000813590506109ae81610988565b92915050565b6000602082840312156109ca576109c961084a565b5b60006109d88482850161099f565b91505092915050565b60006109ec8261093a565b9050919050565b6109fc816109e1565b82525050565b6000602082019050610a1760008301846109f3565b92915050565b610a268161084f565b82525050565b6000602082019050610a416000830184610a1d565b92915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610ab4602683610a47565b9150610abf82610a58565b604082019050919050565b60006020820190508181036000830152610ae381610aa7565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610b20602083610a47565b9150610b2b82610aea565b602082019050919050565b60006020820190508181036000830152610b4f81610b13565b9050919050565b6000604082019050610b6b60008301856108e4565b610b7860208301846108e4565b9392505050565b600081519050610b8e81610859565b92915050565b600060208284031215610baa57610ba961084a565b5b6000610bb884828501610b7f565b91505092915050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000610c1d603683610a47565b9150610c2882610bc1565b604082019050919050565b60006020820190508181036000830152610c4c81610c10565b9050919050565b6000604082019050610c6860008301856108e4565b610c756020830184610a1d565b9392505050565b60008115159050919050565b610c9181610c7c565b8114610c9c57600080fd5b50565b600081519050610cae81610c88565b92915050565b600060208284031215610cca57610cc961084a565b5b6000610cd884828501610c9f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000610d3d602a83610a47565b9150610d4882610ce1565b604082019050919050565b60006020820190508181036000830152610d6c81610d30565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000610dcf602683610a47565b9150610dda82610d73565b604082019050919050565b60006020820190508181036000830152610dfe81610dc2565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015610e39578082015181840152602081019050610e1e565b83811115610e48576000848401525b50505050565b6000610e5982610e05565b610e638185610e10565b9350610e73818560208601610e1b565b80840191505092915050565b6000610e8b8284610e4e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000610ecc601d83610a47565b9150610ed782610e96565b602082019050919050565b60006020820190508181036000830152610efb81610ebf565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000610f2982610f02565b610f338185610a47565b9350610f43818560208601610e1b565b610f4c81610f0d565b840191505092915050565b60006020820190508181036000830152610f718184610f1e565b90509291505056fea264697066735822122046d9f4d7eee93e39cedc274a139f45dd1982cd384c8a667cced62ef5224b96ab64736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c80634a5f545614610067578063715018a6146100835780638da5cb5b1461008d5780639ec5a894146100ab578063f2fde38b146100c9578063fc0c546a146100e5575b600080fd5b610081600480360381019061007c9190610885565b610103565b005b61008b610204565b005b610095610218565b6040516100a291906108f3565b60405180910390f35b6100b3610241565b6040516100c0919061096d565b60405180910390f35b6100e360048036038101906100de91906109b4565b610265565b005b6100ed6102e9565b6040516100fa9190610a02565b60405180910390f35b61010b61030d565b6101767f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661038b9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630e807056826040518263ffffffff1660e01b81526004016101cf9190610a2c565b600060405180830381600087803b1580156101e957600080fd5b505af11580156101fd573d6000803e3d6000fd5b5050505050565b61020c61030d565b61021660006104e9565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b61026d61030d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156102dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d490610aca565b60405180910390fd5b6102e6816104e9565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6103156105ad565b73ffffffffffffffffffffffffffffffffffffffff16610333610218565b73ffffffffffffffffffffffffffffffffffffffff1614610389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038090610b36565b60405180910390fd5b565b6000811480610424575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b81526004016103d2929190610b56565b60206040518083038186803b1580156103ea57600080fd5b505afa1580156103fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104229190610b94565b145b610463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045a90610c33565b60405180910390fd5b6104e48363095ea7b360e01b8484604051602401610482929190610c53565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506105b5565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000610617826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661067c9092919063ffffffff16565b905060008151111561067757808060200190518101906106379190610cb4565b610676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066d90610d53565b60405180910390fd5b5b505050565b606061068b8484600085610694565b90509392505050565b6060824710156106d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d090610de5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516107029190610e7f565b60006040518083038185875af1925050503d806000811461073f576040519150601f19603f3d011682016040523d82523d6000602084013e610744565b606091505b509150915061075587838387610761565b92505050949350505050565b606083156107c4576000835114156107bc5761077c856107d7565b6107bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b290610ee2565b60405180910390fd5b5b8290506107cf565b6107ce83836107fa565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008251111561080d5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108419190610f57565b60405180910390fd5b600080fd5b6000819050919050565b6108628161084f565b811461086d57600080fd5b50565b60008135905061087f81610859565b92915050565b60006020828403121561089b5761089a61084a565b5b60006108a984828501610870565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108dd826108b2565b9050919050565b6108ed816108d2565b82525050565b600060208201905061090860008301846108e4565b92915050565b6000819050919050565b600061093361092e610929846108b2565b61090e565b6108b2565b9050919050565b600061094582610918565b9050919050565b60006109578261093a565b9050919050565b6109678161094c565b82525050565b6000602082019050610982600083018461095e565b92915050565b610991816108d2565b811461099c57600080fd5b50565b6000813590506109ae81610988565b92915050565b6000602082840312156109ca576109c961084a565b5b60006109d88482850161099f565b91505092915050565b60006109ec8261093a565b9050919050565b6109fc816109e1565b82525050565b6000602082019050610a1760008301846109f3565b92915050565b610a268161084f565b82525050565b6000602082019050610a416000830184610a1d565b92915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610ab4602683610a47565b9150610abf82610a58565b604082019050919050565b60006020820190508181036000830152610ae381610aa7565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610b20602083610a47565b9150610b2b82610aea565b602082019050919050565b60006020820190508181036000830152610b4f81610b13565b9050919050565b6000604082019050610b6b60008301856108e4565b610b7860208301846108e4565b9392505050565b600081519050610b8e81610859565b92915050565b600060208284031215610baa57610ba961084a565b5b6000610bb884828501610b7f565b91505092915050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000610c1d603683610a47565b9150610c2882610bc1565b604082019050919050565b60006020820190508181036000830152610c4c81610c10565b9050919050565b6000604082019050610c6860008301856108e4565b610c756020830184610a1d565b9392505050565b60008115159050919050565b610c9181610c7c565b8114610c9c57600080fd5b50565b600081519050610cae81610c88565b92915050565b600060208284031215610cca57610cc961084a565b5b6000610cd884828501610c9f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000610d3d602a83610a47565b9150610d4882610ce1565b604082019050919050565b60006020820190508181036000830152610d6c81610d30565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000610dcf602683610a47565b9150610dda82610d73565b604082019050919050565b60006020820190508181036000830152610dfe81610dc2565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015610e39578082015181840152602081019050610e1e565b83811115610e48576000848401525b50505050565b6000610e5982610e05565b610e638185610e10565b9350610e73818560208601610e1b565b80840191505092915050565b6000610e8b8284610e4e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000610ecc601d83610a47565b9150610ed782610e96565b602082019050919050565b60006020820190508181036000830152610efb81610ebf565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000610f2982610f02565b610f338185610a47565b9350610f43818560208601610e1b565b610f4c81610f0d565b840191505092915050565b60006020820190508181036000830152610f718184610f1e565b90509291505056fea264697066735822122046d9f4d7eee93e39cedc274a139f45dd1982cd384c8a667cced62ef5224b96ab64736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "CoveragePoolBeneficiary", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "notice": "A beneficiary contract that can receive a withdrawal phase from a BatchedPhasedEscrow contract. It immediately transfers the received tokens on a designated RewardsPool contract.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/CoveragePoolBeneficiary.sol:CoveragePoolBeneficiary", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} \ No newline at end of file diff --git a/artifacts/RewardsPool.json b/artifacts/RewardsPool.json new file mode 100644 index 00000000..695bd5e6 --- /dev/null +++ b/artifacts/RewardsPool.json @@ -0,0 +1,323 @@ +{ + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_assetPool", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardToppedUp", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardWithdrawn", + "type": "event" + }, + { + "inputs": [], + "name": "DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "assetPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "earned", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "intervalFinish", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastTimeRewardApplicable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardAccumulated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "name": "topUpReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "transactionIndex": 71, + "gasUsed": "4745721", + "logsBloom": "0x08000000000000000000000000000000000020000000000000800000000000000000000800000000000010000000000000020400000000000000000000000400000000000000000000000000004000000001000000000000000000000000000000000000020000000000010000000800000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020800000000200000000000000000000000000000000000000000000000000400000000800000000000000000000000020000000000000000000000000000000000000000000000000000000008000000800", + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f", + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "logs": [ + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 98, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 99, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 100, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "topics": [ + "0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 101, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + } + ], + "blockNumber": 16327114, + "cumulativeGasUsed": "8956336", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "0x123694886DBf5Ac94DDA07135349534536D14cAf" + ], + "numDeployments": 1, + "bytecode": "0x60c060405260006001556000600255600060035560006004553480156200002557600080fd5b506040516200180a3803806200180a83398181016040528101906200004b9190620003b9565b6200006b6200005f620000ed60201b60201c565b620000f560201b60201c565b8273ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050620000e481620001b960201b60201c565b50505062000530565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b620001c96200025060201b60201c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156200023c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000233906200049c565b60405180910390fd5b6200024d81620000f560201b60201c565b50565b62000260620000ed60201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1662000286620002e160201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1614620002df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620002d6906200050e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200033c826200030f565b9050919050565b600062000350826200032f565b9050919050565b620003628162000343565b81146200036e57600080fd5b50565b600081519050620003828162000357565b92915050565b62000393816200032f565b81146200039f57600080fd5b50565b600081519050620003b38162000388565b92915050565b600080600060608486031215620003d557620003d46200030a565b5b6000620003e58682870162000371565b9350506020620003f886828701620003a2565b92505060406200040b86828701620003a2565b9150509250925092565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006200048460268362000415565b9150620004918262000426565b604082019050919050565b60006020820190508181036000830152620004b78162000475565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000620004f660208362000415565b91506200050382620004be565b602082019050919050565b600060208201905081810360008301526200052981620004e7565b9050919050565b60805160a05161129f6200056b6000396000818161039301526104130152600081816103420152818161043501526105a0015261129f6000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c806380faa57d1161008c578063c910d95011610066578063c910d950146101f1578063d6f192621461020f578063f2fde38b1461022d578063f7c618c114610249576100ea565b806380faa57d146101975780638da5cb5b146101b5578063c8f33c91146101d3576100ea565b80633ccfd60b116100c85780633ccfd60b146101475780636e9a204b14610151578063715018a61461016f5780637b0a47ee14610179576100ea565b80630e807056146100ef5780631be052891461010b5780632ec939f914610129575b600080fd5b61010960048036038101906101049190610b04565b610267565b005b61011361038a565b6040516101209190610b40565b60405180910390f35b610131610391565b60405161013e9190610b9c565b60405180910390f35b61014f6103b5565b005b61015961047c565b6040516101669190610b40565b60405180910390f35b610177610482565b005b610181610496565b60405161018e9190610b40565b60405180910390f35b61019f61049c565b6040516101ac9190610b40565b60405180910390f35b6101bd6104af565b6040516101ca9190610b9c565b60405180910390f35b6101db6104d8565b6040516101e89190610b40565b60405180910390f35b6101f96104de565b6040516102069190610b40565b60405180910390f35b6102176104e4565b6040516102249190610b40565b60405180910390f35b61024760048036038101906102429190610be3565b61051a565b005b61025161059e565b60405161025e9190610c6f565b60405180910390f35b61026f6105c2565b6102776104e4565b60038190555060015442106102a05762093a80816102959190610ce8565b6002819055506102e7565b6000426001546102b09190610d19565b90506000600254826102c29190610d4d565b905062093a8081846102d49190610da7565b6102de9190610ce8565b60028190555050505b62093a80426102f69190610da7565b600181905550426004819055507fb32714d475c9d2f568d4ff24e88d0056b93256b5a04fbdb53a57f26bb765fbed816040516103329190610b40565b60405180910390a16103873330837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610640909392919063ffffffff16565b50565b62093a8081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006103bf6104e4565b905060006003819055506103d161049c565b6004819055507f150a6ec0e6f4e9ddcaaaa1674f157d91165a42d60653016f87a9fc870a39f050816040516104069190610b40565b60405180910390a16104797f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106c99092919063ffffffff16565b50565b60035481565b61048a6105c2565b610494600061074f565b565b60025481565b60006104aa42600154610813565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b60015481565b60006002546004546104f461049c565b6104fe9190610d19565b6105089190610d4d565b6003546105159190610da7565b905090565b6105226105c2565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610592576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058990610e80565b60405180910390fd5b61059b8161074f565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6105ca61082c565b73ffffffffffffffffffffffffffffffffffffffff166105e86104af565b73ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063590610eec565b60405180910390fd5b565b6106c3846323b872dd60e01b85858560405160240161066193929190610f0c565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b50505050565b61074a8363a9059cbb60e01b84846040516024016106e8929190610f43565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183106108225781610824565b825b905092915050565b600033905090565b6000610896826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108fb9092919063ffffffff16565b90506000815111156108f657808060200190518101906108b69190610fa4565b6108f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ec90611043565b60405180910390fd5b5b505050565b606061090a8484600085610913565b90509392505050565b606082471015610958576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094f906110d5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610981919061116f565b60006040518083038185875af1925050503d80600081146109be576040519150601f19603f3d011682016040523d82523d6000602084013e6109c3565b606091505b50915091506109d4878383876109e0565b92505050949350505050565b60608315610a4357600083511415610a3b576109fb85610a56565b610a3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a31906111d2565b60405180910390fd5b5b829050610a4e565b610a4d8383610a79565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610a8c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac09190611247565b60405180910390fd5b600080fd5b6000819050919050565b610ae181610ace565b8114610aec57600080fd5b50565b600081359050610afe81610ad8565b92915050565b600060208284031215610b1a57610b19610ac9565b5b6000610b2884828501610aef565b91505092915050565b610b3a81610ace565b82525050565b6000602082019050610b556000830184610b31565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8682610b5b565b9050919050565b610b9681610b7b565b82525050565b6000602082019050610bb16000830184610b8d565b92915050565b610bc081610b7b565b8114610bcb57600080fd5b50565b600081359050610bdd81610bb7565b92915050565b600060208284031215610bf957610bf8610ac9565b5b6000610c0784828501610bce565b91505092915050565b6000819050919050565b6000610c35610c30610c2b84610b5b565b610c10565b610b5b565b9050919050565b6000610c4782610c1a565b9050919050565b6000610c5982610c3c565b9050919050565b610c6981610c4e565b82525050565b6000602082019050610c846000830184610c60565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610cf382610ace565b9150610cfe83610ace565b925082610d0e57610d0d610c8a565b5b828204905092915050565b6000610d2482610ace565b9150610d2f83610ace565b925082821015610d4257610d41610cb9565b5b828203905092915050565b6000610d5882610ace565b9150610d6383610ace565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610d9c57610d9b610cb9565b5b828202905092915050565b6000610db282610ace565b9150610dbd83610ace565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610df257610df1610cb9565b5b828201905092915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610e6a602683610dfd565b9150610e7582610e0e565b604082019050919050565b60006020820190508181036000830152610e9981610e5d565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610ed6602083610dfd565b9150610ee182610ea0565b602082019050919050565b60006020820190508181036000830152610f0581610ec9565b9050919050565b6000606082019050610f216000830186610b8d565b610f2e6020830185610b8d565b610f3b6040830184610b31565b949350505050565b6000604082019050610f586000830185610b8d565b610f656020830184610b31565b9392505050565b60008115159050919050565b610f8181610f6c565b8114610f8c57600080fd5b50565b600081519050610f9e81610f78565b92915050565b600060208284031215610fba57610fb9610ac9565b5b6000610fc884828501610f8f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061102d602a83610dfd565b915061103882610fd1565b604082019050919050565b6000602082019050818103600083015261105c81611020565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006110bf602683610dfd565b91506110ca82611063565b604082019050919050565b600060208201905081810360008301526110ee816110b2565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561112957808201518184015260208101905061110e565b83811115611138576000848401525b50505050565b6000611149826110f5565b6111538185611100565b935061116381856020860161110b565b80840191505092915050565b600061117b828461113e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b60006111bc601d83610dfd565b91506111c782611186565b602082019050919050565b600060208201905081810360008301526111eb816111af565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000611219826111f2565b6112238185610dfd565b935061123381856020860161110b565b61123c816111fd565b840191505092915050565b60006020820190508181036000830152611261818461120e565b90509291505056fea2646970667358221220c5bae390803cc3f1622719d99fad44d96dace0eca188c3ba7313821ca78e23e664736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806380faa57d1161008c578063c910d95011610066578063c910d950146101f1578063d6f192621461020f578063f2fde38b1461022d578063f7c618c114610249576100ea565b806380faa57d146101975780638da5cb5b146101b5578063c8f33c91146101d3576100ea565b80633ccfd60b116100c85780633ccfd60b146101475780636e9a204b14610151578063715018a61461016f5780637b0a47ee14610179576100ea565b80630e807056146100ef5780631be052891461010b5780632ec939f914610129575b600080fd5b61010960048036038101906101049190610b04565b610267565b005b61011361038a565b6040516101209190610b40565b60405180910390f35b610131610391565b60405161013e9190610b9c565b60405180910390f35b61014f6103b5565b005b61015961047c565b6040516101669190610b40565b60405180910390f35b610177610482565b005b610181610496565b60405161018e9190610b40565b60405180910390f35b61019f61049c565b6040516101ac9190610b40565b60405180910390f35b6101bd6104af565b6040516101ca9190610b9c565b60405180910390f35b6101db6104d8565b6040516101e89190610b40565b60405180910390f35b6101f96104de565b6040516102069190610b40565b60405180910390f35b6102176104e4565b6040516102249190610b40565b60405180910390f35b61024760048036038101906102429190610be3565b61051a565b005b61025161059e565b60405161025e9190610c6f565b60405180910390f35b61026f6105c2565b6102776104e4565b60038190555060015442106102a05762093a80816102959190610ce8565b6002819055506102e7565b6000426001546102b09190610d19565b90506000600254826102c29190610d4d565b905062093a8081846102d49190610da7565b6102de9190610ce8565b60028190555050505b62093a80426102f69190610da7565b600181905550426004819055507fb32714d475c9d2f568d4ff24e88d0056b93256b5a04fbdb53a57f26bb765fbed816040516103329190610b40565b60405180910390a16103873330837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610640909392919063ffffffff16565b50565b62093a8081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006103bf6104e4565b905060006003819055506103d161049c565b6004819055507f150a6ec0e6f4e9ddcaaaa1674f157d91165a42d60653016f87a9fc870a39f050816040516104069190610b40565b60405180910390a16104797f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106c99092919063ffffffff16565b50565b60035481565b61048a6105c2565b610494600061074f565b565b60025481565b60006104aa42600154610813565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b60015481565b60006002546004546104f461049c565b6104fe9190610d19565b6105089190610d4d565b6003546105159190610da7565b905090565b6105226105c2565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610592576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058990610e80565b60405180910390fd5b61059b8161074f565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6105ca61082c565b73ffffffffffffffffffffffffffffffffffffffff166105e86104af565b73ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063590610eec565b60405180910390fd5b565b6106c3846323b872dd60e01b85858560405160240161066193929190610f0c565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b50505050565b61074a8363a9059cbb60e01b84846040516024016106e8929190610f43565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183106108225781610824565b825b905092915050565b600033905090565b6000610896826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108fb9092919063ffffffff16565b90506000815111156108f657808060200190518101906108b69190610fa4565b6108f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ec90611043565b60405180910390fd5b5b505050565b606061090a8484600085610913565b90509392505050565b606082471015610958576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094f906110d5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610981919061116f565b60006040518083038185875af1925050503d80600081146109be576040519150601f19603f3d011682016040523d82523d6000602084013e6109c3565b606091505b50915091506109d4878383876109e0565b92505050949350505050565b60608315610a4357600083511415610a3b576109fb85610a56565b610a3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a31906111d2565b60405180910390fd5b5b829050610a4e565b610a4d8383610a79565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610a8c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac09190611247565b60405180910390fd5b600080fd5b6000819050919050565b610ae181610ace565b8114610aec57600080fd5b50565b600081359050610afe81610ad8565b92915050565b600060208284031215610b1a57610b19610ac9565b5b6000610b2884828501610aef565b91505092915050565b610b3a81610ace565b82525050565b6000602082019050610b556000830184610b31565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8682610b5b565b9050919050565b610b9681610b7b565b82525050565b6000602082019050610bb16000830184610b8d565b92915050565b610bc081610b7b565b8114610bcb57600080fd5b50565b600081359050610bdd81610bb7565b92915050565b600060208284031215610bf957610bf8610ac9565b5b6000610c0784828501610bce565b91505092915050565b6000819050919050565b6000610c35610c30610c2b84610b5b565b610c10565b610b5b565b9050919050565b6000610c4782610c1a565b9050919050565b6000610c5982610c3c565b9050919050565b610c6981610c4e565b82525050565b6000602082019050610c846000830184610c60565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610cf382610ace565b9150610cfe83610ace565b925082610d0e57610d0d610c8a565b5b828204905092915050565b6000610d2482610ace565b9150610d2f83610ace565b925082821015610d4257610d41610cb9565b5b828203905092915050565b6000610d5882610ace565b9150610d6383610ace565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610d9c57610d9b610cb9565b5b828202905092915050565b6000610db282610ace565b9150610dbd83610ace565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610df257610df1610cb9565b5b828201905092915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610e6a602683610dfd565b9150610e7582610e0e565b604082019050919050565b60006020820190508181036000830152610e9981610e5d565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610ed6602083610dfd565b9150610ee182610ea0565b602082019050919050565b60006020820190508181036000830152610f0581610ec9565b9050919050565b6000606082019050610f216000830186610b8d565b610f2e6020830185610b8d565b610f3b6040830184610b31565b949350505050565b6000604082019050610f586000830185610b8d565b610f656020830184610b31565b9392505050565b60008115159050919050565b610f8181610f6c565b8114610f8c57600080fd5b50565b600081519050610f9e81610f78565b92915050565b600060208284031215610fba57610fb9610ac9565b5b6000610fc884828501610f8f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061102d602a83610dfd565b915061103882610fd1565b604082019050919050565b6000602082019050818103600083015261105c81611020565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006110bf602683610dfd565b91506110ca82611063565b604082019050919050565b600060208201905081810360008301526110ee816110b2565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561112957808201518184015260208101905061110e565b83811115611138576000848401525b50505050565b6000611149826110f5565b6111538185611100565b935061116381856020860161110b565b80840191505092915050565b600061117b828461113e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b60006111bc601d83610dfd565b91506111c782611186565b602082019050919050565b600060208201905081810360008301526111eb816111af565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000611219826111f2565b6112238185610dfd565b935061123381856020860161110b565b61123c816111fd565b840191505092915050565b60006020820190508181036000830152611261818461120e565b90509291505056fea2646970667358221220c5bae390803cc3f1622719d99fad44d96dace0eca188c3ba7313821ca78e23e664736f6c63430008090033" +} \ No newline at end of file diff --git a/artifacts/UnderwriterToken.json b/artifacts/UnderwriterToken.json new file mode 100644 index 00000000..6b203191 --- /dev/null +++ b/artifacts/UnderwriterToken.json @@ -0,0 +1,1111 @@ +{ + "address": "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cachedChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cachedDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32", + "name": "pos", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "fromBlock", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct Checkpoints.Checkpoint", + "name": "checkpoint", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signatory", + "type": "address" + }, + { + "internalType": "address", + "name": "delegatee", + "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" + } + ], + "name": "delegateBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastTotalSupply", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x88c54a8d4b60d2ffd05143aa5916af40cbba8a52123001d3f2d9811fd0779633", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "transactionIndex": 77, + "gasUsed": "3654333", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000480000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xdaf32ccfa0f9d599c5a9436a2b6b7ad001071b0b761269ca955f83f54c645634", + "transactionHash": "0x88c54a8d4b60d2ffd05143aa5916af40cbba8a52123001d3f2d9811fd0779633", + "logs": [ + { + "transactionIndex": 77, + "blockNumber": 16327110, + "transactionHash": "0x88c54a8d4b60d2ffd05143aa5916af40cbba8a52123001d3f2d9811fd0779633", + "address": "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 100, + "blockHash": "0xdaf32ccfa0f9d599c5a9436a2b6b7ad001071b0b761269ca955f83f54c645634" + } + ], + "blockNumber": 16327110, + "cumulativeGasUsed": "8325197", + "status": 1, + "byzantium": true + }, + "args": [ + "covT underwriter token", + "covT" + ], + "numDeployments": 1, + "solcInputHash": "b466ba551e3f54d5eed446f39b17a223", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DELEGATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedDomainSeparator\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"pos\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fromBlock\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"internalType\":\"struct Checkpoints.Checkpoint\",\"name\":\"checkpoint\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signatory\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"delegatee\",\"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\"}],\"name\":\"delegateBySig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastTotalSupply\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\",\"returns\":{\"_0\":\"True if the operation succeeded.\"}},\"approveAndCall(address,uint256,bytes)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\",\"returns\":{\"_0\":\"True if both approval and `receiveApproval` calls succeeded.\"}},\"burn(uint256)\":{\"details\":\"Requirements: - the caller must have a balance of at least `amount`.\"},\"burnFrom(address,uint256)\":{\"details\":\"Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`.\"},\"delegate(address)\":{\"params\":{\"delegatee\":\"The address to delegate votes to\"}},\"delegateBySig(address,address,uint256,uint8,bytes32,bytes32)\":{\"params\":{\"deadline\":\"The time at which to expire the signature\",\"delegatee\":\"The address to delegate votes to\",\"r\":\"Half of the ECDSA signature pair\",\"s\":\"Half of the ECDSA signature pair\",\"v\":\"The recovery byte of the signature\"}},\"getPastTotalSupply(uint256)\":{\"details\":\"`blockNumber` must have been already mined\",\"params\":{\"blockNumber\":\"The block number to get the total supply at\"}},\"getPastVotes(address,uint256)\":{\"details\":\"Block number must be a finalized block or else this function will revert to prevent misinformation.\",\"params\":{\"account\":\"The address of the account to check\",\"blockNumber\":\"The block number to get the vote balance at\"},\"returns\":{\"_0\":\"The number of votes the account had as of the given block\"}},\"getVotes(address)\":{\"params\":{\"account\":\"The address to get votes balance\"},\"returns\":{\"_0\":\"The number of current votes for `account`\"}},\"mint(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"details\":\"The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transfer(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferFrom(address,address,uint256)\":{\"details\":\"Requirements: - `spender` and `recipient` cannot be the zero address, - `spender` must have a balance of at least `amount`, - the caller must have allowance for `spender`'s tokens of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"UnderwriterToken\",\"version\":1},\"userdoc\":{\"events\":{\"DelegateChanged(address,address,address)\":{\"notice\":\"Emitted when an account changes their delegate.\"},\"DelegateVotesChanged(address,uint256,uint256)\":{\"notice\":\"Emitted when a balance or delegate change results in changes to an account's voting power.\"}},\"kind\":\"user\",\"methods\":{\"DELEGATION_TYPEHASH()\":{\"notice\":\"The EIP-712 typehash for the delegation struct used by `delegateBySig`.\"},\"DOMAIN_SEPARATOR()\":{\"notice\":\"Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function.\"},\"PERMIT_TYPEHASH()\":{\"notice\":\"Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function.\"},\"allowance(address,address)\":{\"notice\":\"The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default.\"},\"approve(address,uint256)\":{\"notice\":\"Sets `amount` as the allowance of `spender` over the caller's tokens.\"},\"approveAndCall(address,uint256,bytes)\":{\"notice\":\"Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted.\"},\"balanceOf(address)\":{\"notice\":\"The amount of tokens owned by the given account.\"},\"burn(uint256)\":{\"notice\":\"Destroys `amount` tokens from the caller.\"},\"burnFrom(address,uint256)\":{\"notice\":\"Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"},\"decimals()\":{\"notice\":\"The decimals places of the token.\"},\"delegate(address)\":{\"notice\":\"Delegate votes from `msg.sender` to `delegatee`.\"},\"delegateBySig(address,address,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Delegates votes from signatory to `delegatee`\"},\"delegates(address)\":{\"notice\":\"Get the address `account` is currently delegating to.\"},\"getPastTotalSupply(uint256)\":{\"notice\":\"Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances, but it is NOT the sum of all the delegated votes!\"},\"getPastVotes(address,uint256)\":{\"notice\":\"Determine the prior number of votes for an account as of a block number.\"},\"getVotes(address)\":{\"notice\":\"Gets the current votes balance for `account`.\"},\"mint(address,uint256)\":{\"notice\":\"Creates `amount` tokens and assigns them to `account`, increasing the total supply.\"},\"name()\":{\"notice\":\"The name of the token.\"},\"nonce(address)\":{\"notice\":\"Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function.\"},\"numCheckpoints(address)\":{\"notice\":\"Get number of checkpoints for `account`.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction.\"},\"symbol()\":{\"notice\":\"The symbol of the token.\"},\"totalSupply()\":{\"notice\":\"The amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"notice\":\"Moves `amount` tokens from the caller's account to `recipient`.\"},\"transferFrom(address,address,uint256)\":{\"notice\":\"Moves `amount` tokens from `spender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"}},\"notice\":\"Underwriter tokens represent an ownership share in the underlying collateral of the asset-specific pool. Underwriter tokens are minted when a user deposits ERC20 tokens into asset-specific pool and they are burned when a user exits the position. Underwriter tokens natively support meta transactions. Users can authorize a transfer of their underwriter tokens with a signature conforming EIP712 standard instead of an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, as specified in EIP2612 standard, paying gas fees, and possibly performing other actions in the same transaction.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/UnderwriterToken.sol\":\"UnderwriterToken\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 /**\\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 / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xd0a917e32d1251a9b2f1dea15e932815d5382e64e6b0a18104664a6cc774cd70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./IVotesHistory.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\n/// @title Checkpoints\\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\\n/// delegation. This implementation supports token supply up to 2^96 - 1.\\n/// This contract keeps a history (checkpoints) of each account's vote\\n/// power. Vote power can be delegated either by calling the {delegate}\\n/// function directly, or by providing a signature to be used with\\n/// {delegateBySig}. Voting power can be publicly queried through\\n/// {getVotes} and {getPastVotes}.\\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\\n/// @dev This contract is upgrade-safe.\\nabstract contract Checkpoints is IVotesHistory {\\n struct Checkpoint {\\n uint32 fromBlock;\\n uint96 votes;\\n }\\n\\n // slither-disable-next-line uninitialized-state\\n mapping(address => address) internal _delegates;\\n mapping(address => uint128[]) internal _checkpoints;\\n uint128[] internal _totalSupplyCheckpoints;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n /// @notice Emitted when an account changes their delegate.\\n event DelegateChanged(\\n address indexed delegator,\\n address indexed fromDelegate,\\n address indexed toDelegate\\n );\\n\\n /// @notice Emitted when a balance or delegate change results in changes\\n /// to an account's voting power.\\n event DelegateVotesChanged(\\n address indexed delegate,\\n uint256 previousBalance,\\n uint256 newBalance\\n );\\n\\n function checkpoints(address account, uint32 pos)\\n public\\n view\\n virtual\\n returns (Checkpoint memory checkpoint)\\n {\\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\\n _checkpoints[account][pos]\\n );\\n checkpoint = Checkpoint(fromBlock, votes);\\n }\\n\\n /// @notice Get number of checkpoints for `account`.\\n function numCheckpoints(address account)\\n public\\n view\\n virtual\\n returns (uint32)\\n {\\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\\n }\\n\\n /// @notice Get the address `account` is currently delegating to.\\n function delegates(address account) public view virtual returns (address) {\\n return _delegates[account];\\n }\\n\\n /// @notice Gets the current votes balance for `account`.\\n /// @param account The address to get votes balance\\n /// @return The number of current votes for `account`\\n function getVotes(address account) public view returns (uint96) {\\n uint256 pos = _checkpoints[account].length;\\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\\n }\\n\\n /// @notice Determine the prior number of votes for an account as of\\n /// a block number.\\n /// @dev Block number must be a finalized block or else this function will\\n /// revert to prevent misinformation.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_checkpoints[account], blockNumber);\\n }\\n\\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\\n /// Note, this value is the sum of all balances, but it is NOT the\\n /// sum of all the delegated votes!\\n /// @param blockNumber The block number to get the total supply at\\n /// @dev `blockNumber` must have been already mined\\n function getPastTotalSupply(uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\\n }\\n\\n /// @notice Change delegation for `delegator` to `delegatee`.\\n // slither-disable-next-line dead-code\\n function delegate(address delegator, address delegatee) internal virtual;\\n\\n /// @notice Moves voting power from one delegate to another\\n /// @param src Address of old delegate\\n /// @param dst Address of new delegate\\n /// @param amount Voting power amount to transfer between delegates\\n function moveVotingPower(\\n address src,\\n address dst,\\n uint256 amount\\n ) internal {\\n if (src != dst && amount > 0) {\\n if (src != address(0)) {\\n // https://github.com/crytic/slither/issues/960\\n // slither-disable-next-line variable-scope\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[src],\\n subtract,\\n amount\\n );\\n emit DelegateVotesChanged(src, oldWeight, newWeight);\\n }\\n\\n if (dst != address(0)) {\\n // https://github.com/crytic/slither/issues/959\\n // slither-disable-next-line uninitialized-local\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[dst],\\n add,\\n amount\\n );\\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\\n }\\n }\\n }\\n\\n /// @notice Writes a new checkpoint based on operating last stored value\\n /// with a `delta`. Usually, said operation is the `add` or\\n /// `subtract` functions from this contract, but more complex\\n /// functions can be passed as parameters.\\n /// @param ckpts The checkpoints array to use\\n /// @param op The function to apply over the last value and the `delta`\\n /// @param delta Variation with respect to last stored value to be used\\n /// for new checkpoint\\n function writeCheckpoint(\\n uint128[] storage ckpts,\\n function(uint256, uint256) view returns (uint256) op,\\n uint256 delta\\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\\n uint256 pos = ckpts.length;\\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\\n newWeight = op(oldWeight, delta);\\n\\n if (pos > 0) {\\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\\n // slither-disable-next-line incorrect-equality\\n if (fromBlock == block.number) {\\n ckpts[pos - 1] = encodeCheckpoint(\\n fromBlock,\\n SafeCastUpgradeable.toUint96(newWeight)\\n );\\n return (oldWeight, newWeight);\\n }\\n }\\n\\n ckpts.push(\\n encodeCheckpoint(\\n SafeCastUpgradeable.toUint32(block.number),\\n SafeCastUpgradeable.toUint96(newWeight)\\n )\\n );\\n }\\n\\n /// @notice Lookup a value in a list of (sorted) checkpoints.\\n /// @param ckpts The checkpoints array to use\\n /// @param blockNumber Block number when we want to get the checkpoint at\\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\\n internal\\n view\\n returns (uint96)\\n {\\n // We run a binary search to look for the earliest checkpoint taken\\n // after `blockNumber`. During the loop, the index of the wanted\\n // checkpoint remains in the range [low-1, high). With each iteration,\\n // either `low` or `high` is moved towards the middle of the range to\\n // maintain the invariant.\\n // - If the middle checkpoint is after `blockNumber`,\\n // we look in [low, mid)\\n // - If the middle checkpoint is before or equal to `blockNumber`,\\n // we look in [mid+1, high)\\n // Once we reach a single value (when low == high), we've found the\\n // right checkpoint at the index high-1, if not out of bounds (in that\\n // case we're looking too far in the past and the result is 0).\\n // Note that if the latest checkpoint available is exactly for\\n // `blockNumber`, we end up with an index that is past the end of the\\n // array, so we technically don't find a checkpoint after\\n // `blockNumber`, but it works out the same.\\n require(blockNumber < block.number, \\\"Block not yet determined\\\");\\n\\n uint256 high = ckpts.length;\\n uint256 low = 0;\\n while (low < high) {\\n uint256 mid = MathUpgradeable.average(low, high);\\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\\n if (midBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\\n }\\n\\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\\n // slither-disable-next-line dead-code\\n function maxSupply() internal view virtual returns (uint96) {\\n return type(uint96).max;\\n }\\n\\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\\n /// checkpoint.\\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\\n /// remaining 96 bits.\\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\\n internal\\n pure\\n returns (uint128)\\n {\\n return (uint128(blockNumber) << 96) | uint128(value);\\n }\\n\\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\\n function decodeBlockNumber(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32)\\n {\\n return uint32(bytes4(bytes16(checkpoint)));\\n }\\n\\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\\n return uint96(checkpoint);\\n }\\n\\n /// @notice Decodes a block number and voting value from a `uint128`\\n /// `checkpoint`.\\n function decodeCheckpoint(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32 blockNumber, uint96 value)\\n {\\n blockNumber = decodeBlockNumber(checkpoint);\\n value = decodeValue(checkpoint);\\n }\\n\\n // slither-disable-next-line dead-code\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n // slither-disable-next-line dead-code\\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n}\\n\",\"keccak256\":\"0x67b28349e88afe7440c43df93ba5de56873d850a25147161e4469731750efb16\",\"license\":\"GPL-3.0-or-later\"},\"@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\ninterface IVotesHistory {\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n\\n function getPastTotalSupply(uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x535e87cf4c2e9a9439d99cf0918f013965fa6c4ddfbab07ff6ca4b195c8edc9f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/UnderwriterToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\\";\\n\\n/// @title UnderwriterToken\\n/// @notice Underwriter tokens represent an ownership share in the underlying\\n/// collateral of the asset-specific pool. Underwriter tokens are minted\\n/// when a user deposits ERC20 tokens into asset-specific pool and they\\n/// are burned when a user exits the position. Underwriter tokens\\n/// natively support meta transactions. Users can authorize a transfer\\n/// of their underwriter tokens with a signature conforming EIP712\\n/// standard instead of an on-chain transaction from their address.\\n/// Anyone can submit this signature on the user's behalf by calling the\\n/// permit function, as specified in EIP2612 standard, paying gas fees,\\n/// and possibly performing other actions in the same transaction.\\n// slither-disable-next-line missing-inheritance\\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\\n /// @notice The EIP-712 typehash for the delegation struct used by\\n /// `delegateBySig`.\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\n \\\"Delegation(address delegatee,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n constructor(string memory _name, string memory _symbol)\\n ERC20WithPermit(_name, _symbol)\\n {}\\n\\n /// @notice Delegates votes from signatory to `delegatee`\\n /// @param delegatee The address to delegate votes to\\n /// @param deadline The time at which to expire the signature\\n /// @param v The recovery byte of the signature\\n /// @param r Half of the ECDSA signature pair\\n /// @param s Half of the ECDSA signature pair\\n function delegateBySig(\\n address signatory,\\n address delegatee,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Delegation expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n DELEGATION_TYPEHASH,\\n delegatee,\\n nonce[signatory]++,\\n deadline\\n )\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == signatory,\\n \\\"Invalid signature\\\"\\n );\\n\\n return delegate(signatory, delegatee);\\n }\\n\\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) public virtual {\\n return delegate(msg.sender, delegatee);\\n }\\n\\n /// @notice Moves voting power when tokens are minted, burned or transferred.\\n /// @dev Overrides the empty function from the parent contract.\\n /// @param from The address that loses tokens and voting power\\n /// @param to The address that gains tokens and voting power\\n /// @param amount The amount of tokens and voting power that is transferred\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal override {\\n // When minting:\\n if (from == address(0)) {\\n // Does not allow to mint more than uint96 can fit. Otherwise, the\\n // Checkpoint might not fit the balance.\\n require(\\n totalSupply + amount <= maxSupply(),\\n \\\"Maximum total supply exceeded\\\"\\n );\\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\\n }\\n\\n // When burning:\\n if (to == address(0)) {\\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\\n }\\n\\n moveVotingPower(delegates(from), delegates(to), amount);\\n }\\n\\n /// @notice Delegate votes from `delegator` to `delegatee`.\\n /// @param delegator The address to delegate votes from\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegator, address delegatee) internal override {\\n address currentDelegate = delegates(delegator);\\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\\n _delegates[delegator] = delegatee;\\n\\n emit DelegateChanged(delegator, currentDelegate, delegatee);\\n\\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\\n }\\n}\\n\",\"keccak256\":\"0x73aa9781275a0e35c0c80873bfbb3b4b42692fa56f785a3eb4bf0471fb3c277d\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b50604051620046d1380380620046d1833981810160405281019062000037919062000479565b8181620000596200004d620000b460201b60201c565b620000bc60201b60201c565b8160059080519060200190620000719291906200022c565b5080600690805190602001906200008a9291906200022c565b504660808181525050620000a36200018060201b60201c565b60a0818152505050505050620006ff565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051620001b491906200060e565b60405180910390206040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525080519060200120463060405160200162000211959493929190620006a2565b60405160208183030381529060405280519060200120905090565b8280546200023a906200052d565b90600052602060002090601f0160209004810192826200025e5760008555620002aa565b82601f106200027957805160ff1916838001178555620002aa565b82800160010185558215620002aa579182015b82811115620002a95782518255916020019190600101906200028c565b5b509050620002b99190620002bd565b5090565b5b80821115620002d8576000816000905550600101620002be565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200034582620002fa565b810181811067ffffffffffffffff821117156200036757620003666200030b565b5b80604052505050565b60006200037c620002dc565b90506200038a82826200033a565b919050565b600067ffffffffffffffff821115620003ad57620003ac6200030b565b5b620003b882620002fa565b9050602081019050919050565b60005b83811015620003e5578082015181840152602081019050620003c8565b83811115620003f5576000848401525b50505050565b6000620004126200040c846200038f565b62000370565b905082815260208101848484011115620004315762000430620002f5565b5b6200043e848285620003c5565b509392505050565b600082601f8301126200045e576200045d620002f0565b5b815162000470848260208601620003fb565b91505092915050565b60008060408385031215620004935762000492620002e6565b5b600083015167ffffffffffffffff811115620004b457620004b3620002eb565b5b620004c28582860162000446565b925050602083015167ffffffffffffffff811115620004e657620004e5620002eb565b5b620004f48582860162000446565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200054657607f821691505b602082108114156200055d576200055c620004fe565b5b50919050565b600081905092915050565b60008190508160005260206000209050919050565b6000815462000592816200052d565b6200059e818662000563565b94506001821660008114620005bc5760018114620005ce5762000605565b60ff1983168652818601935062000605565b620005d9856200056e565b60005b83811015620005fd57815481890152600182019150602081019050620005dc565b838801955050505b50505092915050565b60006200061c828462000583565b915081905092915050565b6000819050919050565b6200063c8162000627565b82525050565b6000819050919050565b620006578162000642565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200068a826200065d565b9050919050565b6200069c816200067d565b82525050565b600060a082019050620006b9600083018862000631565b620006c8602083018762000631565b620006d7604083018662000631565b620006e660608301856200064c565b620006f5608083018462000691565b9695505050505050565b60805160a051613f9e620007336000396000818161086e015261115a0152600081816108460152610b6e0152613f9e6000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c8063715018a61161010f578063b20d7fa9116100a2578063dd62ed3e11610071578063dd62ed3e146105ba578063e7a324dc146105ea578063f1127ed814610608578063f2fde38b14610638576101e5565b8063b20d7fa914610534578063b4f94b2e14610550578063cae9ca511461056e578063d505accf1461059e576101e5565b80638e539e8c116100de5780638e539e8c1461048657806395d89b41146104b65780639ab24eb0146104d4578063a9059cbb14610504576101e5565b8063715018a614610424578063771da5c51461042e57806379cc67901461044c5780638da5cb5b14610468576101e5565b80633a46b1a8116101875780635c19a95c116101565780635c19a95c146103785780636fcfff451461039457806370a08231146103c457806370ae92d2146103f4576101e5565b80633a46b1a8146102e057806340c10f191461031057806342966c681461032c578063587cde1e14610348576101e5565b806323b872dd116101c357806323b872dd1461025657806330adf81f14610286578063313ce567146102a45780633644e515146102c2576101e5565b806306fdde03146101ea578063095ea7b31461020857806318160ddd14610238575b600080fd5b6101f2610654565b6040516101ff919061292e565b60405180910390f35b610222600480360381019061021d91906129f8565b6106e2565b60405161022f9190612a53565b60405180910390f35b6102406106f9565b60405161024d9190612a7d565b60405180910390f35b610270600480360381019061026b9190612a98565b6106ff565b60405161027d9190612a53565b60405180910390f35b61028e610819565b60405161029b9190612b04565b60405180910390f35b6102ac61083d565b6040516102b99190612b3b565b60405180910390f35b6102ca610842565b6040516102d79190612b04565b60405180910390f35b6102fa60048036038101906102f591906129f8565b6108a2565b6040516103079190612b7d565b60405180910390f35b61032a600480360381019061032591906129f8565b6108f4565b005b61034660048036038101906103419190612b98565b610a51565b005b610362600480360381019061035d9190612bc5565b610a5e565b60405161036f9190612c01565b60405180910390f35b610392600480360381019061038d9190612bc5565b610ac7565b005b6103ae60048036038101906103a99190612bc5565b610ad4565b6040516103bb9190612c3b565b60405180910390f35b6103de60048036038101906103d99190612bc5565b610b28565b6040516103eb9190612a7d565b60405180910390f35b61040e60048036038101906104099190612bc5565b610b40565b60405161041b9190612a7d565b60405180910390f35b61042c610b58565b005b610436610b6c565b6040516104439190612a7d565b60405180910390f35b610466600480360381019061046191906129f8565b610b90565b005b610470610ca1565b60405161047d9190612c01565b60405180910390f35b6104a0600480360381019061049b9190612b98565b610cca565b6040516104ad9190612b7d565b60405180910390f35b6104be610cde565b6040516104cb919061292e565b60405180910390f35b6104ee60048036038101906104e99190612bc5565b610d6c565b6040516104fb9190612b7d565b60405180910390f35b61051e600480360381019061051991906129f8565b610e63565b60405161052b9190612a53565b60405180910390f35b61054e60048036038101906105499190612cae565b610e7a565b005b610558611158565b6040516105659190612b04565b60405180910390f35b61058860048036038101906105839190612e70565b61117c565b6040516105959190612a53565b60405180910390f35b6105b860048036038101906105b39190612edf565b611213565b005b6105d460048036038101906105cf9190612f81565b6114f7565b6040516105e19190612a7d565b60405180910390f35b6105f261151c565b6040516105ff9190612b04565b60405180910390f35b610622600480360381019061061d9190612fed565b611540565b60405161062f919061307a565b60405180910390f35b610652600480360381019061064d9190612bc5565b611613565b005b60058054610661906130c4565b80601f016020809104026020016040519081016040528092919081815260200182805461068d906130c4565b80156106da5780601f106106af576101008083540402835291602001916106da565b820191906000526020600020905b8154815290600101906020018083116106bd57829003601f168201915b505050505081565b60006106ef338484611697565b6001905092915050565b60045481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461080257828110156107eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e290613168565b60405180910390fd5b610801853385846107fc91906131b7565b611697565b5b61080d858585611862565b60019150509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60007f0000000000000000000000000000000000000000000000000000000000000000461415610894577f0000000000000000000000000000000000000000000000000000000000000000905061089f565b61089c611b53565b90505b90565b60006108ec600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083611bfb565b905092915050565b6108fc611d52565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561096c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096390613237565b60405180910390fd5b61097860008383611dd0565b806004600082825461098a9190613257565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109e09190613257565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610a459190612a7d565b60405180910390a35050565b610a5b3382611ee1565b50565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610ad13382612047565b50565b6000610b21600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506121ae565b9050919050565b60016020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b610b60611d52565b610b6a6000612201565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610c925781811015610c7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c72906132f9565b60405180910390fd5b610c9183338484610c8c91906131b7565b611697565b5b610c9c8383611ee1565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000610cd7600983611bfb565b9050919050565b60068054610ceb906130c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610d17906130c4565b8015610d645780601f10610d3957610100808354040283529160200191610d64565b820191906000526020600020905b815481529060010190602001808311610d4757829003601f168201915b505050505081565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050905060008114610e5857610e53600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600183610e0b91906131b7565b81548110610e1c57610e1b613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b610e5b565b60005b915050919050565b6000610e70338484611862565b6001905092915050565b42841015610ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb490613394565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c1115610f23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1a90613400565b60405180910390fd5b601b8360ff161480610f385750601c8360ff16145b610f77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6e9061346c565b60405180910390fd5b6000610f81610842565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e287600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610ff39061348c565b919050558860405160200161100b94939291906134d5565b60405160208183030381529060405280519060200120604051602001611032929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161106f94939291906135c9565b6020604051602081039080840390855afa158015611091573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561110557508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611144576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113b9061365a565b60405180910390fd5b61114e8888612047565b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061118884846106e2565b15611207578373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b81526004016111cc94939291906136cf565b600060405180830381600087803b1580156111e657600080fd5b505af11580156111fa573d6000803e3d6000fd5b505050506001905061120c565b600090505b9392505050565b42841015611256576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124d90613767565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c11156112bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b390613400565b60405180910390fd5b601b8360ff1614806112d15750601c8360ff16145b611310576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113079061346c565b60405180910390fd5b600061131a610842565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9898989600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061138e9061348c565b919050558a6040516020016113a896959493929190613787565b604051602081830303815290604052805190602001206040516020016113cf929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161140c94939291906135c9565b6020604051602081039080840390855afa15801561142e573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156114a257508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b6114e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d89061365a565b60405180910390fd5b6114ec898989611697565b505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e281565b611548612867565b6000806115dc600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208563ffffffff16815481106115a5576115a4613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122cf565b9150915060405180604001604052808363ffffffff168152602001826bffffffffffffffffffffffff168152509250505092915050565b61161b611d52565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561168b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116829061385a565b60405180910390fd5b61169481612201565b50565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe906138c6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176e90613932565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516118559190612a7d565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156118d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c99061399e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611942576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193990613a0a565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a890613a76565b60405180910390fd5b6119bc838383611dd0565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611a43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a3a90613ae2565b60405180910390fd5b8181611a4f91906131b7565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611ae19190613257565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611b459190612a7d565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051611b859190613ba1565b60405180910390206040518060400160405280600181526020017f3100000000000000000000000000000000000000000000000000000000000000815250805190602001204630604051602001611be0959493929190613bb8565b60405160208183030381529060405280519060200120905090565b6000438210611c3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3690613c57565b60405180910390fd5b60008380549050905060005b81811015611cdf576000611c5f82846122ed565b90506000611cb0878381548110611c7957611c78613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050858163ffffffff161115611cc857819350611cd8565b600182611cd59190613257565b92505b5050611c4b565b60008214611d4557611d4085600184611cf891906131b7565b81548110611d0957611d08613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b611d48565b60005b9250505092915050565b611d5a612323565b73ffffffffffffffffffffffffffffffffffffffff16611d78610ca1565b73ffffffffffffffffffffffffffffffffffffffff1614611dce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dc590613cc3565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e7b57611e0d61232b565b6bffffffffffffffffffffffff1681600454611e299190613257565b1115611e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6190613d2f565b60405180910390fd5b611e78600961233f83612355565b50505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ec157611ebe600961256b83612355565b50505b611edc611ecd84610a5e565b611ed684610a5e565b83612581565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611f68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5f90613d9b565b60405180910390fd5b611f7483600084611dd0565b8181611f8091906131b7565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160046000828254611fd591906131b7565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161203a9190612a7d565b60405180910390a3505050565b600061205283610a5e565b9050600061209e600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461277a565b905082600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a46121a88284836bffffffffffffffffffffffff16612581565b50505050565b600063ffffffff80168211156121f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f090613e2d565b60405180910390fd5b819050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000819050919050565b6000806122db83612313565b91506122e6836122c5565b9050915091565b600060028284186122fe9190613e7c565b82841661230b9190613257565b905092915050565b60008160801b60e01c9050919050565b600033905090565b60006bffffffffffffffffffffffff905090565b6000818361234d9190613257565b905092915050565b600080600085805490509050600081146123c7576123c28660018361237a91906131b7565b8154811061238b5761238a613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b6123ca565b60005b6bffffffffffffffffffffffff1692506123e883858763ffffffff16565b915060008111156124e357600061244e8760018461240691906131b7565b8154811061241757612416613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050438163ffffffff1614156124e1576124708161246b856127d5565b612830565b8760018461247e91906131b7565b8154811061248f5761248e613319565b5b90600052602060002090600291828204019190066010026101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055505050612563565b505b856124fe6124f0436121ae565b6124f9856127d5565b612830565b90806001815401808255809150506001900390600052602060002090600291828204019190066010029091909190916101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505b935093915050565b6000818361257991906131b7565b905092915050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156125bd5750600081115b1561277557600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461269b57600080612644600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061256b85612355565b915091508473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612690929190613ead565b60405180910390a250505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146127745760008061271d600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061233f85612355565b915091508373ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612769929190613ead565b60405180910390a250505b5b505050565b60006bffffffffffffffffffffffff80168211156127cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127c490613f48565b60405180910390fd5b819050919050565b60006bffffffffffffffffffffffff8016821115612828576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281f90613f48565b60405180910390fd5b819050919050565b6000816bffffffffffffffffffffffff1660608463ffffffff166fffffffffffffffffffffffffffffffff16901b17905092915050565b6040518060400160405280600063ffffffff16815260200160006bffffffffffffffffffffffff1681525090565b600081519050919050565b600082825260208201905092915050565b60005b838110156128cf5780820151818401526020810190506128b4565b838111156128de576000848401525b50505050565b6000601f19601f8301169050919050565b600061290082612895565b61290a81856128a0565b935061291a8185602086016128b1565b612923816128e4565b840191505092915050565b6000602082019050818103600083015261294881846128f5565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061298f82612964565b9050919050565b61299f81612984565b81146129aa57600080fd5b50565b6000813590506129bc81612996565b92915050565b6000819050919050565b6129d5816129c2565b81146129e057600080fd5b50565b6000813590506129f2816129cc565b92915050565b60008060408385031215612a0f57612a0e61295a565b5b6000612a1d858286016129ad565b9250506020612a2e858286016129e3565b9150509250929050565b60008115159050919050565b612a4d81612a38565b82525050565b6000602082019050612a686000830184612a44565b92915050565b612a77816129c2565b82525050565b6000602082019050612a926000830184612a6e565b92915050565b600080600060608486031215612ab157612ab061295a565b5b6000612abf868287016129ad565b9350506020612ad0868287016129ad565b9250506040612ae1868287016129e3565b9150509250925092565b6000819050919050565b612afe81612aeb565b82525050565b6000602082019050612b196000830184612af5565b92915050565b600060ff82169050919050565b612b3581612b1f565b82525050565b6000602082019050612b506000830184612b2c565b92915050565b60006bffffffffffffffffffffffff82169050919050565b612b7781612b56565b82525050565b6000602082019050612b926000830184612b6e565b92915050565b600060208284031215612bae57612bad61295a565b5b6000612bbc848285016129e3565b91505092915050565b600060208284031215612bdb57612bda61295a565b5b6000612be9848285016129ad565b91505092915050565b612bfb81612984565b82525050565b6000602082019050612c166000830184612bf2565b92915050565b600063ffffffff82169050919050565b612c3581612c1c565b82525050565b6000602082019050612c506000830184612c2c565b92915050565b612c5f81612b1f565b8114612c6a57600080fd5b50565b600081359050612c7c81612c56565b92915050565b612c8b81612aeb565b8114612c9657600080fd5b50565b600081359050612ca881612c82565b92915050565b60008060008060008060c08789031215612ccb57612cca61295a565b5b6000612cd989828a016129ad565b9650506020612cea89828a016129ad565b9550506040612cfb89828a016129e3565b9450506060612d0c89828a01612c6d565b9350506080612d1d89828a01612c99565b92505060a0612d2e89828a01612c99565b9150509295509295509295565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612d7d826128e4565b810181811067ffffffffffffffff82111715612d9c57612d9b612d45565b5b80604052505050565b6000612daf612950565b9050612dbb8282612d74565b919050565b600067ffffffffffffffff821115612ddb57612dda612d45565b5b612de4826128e4565b9050602081019050919050565b82818337600083830152505050565b6000612e13612e0e84612dc0565b612da5565b905082815260208101848484011115612e2f57612e2e612d40565b5b612e3a848285612df1565b509392505050565b600082601f830112612e5757612e56612d3b565b5b8135612e67848260208601612e00565b91505092915050565b600080600060608486031215612e8957612e8861295a565b5b6000612e97868287016129ad565b9350506020612ea8868287016129e3565b925050604084013567ffffffffffffffff811115612ec957612ec861295f565b5b612ed586828701612e42565b9150509250925092565b600080600080600080600060e0888a031215612efe57612efd61295a565b5b6000612f0c8a828b016129ad565b9750506020612f1d8a828b016129ad565b9650506040612f2e8a828b016129e3565b9550506060612f3f8a828b016129e3565b9450506080612f508a828b01612c6d565b93505060a0612f618a828b01612c99565b92505060c0612f728a828b01612c99565b91505092959891949750929550565b60008060408385031215612f9857612f9761295a565b5b6000612fa6858286016129ad565b9250506020612fb7858286016129ad565b9150509250929050565b612fca81612c1c565b8114612fd557600080fd5b50565b600081359050612fe781612fc1565b92915050565b600080604083850312156130045761300361295a565b5b6000613012858286016129ad565b925050602061302385828601612fd8565b9150509250929050565b61303681612c1c565b82525050565b61304581612b56565b82525050565b604082016000820151613061600085018261302d565b506020820151613074602085018261303c565b50505050565b600060408201905061308f600083018461304b565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806130dc57607f821691505b602082108114156130f0576130ef613095565b5b50919050565b7f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b60006131526021836128a0565b915061315d826130f6565b604082019050919050565b6000602082019050818103600083015261318181613145565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006131c2826129c2565b91506131cd836129c2565b9250828210156131e0576131df613188565b5b828203905092915050565b7f4d696e7420746f20746865207a65726f20616464726573730000000000000000600082015250565b60006132216018836128a0565b915061322c826131eb565b602082019050919050565b6000602082019050818103600083015261325081613214565b9050919050565b6000613262826129c2565b915061326d836129c2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156132a2576132a1613188565b5b828201905092915050565b7f4275726e20616d6f756e74206578636565647320616c6c6f77616e6365000000600082015250565b60006132e3601d836128a0565b91506132ee826132ad565b602082019050919050565b60006020820190508181036000830152613312816132d6565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f44656c65676174696f6e20657870697265640000000000000000000000000000600082015250565b600061337e6012836128a0565b915061338982613348565b602082019050919050565b600060208201905081810360008301526133ad81613371565b9050919050565b7f496e76616c6964207369676e6174757265202773272076616c75650000000000600082015250565b60006133ea601b836128a0565b91506133f5826133b4565b602082019050919050565b60006020820190508181036000830152613419816133dd565b9050919050565b7f496e76616c6964207369676e6174757265202776272076616c75650000000000600082015250565b6000613456601b836128a0565b915061346182613420565b602082019050919050565b6000602082019050818103600083015261348581613449565b9050919050565b6000613497826129c2565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156134ca576134c9613188565b5b600182019050919050565b60006080820190506134ea6000830187612af5565b6134f76020830186612bf2565b6135046040830185612a6e565b6135116060830184612a6e565b95945050505050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b600061355b60028361351a565b915061356682613525565b600282019050919050565b6000819050919050565b61358c61358782612aeb565b613571565b82525050565b600061359d8261354e565b91506135a9828561357b565b6020820191506135b9828461357b565b6020820191508190509392505050565b60006080820190506135de6000830187612af5565b6135eb6020830186612b2c565b6135f86040830185612af5565b6136056060830184612af5565b95945050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b60006136446011836128a0565b915061364f8261360e565b602082019050919050565b6000602082019050818103600083015261367381613637565b9050919050565b600081519050919050565b600082825260208201905092915050565b60006136a18261367a565b6136ab8185613685565b93506136bb8185602086016128b1565b6136c4816128e4565b840191505092915050565b60006080820190506136e46000830187612bf2565b6136f16020830186612a6e565b6136fe6040830185612bf2565b81810360608301526137108184613696565b905095945050505050565b7f5065726d697373696f6e20657870697265640000000000000000000000000000600082015250565b60006137516012836128a0565b915061375c8261371b565b602082019050919050565b6000602082019050818103600083015261378081613744565b9050919050565b600060c08201905061379c6000830189612af5565b6137a96020830188612bf2565b6137b66040830187612bf2565b6137c36060830186612a6e565b6137d06080830185612a6e565b6137dd60a0830184612a6e565b979650505050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006138446026836128a0565b915061384f826137e8565b604082019050919050565b6000602082019050818103600083015261387381613837565b9050919050565b7f417070726f76652066726f6d20746865207a65726f2061646472657373000000600082015250565b60006138b0601d836128a0565b91506138bb8261387a565b602082019050919050565b600060208201905081810360008301526138df816138a3565b9050919050565b7f417070726f766520746f20746865207a65726f20616464726573730000000000600082015250565b600061391c601b836128a0565b9150613927826138e6565b602082019050919050565b6000602082019050818103600083015261394b8161390f565b9050919050565b7f5472616e736665722066726f6d20746865207a65726f20616464726573730000600082015250565b6000613988601e836128a0565b915061399382613952565b602082019050919050565b600060208201905081810360008301526139b78161397b565b9050919050565b7f5472616e7366657220746f20746865207a65726f206164647265737300000000600082015250565b60006139f4601c836128a0565b91506139ff826139be565b602082019050919050565b60006020820190508181036000830152613a23816139e7565b9050919050565b7f5472616e7366657220746f2074686520746f6b656e2061646472657373000000600082015250565b6000613a60601d836128a0565b9150613a6b82613a2a565b602082019050919050565b60006020820190508181036000830152613a8f81613a53565b9050919050565b7f5472616e7366657220616d6f756e7420657863656564732062616c616e636500600082015250565b6000613acc601f836128a0565b9150613ad782613a96565b602082019050919050565b60006020820190508181036000830152613afb81613abf565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154613b2f816130c4565b613b398186613b02565b94506001821660008114613b545760018114613b6557613b98565b60ff19831686528186019350613b98565b613b6e85613b0d565b60005b83811015613b9057815481890152600182019150602081019050613b71565b838801955050505b50505092915050565b6000613bad8284613b22565b915081905092915050565b600060a082019050613bcd6000830188612af5565b613bda6020830187612af5565b613be76040830186612af5565b613bf46060830185612a6e565b613c016080830184612bf2565b9695505050505050565b7f426c6f636b206e6f74207965742064657465726d696e65640000000000000000600082015250565b6000613c416018836128a0565b9150613c4c82613c0b565b602082019050919050565b60006020820190508181036000830152613c7081613c34565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613cad6020836128a0565b9150613cb882613c77565b602082019050919050565b60006020820190508181036000830152613cdc81613ca0565b9050919050565b7f4d6178696d756d20746f74616c20737570706c79206578636565646564000000600082015250565b6000613d19601d836128a0565b9150613d2482613ce3565b602082019050919050565b60006020820190508181036000830152613d4881613d0c565b9050919050565b7f4275726e20616d6f756e7420657863656564732062616c616e63650000000000600082015250565b6000613d85601b836128a0565b9150613d9082613d4f565b602082019050919050565b60006020820190508181036000830152613db481613d78565b9050919050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203360008201527f3220626974730000000000000000000000000000000000000000000000000000602082015250565b6000613e176026836128a0565b9150613e2282613dbb565b604082019050919050565b60006020820190508181036000830152613e4681613e0a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613e87826129c2565b9150613e92836129c2565b925082613ea257613ea1613e4d565b5b828204905092915050565b6000604082019050613ec26000830185612a6e565b613ecf6020830184612a6e565b9392505050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203960008201527f3620626974730000000000000000000000000000000000000000000000000000602082015250565b6000613f326026836128a0565b9150613f3d82613ed6565b604082019050919050565b60006020820190508181036000830152613f6181613f25565b905091905056fea264697066735822122080c4ea65fe927ddc01a672c8707e7276fbf471d1a5c285c9638eb1806c347c3764736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101e55760003560e01c8063715018a61161010f578063b20d7fa9116100a2578063dd62ed3e11610071578063dd62ed3e146105ba578063e7a324dc146105ea578063f1127ed814610608578063f2fde38b14610638576101e5565b8063b20d7fa914610534578063b4f94b2e14610550578063cae9ca511461056e578063d505accf1461059e576101e5565b80638e539e8c116100de5780638e539e8c1461048657806395d89b41146104b65780639ab24eb0146104d4578063a9059cbb14610504576101e5565b8063715018a614610424578063771da5c51461042e57806379cc67901461044c5780638da5cb5b14610468576101e5565b80633a46b1a8116101875780635c19a95c116101565780635c19a95c146103785780636fcfff451461039457806370a08231146103c457806370ae92d2146103f4576101e5565b80633a46b1a8146102e057806340c10f191461031057806342966c681461032c578063587cde1e14610348576101e5565b806323b872dd116101c357806323b872dd1461025657806330adf81f14610286578063313ce567146102a45780633644e515146102c2576101e5565b806306fdde03146101ea578063095ea7b31461020857806318160ddd14610238575b600080fd5b6101f2610654565b6040516101ff919061292e565b60405180910390f35b610222600480360381019061021d91906129f8565b6106e2565b60405161022f9190612a53565b60405180910390f35b6102406106f9565b60405161024d9190612a7d565b60405180910390f35b610270600480360381019061026b9190612a98565b6106ff565b60405161027d9190612a53565b60405180910390f35b61028e610819565b60405161029b9190612b04565b60405180910390f35b6102ac61083d565b6040516102b99190612b3b565b60405180910390f35b6102ca610842565b6040516102d79190612b04565b60405180910390f35b6102fa60048036038101906102f591906129f8565b6108a2565b6040516103079190612b7d565b60405180910390f35b61032a600480360381019061032591906129f8565b6108f4565b005b61034660048036038101906103419190612b98565b610a51565b005b610362600480360381019061035d9190612bc5565b610a5e565b60405161036f9190612c01565b60405180910390f35b610392600480360381019061038d9190612bc5565b610ac7565b005b6103ae60048036038101906103a99190612bc5565b610ad4565b6040516103bb9190612c3b565b60405180910390f35b6103de60048036038101906103d99190612bc5565b610b28565b6040516103eb9190612a7d565b60405180910390f35b61040e60048036038101906104099190612bc5565b610b40565b60405161041b9190612a7d565b60405180910390f35b61042c610b58565b005b610436610b6c565b6040516104439190612a7d565b60405180910390f35b610466600480360381019061046191906129f8565b610b90565b005b610470610ca1565b60405161047d9190612c01565b60405180910390f35b6104a0600480360381019061049b9190612b98565b610cca565b6040516104ad9190612b7d565b60405180910390f35b6104be610cde565b6040516104cb919061292e565b60405180910390f35b6104ee60048036038101906104e99190612bc5565b610d6c565b6040516104fb9190612b7d565b60405180910390f35b61051e600480360381019061051991906129f8565b610e63565b60405161052b9190612a53565b60405180910390f35b61054e60048036038101906105499190612cae565b610e7a565b005b610558611158565b6040516105659190612b04565b60405180910390f35b61058860048036038101906105839190612e70565b61117c565b6040516105959190612a53565b60405180910390f35b6105b860048036038101906105b39190612edf565b611213565b005b6105d460048036038101906105cf9190612f81565b6114f7565b6040516105e19190612a7d565b60405180910390f35b6105f261151c565b6040516105ff9190612b04565b60405180910390f35b610622600480360381019061061d9190612fed565b611540565b60405161062f919061307a565b60405180910390f35b610652600480360381019061064d9190612bc5565b611613565b005b60058054610661906130c4565b80601f016020809104026020016040519081016040528092919081815260200182805461068d906130c4565b80156106da5780601f106106af576101008083540402835291602001916106da565b820191906000526020600020905b8154815290600101906020018083116106bd57829003601f168201915b505050505081565b60006106ef338484611697565b6001905092915050565b60045481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461080257828110156107eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e290613168565b60405180910390fd5b610801853385846107fc91906131b7565b611697565b5b61080d858585611862565b60019150509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60007f0000000000000000000000000000000000000000000000000000000000000000461415610894577f0000000000000000000000000000000000000000000000000000000000000000905061089f565b61089c611b53565b90505b90565b60006108ec600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083611bfb565b905092915050565b6108fc611d52565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561096c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096390613237565b60405180910390fd5b61097860008383611dd0565b806004600082825461098a9190613257565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109e09190613257565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610a459190612a7d565b60405180910390a35050565b610a5b3382611ee1565b50565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610ad13382612047565b50565b6000610b21600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506121ae565b9050919050565b60016020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b610b60611d52565b610b6a6000612201565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610c925781811015610c7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c72906132f9565b60405180910390fd5b610c9183338484610c8c91906131b7565b611697565b5b610c9c8383611ee1565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000610cd7600983611bfb565b9050919050565b60068054610ceb906130c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610d17906130c4565b8015610d645780601f10610d3957610100808354040283529160200191610d64565b820191906000526020600020905b815481529060010190602001808311610d4757829003601f168201915b505050505081565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050905060008114610e5857610e53600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600183610e0b91906131b7565b81548110610e1c57610e1b613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b610e5b565b60005b915050919050565b6000610e70338484611862565b6001905092915050565b42841015610ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb490613394565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c1115610f23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1a90613400565b60405180910390fd5b601b8360ff161480610f385750601c8360ff16145b610f77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6e9061346c565b60405180910390fd5b6000610f81610842565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e287600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610ff39061348c565b919050558860405160200161100b94939291906134d5565b60405160208183030381529060405280519060200120604051602001611032929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161106f94939291906135c9565b6020604051602081039080840390855afa158015611091573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561110557508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611144576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113b9061365a565b60405180910390fd5b61114e8888612047565b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061118884846106e2565b15611207578373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b81526004016111cc94939291906136cf565b600060405180830381600087803b1580156111e657600080fd5b505af11580156111fa573d6000803e3d6000fd5b505050506001905061120c565b600090505b9392505050565b42841015611256576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124d90613767565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c11156112bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b390613400565b60405180910390fd5b601b8360ff1614806112d15750601c8360ff16145b611310576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113079061346c565b60405180910390fd5b600061131a610842565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9898989600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061138e9061348c565b919050558a6040516020016113a896959493929190613787565b604051602081830303815290604052805190602001206040516020016113cf929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161140c94939291906135c9565b6020604051602081039080840390855afa15801561142e573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156114a257508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b6114e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d89061365a565b60405180910390fd5b6114ec898989611697565b505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e281565b611548612867565b6000806115dc600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208563ffffffff16815481106115a5576115a4613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122cf565b9150915060405180604001604052808363ffffffff168152602001826bffffffffffffffffffffffff168152509250505092915050565b61161b611d52565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561168b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116829061385a565b60405180910390fd5b61169481612201565b50565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe906138c6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176e90613932565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516118559190612a7d565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156118d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c99061399e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611942576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193990613a0a565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a890613a76565b60405180910390fd5b6119bc838383611dd0565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611a43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a3a90613ae2565b60405180910390fd5b8181611a4f91906131b7565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611ae19190613257565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611b459190612a7d565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051611b859190613ba1565b60405180910390206040518060400160405280600181526020017f3100000000000000000000000000000000000000000000000000000000000000815250805190602001204630604051602001611be0959493929190613bb8565b60405160208183030381529060405280519060200120905090565b6000438210611c3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3690613c57565b60405180910390fd5b60008380549050905060005b81811015611cdf576000611c5f82846122ed565b90506000611cb0878381548110611c7957611c78613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050858163ffffffff161115611cc857819350611cd8565b600182611cd59190613257565b92505b5050611c4b565b60008214611d4557611d4085600184611cf891906131b7565b81548110611d0957611d08613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b611d48565b60005b9250505092915050565b611d5a612323565b73ffffffffffffffffffffffffffffffffffffffff16611d78610ca1565b73ffffffffffffffffffffffffffffffffffffffff1614611dce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dc590613cc3565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e7b57611e0d61232b565b6bffffffffffffffffffffffff1681600454611e299190613257565b1115611e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6190613d2f565b60405180910390fd5b611e78600961233f83612355565b50505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ec157611ebe600961256b83612355565b50505b611edc611ecd84610a5e565b611ed684610a5e565b83612581565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611f68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5f90613d9b565b60405180910390fd5b611f7483600084611dd0565b8181611f8091906131b7565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160046000828254611fd591906131b7565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161203a9190612a7d565b60405180910390a3505050565b600061205283610a5e565b9050600061209e600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461277a565b905082600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a46121a88284836bffffffffffffffffffffffff16612581565b50505050565b600063ffffffff80168211156121f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f090613e2d565b60405180910390fd5b819050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000819050919050565b6000806122db83612313565b91506122e6836122c5565b9050915091565b600060028284186122fe9190613e7c565b82841661230b9190613257565b905092915050565b60008160801b60e01c9050919050565b600033905090565b60006bffffffffffffffffffffffff905090565b6000818361234d9190613257565b905092915050565b600080600085805490509050600081146123c7576123c28660018361237a91906131b7565b8154811061238b5761238a613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b6123ca565b60005b6bffffffffffffffffffffffff1692506123e883858763ffffffff16565b915060008111156124e357600061244e8760018461240691906131b7565b8154811061241757612416613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050438163ffffffff1614156124e1576124708161246b856127d5565b612830565b8760018461247e91906131b7565b8154811061248f5761248e613319565b5b90600052602060002090600291828204019190066010026101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055505050612563565b505b856124fe6124f0436121ae565b6124f9856127d5565b612830565b90806001815401808255809150506001900390600052602060002090600291828204019190066010029091909190916101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505b935093915050565b6000818361257991906131b7565b905092915050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156125bd5750600081115b1561277557600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461269b57600080612644600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061256b85612355565b915091508473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612690929190613ead565b60405180910390a250505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146127745760008061271d600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061233f85612355565b915091508373ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612769929190613ead565b60405180910390a250505b5b505050565b60006bffffffffffffffffffffffff80168211156127cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127c490613f48565b60405180910390fd5b819050919050565b60006bffffffffffffffffffffffff8016821115612828576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281f90613f48565b60405180910390fd5b819050919050565b6000816bffffffffffffffffffffffff1660608463ffffffff166fffffffffffffffffffffffffffffffff16901b17905092915050565b6040518060400160405280600063ffffffff16815260200160006bffffffffffffffffffffffff1681525090565b600081519050919050565b600082825260208201905092915050565b60005b838110156128cf5780820151818401526020810190506128b4565b838111156128de576000848401525b50505050565b6000601f19601f8301169050919050565b600061290082612895565b61290a81856128a0565b935061291a8185602086016128b1565b612923816128e4565b840191505092915050565b6000602082019050818103600083015261294881846128f5565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061298f82612964565b9050919050565b61299f81612984565b81146129aa57600080fd5b50565b6000813590506129bc81612996565b92915050565b6000819050919050565b6129d5816129c2565b81146129e057600080fd5b50565b6000813590506129f2816129cc565b92915050565b60008060408385031215612a0f57612a0e61295a565b5b6000612a1d858286016129ad565b9250506020612a2e858286016129e3565b9150509250929050565b60008115159050919050565b612a4d81612a38565b82525050565b6000602082019050612a686000830184612a44565b92915050565b612a77816129c2565b82525050565b6000602082019050612a926000830184612a6e565b92915050565b600080600060608486031215612ab157612ab061295a565b5b6000612abf868287016129ad565b9350506020612ad0868287016129ad565b9250506040612ae1868287016129e3565b9150509250925092565b6000819050919050565b612afe81612aeb565b82525050565b6000602082019050612b196000830184612af5565b92915050565b600060ff82169050919050565b612b3581612b1f565b82525050565b6000602082019050612b506000830184612b2c565b92915050565b60006bffffffffffffffffffffffff82169050919050565b612b7781612b56565b82525050565b6000602082019050612b926000830184612b6e565b92915050565b600060208284031215612bae57612bad61295a565b5b6000612bbc848285016129e3565b91505092915050565b600060208284031215612bdb57612bda61295a565b5b6000612be9848285016129ad565b91505092915050565b612bfb81612984565b82525050565b6000602082019050612c166000830184612bf2565b92915050565b600063ffffffff82169050919050565b612c3581612c1c565b82525050565b6000602082019050612c506000830184612c2c565b92915050565b612c5f81612b1f565b8114612c6a57600080fd5b50565b600081359050612c7c81612c56565b92915050565b612c8b81612aeb565b8114612c9657600080fd5b50565b600081359050612ca881612c82565b92915050565b60008060008060008060c08789031215612ccb57612cca61295a565b5b6000612cd989828a016129ad565b9650506020612cea89828a016129ad565b9550506040612cfb89828a016129e3565b9450506060612d0c89828a01612c6d565b9350506080612d1d89828a01612c99565b92505060a0612d2e89828a01612c99565b9150509295509295509295565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612d7d826128e4565b810181811067ffffffffffffffff82111715612d9c57612d9b612d45565b5b80604052505050565b6000612daf612950565b9050612dbb8282612d74565b919050565b600067ffffffffffffffff821115612ddb57612dda612d45565b5b612de4826128e4565b9050602081019050919050565b82818337600083830152505050565b6000612e13612e0e84612dc0565b612da5565b905082815260208101848484011115612e2f57612e2e612d40565b5b612e3a848285612df1565b509392505050565b600082601f830112612e5757612e56612d3b565b5b8135612e67848260208601612e00565b91505092915050565b600080600060608486031215612e8957612e8861295a565b5b6000612e97868287016129ad565b9350506020612ea8868287016129e3565b925050604084013567ffffffffffffffff811115612ec957612ec861295f565b5b612ed586828701612e42565b9150509250925092565b600080600080600080600060e0888a031215612efe57612efd61295a565b5b6000612f0c8a828b016129ad565b9750506020612f1d8a828b016129ad565b9650506040612f2e8a828b016129e3565b9550506060612f3f8a828b016129e3565b9450506080612f508a828b01612c6d565b93505060a0612f618a828b01612c99565b92505060c0612f728a828b01612c99565b91505092959891949750929550565b60008060408385031215612f9857612f9761295a565b5b6000612fa6858286016129ad565b9250506020612fb7858286016129ad565b9150509250929050565b612fca81612c1c565b8114612fd557600080fd5b50565b600081359050612fe781612fc1565b92915050565b600080604083850312156130045761300361295a565b5b6000613012858286016129ad565b925050602061302385828601612fd8565b9150509250929050565b61303681612c1c565b82525050565b61304581612b56565b82525050565b604082016000820151613061600085018261302d565b506020820151613074602085018261303c565b50505050565b600060408201905061308f600083018461304b565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806130dc57607f821691505b602082108114156130f0576130ef613095565b5b50919050565b7f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b60006131526021836128a0565b915061315d826130f6565b604082019050919050565b6000602082019050818103600083015261318181613145565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006131c2826129c2565b91506131cd836129c2565b9250828210156131e0576131df613188565b5b828203905092915050565b7f4d696e7420746f20746865207a65726f20616464726573730000000000000000600082015250565b60006132216018836128a0565b915061322c826131eb565b602082019050919050565b6000602082019050818103600083015261325081613214565b9050919050565b6000613262826129c2565b915061326d836129c2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156132a2576132a1613188565b5b828201905092915050565b7f4275726e20616d6f756e74206578636565647320616c6c6f77616e6365000000600082015250565b60006132e3601d836128a0565b91506132ee826132ad565b602082019050919050565b60006020820190508181036000830152613312816132d6565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f44656c65676174696f6e20657870697265640000000000000000000000000000600082015250565b600061337e6012836128a0565b915061338982613348565b602082019050919050565b600060208201905081810360008301526133ad81613371565b9050919050565b7f496e76616c6964207369676e6174757265202773272076616c75650000000000600082015250565b60006133ea601b836128a0565b91506133f5826133b4565b602082019050919050565b60006020820190508181036000830152613419816133dd565b9050919050565b7f496e76616c6964207369676e6174757265202776272076616c75650000000000600082015250565b6000613456601b836128a0565b915061346182613420565b602082019050919050565b6000602082019050818103600083015261348581613449565b9050919050565b6000613497826129c2565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156134ca576134c9613188565b5b600182019050919050565b60006080820190506134ea6000830187612af5565b6134f76020830186612bf2565b6135046040830185612a6e565b6135116060830184612a6e565b95945050505050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b600061355b60028361351a565b915061356682613525565b600282019050919050565b6000819050919050565b61358c61358782612aeb565b613571565b82525050565b600061359d8261354e565b91506135a9828561357b565b6020820191506135b9828461357b565b6020820191508190509392505050565b60006080820190506135de6000830187612af5565b6135eb6020830186612b2c565b6135f86040830185612af5565b6136056060830184612af5565b95945050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b60006136446011836128a0565b915061364f8261360e565b602082019050919050565b6000602082019050818103600083015261367381613637565b9050919050565b600081519050919050565b600082825260208201905092915050565b60006136a18261367a565b6136ab8185613685565b93506136bb8185602086016128b1565b6136c4816128e4565b840191505092915050565b60006080820190506136e46000830187612bf2565b6136f16020830186612a6e565b6136fe6040830185612bf2565b81810360608301526137108184613696565b905095945050505050565b7f5065726d697373696f6e20657870697265640000000000000000000000000000600082015250565b60006137516012836128a0565b915061375c8261371b565b602082019050919050565b6000602082019050818103600083015261378081613744565b9050919050565b600060c08201905061379c6000830189612af5565b6137a96020830188612bf2565b6137b66040830187612bf2565b6137c36060830186612a6e565b6137d06080830185612a6e565b6137dd60a0830184612a6e565b979650505050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006138446026836128a0565b915061384f826137e8565b604082019050919050565b6000602082019050818103600083015261387381613837565b9050919050565b7f417070726f76652066726f6d20746865207a65726f2061646472657373000000600082015250565b60006138b0601d836128a0565b91506138bb8261387a565b602082019050919050565b600060208201905081810360008301526138df816138a3565b9050919050565b7f417070726f766520746f20746865207a65726f20616464726573730000000000600082015250565b600061391c601b836128a0565b9150613927826138e6565b602082019050919050565b6000602082019050818103600083015261394b8161390f565b9050919050565b7f5472616e736665722066726f6d20746865207a65726f20616464726573730000600082015250565b6000613988601e836128a0565b915061399382613952565b602082019050919050565b600060208201905081810360008301526139b78161397b565b9050919050565b7f5472616e7366657220746f20746865207a65726f206164647265737300000000600082015250565b60006139f4601c836128a0565b91506139ff826139be565b602082019050919050565b60006020820190508181036000830152613a23816139e7565b9050919050565b7f5472616e7366657220746f2074686520746f6b656e2061646472657373000000600082015250565b6000613a60601d836128a0565b9150613a6b82613a2a565b602082019050919050565b60006020820190508181036000830152613a8f81613a53565b9050919050565b7f5472616e7366657220616d6f756e7420657863656564732062616c616e636500600082015250565b6000613acc601f836128a0565b9150613ad782613a96565b602082019050919050565b60006020820190508181036000830152613afb81613abf565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154613b2f816130c4565b613b398186613b02565b94506001821660008114613b545760018114613b6557613b98565b60ff19831686528186019350613b98565b613b6e85613b0d565b60005b83811015613b9057815481890152600182019150602081019050613b71565b838801955050505b50505092915050565b6000613bad8284613b22565b915081905092915050565b600060a082019050613bcd6000830188612af5565b613bda6020830187612af5565b613be76040830186612af5565b613bf46060830185612a6e565b613c016080830184612bf2565b9695505050505050565b7f426c6f636b206e6f74207965742064657465726d696e65640000000000000000600082015250565b6000613c416018836128a0565b9150613c4c82613c0b565b602082019050919050565b60006020820190508181036000830152613c7081613c34565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613cad6020836128a0565b9150613cb882613c77565b602082019050919050565b60006020820190508181036000830152613cdc81613ca0565b9050919050565b7f4d6178696d756d20746f74616c20737570706c79206578636565646564000000600082015250565b6000613d19601d836128a0565b9150613d2482613ce3565b602082019050919050565b60006020820190508181036000830152613d4881613d0c565b9050919050565b7f4275726e20616d6f756e7420657863656564732062616c616e63650000000000600082015250565b6000613d85601b836128a0565b9150613d9082613d4f565b602082019050919050565b60006020820190508181036000830152613db481613d78565b9050919050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203360008201527f3220626974730000000000000000000000000000000000000000000000000000602082015250565b6000613e176026836128a0565b9150613e2282613dbb565b604082019050919050565b60006020820190508181036000830152613e4681613e0a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613e87826129c2565b9150613e92836129c2565b925082613ea257613ea1613e4d565b5b828204905092915050565b6000604082019050613ec26000830185612a6e565b613ecf6020830184612a6e565b9392505050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203960008201527f3620626974730000000000000000000000000000000000000000000000000000602082015250565b6000613f326026836128a0565b9150613f3d82613ed6565b604082019050919050565b60006020820190508181036000830152613f6181613f25565b905091905056fea264697066735822122080c4ea65fe927ddc01a672c8707e7276fbf471d1a5c285c9638eb1806c347c3764736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "approve(address,uint256)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729", + "returns": { + "_0": "True if the operation succeeded." + } + }, + "approveAndCall(address,uint256,bytes)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.", + "returns": { + "_0": "True if both approval and `receiveApproval` calls succeeded." + } + }, + "burn(uint256)": { + "details": "Requirements: - the caller must have a balance of at least `amount`." + }, + "burnFrom(address,uint256)": { + "details": "Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`." + }, + "delegate(address)": { + "params": { + "delegatee": "The address to delegate votes to" + } + }, + "delegateBySig(address,address,uint256,uint8,bytes32,bytes32)": { + "params": { + "deadline": "The time at which to expire the signature", + "delegatee": "The address to delegate votes to", + "r": "Half of the ECDSA signature pair", + "s": "Half of the ECDSA signature pair", + "v": "The recovery byte of the signature" + } + }, + "getPastTotalSupply(uint256)": { + "details": "`blockNumber` must have been already mined", + "params": { + "blockNumber": "The block number to get the total supply at" + } + }, + "getPastVotes(address,uint256)": { + "details": "Block number must be a finalized block or else this function will revert to prevent misinformation.", + "params": { + "account": "The address of the account to check", + "blockNumber": "The block number to get the vote balance at" + }, + "returns": { + "_0": "The number of votes the account had as of the given block" + } + }, + "getVotes(address)": { + "params": { + "account": "The address to get votes balance" + }, + "returns": { + "_0": "The number of current votes for `account`" + } + }, + "mint(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "details": "The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transfer(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferFrom(address,address,uint256)": { + "details": "Requirements: - `spender` and `recipient` cannot be the zero address, - `spender` must have a balance of at least `amount`, - the caller must have allowance for `spender`'s tokens of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "UnderwriterToken", + "version": 1 + }, + "userdoc": { + "events": { + "DelegateChanged(address,address,address)": { + "notice": "Emitted when an account changes their delegate." + }, + "DelegateVotesChanged(address,uint256,uint256)": { + "notice": "Emitted when a balance or delegate change results in changes to an account's voting power." + } + }, + "kind": "user", + "methods": { + "DELEGATION_TYPEHASH()": { + "notice": "The EIP-712 typehash for the delegation struct used by `delegateBySig`." + }, + "DOMAIN_SEPARATOR()": { + "notice": "Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function." + }, + "PERMIT_TYPEHASH()": { + "notice": "Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function." + }, + "allowance(address,address)": { + "notice": "The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default." + }, + "approve(address,uint256)": { + "notice": "Sets `amount` as the allowance of `spender` over the caller's tokens." + }, + "approveAndCall(address,uint256,bytes)": { + "notice": "Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted." + }, + "balanceOf(address)": { + "notice": "The amount of tokens owned by the given account." + }, + "burn(uint256)": { + "notice": "Destroys `amount` tokens from the caller." + }, + "burnFrom(address,uint256)": { + "notice": "Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + }, + "decimals()": { + "notice": "The decimals places of the token." + }, + "delegate(address)": { + "notice": "Delegate votes from `msg.sender` to `delegatee`." + }, + "delegateBySig(address,address,uint256,uint8,bytes32,bytes32)": { + "notice": "Delegates votes from signatory to `delegatee`" + }, + "delegates(address)": { + "notice": "Get the address `account` is currently delegating to." + }, + "getPastTotalSupply(uint256)": { + "notice": "Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances, but it is NOT the sum of all the delegated votes!" + }, + "getPastVotes(address,uint256)": { + "notice": "Determine the prior number of votes for an account as of a block number." + }, + "getVotes(address)": { + "notice": "Gets the current votes balance for `account`." + }, + "mint(address,uint256)": { + "notice": "Creates `amount` tokens and assigns them to `account`, increasing the total supply." + }, + "name()": { + "notice": "The name of the token." + }, + "nonce(address)": { + "notice": "Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function." + }, + "numCheckpoints(address)": { + "notice": "Get number of checkpoints for `account`." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "notice": "EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction." + }, + "symbol()": { + "notice": "The symbol of the token." + }, + "totalSupply()": { + "notice": "The amount of tokens in existence." + }, + "transfer(address,uint256)": { + "notice": "Moves `amount` tokens from the caller's account to `recipient`." + }, + "transferFrom(address,address,uint256)": { + "notice": "Moves `amount` tokens from `spender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + } + }, + "notice": "Underwriter tokens represent an ownership share in the underlying collateral of the asset-specific pool. Underwriter tokens are minted when a user deposits ERC20 tokens into asset-specific pool and they are burned when a user exits the position. Underwriter tokens natively support meta transactions. Users can authorize a transfer of their underwriter tokens with a signature conforming EIP712 standard instead of an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, as specified in EIP2612 standard, paying gas fees, and possibly performing other actions in the same transaction.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 3955, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "balanceOf", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 3963, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "allowance", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 3969, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "nonce", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 3984, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "totalSupply", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 3988, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "name", + "offset": 0, + "slot": "5", + "type": "t_string_storage" + }, + { + "astId": 3992, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "symbol", + "offset": 0, + "slot": "6", + "type": "t_string_storage" + }, + { + "astId": 4788, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_delegates", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 4793, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_checkpoints", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_array(t_uint128)dyn_storage)" + }, + { + "astId": 4796, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_totalSupplyCheckpoints", + "offset": 0, + "slot": "9", + "type": "t_array(t_uint128)dyn_storage" + }, + { + "astId": 4800, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "__gap", + "offset": 0, + "slot": "10", + "type": "t_array(t_uint256)47_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint128)dyn_storage": { + "base": "t_uint128", + "encoding": "dynamic_array", + "label": "uint128[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)47_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_array(t_uint128)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint128[])", + "numberOfBytes": "32", + "value": "t_array(t_uint128)dyn_storage" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint128": { + "encoding": "inplace", + "label": "uint128", + "numberOfBytes": "16" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/artifacts/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json b/artifacts/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json new file mode 100644 index 00000000..8c3edbba --- /dev/null +++ b/artifacts/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json @@ -0,0 +1,198 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.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 /**\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 / b + (a % b == 0 ? 0 : 1);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@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" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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 Context {\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" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.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 IERC165 {\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" + }, + "@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 // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `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" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/clone/CloneFactory.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.5;\n\n/*\nThe MIT License (MIT)\nCopyright (c) 2018 Murray Software, LLC.\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n/// @notice Implementation of [EIP-1167] based on [clone-factory]\n/// source code.\n///\n/// EIP 1167: https://eips.ethereum.org/EIPS/eip-1167\n// Original implementation: https://github.com/optionality/clone-factory\n// Modified to use ^0.8.5; instead of ^0.4.23 solidity version.\n/* solhint-disable no-inline-assembly */\nabstract contract CloneFactory {\n /// @notice Creates EIP-1167 clone of the contract under the provided\n /// `target` address. Returns address of the created clone.\n /// @dev In specific circumstances, such as the `target` contract destroyed,\n /// create opcode may return 0x0 address. The code calling this\n /// function should handle this corner case properly.\n function createClone(address target) internal returns (address result) {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000\n )\n mstore(add(clone, 0x14), targetBytes)\n mstore(\n add(clone, 0x28),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n result := create(0, clone, 0x37)\n }\n }\n\n /// @notice Checks if the contract under the `query` address is a EIP-1167\n /// clone of the contract under `target` address.\n function isClone(address target, address query)\n internal\n view\n returns (bool result)\n {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000\n )\n mstore(add(clone, 0xa), targetBytes)\n mstore(\n add(clone, 0x1e),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n\n let other := add(clone, 0x40)\n extcodecopy(query, other, 0, 0x2d)\n result := and(\n eq(mload(clone), mload(other)),\n eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))\n )\n }\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport \"./IERC20WithPermit.sol\";\nimport \"./IReceiveApproval.sol\";\n\n/// @title ERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\n /// @notice The amount of tokens owned by the given account.\n mapping(address => uint256) public override balanceOf;\n\n /// @notice The remaining number of tokens that spender will be\n /// allowed to spend on behalf of owner through `transferFrom` and\n /// `burnFrom`. This is zero by default.\n mapping(address => mapping(address => uint256)) public override allowance;\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n mapping(address => uint256) public override nonce;\n\n uint256 public immutable cachedChainId;\n bytes32 public immutable cachedDomainSeparator;\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n bytes32 public constant override PERMIT_TYPEHASH =\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n /// @notice The amount of tokens in existence.\n uint256 public override totalSupply;\n\n /// @notice The name of the token.\n string public override name;\n\n /// @notice The symbol of the token.\n string public override symbol;\n\n /// @notice The decimals places of the token.\n uint8 public constant override decimals = 18;\n\n constructor(string memory _name, string memory _symbol) {\n name = _name;\n symbol = _symbol;\n\n cachedChainId = block.chainid;\n cachedDomainSeparator = buildDomainSeparator();\n }\n\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address,\n /// - the caller must have a balance of at least `amount`.\n function transfer(address recipient, uint256 amount)\n external\n override\n returns (bool)\n {\n _transfer(msg.sender, recipient, amount);\n return true;\n }\n\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\n /// allowance mechanism. `amount` is then deducted from the caller's\n /// allowance unless the allowance was made for `type(uint256).max`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `spender` and `recipient` cannot be the zero address,\n /// - `spender` must have a balance of at least `amount`,\n /// - the caller must have allowance for `spender`'s tokens of at least\n /// `amount`.\n function transferFrom(\n address spender,\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n uint256 currentAllowance = allowance[spender][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Transfer amount exceeds allowance\"\n );\n _approve(spender, msg.sender, currentAllowance - amount);\n }\n _transfer(spender, recipient, amount);\n return true;\n }\n\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire. If the `amount` is set\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\n /// not reduce an allowance.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Permission expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n PERMIT_TYPEHASH,\n owner,\n spender,\n amount,\n nonce[owner]++,\n deadline\n )\n )\n )\n );\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == owner,\n \"Invalid signature\"\n );\n _approve(owner, spender, amount);\n }\n\n /// @notice Creates `amount` tokens and assigns them to `account`,\n /// increasing the total supply.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address.\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(recipient != address(0), \"Mint to the zero address\");\n\n beforeTokenTransfer(address(0), recipient, amount);\n\n totalSupply += amount;\n balanceOf[recipient] += amount;\n emit Transfer(address(0), recipient, amount);\n }\n\n /// @notice Destroys `amount` tokens from the caller.\n /// @dev Requirements:\n /// - the caller must have a balance of at least `amount`.\n function burn(uint256 amount) external override {\n _burn(msg.sender, amount);\n }\n\n /// @notice Destroys `amount` of tokens from `account` using the allowance\n /// mechanism. `amount` is then deducted from the caller's allowance\n /// unless the allowance was made for `type(uint256).max`.\n /// @dev Requirements:\n /// - `account` must have a balance of at least `amount`,\n /// - the caller must have allowance for `account`'s tokens of at least\n /// `amount`.\n function burnFrom(address account, uint256 amount) external override {\n uint256 currentAllowance = allowance[account][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Burn amount exceeds allowance\"\n );\n _approve(account, msg.sender, currentAllowance - amount);\n }\n _burn(account, amount);\n }\n\n /// @notice Calls `receiveApproval` function on spender previously approving\n /// the spender to withdraw from the caller multiple times, up to\n /// the `amount` amount. If this function is called again, it\n /// overwrites the current allowance with `amount`. Reverts if the\n /// approval reverted or if `receiveApproval` call on the spender\n /// reverted.\n /// @return True if both approval and `receiveApproval` calls succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external override returns (bool) {\n if (approve(spender, amount)) {\n IReceiveApproval(spender).receiveApproval(\n msg.sender,\n amount,\n address(this),\n extraData\n );\n return true;\n }\n return false;\n }\n\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\n /// tokens.\n /// @return True if the operation succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n /// Beware that changing an allowance with this method brings the risk\n /// that someone may use both the old and the new allowance by\n /// unfortunate transaction ordering. One possible solution to mitigate\n /// this race condition is to first reduce the spender's allowance to 0\n /// and set the desired value afterwards:\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n function approve(address spender, uint256 amount)\n public\n override\n returns (bool)\n {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\n // chainId and is defined at contract deployment instead of\n // reconstructed for every signature, there is a risk of possible replay\n // attacks between chains in the event of a future chain split.\n // To address this issue, we check the cached chain ID against the\n // current one and in case they are different, we build domain separator\n // from scratch.\n if (block.chainid == cachedChainId) {\n return cachedDomainSeparator;\n } else {\n return buildDomainSeparator();\n }\n }\n\n /// @dev Hook that is called before any transfer of tokens. This includes\n /// minting and burning.\n ///\n /// Calling conditions:\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\n /// will be to transferred to `to`.\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n /// - `from` and `to` are never both zero.\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _burn(address account, uint256 amount) internal {\n uint256 currentBalance = balanceOf[account];\n require(currentBalance >= amount, \"Burn amount exceeds balance\");\n\n beforeTokenTransfer(account, address(0), amount);\n\n balanceOf[account] = currentBalance - amount;\n totalSupply -= amount;\n emit Transfer(account, address(0), amount);\n }\n\n function _transfer(\n address spender,\n address recipient,\n uint256 amount\n ) private {\n require(spender != address(0), \"Transfer from the zero address\");\n require(recipient != address(0), \"Transfer to the zero address\");\n require(recipient != address(this), \"Transfer to the token address\");\n\n beforeTokenTransfer(spender, recipient, amount);\n\n uint256 spenderBalance = balanceOf[spender];\n require(spenderBalance >= amount, \"Transfer amount exceeds balance\");\n balanceOf[spender] = spenderBalance - amount;\n balanceOf[recipient] += amount;\n emit Transfer(spender, recipient, amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) private {\n require(owner != address(0), \"Approve from the zero address\");\n require(spender != address(0), \"Approve to the zero address\");\n allowance[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function buildDomainSeparator() private view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n ),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n block.chainid,\n address(this)\n )\n );\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by tokens supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IApproveAndCall {\n /// @notice Executes `receiveApproval` function on spender as specified in\n /// `IReceiveApproval` interface. Approves spender to withdraw from\n /// the caller multiple times, up to the `amount`. If this\n /// function is called again, it overwrites the current allowance\n /// with `amount`. Reverts if the approval reverted or if\n /// `receiveApproval` call on the spender reverted.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external returns (bool);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"./IApproveAndCall.sol\";\n\n/// @title IERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /// @notice Destroys `amount` tokens from the caller.\n function burn(uint256 amount) external;\n\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\n /// from caller's allowance.\n function burnFrom(address account, uint256 amount) external;\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n function nonce(address owner) external view returns (uint256);\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n /* solhint-disable-next-line func-name-mixedcase */\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by contracts supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IReceiveApproval {\n /// @notice Receives approval to spend tokens. Called as a result of\n /// `approveAndCall` call on the token.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external;\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title MisfundRecovery\n/// @notice Allows the owner of the token contract extending MisfundRecovery\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\n/// contract address.\ncontract MisfundRecovery is Ownable {\n using SafeERC20 for IERC20;\n\n function recoverERC20(\n IERC20 token,\n address recipient,\n uint256 amount\n ) external onlyOwner {\n token.safeTransfer(recipient, amount);\n }\n\n function recoverERC721(\n IERC721 token,\n address recipient,\n uint256 tokenId,\n bytes calldata data\n ) external onlyOwner {\n token.safeTransferFrom(address(this), recipient, tokenId, data);\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"./IVotesHistory.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\";\n\n/// @title Checkpoints\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\n/// delegation. This implementation supports token supply up to 2^96 - 1.\n/// This contract keeps a history (checkpoints) of each account's vote\n/// power. Vote power can be delegated either by calling the {delegate}\n/// function directly, or by providing a signature to be used with\n/// {delegateBySig}. Voting power can be publicly queried through\n/// {getVotes} and {getPastVotes}.\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\n/// @dev This contract is upgrade-safe.\nabstract contract Checkpoints is IVotesHistory {\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n // slither-disable-next-line uninitialized-state\n mapping(address => address) internal _delegates;\n mapping(address => uint128[]) internal _checkpoints;\n uint128[] internal _totalSupplyCheckpoints;\n\n // Reserved storage space in case we need to add more variables,\n // since there are upgradeable contracts that inherit from this one.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[47] private __gap;\n\n /// @notice Emitted when an account changes their delegate.\n event DelegateChanged(\n address indexed delegator,\n address indexed fromDelegate,\n address indexed toDelegate\n );\n\n /// @notice Emitted when a balance or delegate change results in changes\n /// to an account's voting power.\n event DelegateVotesChanged(\n address indexed delegate,\n uint256 previousBalance,\n uint256 newBalance\n );\n\n function checkpoints(address account, uint32 pos)\n public\n view\n virtual\n returns (Checkpoint memory checkpoint)\n {\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\n _checkpoints[account][pos]\n );\n checkpoint = Checkpoint(fromBlock, votes);\n }\n\n /// @notice Get number of checkpoints for `account`.\n function numCheckpoints(address account)\n public\n view\n virtual\n returns (uint32)\n {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /// @notice Get the address `account` is currently delegating to.\n function delegates(address account) public view virtual returns (address) {\n return _delegates[account];\n }\n\n /// @notice Gets the current votes balance for `account`.\n /// @param account The address to get votes balance\n /// @return The number of current votes for `account`\n function getVotes(address account) public view returns (uint96) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\n }\n\n /// @notice Determine the prior number of votes for an account as of\n /// a block number.\n /// @dev Block number must be a finalized block or else this function will\n /// revert to prevent misinformation.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_checkpoints[account], blockNumber);\n }\n\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\n /// Note, this value is the sum of all balances, but it is NOT the\n /// sum of all the delegated votes!\n /// @param blockNumber The block number to get the total supply at\n /// @dev `blockNumber` must have been already mined\n function getPastTotalSupply(uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\n }\n\n /// @notice Change delegation for `delegator` to `delegatee`.\n // slither-disable-next-line dead-code\n function delegate(address delegator, address delegatee) internal virtual;\n\n /// @notice Moves voting power from one delegate to another\n /// @param src Address of old delegate\n /// @param dst Address of new delegate\n /// @param amount Voting power amount to transfer between delegates\n function moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) internal {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n // https://github.com/crytic/slither/issues/960\n // slither-disable-next-line variable-scope\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[src],\n subtract,\n amount\n );\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n // https://github.com/crytic/slither/issues/959\n // slither-disable-next-line uninitialized-local\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[dst],\n add,\n amount\n );\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n /// @notice Writes a new checkpoint based on operating last stored value\n /// with a `delta`. Usually, said operation is the `add` or\n /// `subtract` functions from this contract, but more complex\n /// functions can be passed as parameters.\n /// @param ckpts The checkpoints array to use\n /// @param op The function to apply over the last value and the `delta`\n /// @param delta Variation with respect to last stored value to be used\n /// for new checkpoint\n function writeCheckpoint(\n uint128[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\n newWeight = op(oldWeight, delta);\n\n if (pos > 0) {\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\n // slither-disable-next-line incorrect-equality\n if (fromBlock == block.number) {\n ckpts[pos - 1] = encodeCheckpoint(\n fromBlock,\n SafeCastUpgradeable.toUint96(newWeight)\n );\n return (oldWeight, newWeight);\n }\n }\n\n ckpts.push(\n encodeCheckpoint(\n SafeCastUpgradeable.toUint32(block.number),\n SafeCastUpgradeable.toUint96(newWeight)\n )\n );\n }\n\n /// @notice Lookup a value in a list of (sorted) checkpoints.\n /// @param ckpts The checkpoints array to use\n /// @param blockNumber Block number when we want to get the checkpoint at\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\n internal\n view\n returns (uint96)\n {\n // We run a binary search to look for the earliest checkpoint taken\n // after `blockNumber`. During the loop, the index of the wanted\n // checkpoint remains in the range [low-1, high). With each iteration,\n // either `low` or `high` is moved towards the middle of the range to\n // maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`,\n // we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`,\n // we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the\n // right checkpoint at the index high-1, if not out of bounds (in that\n // case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for\n // `blockNumber`, we end up with an index that is past the end of the\n // array, so we technically don't find a checkpoint after\n // `blockNumber`, but it works out the same.\n require(blockNumber < block.number, \"Block not yet determined\");\n\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\n if (midBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\n }\n\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\n // slither-disable-next-line dead-code\n function maxSupply() internal view virtual returns (uint96) {\n return type(uint96).max;\n }\n\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\n /// checkpoint.\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\n /// remaining 96 bits.\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\n internal\n pure\n returns (uint128)\n {\n return (uint128(blockNumber) << 96) | uint128(value);\n }\n\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\n function decodeBlockNumber(uint128 checkpoint)\n internal\n pure\n returns (uint32)\n {\n return uint32(bytes4(bytes16(checkpoint)));\n }\n\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\n return uint96(checkpoint);\n }\n\n /// @notice Decodes a block number and voting value from a `uint128`\n /// `checkpoint`.\n function decodeCheckpoint(uint128 checkpoint)\n internal\n pure\n returns (uint32 blockNumber, uint96 value)\n {\n blockNumber = decodeBlockNumber(checkpoint);\n value = decodeValue(checkpoint);\n }\n\n // slither-disable-next-line dead-code\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n // slither-disable-next-line dead-code\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\ninterface IVotesHistory {\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n\n function getPastTotalSupply(uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"../governance/Checkpoints.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\";\n\n/// @title T token\n/// @notice Threshold Network T token\n/// @dev By default, token balance does not account for voting power.\n/// This makes transfers cheaper. The downside is that it requires users\n/// to delegate to themselves to activate checkpoints and have their\n/// voting power tracked.\ncontract T is ERC20WithPermit, MisfundRecovery, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor() ERC20WithPermit(\"Threshold Network Token\", \"T\") {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n uint96 safeAmount = SafeCast.toUint96(amount);\n\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, safeAmount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, safeAmount);\n }\n\n moveVotingPower(delegates(from), delegates(to), safeAmount);\n }\n\n function delegate(address delegator, address delegatee)\n internal\n virtual\n override\n {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/AssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPool.sol\";\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./RewardsPool.sol\";\nimport \"./UnderwriterToken.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Asset Pool\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\n/// accepts a single ERC20 token as collateral, and returns an\n/// underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\n/// as a deposit. It means that the total supply of the collateral token\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\n/// acceptable that not all tokens can be deposited into the pool.\ncontract AssetPool is Ownable, IAssetPool {\n using SafeERC20 for ICollateralToken;\n using SafeERC20 for UnderwriterToken;\n\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n RewardsPool public immutable rewardsPool;\n\n IAssetPoolUpgrade public newAssetPool;\n\n /// @notice The time it takes the underwriter to withdraw their collateral\n /// and rewards from the pool. This is the time that needs to pass\n /// between initiating and completing the withdrawal. During that\n /// time, underwriter is still earning rewards and their share of\n /// the pool is still a subject of a possible coverage claim.\n uint256 public withdrawalDelay = 21 days;\n uint256 public newWithdrawalDelay;\n uint256 public withdrawalDelayChangeInitiated;\n\n /// @notice The time the underwriter has after the withdrawal delay passed\n /// to complete the withdrawal. During that time, underwriter is\n /// still earning rewards and their share of the pool is still\n /// a subject of a possible coverage claim.\n /// After the withdrawal timeout elapses, tokens stay in the pool\n /// and the underwriter has to initiate the withdrawal again and\n /// wait for the full withdrawal delay to complete the withdrawal.\n uint256 public withdrawalTimeout = 2 days;\n uint256 public newWithdrawalTimeout;\n uint256 public withdrawalTimeoutChangeInitiated;\n\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\n mapping(address => uint256) public pendingWithdrawal;\n\n event Deposited(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount\n );\n\n event CoverageClaimed(\n address indexed recipient,\n uint256 amount,\n uint256 timestamp\n );\n\n event WithdrawalInitiated(\n address indexed underwriter,\n uint256 covAmount,\n uint256 timestamp\n );\n event WithdrawalCompleted(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event ApprovedAssetPoolUpgrade(address newAssetPool);\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\n event AssetPoolUpgraded(\n address indexed underwriter,\n uint256 collateralAmount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event WithdrawalDelayUpdateStarted(\n uint256 withdrawalDelay,\n uint256 timestamp\n );\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\n event WithdrawalTimeoutUpdateStarted(\n uint256 withdrawalTimeout,\n uint256 timestamp\n );\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\n\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\n /// if the change was not yet initiated.\n /// @param changeInitiatedTimestamp The timestamp at which the change has\n /// been initiated\n modifier onlyAfterWithdrawalGovernanceDelay(\n uint256 changeInitiatedTimestamp\n ) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >=\n withdrawalGovernanceDelay(),\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n constructor(\n ICollateralToken _collateralToken,\n UnderwriterToken _underwriterToken,\n address rewardsManager\n ) {\n collateralToken = _collateralToken;\n underwriterToken = _underwriterToken;\n\n rewardsPool = new RewardsPool(\n _collateralToken,\n address(this),\n rewardsManager\n );\n\n initGovernance(_collateralToken);\n }\n\n /// @dev Overwrite to empty if collateral token used by the AssetPool\n /// does not support DAO checkpoints. Used for tests with KEEP token.\n function initGovernance(ICollateralToken _collateralToken)\n internal\n virtual\n {\n _collateralToken.delegate(address(this));\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// Optional data in extraData may include a minimal amount of\n /// underwriter tokens expected to be minted for a depositor. There\n /// are cases when an amount of minted tokens matters for a\n /// depositor, as tokens might be used in third party exchanges.\n /// @dev This function is a shortcut for approve + deposit.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external {\n require(\n amount + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n require(msg.sender == token, \"Only token caller allowed\");\n require(\n token == address(collateralToken),\n \"Unsupported collateral token\"\n );\n\n uint256 toMint = _calculateTokensToMint(amount);\n if (extraData.length != 0) {\n require(extraData.length == 32, \"Unexpected data length\");\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n }\n\n _deposit(from, amount, toMint);\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal to\n /// 2^96-1\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amountToDeposit)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership. The amount locked in the pool after accepting\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\n /// function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal\n /// to 2^96-1\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\n /// expects to receive in exchange for the deposited\n /// collateral tokens\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Initiates the withdrawal of collateral and rewards from the\n /// pool. Must be followed with completeWithdrawal call after the\n /// withdrawal delay passes. Accepts the amount of underwriter\n /// tokens representing the share of the pool that should be\n /// withdrawn. Can be called multiple times increasing the pool share\n /// to withdraw and resetting the withdrawal initiated timestamp for\n /// each call. Can be called with 0 covAmount to reset the\n /// withdrawal initiated timestamp if the underwriter has a pending\n /// withdrawal. In practice 0 covAmount should be used only to\n /// initiate the withdrawal again in case one did not complete the\n /// withdrawal before the withdrawal timeout elapsed.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external override {\n uint256 pending = pendingWithdrawal[msg.sender];\n require(\n covAmount > 0 || pending > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n pending += covAmount;\n pendingWithdrawal[msg.sender] = pending;\n /* solhint-disable not-rely-on-time */\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\n\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\n /* solhint-enable not-rely-on-time */\n\n if (covAmount > 0) {\n underwriterToken.safeTransferFrom(\n msg.sender,\n address(this),\n covAmount\n );\n }\n }\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter. Anyone can complete the withdrawal for the\n /// underwriter. The withdrawal has to be completed before the\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\n /// be initiated again and the underwriter has to wait for the\n /// entire withdrawal delay again before being able to complete\n /// the withdrawal.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter)\n external\n override\n returns (uint256)\n {\n /* solhint-disable not-rely-on-time */\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\n require(initiatedAt > 0, \"No withdrawal initiated for the underwriter\");\n\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\n require(\n withdrawalDelayEndTimestamp < block.timestamp,\n \"Withdrawal delay has not elapsed\"\n );\n\n require(\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\n \"Withdrawal timeout elapsed\"\n );\n\n uint256 covAmount = pendingWithdrawal[underwriter];\n uint256 covSupply = underwriterToken.totalSupply();\n delete withdrawalInitiatedTimestamp[underwriter];\n delete pendingWithdrawal[underwriter];\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\n\n emit WithdrawalCompleted(\n underwriter,\n amountToWithdraw,\n covAmount,\n block.timestamp\n );\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\n\n /* solhint-enable not-rely-on-time */\n underwriterToken.burn(covAmount);\n\n return amountToWithdraw;\n }\n\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\n /// was approved by the governance. Upgrade does not have to obey\n /// withdrawal delay.\n /// Old underwriter tokens are burned in favor of new tokens minted\n /// in a new Asset Pool. New tokens are sent directly to the\n /// underwriter from a new Asset Pool.\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\n /// tokens which are transferred to a new asset pool\n /// @param _newAssetPool New Asset Pool address to check validity with the one\n /// that was approved by the governance\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\n external\n {\n /* solhint-disable not-rely-on-time */\n require(\n address(newAssetPool) != address(0),\n \"New asset pool must be assigned\"\n );\n\n require(\n address(newAssetPool) == _newAssetPool,\n \"Addresses of a new asset pool must match\"\n );\n\n require(\n covAmount > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n uint256 covSupply = underwriterToken.totalSupply();\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\n covSupply;\n\n collateralToken.safeApprove(\n address(newAssetPool),\n collateralToTransfer\n );\n // old underwriter tokens are burned in favor of new minted in a new\n // asset pool\n underwriterToken.burnFrom(msg.sender, covAmount);\n // collateralToTransfer will be sent to a new AssetPool and new\n // underwriter tokens will be minted and transferred back to the underwriter\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\n\n emit AssetPoolUpgraded(\n msg.sender,\n collateralToTransfer,\n covAmount,\n block.timestamp\n );\n }\n\n /// @notice Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n require(\n address(_newAssetPool) != address(0),\n \"New asset pool can't be zero address\"\n );\n\n newAssetPool = _newAssetPool;\n\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\n }\n\n /// @notice Allows governance to cancel already approved new asset pool\n /// in case of some misconfiguration.\n function cancelNewAssetPoolUpgrade() external onlyOwner {\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\n\n newAssetPool = IAssetPoolUpgrade(address(0));\n }\n\n /// @notice Allows the coverage pool to demand coverage from the asset hold\n /// by this pool and send it to the provided recipient address.\n function claim(address recipient, uint256 amount) external onlyOwner {\n emit CoverageClaimed(recipient, amount, block.timestamp);\n rewardsPool.withdraw();\n require(\n amount <= collateralToken.balanceOf(address(this)),\n \"Amount to seize exceeds the pool balance\"\n );\n collateralToken.safeTransfer(recipient, amount);\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param _newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\n external\n onlyOwner\n {\n newWithdrawalDelay = _newWithdrawalDelay;\n withdrawalDelayChangeInitiated = block.timestamp;\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\n {\n withdrawalDelay = newWithdrawalDelay;\n emit WithdrawalDelayUpdated(withdrawalDelay);\n newWithdrawalDelay = 0;\n withdrawalDelayChangeInitiated = 0;\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\n external\n onlyOwner\n {\n newWithdrawalTimeout = _newWithdrawalTimeout;\n withdrawalTimeoutChangeInitiated = block.timestamp;\n emit WithdrawalTimeoutUpdateStarted(\n _newWithdrawalTimeout,\n block.timestamp\n );\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\n {\n withdrawalTimeout = newWithdrawalTimeout;\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\n newWithdrawalTimeout = 0;\n withdrawalTimeoutChangeInitiated = 0;\n }\n\n /// @notice Grants pool shares by minting a given amount of the underwriter\n /// tokens for the recipient address. In result, the recipient\n /// obtains part of the pool ownership without depositing any\n /// collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by the contract owner.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantShares(address recipient, uint256 covAmount)\n external\n onlyOwner\n {\n rewardsPool.withdraw();\n underwriterToken.mint(recipient, covAmount);\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal delay update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal delay update can be finalized\n function getRemainingWithdrawalDelayUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalDelayChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal timeout update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal timeout update can be finalized\n function getRemainingWithdrawalTimeoutUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalTimeoutChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the current collateral token balance of the asset pool\n /// plus the reward amount (in collateral token) earned by the asset\n /// pool and not yet withdrawn to the asset pool.\n /// @return The total value of asset pool in collateral token.\n function totalValue() public view returns (uint256) {\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\n }\n\n /// @notice The time it takes to initiate and complete the withdrawal from\n /// the pool plus 2 days to make a decision. This governance delay\n /// should be used for all changes directly affecting underwriter\n /// positions. This time is a minimum and the governance may choose\n /// to wait longer before finalizing the update.\n /// @return The withdrawal governance delay in seconds\n function withdrawalGovernanceDelay() public view returns (uint256) {\n return withdrawalDelay + withdrawalTimeout + 2 days;\n }\n\n /// @dev Calculates underwriter tokens to mint.\n function _calculateTokensToMint(uint256 amountToDeposit)\n internal\n returns (uint256)\n {\n rewardsPool.withdraw();\n\n uint256 covSupply = underwriterToken.totalSupply();\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n if (covSupply == 0) {\n return amountToDeposit;\n }\n\n return (amountToDeposit * covSupply) / collateralBalance;\n }\n\n function _deposit(\n address depositor,\n uint256 amountToDeposit,\n uint256 amountToMint\n ) internal {\n require(depositor != address(this), \"Self-deposit not allowed\");\n\n require(\n amountToMint > 0,\n \"Minted tokens amount must be greater than 0\"\n );\n\n emit Deposited(depositor, amountToDeposit, amountToMint);\n\n underwriterToken.mint(depositor, amountToMint);\n collateralToken.safeTransferFrom(\n depositor,\n address(this),\n amountToDeposit\n );\n }\n}\n" + }, + "contracts/Auction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAuction.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title Auction\n/// @notice A contract to run a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\n/// pool. Auctions can be partially filled, and are meant to be amenable\n/// to flash loans and other atomic constructions to take advantage of\n/// arbitrage opportunities within a single block.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// Auction contracts are not meant to be deployed directly, and are\n/// instead cloned by an auction factory. Auction contracts clean up and\n/// self-destruct on close. An auction that has run the entire length will\n/// stay open, forever, or until priced fluctuate and it's eventually\n/// profitable to close.\ncontract Auction is IAuction {\n using SafeERC20 for IERC20;\n\n struct AuctionStorage {\n IERC20 tokenAccepted;\n Auctioneer auctioneer;\n // the auction price, denominated in tokenAccepted\n uint256 amountOutstanding;\n uint256 amountDesired;\n uint256 startTime;\n uint256 startTimeOffset;\n uint256 auctionLength;\n }\n\n AuctionStorage public self;\n address public immutable masterContract;\n\n /// @notice Throws if called by any account other than the auctioneer.\n modifier onlyAuctioneer() {\n //slither-disable-next-line incorrect-equality\n require(\n msg.sender == address(self.auctioneer),\n \"Caller is not the auctioneer\"\n );\n\n _;\n }\n\n constructor() {\n masterContract = address(this);\n }\n\n /// @notice Initializes auction\n /// @dev At the beginning of an auction, velocity pool depleting rate is\n /// always 1. It increases over time after a partial auction buy.\n /// @param _auctioneer the auctioneer contract responsible for seizing\n /// funds from the backing collateral pool\n /// @param _tokenAccepted the token with which the auction can be taken\n /// @param _amountDesired the amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param _auctionLength the amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function initialize(\n Auctioneer _auctioneer,\n IERC20 _tokenAccepted,\n uint256 _amountDesired,\n uint256 _auctionLength\n ) external {\n require(!isMasterContract(), \"Can not initialize master contract\");\n //slither-disable-next-line incorrect-equality\n require(self.startTime == 0, \"Auction already initialized\");\n require(_amountDesired > 0, \"Amount desired must be greater than zero\");\n require(_auctionLength > 0, \"Auction length must be greater than zero\");\n self.auctioneer = _auctioneer;\n self.tokenAccepted = _tokenAccepted;\n self.amountOutstanding = _amountDesired;\n self.amountDesired = _amountDesired;\n /* solhint-disable-next-line not-rely-on-time */\n self.startTime = block.timestamp;\n self.startTimeOffset = 0;\n self.auctionLength = _auctionLength;\n }\n\n /// @notice Takes an offer from an auction buyer.\n /// @dev There are two possible ways to take an offer from a buyer. The first\n /// one is to buy entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// WARNING: When calling this function directly, it might happen that\n /// the expected amount of tokens to seize from the coverage pool is\n /// different from the actual one. There are a couple of reasons for that\n /// such another bids taking this offer, claims or withdrawals on an\n /// Asset Pool that are executed in the same block. The recommended way\n /// for taking an offer is through 'AuctionBidder' contract with\n /// 'takeOfferWithMin' function, where a caller can specify the minimal\n /// value to receive from the coverage pool in exchange for its amount\n /// of tokenAccepted.\n /// @param amount the amount the taker is paying, denominated in tokenAccepted.\n /// In the scenario when amount exceeds the outstanding tokens\n /// for the auction to complete, only the amount outstanding will\n /// be taken from a caller.\n function takeOffer(uint256 amount) external override {\n require(amount > 0, \"Can't pay 0 tokens\");\n uint256 amountToTransfer = Math.min(amount, self.amountOutstanding);\n uint256 amountOnOffer = _onOffer();\n\n //slither-disable-next-line reentrancy-no-eth\n self.tokenAccepted.safeTransferFrom(\n msg.sender,\n address(self.auctioneer),\n amountToTransfer\n );\n\n uint256 portionToSeize = (amountOnOffer * amountToTransfer) /\n self.amountOutstanding;\n\n if (!isAuctionOver() && amountToTransfer != self.amountOutstanding) {\n // Time passed since the auction start or the last takeOffer call\n // with a partial fill.\n\n\n uint256 timePassed /* solhint-disable-next-line not-rely-on-time */\n = block.timestamp - self.startTime - self.startTimeOffset;\n\n // Ratio of the auction's amount included in this takeOffer call to\n // the whole outstanding auction amount.\n uint256 ratioAmountPaid = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * amountToTransfer) /\n self.amountOutstanding;\n // We will shift the start time offset and increase the velocity pool\n // depleting rate proportionally to the fraction of the outstanding\n // amount paid in this function call so that the auction can offer\n // no worse financial outcome for the next takers than the current\n // taker has.\n //\n //slither-disable-next-line divide-before-multiply\n self.startTimeOffset =\n self.startTimeOffset +\n ((timePassed * ratioAmountPaid) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n self.amountOutstanding -= amountToTransfer;\n\n //slither-disable-next-line incorrect-equality\n bool isFullyFilled = self.amountOutstanding == 0;\n\n // inform auctioneer of proceeds and winner. the auctioneer seizes funds\n // from the collateral pool in the name of the winner, and controls all\n // proceeds\n //\n //slither-disable-next-line reentrancy-no-eth\n self.auctioneer.offerTaken(\n msg.sender,\n self.tokenAccepted,\n amountToTransfer,\n portionToSeize,\n isFullyFilled\n );\n\n //slither-disable-next-line incorrect-equality\n if (isFullyFilled) {\n harikari();\n }\n }\n\n /// @notice Tears down the auction manually, before its entire amount\n /// is bought by takers.\n /// @dev Can be called only by the auctioneer which may decide to early\n // close the auction in case it is no longer needed.\n function earlyClose() external onlyAuctioneer {\n require(self.amountOutstanding > 0, \"Auction must be open\");\n\n harikari();\n }\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @dev _onOffer() / FLOATING_POINT_DIVISOR) returns a portion of the\n /// collateral pool. Ex. if 35% available of the collateral pool,\n /// then _onOffer() / FLOATING_POINT_DIVISOR) returns 0.35\n /// @return the ratio of the collateral pool currently on offer\n function onOffer() external view override returns (uint256, uint256) {\n return (_onOffer(), CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n function amountOutstanding() external view returns (uint256) {\n return self.amountOutstanding;\n }\n\n function amountTransferred() external view returns (uint256) {\n return self.amountDesired - self.amountOutstanding;\n }\n\n /// @dev Delete all storage and destroy the contract. Should only be called\n /// after an auction has closed.\n function harikari() internal {\n require(!isMasterContract(), \"Master contract can not harikari\");\n selfdestruct(payable(address(self.auctioneer)));\n }\n\n function _onOffer() internal view returns (uint256) {\n // when the auction is over, entire pool is on offer\n if (isAuctionOver()) {\n // Down the road, for determining a portion on offer, a value returned\n // by this function will be divided by FLOATING_POINT_DIVISOR. To\n // return the entire pool, we need to return just this divisor in order\n // to get 1.0 ie. FLOATING_POINT_DIVISOR / FLOATING_POINT_DIVISOR = 1.0\n return CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n\n // How fast portions of the collateral pool become available on offer.\n // It is needed to calculate the right portion value on offer at the\n // given moment before the auction is over.\n // Auction length once set is constant and what changes is the auction's\n // \"start time offset\" once the takeOffer() call has been processed for\n // partial fill. The auction's \"start time offset\" is updated every takeOffer().\n // velocityPoolDepletingRate = auctionLength / (auctionLength - startTimeOffset)\n // velocityPoolDepletingRate always starts at 1.0 and then can go up\n // depending on partial offer calls over auction life span to maintain\n // the right ratio between the remaining auction time and the remaining\n // portion of the collateral pool.\n //slither-disable-next-line divide-before-multiply\n uint256 velocityPoolDepletingRate = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * self.auctionLength) /\n (self.auctionLength - self.startTimeOffset);\n\n return\n /* solhint-disable-next-line not-rely-on-time */\n ((block.timestamp - (self.startTime + self.startTimeOffset)) *\n velocityPoolDepletingRate) / self.auctionLength;\n }\n\n function isAuctionOver() internal view returns (bool) {\n /* solhint-disable-next-line not-rely-on-time */\n return block.timestamp >= self.startTime + self.auctionLength;\n }\n\n function isMasterContract() internal view returns (bool) {\n return masterContract == address(this);\n }\n}\n" + }, + "contracts/AuctionBidder.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\n/// @title AuctionBidder\n/// @notice A contract for auction bidders for buying coverage pool auctions. This\n/// contract offers additional features for bidders to decide if their\n/// requirements for making a purchase are satisfied.\ncontract AuctionBidder {\n CoveragePool public immutable coveragePool;\n\n constructor(CoveragePool _coveragePool) {\n coveragePool = _coveragePool;\n }\n\n /// @notice Takes an offer from an auction buyer with a minimum required amount\n /// of tokens to seize from the coverage pool.\n /// @dev This contract is used only for KEEP coverage pool in v1 that was\n /// depricated. Going forward T coverage pool will be used for v2.\n /// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n ///\n /// 'minAmountToSeize' sets a minimum amount of tokens to seize in this\n /// transaction. A bidder can call `takeOffer` directly in the Auction\n /// contract but this function is a recommended way of taking coverage pool\n /// auctions. It might happen that the order of transactions might be changed\n /// for 'takeOffer' calls in the same block or claim and withdrawals from\n /// an AssetPool might occur. These reasons can affect a taker's expected\n /// amount of the coverage pool tokens to receive. Whereas if a minimum\n /// amount of tokens is specified but not satisfied, then the transaction\n /// will revert.\n /// @param auction coverage pool auction\n /// @param amount the amount a taker is paying, denominated in token accepted\n /// by the auction\n /// @param minAmountToSeize minimum amount of tokens to seize from the coverage\n /// pool\n function takeOfferWithMin(\n Auction auction,\n uint256 amount,\n uint256 minAmountToSeize\n ) external {\n uint256 auctionAmountOutstanding = auction.amountOutstanding();\n uint256 amountToPay = Math.min(amount, auctionAmountOutstanding);\n (uint256 amountOnOffer, ) = auction.onOffer();\n uint256 portionToSeize = (amountOnOffer * amountToPay) /\n auctionAmountOutstanding;\n\n uint256 amountToSeize = coveragePool.amountToSeize(portionToSeize);\n\n require(\n minAmountToSeize <= amountToSeize,\n \"Can't fulfill offer with a minimal amount to seize\"\n );\n\n auction.takeOffer(amount);\n }\n}\n" + }, + "contracts/Auctioneer.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\nimport \"@thesis/solidity-contracts/contracts/clone/CloneFactory.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Auctioneer\n/// @notice Factory for the creation of new auction clones and receiving proceeds.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// We avoid redeployment of auction contracts by using the clone factory.\n/// Proxy delegates calls to Auction and therefore does not affect auction state.\n/// This means that we only need to deploy the auction contracts once.\n/// The auctioneer provides clean state for every new auction clone.\ncontract Auctioneer is CloneFactory {\n // Holds the address of the auction contract\n // which will be used as a master contract for cloning.\n address public immutable masterAuction;\n mapping(address => bool) public openAuctions;\n uint256 public openAuctionsCount;\n\n CoveragePool public immutable coveragePool;\n\n event AuctionCreated(\n address indexed tokenAccepted,\n uint256 amount,\n address auctionAddress\n );\n event AuctionOfferTaken(\n address indexed auction,\n address indexed offerTaker,\n address tokenAccepted,\n uint256 amount,\n uint256 portionToSeize // This amount should be divided by FLOATING_POINT_DIVISOR\n );\n event AuctionClosed(address indexed auction);\n\n constructor(CoveragePool _coveragePool, address _masterAuction) {\n coveragePool = _coveragePool;\n // slither-disable-next-line missing-zero-check\n masterAuction = _masterAuction;\n }\n\n /// @notice Informs the auctioneer to seize funds and log appropriate events\n /// @dev This function is meant to be called from a cloned auction. It logs\n /// \"offer taken\" and \"auction closed\" events, seizes funds, and cleans\n /// up closed auctions.\n /// @param offerTaker The address of the taker of the auction offer,\n /// who will receive the pool's seized funds\n /// @param tokenPaid The token this auction is denominated in\n /// @param tokenAmountPaid The amount of the token the taker paid\n /// @param portionToSeize The portion of the pool the taker won at auction.\n /// This amount should be divided by FLOATING_POINT_DIVISOR\n /// to calculate how much of the pool should be set\n /// aside as the taker's winnings.\n /// @param fullyFilled Indicates whether the auction was taken fully or\n /// partially. If auction was fully filled, it is\n /// closed. If auction was partially filled, it is\n /// sill open and waiting for remaining bids.\n function offerTaken(\n address offerTaker,\n IERC20 tokenPaid,\n uint256 tokenAmountPaid,\n uint256 portionToSeize,\n bool fullyFilled\n ) external {\n require(openAuctions[msg.sender], \"Sender isn't an auction\");\n\n emit AuctionOfferTaken(\n msg.sender,\n offerTaker,\n address(tokenPaid),\n tokenAmountPaid,\n portionToSeize\n );\n\n // actually seize funds, setting them aside for the taker to withdraw\n // from the coverage pool.\n // `portionToSeize` will be divided by FLOATING_POINT_DIVISOR which is\n // defined in Auction.sol\n //\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n coveragePool.seizePortion(offerTaker, portionToSeize);\n\n Auction auction = Auction(msg.sender);\n if (fullyFilled) {\n onAuctionFullyFilled(auction);\n\n emit AuctionClosed(msg.sender);\n delete openAuctions[msg.sender];\n openAuctionsCount -= 1;\n } else {\n onAuctionPartiallyFilled(auction);\n }\n }\n\n /// @notice Opens a new auction against the coverage pool. The auction\n /// will remain open until filled.\n /// @dev Calls `Auction.initialize` to initialize the instance.\n /// @param tokenAccepted The token with which the auction can be taken\n /// @param amountDesired The amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param auctionLength The amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function createAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) internal returns (address) {\n address cloneAddress = createClone(masterAuction);\n require(cloneAddress != address(0), \"Cloned auction address is 0\");\n\n Auction auction = Auction(cloneAddress);\n //slither-disable-next-line reentrancy-benign,reentrancy-events\n auction.initialize(this, tokenAccepted, amountDesired, auctionLength);\n\n openAuctions[cloneAddress] = true;\n openAuctionsCount += 1;\n\n emit AuctionCreated(\n address(tokenAccepted),\n amountDesired,\n cloneAddress\n );\n\n return cloneAddress;\n }\n\n /// @notice Tears down an open auction with given address immediately.\n /// @dev Can be called by contract owner to early close an auction if it\n /// is no longer needed. Bear in mind that funds from the early closed\n /// auction last on the auctioneer contract. Calling code should take\n /// care of them.\n /// @return Amount of funds transferred to this contract by the Auction\n /// being early closed.\n function earlyCloseAuction(Auction auction) internal returns (uint256) {\n address auctionAddress = address(auction);\n\n require(openAuctions[auctionAddress], \"Address is not an open auction\");\n\n uint256 amountTransferred = auction.amountTransferred();\n\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n auction.earlyClose();\n\n emit AuctionClosed(auctionAddress);\n delete openAuctions[auctionAddress];\n openAuctionsCount -= 1;\n\n return amountTransferred;\n }\n\n /// @notice Auction lifecycle hook allowing to act on auction closed\n /// as fully filled. This function is not executed when an auction\n /// was partially filled. When this function is executed auction is\n /// already closed and funds from the coverage pool are seized.\n /// @dev Override this function to act on auction closed as fully filled.\n function onAuctionFullyFilled(Auction auction) internal virtual {}\n\n /// @notice Auction lifecycle hook allowing to act on auction partially\n /// filled. This function is not executed when an auction\n /// was fully filled.\n /// @dev Override this function to act on auction partially filled.\n function onAuctionPartiallyFilled(Auction auction) internal view virtual {}\n}\n" + }, + "contracts/BatchedPhasedEscrow.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Batched Phased Escrow Beneficiary\n/// @notice Interface expected from contracts receiving tokens from the\n/// BatchedPhasedEscrow.\ninterface IBeneficiaryContract {\n function __escrowSentTokens(uint256 amount) external;\n}\n\n/// @title BatchedPhasedEscrow\n/// @notice A token holder contract allowing contract owner to approve a set of\n/// beneficiaries of tokens held by the contract, to appoint a separate\n/// drawee role, and allowing that drawee to withdraw tokens to approved\n/// beneficiaries in phases.\ncontract BatchedPhasedEscrow is Ownable {\n using SafeERC20 for IERC20;\n\n event BeneficiaryApproved(address beneficiary);\n event TokensWithdrawn(address beneficiary, uint256 amount);\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\n\n IERC20 public token;\n address public drawee;\n mapping(address => bool) private approvedBeneficiaries;\n\n modifier onlyDrawee() {\n require(drawee == msg.sender, \"Caller is not the drawee\");\n _;\n }\n\n constructor(IERC20 _token) {\n token = _token;\n drawee = msg.sender;\n }\n\n /// @notice Approves the provided address as a beneficiary of tokens held by\n /// the escrow. Can be called only by escrow owner.\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\n external\n onlyOwner\n {\n address beneficiaryAddress = address(_beneficiary);\n require(\n beneficiaryAddress != address(0),\n \"Beneficiary can not be zero address\"\n );\n approvedBeneficiaries[beneficiaryAddress] = true;\n emit BeneficiaryApproved(beneficiaryAddress);\n }\n\n /// @notice Returns `true` if the given address has been approved as a\n /// beneficiary of the escrow, `false` otherwise.\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\n public\n view\n returns (bool)\n {\n return approvedBeneficiaries[address(_beneficiary)];\n }\n\n /// @notice Transfers the role of drawee to another address. Can be called\n /// only by the contract owner.\n function setDrawee(address newDrawee) external onlyOwner {\n require(newDrawee != address(0), \"New drawee can not be zero address\");\n emit DraweeRoleTransferred(drawee, newDrawee);\n drawee = newDrawee;\n }\n\n /// @notice Funds the escrow by transferring all of the approved tokens\n /// to the escrow.\n function receiveApproval(\n address _from,\n uint256 _value,\n address _token,\n bytes memory\n ) external {\n require(IERC20(_token) == token, \"Unsupported token\");\n token.safeTransferFrom(_from, address(this), _value);\n }\n\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\n /// transferring to each beneficiary the amount of tokens specified\n /// as a parameter. Only beneficiaries previously approved by escrow\n /// owner can receive funds.\n function batchedWithdraw(\n IBeneficiaryContract[] memory beneficiaries,\n uint256[] memory amounts\n ) external onlyDrawee {\n require(\n beneficiaries.length == amounts.length,\n \"Mismatched arrays length\"\n );\n\n for (uint256 i = 0; i < beneficiaries.length; i++) {\n IBeneficiaryContract beneficiary = beneficiaries[i];\n require(\n isBeneficiaryApproved(beneficiary),\n \"Beneficiary was not approved\"\n );\n withdraw(beneficiary, amounts[i]);\n }\n }\n\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\n private\n {\n emit TokensWithdrawn(address(beneficiary), amount);\n token.safeTransfer(address(beneficiary), amount);\n // slither-disable-next-line calls-loop\n beneficiary.__escrowSentTokens(amount);\n }\n}\n" + }, + "contracts/CoveragePool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./AssetPool.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Coverage Pool\n/// @notice A contract that manages a single asset pool. Handles approving and\n/// unapproving of risk managers and allows them to seize funds from the\n/// asset pool if they are approved.\n/// @dev Coverage pool contract is owned by the governance. Coverage pool is the\n/// owner of the asset pool contract.\ncontract CoveragePool is Ownable {\n AssetPool public immutable assetPool;\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n bool public firstRiskManagerApproved = false;\n\n // Currently approved risk managers\n mapping(address => bool) public approvedRiskManagers;\n // Timestamps of risk managers whose approvals have been initiated\n mapping(address => uint256) public riskManagerApprovalTimestamps;\n\n event RiskManagerApprovalStarted(address riskManager, uint256 timestamp);\n event RiskManagerApprovalCompleted(address riskManager, uint256 timestamp);\n event RiskManagerUnapproved(address riskManager, uint256 timestamp);\n\n /// @notice Reverts if called by a risk manager that is not approved\n modifier onlyApprovedRiskManager() {\n require(approvedRiskManagers[msg.sender], \"Risk manager not approved\");\n _;\n }\n\n constructor(AssetPool _assetPool) {\n assetPool = _assetPool;\n collateralToken = _assetPool.collateralToken();\n underwriterToken = _assetPool.underwriterToken();\n }\n\n /// @notice Approves the first risk manager\n /// @dev Can be called only by the contract owner. Can be called only once.\n /// Does not require any further calls to any functions.\n /// @param riskManager Risk manager that will be approved\n function approveFirstRiskManager(address riskManager) external onlyOwner {\n require(\n !firstRiskManagerApproved,\n \"The first risk manager was approved\"\n );\n approvedRiskManagers[riskManager] = true;\n firstRiskManagerApproved = true;\n }\n\n /// @notice Begins risk manager approval process.\n /// @dev Can be called only by the contract owner and only when the first\n /// risk manager is already approved. For a risk manager to be\n /// approved, a call to `finalizeRiskManagerApproval` must follow\n /// (after a governance delay).\n /// @param riskManager Risk manager that will be approved\n function beginRiskManagerApproval(address riskManager) external onlyOwner {\n require(\n firstRiskManagerApproved,\n \"The first risk manager is not yet approved; Please use \"\n \"approveFirstRiskManager instead\"\n );\n\n require(\n !approvedRiskManagers[riskManager],\n \"Risk manager already approved\"\n );\n\n /* solhint-disable-next-line not-rely-on-time */\n riskManagerApprovalTimestamps[riskManager] = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalStarted(riskManager, block.timestamp);\n }\n\n /// @notice Finalizes risk manager approval process.\n /// @dev Can be called only by the contract owner. Must be preceded with a\n /// call to beginRiskManagerApproval and a governance delay must elapse.\n /// @param riskManager Risk manager that will be approved\n function finalizeRiskManagerApproval(address riskManager)\n external\n onlyOwner\n {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0,\n \"Risk manager approval not initiated\"\n );\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - riskManagerApprovalTimestamps[riskManager] >=\n assetPool.withdrawalGovernanceDelay(),\n \"Risk manager governance delay has not elapsed\"\n );\n approvedRiskManagers[riskManager] = true;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalCompleted(riskManager, block.timestamp);\n delete riskManagerApprovalTimestamps[riskManager];\n }\n\n /// @notice Unapproves an already approved risk manager or cancels the\n /// approval process of a risk manager (the latter happens if called\n /// between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`).\n /// The change takes effect immediately.\n /// @dev Can be called only by the contract owner.\n /// @param riskManager Risk manager that will be unapproved\n function unapproveRiskManager(address riskManager) external onlyOwner {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0 ||\n approvedRiskManagers[riskManager],\n \"Risk manager is neither approved nor with a pending approval\"\n );\n delete riskManagerApprovalTimestamps[riskManager];\n delete approvedRiskManagers[riskManager];\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerUnapproved(riskManager, block.timestamp);\n }\n\n /// @notice Approves upgradeability to the new asset pool.\n /// Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n /// @param _newAssetPool New asset pool\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n assetPool.approveNewAssetPoolUpgrade(_newAssetPool);\n }\n\n /// @notice Lets the governance to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 newWithdrawalDelay)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalDelayUpdate(newWithdrawalDelay);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalDelayUpdate();\n }\n\n /// @notice Lets the governance to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 newWithdrawalTimeout)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalTimeoutUpdate(newWithdrawalTimeout);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalTimeoutUpdate();\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @dev `portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR`\n /// for calculation precision purposes. Further calculations in this\n /// function will need to take this divisor into account.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by `FLOATING_POINT_DIVISOR`\n function seizePortion(address recipient, uint256 portionToSeize)\n external\n onlyApprovedRiskManager\n {\n require(\n portionToSeize > 0 &&\n portionToSeize <= CoveragePoolConstants.FLOATING_POINT_DIVISOR,\n \"Portion to seize is not within the range (0, 1]\"\n );\n\n assetPool.claim(recipient, amountToSeize(portionToSeize));\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param amountToSeize Amount to be seized from the pool\n // slither-disable-next-line shadowing-local\n function seizeAmount(address recipient, uint256 amountToSeize)\n external\n onlyApprovedRiskManager\n {\n require(amountToSeize > 0, \"Amount to seize must be >0\");\n\n assetPool.claim(recipient, amountToSeize);\n }\n\n /// @notice Grants asset pool shares by minting a given amount of the\n /// underwriter tokens for the recipient address. In result, the\n /// recipient obtains part of the pool ownership without depositing\n /// any collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by an approved risk manager.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n onlyApprovedRiskManager\n {\n assetPool.grantShares(recipient, covAmount);\n }\n\n /// @notice Returns the time remaining until the risk manager approval\n /// process can be finalized\n /// @param riskManager Risk manager in the process of approval\n /// @return Remaining time in seconds.\n function getRemainingRiskManagerApprovalTime(address riskManager)\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n riskManagerApprovalTimestamps[riskManager],\n assetPool.withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Determine the prior number of DAO votes for the given coverage\n /// pool underwriter.\n /// @param account The underwriter address to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the underwriter had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96)\n {\n uint96 underwriterVotes = underwriterToken.getPastVotes(\n account,\n blockNumber\n );\n uint96 underwriterTokenSupply = underwriterToken.getPastTotalSupply(\n blockNumber\n );\n\n if (underwriterTokenSupply == 0) {\n return 0;\n }\n\n uint96 covPoolVotes = collateralToken.getPastVotes(\n address(assetPool),\n blockNumber\n );\n\n return\n uint96(\n (uint256(underwriterVotes) * covPoolVotes) /\n underwriterTokenSupply\n );\n }\n\n /// @notice Calculates amount of tokens to be seized from the coverage pool.\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by FLOATING_POINT_DIVISOR\n function amountToSeize(uint256 portionToSeize)\n public\n view\n returns (uint256)\n {\n return\n (collateralToken.balanceOf(address(assetPool)) * portionToSeize) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n}\n" + }, + "contracts/CoveragePoolBeneficiary.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./RewardsPool.sol\";\nimport \"./BatchedPhasedEscrow.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title CoveragePoolBeneficiary\n/// @notice A beneficiary contract that can receive a withdrawal phase from a\n/// BatchedPhasedEscrow contract.\n/// It immediately transfers the received tokens on a designated\n/// RewardsPool contract.\ncontract CoveragePoolBeneficiary is Ownable, IBeneficiaryContract {\n using SafeERC20 for IERC20;\n\n IERC20 public immutable token;\n RewardsPool public immutable rewards;\n\n constructor(IERC20 _token, RewardsPool _rewards) {\n token = _token;\n rewards = _rewards;\n }\n\n function __escrowSentTokens(uint256 amount) external override onlyOwner {\n token.safeApprove(address(rewards), amount);\n rewards.topUpReward(amount);\n }\n}\n" + }, + "contracts/CoveragePoolConstants.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary CoveragePoolConstants {\n // This divisor is for precision purposes only. We use this divisor around\n // auction related code to get the precise values without rounding it down\n // when dealing with floating numbers.\n uint256 public constant FLOATING_POINT_DIVISOR = 1e18;\n}\n" + }, + "contracts/GovernanceUtils.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary GovernanceUtils {\n /// @notice Gets the time remaining until the governable parameter update\n /// can be committed.\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\n /// @param delay Governance delay.\n /// @return Remaining time in seconds.\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\n internal\n view\n returns (uint256)\n {\n require(changeTimestamp > 0, \"Change not initiated\");\n /* solhint-disable-next-line not-rely-on-time */\n uint256 elapsed = block.timestamp - changeTimestamp;\n if (elapsed >= delay) {\n return 0;\n } else {\n return delay - elapsed;\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@threshold-network/solidity-contracts/contracts/token/T.sol';\n" + }, + "contracts/interfaces/IAssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool interface\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\n/// an underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool.\ninterface IAssetPool {\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amount) external returns (uint256);\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n returns (uint256);\n\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external;\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter) external returns (uint256);\n}\n" + }, + "contracts/interfaces/IAssetPoolUpgrade.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool upgrade interface\n/// @notice Interface that has to be implemented by an Asset Pool accepting\n/// upgrades from another asset pool.\ninterface IAssetPoolUpgrade {\n /// @notice Accepts the given underwriter with collateral tokens amount as a\n /// deposit. In exchange new underwriter tokens will be calculated,\n /// minted and then transferred back to the underwriter.\n function depositFor(address underwriter, uint256 amount) external;\n}\n" + }, + "contracts/interfaces/IAuction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Auction interface\n/// @notice Auction runs a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\ninterface IAuction {\n /// @notice Takes an offer from an auction buyer. There are two possible\n /// ways to take an offer from a buyer. The first one is to buy\n /// entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// @dev The implementation is not guaranteed to be protecting against\n /// frontrunning. See `AuctionBidder` for an example protection.\n function takeOffer(uint256 amount) external;\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @return The ratio of the collateral pool currently on offer and divisor\n /// for precision purposes.\n function onOffer() external view returns (uint256, uint256);\n}\n" + }, + "contracts/interfaces/ICollateralToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Collateral Token interface\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\n/// as a deposit token by underwriters. Collateral token positions of\n/// underwriters can be affected when the Risk Manager claims coverage.\n/// Collateral token needs to support DAO checkpoints and let to\n/// retrieve past number of votes for the given address so that\n/// Coverage Pool underwriters can participate in token holder DAO.\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\ninterface ICollateralToken is IERC20 {\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) external;\n\n /// @notice Determine the prior number of DAO votes for an account as of\n /// a block number.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "contracts/interfaces/IRiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Interface for tBTC v1 Risk Manager\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\ninterface IRiskManagerV1 {\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external;\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external;\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n /// @param amount Amount of signer bonds being withdrawn.\n function withdrawSignerBonds(uint256 amount) external;\n\n /// @notice Returns true if there are open auctions managed by the risk\n /// manager. Returns false otherwise.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n function hasOpenAuctions() external view returns (bool);\n}\n" + }, + "contracts/RewardsPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Rewards Pool\n/// @notice RewardsPool accepts a single reward token and releases it to the\n/// AssetPool over time in one week reward intervals. The owner of this\n/// contract is the reward distribution address funding it with reward\n/// tokens.\ncontract RewardsPool is Ownable {\n using SafeERC20 for IERC20;\n\n uint256 public constant DURATION = 7 days;\n\n IERC20 public immutable rewardToken;\n address public immutable assetPool;\n\n // timestamp of the current reward interval end or the timestamp of the\n // last interval end in case a new reward interval has not been allocated\n uint256 public intervalFinish = 0;\n // rate per second with which reward tokens are unlocked\n uint256 public rewardRate = 0;\n // amount of rewards accumulated and not yet withdrawn from the previous\n // reward interval(s)\n uint256 public rewardAccumulated = 0;\n // the last time information in this contract was updated\n uint256 public lastUpdateTime = 0;\n\n event RewardToppedUp(uint256 amount);\n event RewardWithdrawn(uint256 amount);\n\n constructor(\n IERC20 _rewardToken,\n address _assetPool,\n address owner\n ) {\n rewardToken = _rewardToken;\n // slither-disable-next-line missing-zero-check\n assetPool = _assetPool;\n transferOwnership(owner);\n }\n\n /// @notice Transfers the provided reward amount into RewardsPool and\n /// creates a new, one-week reward interval starting from now.\n /// Reward tokens from the previous reward interval that unlocked\n /// over the time will be available for withdrawal immediately.\n /// Reward tokens from the previous interval that has not been yet\n /// unlocked, are added to the new interval being created.\n /// @dev This function can be called only by the owner given that it creates\n /// a new interval with one week length, starting from now.\n function topUpReward(uint256 reward) external onlyOwner {\n rewardAccumulated = earned();\n\n /* solhint-disable not-rely-on-time */\n if (block.timestamp >= intervalFinish) {\n // see https://github.com/crytic/slither/issues/844\n // slither-disable-next-line divide-before-multiply\n rewardRate = reward / DURATION;\n } else {\n uint256 remaining = intervalFinish - block.timestamp;\n uint256 leftover = remaining * rewardRate;\n rewardRate = (reward + leftover) / DURATION;\n }\n intervalFinish = block.timestamp + DURATION;\n lastUpdateTime = block.timestamp;\n /* solhint-enable avoid-low-level-calls */\n\n emit RewardToppedUp(reward);\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\n }\n\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\n function withdraw() external {\n uint256 amount = earned();\n rewardAccumulated = 0;\n lastUpdateTime = lastTimeRewardApplicable();\n emit RewardWithdrawn(amount);\n rewardToken.safeTransfer(assetPool, amount);\n }\n\n /// @notice Returns the amount of earned and not yet withdrawn reward\n /// tokens.\n function earned() public view returns (uint256) {\n return\n rewardAccumulated +\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\n }\n\n /// @notice Returns the timestamp at which a reward was last time applicable.\n /// When reward interval is pending, returns current block's\n /// timestamp. If the last reward interval ended and no other reward\n /// interval had been allocated, returns the last reward interval's\n /// end timestamp.\n function lastTimeRewardApplicable() public view returns (uint256) {\n return Math.min(block.timestamp, intervalFinish);\n }\n}\n" + }, + "contracts/RiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./Auction.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title tBTC v1 Deposit contract interface\n/// @notice This is an interface with just a few function signatures of a main\n/// Deposit contract from tBTC. tBTC deposit contract functions declared in\n/// this interface are used by RiskManagerV1 contract to interact with tBTC\n/// v1 deposits. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface IDeposit {\n function withdrawFunds() external;\n\n function purchaseSignerBondsAtAuction() external;\n\n function currentState() external view returns (uint256);\n\n function lotSizeTbtc() external view returns (uint256);\n\n function withdrawableAmount() external view returns (uint256);\n\n function auctionValue() external view returns (uint256);\n}\n\n/// @title tBTC v1 deposit token (TDT) interface\n/// @notice This is an interface with just a few function signatures of a main\n/// contract from tBTC. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/system/TBTCDepositToken.sol\ninterface ITBTCDepositToken {\n function exists(uint256 _tokenId) external view returns (bool);\n}\n\n/// @title Signer bonds swap strategy\n/// @notice This interface is meant to abstract the underlying signer bonds\n/// swap strategy and make it interchangeable for the governance.\n/// Risk manager uses the strategy to swap ETH from tBTC deposit\n/// purchased signer bonds back into collateral token accepted by\n/// coverage pool.\ninterface ISignerBondsSwapStrategy {\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external;\n}\n\n/// @title Risk Manager for tBTC v1\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract RiskManagerV1 is IRiskManagerV1, Auctioneer, Ownable {\n using SafeERC20 for IERC20;\n using RiskManagerV1Rewards for RiskManagerV1Rewards.Storage;\n\n /// @notice Governance delay that needs to pass before any risk manager\n /// parameter change initiated by the governance takes effect.\n uint256 public constant GOVERNANCE_DELAY = 12 hours;\n\n // See https://github.com/keep-network/tbtc/blob/v1.1.0/solidity/contracts/deposit/DepositStates.sol\n uint256 public constant DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE = 9;\n uint256 public constant DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE = 10;\n uint256 public constant DEPOSIT_LIQUIDATED_STATE = 11;\n\n /// @notice Coverage pool auction will not be opened if the deposit's bond\n /// auction offers a bond percentage lower than this threshold.\n /// Risk manager should open a coverage pool auction for only those\n // tBTC deposits that nobody else is willing to purchase bonds\n /// from. The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public bondAuctionThreshold; // percentage\n uint256 public newBondAuctionThreshold;\n uint256 public bondAuctionThresholdChangeInitiated;\n\n /// @notice The length with which every new auction is opened. Auction length\n /// is the amount of time it takes for the auction to get to 100%\n /// of all collateral on offer, in seconds. This parameter value\n /// should be updated and kept up to date based on the coverage pool\n /// TVL and tBTC v1 minimum lot size allowed so that a new auction\n /// does not liquidate too much too early. Auction length is the\n /// same, no matter tBTC deposit lot size.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public auctionLength;\n uint256 public newAuctionLength;\n uint256 public auctionLengthChangeInitiated;\n\n /// @notice The strategy used to swap ETH from tBTC deposit purchased signer\n /// bonds into an asset accepted by coverage pool as collateral.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n ISignerBondsSwapStrategy public signerBondsSwapStrategy;\n ISignerBondsSwapStrategy public newSignerBondsSwapStrategy;\n uint256 public signerBondsSwapStrategyInitiated;\n\n IERC20 public immutable tbtcToken;\n ITBTCDepositToken public immutable tbtcDepositToken;\n\n /// @notice TBTC surplus collected from early closed auctions.\n /// When tBTC deposit gets liquidated outside of coverage pools and\n /// an auction was opened earlier by the risk manager for that\n /// deposit, it might happen that the auction was partially filled\n /// and some TBTC from that auction has accumulated. In such a case,\n /// TBTC surplus left on the risk manager can be used to purchase\n /// signer bonds from another liquidating tBTC deposit in the future\n /// assuming enough surplus will accumulate up to that point.\n uint256 public tbtcSurplus;\n\n /// @notice Keeps track of notifier rewards for those calling\n /// `notifyLiquidation` and `notifyLiquidated`.\n RiskManagerV1Rewards.Storage public rewards;\n\n // deposit in liquidation => opened coverage pool auction\n mapping(address => address) public depositToAuction;\n // opened coverage pool auction => deposit in liquidation\n mapping(address => address) public auctionToDeposit;\n\n event NotifiedLiquidated(address indexed deposit, address notifier);\n event NotifiedLiquidation(address indexed deposit, address notifier);\n\n event BondAuctionThresholdUpdateStarted(\n uint256 bondAuctionThreshold,\n uint256 timestamp\n );\n event BondAuctionThresholdUpdated(uint256 bondAuctionThreshold);\n\n event AuctionLengthUpdateStarted(uint256 auctionLength, uint256 timestamp);\n event AuctionLengthUpdated(uint256 auctionLength);\n\n event SignerBondsSwapStrategyUpdateStarted(\n address indexed signerBondsSwapStrategy,\n uint256 timestamp\n );\n event SignerBondsSwapStrategyUpdated(\n address indexed signerBondsSwapStrategy\n );\n\n event LiquidationNotifierRewardUpdateStarted(\n uint256 liquidationNotifierReward,\n uint256 timestamp\n );\n event LiquidationNotifierRewardUpdated(uint256 liquidationNotifierReward);\n\n event LiquidatedNotifierRewardUpdateStarted(\n uint256 liquidatedNotifierReward,\n uint256 timestamp\n );\n event LiquidatedNotifierRewardUpdated(uint256 liquidatedNotifierReward);\n\n /// @notice Reverts if called before the governance delay elapses.\n /// @param changeInitiatedTimestamp Timestamp indicating the beginning\n /// of the change.\n modifier onlyAfterGovernanceDelay(uint256 changeInitiatedTimestamp) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >= GOVERNANCE_DELAY,\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n /// @notice Reverts if called by any account other than the current signer\n /// bonds swap strategy.\n modifier onlySignerBondsSwapStrategy() {\n require(\n msg.sender == address(signerBondsSwapStrategy),\n \"Caller is not the signer bonds swap strategy\"\n );\n _;\n }\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n ) Auctioneer(_coveragePool, _masterAuction) {\n tbtcToken = _tbtcToken;\n tbtcDepositToken = _tbtcDepositToken;\n signerBondsSwapStrategy = _signerBondsSwapStrategy;\n auctionLength = _auctionLength;\n bondAuctionThreshold = _bondAuctionThreshold;\n }\n\n /// @notice Receives ETH from tBTC for purchasing and withdrawing deposit\n /// signer bonds.\n //slither-disable-next-line locked-ether\n receive() external payable {}\n\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external override {\n require(\n tbtcDepositToken.exists(uint256(uint160(depositAddress))),\n \"Address is not a deposit contract\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit is not in liquidation state\"\n );\n\n require(\n depositToAuction[depositAddress] == address(0),\n \"Already notified on the deposit in liquidation\"\n );\n\n require(\n deposit.auctionValue() >=\n (address(deposit).balance * bondAuctionThreshold) / 100,\n \"Deposit bond auction percentage is below the threshold level\"\n );\n\n uint256 lotSizeTbtc = deposit.lotSizeTbtc();\n\n emit NotifiedLiquidation(depositAddress, msg.sender);\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidationNotifierReward > 0) {\n // slither-disable-next-line reentrancy-benign\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidationNotifierReward\n );\n }\n\n // If the surplus can cover the deposit liquidation cost, liquidate\n // that deposit directly without the auction process.\n if (tbtcSurplus >= lotSizeTbtc) {\n tbtcSurplus -= lotSizeTbtc;\n liquidateDeposit(deposit);\n return;\n }\n\n // slither-disable-next-line reentrancy-no-eth\n address auctionAddress = createAuction(\n tbtcToken,\n lotSizeTbtc,\n auctionLength\n );\n depositToAuction[depositAddress] = auctionAddress;\n auctionToDeposit[auctionAddress] = depositAddress;\n }\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external override {\n require(\n depositToAuction[depositAddress] != address(0),\n \"No auction for given deposit\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n deposit.currentState() == DEPOSIT_LIQUIDATED_STATE,\n \"Deposit is not in liquidated state\"\n );\n emit NotifiedLiquidated(depositAddress, msg.sender);\n\n Auction auction = Auction(depositToAuction[depositAddress]);\n\n delete depositToAuction[depositAddress];\n delete auctionToDeposit[address(auction)];\n uint256 amountTransferred = earlyCloseAuction(auction);\n\n // Add auction's transferred amount to the surplus pool.\n // slither-disable-next-line reentrancy-benign\n tbtcSurplus += amountTransferred;\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidatedNotifierReward > 0) {\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidatedNotifierReward\n );\n }\n }\n\n /// @notice Begins the bond auction threshold update process. The value of\n /// the threshold must not be greater than 100. The threshold should\n /// be high enough so that the possibility of purchasing signer\n /// bonds outside of coverage pools after opening an auction is\n /// minimal.\n /// @dev Can be called only by the contract owner.\n /// @param _newBondAuctionThreshold New bond auction threshold in percent\n function beginBondAuctionThresholdUpdate(uint256 _newBondAuctionThreshold)\n external\n onlyOwner\n {\n require(\n _newBondAuctionThreshold <= 100,\n \"Bond auction threshold must be lower or equal to 100\"\n );\n newBondAuctionThreshold = _newBondAuctionThreshold;\n /* solhint-disable-next-line not-rely-on-time */\n bondAuctionThresholdChangeInitiated = block.timestamp;\n /* solhint-disable not-rely-on-time */\n emit BondAuctionThresholdUpdateStarted(\n _newBondAuctionThreshold,\n block.timestamp\n );\n }\n\n /// @notice Finalizes the bond auction threshold update process.\n /// @dev Can be called only by the contract owner, after the the\n /// governance delay elapses.\n function finalizeBondAuctionThresholdUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(bondAuctionThresholdChangeInitiated)\n {\n bondAuctionThreshold = newBondAuctionThreshold;\n emit BondAuctionThresholdUpdated(bondAuctionThreshold);\n bondAuctionThresholdChangeInitiated = 0;\n newBondAuctionThreshold = 0;\n }\n\n /// @notice Begins the auction length update process. The auction length\n /// should be adjusted very carefully. Total value locked of the\n /// coverage pool and minimum possible auction amount need to be\n /// taken into account. The goal is to find a \"sweet spot\" for\n /// auction length, not making it too short (which leads to big\n /// sums of coverage pool become available in a short time) and not\n /// making it too long (which leads to bidders waiting for too long\n /// until it will makes sense for them to bid on an auction).\n /// @dev Can be called only by the contract owner.\n /// @param _newAuctionLength New auction length in seconds\n function beginAuctionLengthUpdate(uint256 _newAuctionLength)\n external\n onlyOwner\n {\n newAuctionLength = _newAuctionLength;\n /* solhint-disable-next-line not-rely-on-time */\n auctionLengthChangeInitiated = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit AuctionLengthUpdateStarted(_newAuctionLength, block.timestamp);\n }\n\n /// @notice Finalizes the auction length update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeAuctionLengthUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(auctionLengthChangeInitiated)\n {\n auctionLength = newAuctionLength;\n emit AuctionLengthUpdated(newAuctionLength);\n newAuctionLength = 0;\n auctionLengthChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidation` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @dev Can be called only by the contract owner.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward\n function beginLiquidationNotifierRewardUpdate(\n uint256 _newLiquidationNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidationNotifierRewardUpdateStarted(\n _newLiquidationNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidationNotifierRewardUpdate(\n _newLiquidationNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeLiquidationNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidationNotifierRewardChangeInitiated\n )\n {\n emit LiquidationNotifierRewardUpdated(\n rewards.newLiquidationNotifierReward\n );\n\n rewards.finalizeLiquidationNotifierRewardUpdate();\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidated` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n uint256 _newLiquidatedNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidatedNotifierRewardUpdateStarted(\n _newLiquidatedNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidatedNotifierRewardUpdate(\n _newLiquidatedNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses\n function finalizeLiquidatedNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidatedNotifierRewardChangeInitiated\n )\n {\n emit LiquidatedNotifierRewardUpdated(\n rewards.newLiquidatedNotifierReward\n );\n\n rewards.finalizeLiquidatedNotifierRewardUpdate();\n }\n\n /// @notice Begins the signer bonds swap strategy update process.\n /// @dev Must be followed by a finalizeSignerBondsSwapStrategyUpdate after\n /// the governance delay elapses.\n /// @param _newSignerBondsSwapStrategy The new signer bonds swap strategy\n function beginSignerBondsSwapStrategyUpdate(\n ISignerBondsSwapStrategy _newSignerBondsSwapStrategy\n ) external onlyOwner {\n require(\n address(_newSignerBondsSwapStrategy) != address(0),\n \"Invalid signer bonds swap strategy address\"\n );\n newSignerBondsSwapStrategy = _newSignerBondsSwapStrategy;\n /* solhint-disable-next-line not-rely-on-time */\n signerBondsSwapStrategyInitiated = block.timestamp;\n emit SignerBondsSwapStrategyUpdateStarted(\n address(_newSignerBondsSwapStrategy),\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp\n );\n }\n\n /// @notice Finalizes the signer bonds swap strategy update.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeSignerBondsSwapStrategyUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(signerBondsSwapStrategyInitiated)\n {\n signerBondsSwapStrategy = newSignerBondsSwapStrategy;\n emit SignerBondsSwapStrategyUpdated(\n address(newSignerBondsSwapStrategy)\n );\n delete newSignerBondsSwapStrategy;\n signerBondsSwapStrategyInitiated = 0;\n }\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Can be called only by the signer bonds swap strategy itself.\n /// This method should typically be used as part of the swap logic.\n /// Third-party calls may block funds on the strategy contract in case\n /// that strategy is not able to perform the swap.\n /// @param amount Amount of signer bonds being withdrawn\n function withdrawSignerBonds(uint256 amount)\n external\n override\n onlySignerBondsSwapStrategy\n {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = address(signerBondsSwapStrategy).call{value: amount}(\n \"\"\n );\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n /// @notice Get the time remaining until the bond auction threshold\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingBondAuctionThresholdUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n bondAuctionThresholdChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the auction length parameter\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingAuctionLengthUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n auctionLengthChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidation notifier reward\n /// parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidationNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidationNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidated notifier reward\n /// amount parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidatedNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidatedNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the signer bonds swap strategy\n /// can be changed.\n /// @return Remaining time in seconds.\n function getRemainingSignerBondsSwapStrategyChangeTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n signerBondsSwapStrategyInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @return True if there are open auctions managed by the risk manager.\n /// Returns false otherwise.\n function hasOpenAuctions() external view override returns (bool) {\n return openAuctionsCount > 0;\n }\n\n /// @return Current value of the liquidation notifier reward.\n function liquidationNotifierReward() external view returns (uint256) {\n return rewards.liquidationNotifierReward;\n }\n\n /// @return Current value of the liquidated notifier reward.\n function liquidatedNotifierReward() external view returns (uint256) {\n return rewards.liquidatedNotifierReward;\n }\n\n /// @notice Cleans up auction and deposit data and executes deposit liquidation.\n /// @dev This function is invoked when Auctioneer determines that an auction\n /// is eligible to be closed. It cannot be called on-demand outside\n /// the Auctioneer contract. By the time this function is called, all\n /// the TBTC tokens for the coverage pool auction should be transferred\n /// to this contract in order to buy signer bonds.\n /// @param auction Coverage pool auction\n function onAuctionFullyFilled(Auction auction) internal override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n\n delete depositToAuction[address(deposit)];\n delete auctionToDeposit[address(auction)];\n\n liquidateDeposit(deposit);\n }\n\n /// @notice Purchases ETH from signer bonds and swaps obtained funds\n /// using the underlying signer bonds swap strategy.\n /// @dev By the time this function is called, TBTC token balance for this\n /// contract should be enough to buy signer bonds.\n /// @param deposit TBTC deposit which should be liquidated.\n function liquidateDeposit(IDeposit deposit) internal {\n uint256 approvedAmount = deposit.lotSizeTbtc();\n tbtcToken.safeApprove(address(deposit), approvedAmount);\n\n // Purchase signers bonds ETH with TBTC acquired from the auction or\n // taken from the surplus pool.\n deposit.purchaseSignerBondsAtAuction();\n\n uint256 withdrawableAmount = deposit.withdrawableAmount();\n deposit.withdrawFunds();\n\n signerBondsSwapStrategy.onSignerBondsPurchased(withdrawableAmount);\n }\n\n /// @notice Reverts if the deposit for which the auction was created is no\n /// longer in the liquidation state. This could happen if signer\n /// bonds were purchased from tBTC deposit directly, outside of\n /// coverage pool auction.\n /// @dev This function is invoked when the auctioneer is informed about the\n /// results of an auction and the auction was partially filled.\n /// @param auction Address of an auction whose deposit needs to be checked.\n function onAuctionPartiallyFilled(Auction auction) internal view override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n }\n\n function isDepositLiquidationInProgress(IDeposit deposit)\n internal\n view\n returns (bool)\n {\n uint256 state = deposit.currentState();\n\n return (state == DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE ||\n state == DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE);\n }\n}\n\n/// @title RiskManagerV1Rewards\n/// @notice Contains logic responsible for calculating notifier rewards for\n/// both deposit liquidation start and deposit liquidated events.\n/// All parameters can be updated using a two-phase process.\n/// @dev The client contract should take care of authorizations or governance\n/// delays according to their needs.\n/* solhint-disable-next-line ordering */\nlibrary RiskManagerV1Rewards {\n struct Storage {\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about the start of deposit liquidation process.\n uint256 liquidationNotifierReward;\n uint256 newLiquidationNotifierReward;\n uint256 liquidationNotifierRewardChangeInitiated;\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about a deposit being liquidated outside of the\n // coverage pool.\n uint256 liquidatedNotifierReward;\n uint256 newLiquidatedNotifierReward;\n uint256 liquidatedNotifierRewardChangeInitiated;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward.\n function beginLiquidationNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidationNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidationNotifierReward = _newLiquidationNotifierReward;\n self.liquidationNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n function finalizeLiquidationNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidationNotifierReward = self.newLiquidationNotifierReward;\n self.newLiquidationNotifierReward = 0;\n self.liquidationNotifierRewardChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidatedNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidatedNotifierReward = _newLiquidatedNotifierReward;\n self.liquidatedNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n function finalizeLiquidatedNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidatedNotifierReward = self.newLiquidatedNotifierReward;\n self.newLiquidatedNotifierReward = 0;\n self.liquidatedNotifierRewardChangeInitiated = 0;\n }\n}\n" + }, + "contracts/SignerBondsManualSwap.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title SignerBondsManualSwap\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsManualSwap strategy allows the governance to withdraw\n/// the bonds from the risk manager and do the swap manually.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsManualSwap is ISignerBondsSwapStrategy, Ownable {\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Withdraws collected bonds to the given target address.\n /// @dev Can be called by the governance only.\n /// @param recipient Arbitrary recipient address chosen by the governance\n /// that will be responsible for swapping ETH and depositing\n /// collateral to the coverage pool.\n function withdrawSignerBonds(\n IRiskManagerV1 riskManager,\n uint256 amount,\n address payable recipient\n ) external onlyOwner {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n require(recipient != address(0), \"Invalid recipient address\");\n\n riskManager.withdrawSignerBonds(amount);\n\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls,arbitrary-send\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n}\n" + }, + "contracts/SignerBondsUniswapV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\nimport \"./CoveragePool.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @notice Interface for the Uniswap v2 router.\n/// @dev This is an interface with just a few function signatures of the\n/// router contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/router02\ninterface IUniswapV2Router {\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function factory() external pure returns (address);\n\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure returns (address);\n}\n\n/// @notice Interface for the Uniswap v2 pair.\n/// @dev This is an interface with just a few function signatures of the\n/// pair contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/pair\ninterface IUniswapV2Pair {\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n}\n\n/// @title SignerBondsUniswapV2\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsUniswapV2 is a swap strategy implementation which\n/// can withdraw the given bonds amount from the risk manager, swap them\n/// on Uniswap v2 exchange and deposit as coverage pool collateral.\n/// The governance can set crucial swap parameters: max allowed\n/// percentage impact, slippage tolerance and swap deadline, to force\n/// reasonable swap outcomes. It is up to the governance to decide what\n/// these values should be.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsUniswapV2 is ISignerBondsSwapStrategy, Ownable {\n // One basis point is equivalent to 1/100th of a percent.\n uint256 public constant BASIS_POINTS_DIVISOR = 10000;\n\n IUniswapV2Router public immutable uniswapRouter;\n IUniswapV2Pair public immutable uniswapPair;\n address public immutable assetPool;\n address public immutable collateralToken;\n\n mapping(address => bool) public approvedSwappers;\n\n // Determines the maximum allowed price impact for the swap transaction.\n // If transaction's price impact is higher, transaction will be reverted.\n // Default value is 100 basis points (1%).\n uint256 public maxAllowedPriceImpact = 100;\n // Determines the slippage tolerance for the swap transaction.\n // If transaction's slippage is higher, transaction will be reverted.\n // Default value is 50 basis points (0.5%).\n uint256 public slippageTolerance = 50;\n // Determines the deadline in which the swap transaction has to be mined.\n // If that deadline is exceeded, transaction will be reverted.\n uint256 public swapDeadline = 20 minutes;\n // Determines if the swap should revert when open auctions exists. If true,\n // swaps cannot be performed if there is at least one open auction.\n // If false, open auctions are not taken into account.\n bool public revertIfAuctionOpen = true;\n\n event SignerBondsSwapperApproved(address swapper);\n event SignerBondsSwapperUnapproved(address swapper);\n event UniswapV2SwapExecuted(uint256[] amounts);\n\n /// @notice Reverts if called by a signer bonds swapper that is not approved\n modifier onlyApprovedSwapper() {\n require(\n approvedSwappers[msg.sender],\n \"Signer bonds swapper not approved\"\n );\n _;\n }\n\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool) {\n uniswapRouter = _uniswapRouter;\n assetPool = address(_coveragePool.assetPool());\n address _collateralToken = address(_coveragePool.collateralToken());\n collateralToken = _collateralToken;\n uniswapPair = IUniswapV2Pair(\n computePairAddress(\n _uniswapRouter.factory(),\n _uniswapRouter.WETH(),\n _collateralToken\n )\n );\n }\n\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n /// @dev Do not send arbitrary funds. They will be locked forever.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Sets the maximum price impact allowed for a swap transaction.\n /// @param _maxAllowedPriceImpact Maximum allowed price impact specified\n /// in basis points. Value of this parameter must be between\n /// 0 and 10000 (inclusive). It should be chosen carefully as\n /// high limit level will accept transactions with high volumes.\n /// Those transactions may result in poor execution prices. Very low\n /// limit will force low swap volumes. Limit equal to 0 will\n /// effectively make swaps impossible.\n function setMaxAllowedPriceImpact(uint256 _maxAllowedPriceImpact)\n external\n onlyOwner\n {\n require(\n _maxAllowedPriceImpact <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n maxAllowedPriceImpact = _maxAllowedPriceImpact;\n }\n\n /// @notice Sets the slippage tolerance for a swap transaction.\n /// @param _slippageTolerance Slippage tolerance in basis points. Value of\n /// this parameter must be between 0 and 10000 (inclusive). It\n /// should be chosen carefully as transactions with high slippage\n /// tolerance result in poor execution prices. On the other hand,\n /// very low slippage tolerance may cause transactions to be\n /// reverted frequently. Slippage tolerance equal to 0 is possible\n /// and disallows any slippage to happen on the swap at the cost\n /// of higher revert risk.\n function setSlippageTolerance(uint256 _slippageTolerance)\n external\n onlyOwner\n {\n require(\n _slippageTolerance <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n slippageTolerance = _slippageTolerance;\n }\n\n /// @notice Sets the deadline for a swap transaction.\n /// @param _swapDeadline Swap deadline in seconds. Value of this parameter\n /// should be equal or greater than 0. It should be chosen carefully\n /// as transactions with long deadlines may result in poor execution\n /// prices. On the other hand, very short deadlines may cause\n /// transactions to be reverted frequently, especially in a\n /// gas-expensive environment. Deadline equal to 0 will effectively\n // make swaps impossible.\n function setSwapDeadline(uint256 _swapDeadline) external onlyOwner {\n swapDeadline = _swapDeadline;\n }\n\n /// @notice Sets whether a swap should revert if at least one\n /// open auction exists.\n /// @param _revertIfAuctionOpen If true, revert the swap if there is at\n /// least one open auction. If false, open auctions won't be taken\n /// into account.\n function setRevertIfAuctionOpen(bool _revertIfAuctionOpen)\n external\n onlyOwner\n {\n revertIfAuctionOpen = _revertIfAuctionOpen;\n }\n\n /// @notice Swaps signer bonds on Uniswap v2 exchange.\n /// @dev Swaps the given ETH amount for the collateral token using the\n /// Uniswap exchange. The maximum ETH amount is capped by the\n /// contract balance. Some governance parameters are applied on the\n /// transaction. The swap's price impact must fit within the\n /// maximum allowed price impact and the transaction is constrained\n /// with the slippage tolerance and deadline. Acquired collateral\n /// tokens are sent to the asset pool address set during\n /// contract construction.\n /// @param riskManager Address of the risk manager which holds the bonds.\n /// @param amount Amount to swap.\n function swapSignerBondsOnUniswapV2(\n IRiskManagerV1 riskManager,\n uint256 amount\n ) external onlyApprovedSwapper {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n\n if (revertIfAuctionOpen) {\n require(!riskManager.hasOpenAuctions(), \"There are open auctions\");\n }\n\n riskManager.withdrawSignerBonds(amount);\n\n // Setup the swap path. WETH must be the first component.\n address[] memory path = new address[](2);\n path[0] = uniswapRouter.WETH();\n path[1] = collateralToken;\n\n // Calculate the maximum output token amount basing on pair reserves.\n // This value will be used as the minimum amount of output tokens that\n // must be received for the transaction not to revert.\n // This value includes liquidity fee equal to 0.3%.\n uint256 amountOutMin = uniswapRouter.getAmountsOut(amount, path)[1];\n\n require(\n isAllowedPriceImpact(amountOutMin),\n \"Price impact exceeds allowed limit\"\n );\n\n // Include slippage tolerance into the minimum amount of output tokens.\n amountOutMin =\n (amountOutMin * (BASIS_POINTS_DIVISOR - slippageTolerance)) /\n BASIS_POINTS_DIVISOR;\n\n // slither-disable-next-line arbitrary-send,reentrancy-events\n uint256[] memory amounts = uniswapRouter.swapExactETHForTokens{\n value: amount\n }(\n amountOutMin,\n path,\n assetPool,\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp + swapDeadline\n );\n\n emit UniswapV2SwapExecuted(amounts);\n }\n\n /// @notice Approves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be approved\n function approveSwapper(address swapper) external onlyOwner {\n require(\n !approvedSwappers[swapper],\n \"Signer bonds swapper has been already approved\"\n );\n emit SignerBondsSwapperApproved(swapper);\n approvedSwappers[swapper] = true;\n }\n\n /// @notice Unapproves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be unapproved\n function unapproveSwapper(address swapper) external onlyOwner {\n require(\n approvedSwappers[swapper],\n \"Signer bonds swapper is not approved\"\n );\n emit SignerBondsSwapperUnapproved(swapper);\n delete approvedSwappers[swapper];\n }\n\n /// @notice Checks the price impact of buying a given amount of tokens\n /// against the maximum allowed price impact limit.\n /// @param amount Amount of tokens.\n /// @return True if the price impact is allowed, false otherwise.\n function isAllowedPriceImpact(uint256 amount) public view returns (bool) {\n // Get reserve of the collateral token.\n address WETH = uniswapRouter.WETH();\n address token0 = WETH < collateralToken ? WETH : collateralToken;\n (uint256 reserve0, uint256 reserve1, ) = uniswapPair.getReserves();\n uint256 collateralTokenReserve = WETH == token0 ? reserve1 : reserve0;\n\n // Same as: priceImpact <= priceImpactLimit\n return\n amount * BASIS_POINTS_DIVISOR <=\n maxAllowedPriceImpact * collateralTokenReserve;\n }\n\n /// @notice Compute Uniswap v2 pair address.\n /// @param factory Address of the Uniswap v2 factory.\n /// @param tokenA Address of token A.\n /// @param tokenB Address of token B.\n /// @return Address of token pair.\n function computePairAddress(\n address factory,\n address tokenA,\n address tokenB\n ) internal pure returns (address) {\n (address token0, address token1) = tokenA < tokenB\n ? (tokenA, tokenB)\n : (tokenB, tokenA);\n\n return\n address(\n uint160(\n uint256(\n keccak256(\n abi.encodePacked(\n hex\"ff\",\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex\"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\"\n )\n )\n )\n )\n );\n }\n}\n" + }, + "contracts/test/AuctioneerStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../Auctioneer.sol\";\n\ncontract AuctioneerStub is Auctioneer {\n event AuctionEarlyClosed(uint256 transferredAmount);\n\n constructor(CoveragePool _coveragePool, address _masterAuction)\n Auctioneer(_coveragePool, _masterAuction)\n {}\n\n /// @dev This fallback function is needed by the `impersonateAccount`\n /// test helper function.\n receive() external payable {}\n\n function publicCreateAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) public {\n createAuction(tokenAccepted, amountDesired, auctionLength);\n }\n\n function publicEarlyCloseAuction(Auction auction) public {\n uint256 transferredAmount = earlyCloseAuction(auction);\n emit AuctionEarlyClosed(transferredAmount);\n }\n}\n" + }, + "contracts/test/AuctionStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAuction.sol\";\n\ncontract AuctionStub is IAuction {\n uint256 public divisor;\n uint256 public offer;\n uint256 public amountOutstanding;\n\n event TakeOffer(uint256 amount);\n\n /// @dev Simulates calling Auction.takeOffer(amount) from the\n /// AuctionBidder contract.\n function takeOffer(uint256 amount) external override {\n emit TakeOffer(amount);\n }\n\n function onOffer() external view override returns (uint256, uint256) {\n return (offer, divisor);\n }\n\n function setOnOffer(uint256 _onOffer) public {\n offer = _onOffer;\n }\n\n function setDivisor(uint256 _divisor) public {\n divisor = _divisor;\n }\n\n function setAmountOutstanding(uint256 _amountOutstanding) public {\n amountOutstanding = _amountOutstanding;\n }\n}\n" + }, + "contracts/test/CoveragePoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../CoveragePoolConstants.sol\";\n\ncontract CoveragePoolStub {\n uint256 public covTotalSupply;\n\n event PortionSeized(address indexed recipient, uint256 portionToSeize);\n event AssetPoolSharesGranted(address indexed recipient, uint256 covAmount);\n\n function seizePortion(address recipient, uint256 portionToSeize) external {\n emit PortionSeized(recipient, portionToSeize);\n }\n\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n {\n emit AssetPoolSharesGranted(recipient, covAmount);\n }\n}\n" + }, + "contracts/test/DepositStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../RiskManagerV1.sol\";\n\n/// @dev tBTC v1 deposit interface with a subset of functions used by unit and\n/// system tests. For more information about tBTC Deposit, please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface ITBTCDeposit is IDeposit {\n function notifyRedemptionSignatureTimedOut() external;\n}\n\n/// @dev Stub contract simulating - in a simplified way - behavior of tBTC v1\n/// deposit when it comes to purchasing signer bonds. This is _not_\n/// a complete tBTC v1 Deposit implementation.\ncontract DepositStub is ITBTCDeposit {\n using SafeERC20 for IERC20;\n\n enum States {\n // DOES NOT EXIST YET\n START,\n // FUNDING FLOW\n AWAITING_SIGNER_SETUP,\n AWAITING_BTC_FUNDING_PROOF,\n // FAILED SETUP\n FAILED_SETUP,\n // ACTIVE\n ACTIVE, // includes courtesy call\n // REDEMPTION FLOW\n AWAITING_WITHDRAWAL_SIGNATURE,\n AWAITING_WITHDRAWAL_PROOF,\n REDEEMED,\n // SIGNER LIQUIDATION FLOW\n COURTESY_CALL,\n FRAUD_LIQUIDATION_IN_PROGRESS,\n LIQUIDATION_IN_PROGRESS,\n LIQUIDATED\n }\n\n IERC20 public tbtcToken;\n uint256 public override lotSizeTbtc;\n uint256 public override currentState;\n uint256 public override auctionValue;\n\n address public buyer;\n\n constructor(IERC20 _tbtcToken, uint256 _lotSizeTbtc) {\n tbtcToken = _tbtcToken;\n lotSizeTbtc = _lotSizeTbtc;\n currentState = 4; // active by default\n }\n\n /// @dev Needed to receive ETH bonds at deposit setup.\n receive() external payable {}\n\n function withdrawFunds() external override {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = buyer.call{value: address(this).balance}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n function purchaseSignerBondsAtAuction() external override {\n require(\n currentState == uint256(States.LIQUIDATION_IN_PROGRESS),\n \"Not in liquidation\"\n );\n currentState = uint256(States.LIQUIDATED);\n buyer = msg.sender;\n tbtcToken.safeTransferFrom(buyer, address(this), lotSizeTbtc);\n }\n\n function notifyUndercollateralizedLiquidation() external {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n function notifyRedemptionSignatureTimedOut() external override {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function setAuctionValue(uint256 _auctionValue) external {\n auctionValue = _auctionValue;\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function notifyFraud() external {\n currentState = uint256(States.FRAUD_LIQUIDATION_IN_PROGRESS);\n }\n\n function withdrawableAmount() external view override returns (uint256) {\n return address(this).balance;\n }\n}\n" + }, + "contracts/test/KeepAssetPool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../AssetPool.sol\";\n\ncontract KeepAssetPool is AssetPool {\n constructor(\n ICollateralToken collateralToken,\n UnderwriterToken underwriterToken,\n address rewardsManager\n ) AssetPool(collateralToken, underwriterToken, rewardsManager) {}\n\n function initGovernance(ICollateralToken _collateralToken)\n internal\n override\n {\n // KEEP does not support DAO checkpoints\n }\n}\n" + }, + "contracts/test/NewAssetPoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAssetPool.sol\";\nimport \"../interfaces/IAssetPoolUpgrade.sol\";\nimport \"../UnderwriterToken.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract NewAssetPoolStub is IAssetPoolUpgrade {\n using SafeERC20 for IERC20;\n\n IERC20 public collateralToken;\n UnderwriterToken public newUnderwriterToken;\n\n constructor(IERC20 _collateralToken, UnderwriterToken _newUnderwriterToken)\n {\n collateralToken = _collateralToken;\n newUnderwriterToken = _newUnderwriterToken;\n }\n\n function depositFor(address underwriter, uint256 collateralAmount)\n external\n override\n {\n collateralToken.safeTransferFrom(\n msg.sender,\n address(this),\n collateralAmount\n );\n // In a real contract amount of new cov tokens will be calculated based\n // on certain rules.\n // For testing purposes, cov tokens amount = collateral tokens amount\n newUnderwriterToken.mint(underwriter, collateralAmount);\n }\n}\n" + }, + "contracts/test/RiskManagerV1Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract RiskManagerV1Stub is RiskManagerV1 {\n using SafeERC20 for IERC20;\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n )\n RiskManagerV1(\n _tbtcToken,\n _tbtcDepositToken,\n _coveragePool,\n _signerBondsSwapStrategy,\n _masterAuction,\n _auctionLength,\n _bondAuctionThreshold\n )\n {}\n\n function fundTbtcSurplus(uint256 amount) external {\n tbtcToken.safeTransferFrom(msg.sender, address(this), amount);\n tbtcSurplus = tbtcSurplus + amount;\n }\n}\n" + }, + "contracts/test/SignerBondsUniswapV2Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract SignerBondsUniswapV2Stub is SignerBondsUniswapV2 {\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool)\n SignerBondsUniswapV2(_uniswapRouter, _coveragePool)\n {}\n}\n" + }, + "contracts/test/TBTCDepositTokenStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract TBTCDepositTokenStub is ITBTCDepositToken {\n mapping(uint256 => bool) public tokenIds;\n\n function setExists(uint256 tokenId, bool _exists) external {\n tokenIds[tokenId] = _exists;\n }\n\n function exists(uint256 tokenId) external view override returns (bool) {\n return tokenIds[tokenId];\n }\n}\n" + }, + "contracts/test/TestSimpleBeneficiary.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n// Simple beneficiary that does nothing when notified that it has received\n// tokens.\ncontract TestSimpleBeneficiary {\n function __escrowSentTokens(uint256 amount) external {}\n}\n" + }, + "contracts/test/TestToken.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/ICollateralToken.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\n\n/// @title Test ERC-20 token\n/// @dev Token with unlimited minting capacity. It does implement DAO-related\n/// functions from ICollateralToken but with just a dummy code.\n/// Implementation of DAO checkpoints is complex. Even if we used\n/// `Checkpoints` contract from `threshold-network` here, it would require\n/// implementation for `delegate(address delegator, address delegatee)` and\n/// updating checkpoints in `beforeTokenTransfer(address from, address to, uint amount)`\n/// of TestToken. Every time DAO related functions need to be tested, please\n/// use real token with proper DAO implementation, such as `T`.\ncontract TestToken is ERC20WithPermit, ICollateralToken {\n mapping(address => address) public delegatee;\n\n /* solhint-disable-next-line no-empty-blocks */\n constructor() ERC20WithPermit(\"Test Token\", \"TT\") {}\n\n function delegate(address _delegatee) external virtual {\n delegatee[msg.sender] = _delegatee;\n }\n\n function getPastVotes(address, uint256) external pure returns (uint96) {\n return 0;\n }\n}\n" + }, + "contracts/test/UniswapV2RouterStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract UniswapV2RouterStub is IUniswapV2Router {\n // Settable fake exchange rate is defined here to avoid pair logic complexity.\n // It determines how much tokens can be received for 1 ETH.\n uint256 public exchangeRate = 1;\n\n event SwapExactETHForTokensExecuted(\n uint256 amountOutMin,\n address[] path,\n address to,\n uint256 deadline\n );\n\n function setExchangeRate(uint256 _exchangeRate) external {\n exchangeRate = _exchangeRate;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one. Emits an event with input parameters.\n /// Calculates returned amounts to behave like a real method.\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable override returns (uint256[] memory amounts) {\n require(msg.value > 0, \"Amount must be grater than zero\");\n\n emit SwapExactETHForTokensExecuted(amountOutMin, path, to, deadline);\n\n amounts = new uint256[](2);\n amounts[0] = msg.value;\n amounts[1] = (msg.value * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one.\n function getAmountsOut(uint256 amountIn, address[] calldata)\n external\n view\n override\n returns (uint256[] memory amounts)\n {\n amounts = new uint256[](2);\n amounts[0] = amountIn;\n amounts[1] = (amountIn * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n function factory() external pure override returns (address) {\n return 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure override returns (address) {\n return 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n }\n}\n" + }, + "contracts/UnderwriterToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\";\n\n/// @title UnderwriterToken\n/// @notice Underwriter tokens represent an ownership share in the underlying\n/// collateral of the asset-specific pool. Underwriter tokens are minted\n/// when a user deposits ERC20 tokens into asset-specific pool and they\n/// are burned when a user exits the position. Underwriter tokens\n/// natively support meta transactions. Users can authorize a transfer\n/// of their underwriter tokens with a signature conforming EIP712\n/// standard instead of an on-chain transaction from their address.\n/// Anyone can submit this signature on the user's behalf by calling the\n/// permit function, as specified in EIP2612 standard, paying gas fees,\n/// and possibly performing other actions in the same transaction.\n// slither-disable-next-line missing-inheritance\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor(string memory _name, string memory _symbol)\n ERC20WithPermit(_name, _symbol)\n {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n /// @notice Moves voting power when tokens are minted, burned or transferred.\n /// @dev Overrides the empty function from the parent contract.\n /// @param from The address that loses tokens and voting power\n /// @param to The address that gains tokens and voting power\n /// @param amount The amount of tokens and voting power that is transferred\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\n }\n\n moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /// @notice Delegate votes from `delegator` to `delegatee`.\n /// @param delegator The address to delegate votes from\n /// @param delegatee The address to delegate votes to\n function delegate(address delegator, address delegatee) internal override {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/v2/RewardsPoolV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title RewardTokenMinting\n/// @notice Implements minting of reward tokens for registered Asset Pools with\n/// a reward rate assigned individually for each Asset Pool.\n/// Each Asset Pool is assigned a relative rate establishing a way for\n/// Governance to incentivize different assets to target a particular\n/// Collateral Pool composition.\n/// @dev Contract is not meant to be deployed directly. It implements\n/// a specific part of the functionality of the RewardPool and should be\n/// used only as a RewardPool parent contract.\nabstract contract RewardTokenMinting {\n // Reward rate per Asset Pool address.\n // Reward rate is 1e18 precision number.\n mapping(address => uint256) public rewardRates;\n\n // The last time minting rates were updated.\n uint256 public lastUpdateTime;\n\n uint256 internal tokenPerRateUnitAccumulated;\n mapping(address => uint256) internal poolTokenPerRateUnitPaid;\n mapping(address => uint256) internal poolTokens;\n\n // TODO: should be internal and used by governance function with a delay\n function setRewardRate(address assetPool, uint256 rewardRate) external {\n updateReward(assetPool);\n rewardRates[assetPool] = rewardRate;\n }\n\n function earned(address assetPool) public view returns (uint256) {\n return\n rewardRates[assetPool] *\n (tokenPerRateUnit() - poolTokenPerRateUnitPaid[assetPool]) +\n poolTokens[assetPool];\n }\n\n function updateReward(address assetPool) internal {\n tokenPerRateUnitAccumulated = tokenPerRateUnit();\n /* solhint-disable-next-line not-rely-on-time */\n lastUpdateTime = block.timestamp;\n poolTokens[assetPool] = earned(assetPool);\n poolTokenPerRateUnitPaid[assetPool] = tokenPerRateUnitAccumulated;\n }\n\n function tokenPerRateUnit() internal view returns (uint256) {\n return\n tokenPerRateUnitAccumulated +\n (/* solhint-disable-next-line not-rely-on-time */\n block.timestamp - lastUpdateTime);\n }\n}\n\n/// @title RewardsPool\n/// @notice Rewards Pool is a contract that accepts arbitrary assets and mints\n/// a single reward token. Recipients of the reward token can at any\n/// time turn it in for a portion of the rewards in the pool.\n/// A rewards pool maintains a governable list of recipients and\n/// relative reward rates. For example, a rewards pool might have two\n/// recipients — a WETH Asset Pool, and a WBTC asset pool, with\n/// respective reward rates of 1 and 2. Rewards tokens are minted\n/// constantly over time and distributed according to the relative\n/// reward rates. Reward rates allows establishing a way for Governance\n/// to incentivize different assets to target a particular Collateral\n/// Pool composition.\ncontract RewardPoolV2 is RewardTokenMinting {\n // TODO: Add function to update reward rate with a governance delay.\n // TODO: Allow to withdraw rewards based on the amount of reward tokens.\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": false, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "storageLayout", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + }, + "libraries": {} + } +} \ No newline at end of file diff --git a/artifacts/solcInputs/b466ba551e3f54d5eed446f39b17a223.json b/artifacts/solcInputs/b466ba551e3f54d5eed446f39b17a223.json new file mode 100644 index 00000000..ee0a0e6e --- /dev/null +++ b/artifacts/solcInputs/b466ba551e3f54d5eed446f39b17a223.json @@ -0,0 +1,197 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.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 /**\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 / b + (a % b == 0 ? 0 : 1);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@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" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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 Context {\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" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.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 IERC165 {\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" + }, + "@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 // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `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" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/clone/CloneFactory.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.5;\n\n/*\nThe MIT License (MIT)\nCopyright (c) 2018 Murray Software, LLC.\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n/// @notice Implementation of [EIP-1167] based on [clone-factory]\n/// source code.\n///\n/// EIP 1167: https://eips.ethereum.org/EIPS/eip-1167\n// Original implementation: https://github.com/optionality/clone-factory\n// Modified to use ^0.8.5; instead of ^0.4.23 solidity version.\n/* solhint-disable no-inline-assembly */\nabstract contract CloneFactory {\n /// @notice Creates EIP-1167 clone of the contract under the provided\n /// `target` address. Returns address of the created clone.\n /// @dev In specific circumstances, such as the `target` contract destroyed,\n /// create opcode may return 0x0 address. The code calling this\n /// function should handle this corner case properly.\n function createClone(address target) internal returns (address result) {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000\n )\n mstore(add(clone, 0x14), targetBytes)\n mstore(\n add(clone, 0x28),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n result := create(0, clone, 0x37)\n }\n }\n\n /// @notice Checks if the contract under the `query` address is a EIP-1167\n /// clone of the contract under `target` address.\n function isClone(address target, address query)\n internal\n view\n returns (bool result)\n {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000\n )\n mstore(add(clone, 0xa), targetBytes)\n mstore(\n add(clone, 0x1e),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n\n let other := add(clone, 0x40)\n extcodecopy(query, other, 0, 0x2d)\n result := and(\n eq(mload(clone), mload(other)),\n eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))\n )\n }\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport \"./IERC20WithPermit.sol\";\nimport \"./IReceiveApproval.sol\";\n\n/// @title ERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\n /// @notice The amount of tokens owned by the given account.\n mapping(address => uint256) public override balanceOf;\n\n /// @notice The remaining number of tokens that spender will be\n /// allowed to spend on behalf of owner through `transferFrom` and\n /// `burnFrom`. This is zero by default.\n mapping(address => mapping(address => uint256)) public override allowance;\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n mapping(address => uint256) public override nonce;\n\n uint256 public immutable cachedChainId;\n bytes32 public immutable cachedDomainSeparator;\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n bytes32 public constant override PERMIT_TYPEHASH =\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n /// @notice The amount of tokens in existence.\n uint256 public override totalSupply;\n\n /// @notice The name of the token.\n string public override name;\n\n /// @notice The symbol of the token.\n string public override symbol;\n\n /// @notice The decimals places of the token.\n uint8 public constant override decimals = 18;\n\n constructor(string memory _name, string memory _symbol) {\n name = _name;\n symbol = _symbol;\n\n cachedChainId = block.chainid;\n cachedDomainSeparator = buildDomainSeparator();\n }\n\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address,\n /// - the caller must have a balance of at least `amount`.\n function transfer(address recipient, uint256 amount)\n external\n override\n returns (bool)\n {\n _transfer(msg.sender, recipient, amount);\n return true;\n }\n\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\n /// allowance mechanism. `amount` is then deducted from the caller's\n /// allowance unless the allowance was made for `type(uint256).max`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `spender` and `recipient` cannot be the zero address,\n /// - `spender` must have a balance of at least `amount`,\n /// - the caller must have allowance for `spender`'s tokens of at least\n /// `amount`.\n function transferFrom(\n address spender,\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n uint256 currentAllowance = allowance[spender][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Transfer amount exceeds allowance\"\n );\n _approve(spender, msg.sender, currentAllowance - amount);\n }\n _transfer(spender, recipient, amount);\n return true;\n }\n\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire. If the `amount` is set\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\n /// not reduce an allowance.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Permission expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n PERMIT_TYPEHASH,\n owner,\n spender,\n amount,\n nonce[owner]++,\n deadline\n )\n )\n )\n );\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == owner,\n \"Invalid signature\"\n );\n _approve(owner, spender, amount);\n }\n\n /// @notice Creates `amount` tokens and assigns them to `account`,\n /// increasing the total supply.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address.\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(recipient != address(0), \"Mint to the zero address\");\n\n beforeTokenTransfer(address(0), recipient, amount);\n\n totalSupply += amount;\n balanceOf[recipient] += amount;\n emit Transfer(address(0), recipient, amount);\n }\n\n /// @notice Destroys `amount` tokens from the caller.\n /// @dev Requirements:\n /// - the caller must have a balance of at least `amount`.\n function burn(uint256 amount) external override {\n _burn(msg.sender, amount);\n }\n\n /// @notice Destroys `amount` of tokens from `account` using the allowance\n /// mechanism. `amount` is then deducted from the caller's allowance\n /// unless the allowance was made for `type(uint256).max`.\n /// @dev Requirements:\n /// - `account` must have a balance of at least `amount`,\n /// - the caller must have allowance for `account`'s tokens of at least\n /// `amount`.\n function burnFrom(address account, uint256 amount) external override {\n uint256 currentAllowance = allowance[account][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Burn amount exceeds allowance\"\n );\n _approve(account, msg.sender, currentAllowance - amount);\n }\n _burn(account, amount);\n }\n\n /// @notice Calls `receiveApproval` function on spender previously approving\n /// the spender to withdraw from the caller multiple times, up to\n /// the `amount` amount. If this function is called again, it\n /// overwrites the current allowance with `amount`. Reverts if the\n /// approval reverted or if `receiveApproval` call on the spender\n /// reverted.\n /// @return True if both approval and `receiveApproval` calls succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external override returns (bool) {\n if (approve(spender, amount)) {\n IReceiveApproval(spender).receiveApproval(\n msg.sender,\n amount,\n address(this),\n extraData\n );\n return true;\n }\n return false;\n }\n\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\n /// tokens.\n /// @return True if the operation succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n /// Beware that changing an allowance with this method brings the risk\n /// that someone may use both the old and the new allowance by\n /// unfortunate transaction ordering. One possible solution to mitigate\n /// this race condition is to first reduce the spender's allowance to 0\n /// and set the desired value afterwards:\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n function approve(address spender, uint256 amount)\n public\n override\n returns (bool)\n {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\n // chainId and is defined at contract deployment instead of\n // reconstructed for every signature, there is a risk of possible replay\n // attacks between chains in the event of a future chain split.\n // To address this issue, we check the cached chain ID against the\n // current one and in case they are different, we build domain separator\n // from scratch.\n if (block.chainid == cachedChainId) {\n return cachedDomainSeparator;\n } else {\n return buildDomainSeparator();\n }\n }\n\n /// @dev Hook that is called before any transfer of tokens. This includes\n /// minting and burning.\n ///\n /// Calling conditions:\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\n /// will be to transferred to `to`.\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n /// - `from` and `to` are never both zero.\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _burn(address account, uint256 amount) internal {\n uint256 currentBalance = balanceOf[account];\n require(currentBalance >= amount, \"Burn amount exceeds balance\");\n\n beforeTokenTransfer(account, address(0), amount);\n\n balanceOf[account] = currentBalance - amount;\n totalSupply -= amount;\n emit Transfer(account, address(0), amount);\n }\n\n function _transfer(\n address spender,\n address recipient,\n uint256 amount\n ) private {\n require(spender != address(0), \"Transfer from the zero address\");\n require(recipient != address(0), \"Transfer to the zero address\");\n require(recipient != address(this), \"Transfer to the token address\");\n\n beforeTokenTransfer(spender, recipient, amount);\n\n uint256 spenderBalance = balanceOf[spender];\n require(spenderBalance >= amount, \"Transfer amount exceeds balance\");\n balanceOf[spender] = spenderBalance - amount;\n balanceOf[recipient] += amount;\n emit Transfer(spender, recipient, amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) private {\n require(owner != address(0), \"Approve from the zero address\");\n require(spender != address(0), \"Approve to the zero address\");\n allowance[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function buildDomainSeparator() private view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n ),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n block.chainid,\n address(this)\n )\n );\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by tokens supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IApproveAndCall {\n /// @notice Executes `receiveApproval` function on spender as specified in\n /// `IReceiveApproval` interface. Approves spender to withdraw from\n /// the caller multiple times, up to the `amount`. If this\n /// function is called again, it overwrites the current allowance\n /// with `amount`. Reverts if the approval reverted or if\n /// `receiveApproval` call on the spender reverted.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external returns (bool);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"./IApproveAndCall.sol\";\n\n/// @title IERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /// @notice Destroys `amount` tokens from the caller.\n function burn(uint256 amount) external;\n\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\n /// from caller's allowance.\n function burnFrom(address account, uint256 amount) external;\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n function nonce(address owner) external view returns (uint256);\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n /* solhint-disable-next-line func-name-mixedcase */\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by contracts supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IReceiveApproval {\n /// @notice Receives approval to spend tokens. Called as a result of\n /// `approveAndCall` call on the token.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external;\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title MisfundRecovery\n/// @notice Allows the owner of the token contract extending MisfundRecovery\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\n/// contract address.\ncontract MisfundRecovery is Ownable {\n using SafeERC20 for IERC20;\n\n function recoverERC20(\n IERC20 token,\n address recipient,\n uint256 amount\n ) external onlyOwner {\n token.safeTransfer(recipient, amount);\n }\n\n function recoverERC721(\n IERC721 token,\n address recipient,\n uint256 tokenId,\n bytes calldata data\n ) external onlyOwner {\n token.safeTransferFrom(address(this), recipient, tokenId, data);\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"./IVotesHistory.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\";\n\n/// @title Checkpoints\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\n/// delegation. This implementation supports token supply up to 2^96 - 1.\n/// This contract keeps a history (checkpoints) of each account's vote\n/// power. Vote power can be delegated either by calling the {delegate}\n/// function directly, or by providing a signature to be used with\n/// {delegateBySig}. Voting power can be publicly queried through\n/// {getVotes} and {getPastVotes}.\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\n/// @dev This contract is upgrade-safe.\nabstract contract Checkpoints is IVotesHistory {\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n // slither-disable-next-line uninitialized-state\n mapping(address => address) internal _delegates;\n mapping(address => uint128[]) internal _checkpoints;\n uint128[] internal _totalSupplyCheckpoints;\n\n // Reserved storage space in case we need to add more variables,\n // since there are upgradeable contracts that inherit from this one.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[47] private __gap;\n\n /// @notice Emitted when an account changes their delegate.\n event DelegateChanged(\n address indexed delegator,\n address indexed fromDelegate,\n address indexed toDelegate\n );\n\n /// @notice Emitted when a balance or delegate change results in changes\n /// to an account's voting power.\n event DelegateVotesChanged(\n address indexed delegate,\n uint256 previousBalance,\n uint256 newBalance\n );\n\n function checkpoints(address account, uint32 pos)\n public\n view\n virtual\n returns (Checkpoint memory checkpoint)\n {\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\n _checkpoints[account][pos]\n );\n checkpoint = Checkpoint(fromBlock, votes);\n }\n\n /// @notice Get number of checkpoints for `account`.\n function numCheckpoints(address account)\n public\n view\n virtual\n returns (uint32)\n {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /// @notice Get the address `account` is currently delegating to.\n function delegates(address account) public view virtual returns (address) {\n return _delegates[account];\n }\n\n /// @notice Gets the current votes balance for `account`.\n /// @param account The address to get votes balance\n /// @return The number of current votes for `account`\n function getVotes(address account) public view returns (uint96) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\n }\n\n /// @notice Determine the prior number of votes for an account as of\n /// a block number.\n /// @dev Block number must be a finalized block or else this function will\n /// revert to prevent misinformation.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_checkpoints[account], blockNumber);\n }\n\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\n /// Note, this value is the sum of all balances, but it is NOT the\n /// sum of all the delegated votes!\n /// @param blockNumber The block number to get the total supply at\n /// @dev `blockNumber` must have been already mined\n function getPastTotalSupply(uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\n }\n\n /// @notice Change delegation for `delegator` to `delegatee`.\n // slither-disable-next-line dead-code\n function delegate(address delegator, address delegatee) internal virtual;\n\n /// @notice Moves voting power from one delegate to another\n /// @param src Address of old delegate\n /// @param dst Address of new delegate\n /// @param amount Voting power amount to transfer between delegates\n function moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) internal {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n // https://github.com/crytic/slither/issues/960\n // slither-disable-next-line variable-scope\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[src],\n subtract,\n amount\n );\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n // https://github.com/crytic/slither/issues/959\n // slither-disable-next-line uninitialized-local\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[dst],\n add,\n amount\n );\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n /// @notice Writes a new checkpoint based on operating last stored value\n /// with a `delta`. Usually, said operation is the `add` or\n /// `subtract` functions from this contract, but more complex\n /// functions can be passed as parameters.\n /// @param ckpts The checkpoints array to use\n /// @param op The function to apply over the last value and the `delta`\n /// @param delta Variation with respect to last stored value to be used\n /// for new checkpoint\n function writeCheckpoint(\n uint128[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\n newWeight = op(oldWeight, delta);\n\n if (pos > 0) {\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\n // slither-disable-next-line incorrect-equality\n if (fromBlock == block.number) {\n ckpts[pos - 1] = encodeCheckpoint(\n fromBlock,\n SafeCastUpgradeable.toUint96(newWeight)\n );\n return (oldWeight, newWeight);\n }\n }\n\n ckpts.push(\n encodeCheckpoint(\n SafeCastUpgradeable.toUint32(block.number),\n SafeCastUpgradeable.toUint96(newWeight)\n )\n );\n }\n\n /// @notice Lookup a value in a list of (sorted) checkpoints.\n /// @param ckpts The checkpoints array to use\n /// @param blockNumber Block number when we want to get the checkpoint at\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\n internal\n view\n returns (uint96)\n {\n // We run a binary search to look for the earliest checkpoint taken\n // after `blockNumber`. During the loop, the index of the wanted\n // checkpoint remains in the range [low-1, high). With each iteration,\n // either `low` or `high` is moved towards the middle of the range to\n // maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`,\n // we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`,\n // we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the\n // right checkpoint at the index high-1, if not out of bounds (in that\n // case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for\n // `blockNumber`, we end up with an index that is past the end of the\n // array, so we technically don't find a checkpoint after\n // `blockNumber`, but it works out the same.\n require(blockNumber < block.number, \"Block not yet determined\");\n\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\n if (midBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\n }\n\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\n // slither-disable-next-line dead-code\n function maxSupply() internal view virtual returns (uint96) {\n return type(uint96).max;\n }\n\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\n /// checkpoint.\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\n /// remaining 96 bits.\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\n internal\n pure\n returns (uint128)\n {\n return (uint128(blockNumber) << 96) | uint128(value);\n }\n\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\n function decodeBlockNumber(uint128 checkpoint)\n internal\n pure\n returns (uint32)\n {\n return uint32(bytes4(bytes16(checkpoint)));\n }\n\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\n return uint96(checkpoint);\n }\n\n /// @notice Decodes a block number and voting value from a `uint128`\n /// `checkpoint`.\n function decodeCheckpoint(uint128 checkpoint)\n internal\n pure\n returns (uint32 blockNumber, uint96 value)\n {\n blockNumber = decodeBlockNumber(checkpoint);\n value = decodeValue(checkpoint);\n }\n\n // slither-disable-next-line dead-code\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n // slither-disable-next-line dead-code\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\ninterface IVotesHistory {\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n\n function getPastTotalSupply(uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"../governance/Checkpoints.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\";\n\n/// @title T token\n/// @notice Threshold Network T token\n/// @dev By default, token balance does not account for voting power.\n/// This makes transfers cheaper. The downside is that it requires users\n/// to delegate to themselves to activate checkpoints and have their\n/// voting power tracked.\ncontract T is ERC20WithPermit, MisfundRecovery, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor() ERC20WithPermit(\"Threshold Network Token\", \"T\") {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n uint96 safeAmount = SafeCast.toUint96(amount);\n\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, safeAmount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, safeAmount);\n }\n\n moveVotingPower(delegates(from), delegates(to), safeAmount);\n }\n\n function delegate(address delegator, address delegatee)\n internal\n virtual\n override\n {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/AssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPool.sol\";\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./RewardsPool.sol\";\nimport \"./UnderwriterToken.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Asset Pool\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\n/// accepts a single ERC20 token as collateral, and returns an\n/// underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\n/// as a deposit. It means that the total supply of the collateral token\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\n/// acceptable that not all tokens can be deposited into the pool.\ncontract AssetPool is Ownable, IAssetPool {\n using SafeERC20 for ICollateralToken;\n using SafeERC20 for UnderwriterToken;\n\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n RewardsPool public immutable rewardsPool;\n\n IAssetPoolUpgrade public newAssetPool;\n\n /// @notice The time it takes the underwriter to withdraw their collateral\n /// and rewards from the pool. This is the time that needs to pass\n /// between initiating and completing the withdrawal. During that\n /// time, underwriter is still earning rewards and their share of\n /// the pool is still a subject of a possible coverage claim.\n uint256 public withdrawalDelay = 21 days;\n uint256 public newWithdrawalDelay;\n uint256 public withdrawalDelayChangeInitiated;\n\n /// @notice The time the underwriter has after the withdrawal delay passed\n /// to complete the withdrawal. During that time, underwriter is\n /// still earning rewards and their share of the pool is still\n /// a subject of a possible coverage claim.\n /// After the withdrawal timeout elapses, tokens stay in the pool\n /// and the underwriter has to initiate the withdrawal again and\n /// wait for the full withdrawal delay to complete the withdrawal.\n uint256 public withdrawalTimeout = 2 days;\n uint256 public newWithdrawalTimeout;\n uint256 public withdrawalTimeoutChangeInitiated;\n\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\n mapping(address => uint256) public pendingWithdrawal;\n\n event Deposited(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount\n );\n\n event CoverageClaimed(\n address indexed recipient,\n uint256 amount,\n uint256 timestamp\n );\n\n event WithdrawalInitiated(\n address indexed underwriter,\n uint256 covAmount,\n uint256 timestamp\n );\n event WithdrawalCompleted(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event ApprovedAssetPoolUpgrade(address newAssetPool);\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\n event AssetPoolUpgraded(\n address indexed underwriter,\n uint256 collateralAmount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event WithdrawalDelayUpdateStarted(\n uint256 withdrawalDelay,\n uint256 timestamp\n );\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\n event WithdrawalTimeoutUpdateStarted(\n uint256 withdrawalTimeout,\n uint256 timestamp\n );\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\n\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\n /// if the change was not yet initiated.\n /// @param changeInitiatedTimestamp The timestamp at which the change has\n /// been initiated\n modifier onlyAfterWithdrawalGovernanceDelay(\n uint256 changeInitiatedTimestamp\n ) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >=\n withdrawalGovernanceDelay(),\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n constructor(\n ICollateralToken _collateralToken,\n UnderwriterToken _underwriterToken,\n address rewardsManager\n ) {\n collateralToken = _collateralToken;\n underwriterToken = _underwriterToken;\n\n rewardsPool = new RewardsPool(\n _collateralToken,\n address(this),\n rewardsManager\n );\n\n initGovernance(_collateralToken);\n }\n\n /// @dev Overwrite to empty if collateral token used by the AssetPool\n /// does not support DAO checkpoints. Used for tests with KEEP token.\n function initGovernance(ICollateralToken _collateralToken)\n internal\n virtual\n {\n _collateralToken.delegate(address(this));\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// Optional data in extraData may include a minimal amount of\n /// underwriter tokens expected to be minted for a depositor. There\n /// are cases when an amount of minted tokens matters for a\n /// depositor, as tokens might be used in third party exchanges.\n /// @dev This function is a shortcut for approve + deposit.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external {\n require(\n amount + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n require(msg.sender == token, \"Only token caller allowed\");\n require(\n token == address(collateralToken),\n \"Unsupported collateral token\"\n );\n\n uint256 toMint = _calculateTokensToMint(amount);\n if (extraData.length != 0) {\n require(extraData.length == 32, \"Unexpected data length\");\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n }\n\n _deposit(from, amount, toMint);\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal to\n /// 2^96-1\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amountToDeposit)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership. The amount locked in the pool after accepting\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\n /// function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal\n /// to 2^96-1\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\n /// expects to receive in exchange for the deposited\n /// collateral tokens\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Initiates the withdrawal of collateral and rewards from the\n /// pool. Must be followed with completeWithdrawal call after the\n /// withdrawal delay passes. Accepts the amount of underwriter\n /// tokens representing the share of the pool that should be\n /// withdrawn. Can be called multiple times increasing the pool share\n /// to withdraw and resetting the withdrawal initiated timestamp for\n /// each call. Can be called with 0 covAmount to reset the\n /// withdrawal initiated timestamp if the underwriter has a pending\n /// withdrawal. In practice 0 covAmount should be used only to\n /// initiate the withdrawal again in case one did not complete the\n /// withdrawal before the withdrawal timeout elapsed.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external override {\n uint256 pending = pendingWithdrawal[msg.sender];\n require(\n covAmount > 0 || pending > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n pending += covAmount;\n pendingWithdrawal[msg.sender] = pending;\n /* solhint-disable not-rely-on-time */\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\n\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\n /* solhint-enable not-rely-on-time */\n\n if (covAmount > 0) {\n underwriterToken.safeTransferFrom(\n msg.sender,\n address(this),\n covAmount\n );\n }\n }\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter. Anyone can complete the withdrawal for the\n /// underwriter. The withdrawal has to be completed before the\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\n /// be initiated again and the underwriter has to wait for the\n /// entire withdrawal delay again before being able to complete\n /// the withdrawal.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter)\n external\n override\n returns (uint256)\n {\n /* solhint-disable not-rely-on-time */\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\n require(initiatedAt > 0, \"No withdrawal initiated for the underwriter\");\n\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\n require(\n withdrawalDelayEndTimestamp < block.timestamp,\n \"Withdrawal delay has not elapsed\"\n );\n\n require(\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\n \"Withdrawal timeout elapsed\"\n );\n\n uint256 covAmount = pendingWithdrawal[underwriter];\n uint256 covSupply = underwriterToken.totalSupply();\n delete withdrawalInitiatedTimestamp[underwriter];\n delete pendingWithdrawal[underwriter];\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\n\n emit WithdrawalCompleted(\n underwriter,\n amountToWithdraw,\n covAmount,\n block.timestamp\n );\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\n\n /* solhint-enable not-rely-on-time */\n underwriterToken.burn(covAmount);\n\n return amountToWithdraw;\n }\n\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\n /// was approved by the governance. Upgrade does not have to obey\n /// withdrawal delay.\n /// Old underwriter tokens are burned in favor of new tokens minted\n /// in a new Asset Pool. New tokens are sent directly to the\n /// underwriter from a new Asset Pool.\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\n /// tokens which are transferred to a new asset pool\n /// @param _newAssetPool New Asset Pool address to check validity with the one\n /// that was approved by the governance\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\n external\n {\n /* solhint-disable not-rely-on-time */\n require(\n address(newAssetPool) != address(0),\n \"New asset pool must be assigned\"\n );\n\n require(\n address(newAssetPool) == _newAssetPool,\n \"Addresses of a new asset pool must match\"\n );\n\n require(\n covAmount > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n uint256 covSupply = underwriterToken.totalSupply();\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\n covSupply;\n\n collateralToken.safeApprove(\n address(newAssetPool),\n collateralToTransfer\n );\n // old underwriter tokens are burned in favor of new minted in a new\n // asset pool\n underwriterToken.burnFrom(msg.sender, covAmount);\n // collateralToTransfer will be sent to a new AssetPool and new\n // underwriter tokens will be minted and transferred back to the underwriter\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\n\n emit AssetPoolUpgraded(\n msg.sender,\n collateralToTransfer,\n covAmount,\n block.timestamp\n );\n }\n\n /// @notice Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n require(\n address(_newAssetPool) != address(0),\n \"New asset pool can't be zero address\"\n );\n\n newAssetPool = _newAssetPool;\n\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\n }\n\n /// @notice Allows governance to cancel already approved new asset pool\n /// in case of some misconfiguration.\n function cancelNewAssetPoolUpgrade() external onlyOwner {\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\n\n newAssetPool = IAssetPoolUpgrade(address(0));\n }\n\n /// @notice Allows the coverage pool to demand coverage from the asset hold\n /// by this pool and send it to the provided recipient address.\n function claim(address recipient, uint256 amount) external onlyOwner {\n emit CoverageClaimed(recipient, amount, block.timestamp);\n rewardsPool.withdraw();\n require(\n amount <= collateralToken.balanceOf(address(this)),\n \"Amount to seize exceeds the pool balance\"\n );\n collateralToken.safeTransfer(recipient, amount);\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param _newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\n external\n onlyOwner\n {\n newWithdrawalDelay = _newWithdrawalDelay;\n withdrawalDelayChangeInitiated = block.timestamp;\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\n {\n withdrawalDelay = newWithdrawalDelay;\n emit WithdrawalDelayUpdated(withdrawalDelay);\n newWithdrawalDelay = 0;\n withdrawalDelayChangeInitiated = 0;\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\n external\n onlyOwner\n {\n newWithdrawalTimeout = _newWithdrawalTimeout;\n withdrawalTimeoutChangeInitiated = block.timestamp;\n emit WithdrawalTimeoutUpdateStarted(\n _newWithdrawalTimeout,\n block.timestamp\n );\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\n {\n withdrawalTimeout = newWithdrawalTimeout;\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\n newWithdrawalTimeout = 0;\n withdrawalTimeoutChangeInitiated = 0;\n }\n\n /// @notice Grants pool shares by minting a given amount of the underwriter\n /// tokens for the recipient address. In result, the recipient\n /// obtains part of the pool ownership without depositing any\n /// collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by the contract owner.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantShares(address recipient, uint256 covAmount)\n external\n onlyOwner\n {\n rewardsPool.withdraw();\n underwriterToken.mint(recipient, covAmount);\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal delay update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal delay update can be finalized\n function getRemainingWithdrawalDelayUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalDelayChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal timeout update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal timeout update can be finalized\n function getRemainingWithdrawalTimeoutUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalTimeoutChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the current collateral token balance of the asset pool\n /// plus the reward amount (in collateral token) earned by the asset\n /// pool and not yet withdrawn to the asset pool.\n /// @return The total value of asset pool in collateral token.\n function totalValue() public view returns (uint256) {\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\n }\n\n /// @notice The time it takes to initiate and complete the withdrawal from\n /// the pool plus 2 days to make a decision. This governance delay\n /// should be used for all changes directly affecting underwriter\n /// positions. This time is a minimum and the governance may choose\n /// to wait longer before finalizing the update.\n /// @return The withdrawal governance delay in seconds\n function withdrawalGovernanceDelay() public view returns (uint256) {\n return withdrawalDelay + withdrawalTimeout + 2 days;\n }\n\n /// @dev Calculates underwriter tokens to mint.\n function _calculateTokensToMint(uint256 amountToDeposit)\n internal\n returns (uint256)\n {\n rewardsPool.withdraw();\n\n uint256 covSupply = underwriterToken.totalSupply();\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n if (covSupply == 0) {\n return amountToDeposit;\n }\n\n return (amountToDeposit * covSupply) / collateralBalance;\n }\n\n function _deposit(\n address depositor,\n uint256 amountToDeposit,\n uint256 amountToMint\n ) internal {\n require(depositor != address(this), \"Self-deposit not allowed\");\n\n require(\n amountToMint > 0,\n \"Minted tokens amount must be greater than 0\"\n );\n\n emit Deposited(depositor, amountToDeposit, amountToMint);\n\n underwriterToken.mint(depositor, amountToMint);\n collateralToken.safeTransferFrom(\n depositor,\n address(this),\n amountToDeposit\n );\n }\n}\n" + }, + "contracts/Auction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAuction.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title Auction\n/// @notice A contract to run a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\n/// pool. Auctions can be partially filled, and are meant to be amenable\n/// to flash loans and other atomic constructions to take advantage of\n/// arbitrage opportunities within a single block.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// Auction contracts are not meant to be deployed directly, and are\n/// instead cloned by an auction factory. Auction contracts clean up and\n/// self-destruct on close. An auction that has run the entire length will\n/// stay open, forever, or until priced fluctuate and it's eventually\n/// profitable to close.\ncontract Auction is IAuction {\n using SafeERC20 for IERC20;\n\n struct AuctionStorage {\n IERC20 tokenAccepted;\n Auctioneer auctioneer;\n // the auction price, denominated in tokenAccepted\n uint256 amountOutstanding;\n uint256 amountDesired;\n uint256 startTime;\n uint256 startTimeOffset;\n uint256 auctionLength;\n }\n\n AuctionStorage public self;\n address public immutable masterContract;\n\n /// @notice Throws if called by any account other than the auctioneer.\n modifier onlyAuctioneer() {\n //slither-disable-next-line incorrect-equality\n require(\n msg.sender == address(self.auctioneer),\n \"Caller is not the auctioneer\"\n );\n\n _;\n }\n\n constructor() {\n masterContract = address(this);\n }\n\n /// @notice Initializes auction\n /// @dev At the beginning of an auction, velocity pool depleting rate is\n /// always 1. It increases over time after a partial auction buy.\n /// @param _auctioneer the auctioneer contract responsible for seizing\n /// funds from the backing collateral pool\n /// @param _tokenAccepted the token with which the auction can be taken\n /// @param _amountDesired the amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param _auctionLength the amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function initialize(\n Auctioneer _auctioneer,\n IERC20 _tokenAccepted,\n uint256 _amountDesired,\n uint256 _auctionLength\n ) external {\n require(!isMasterContract(), \"Can not initialize master contract\");\n //slither-disable-next-line incorrect-equality\n require(self.startTime == 0, \"Auction already initialized\");\n require(_amountDesired > 0, \"Amount desired must be greater than zero\");\n require(_auctionLength > 0, \"Auction length must be greater than zero\");\n self.auctioneer = _auctioneer;\n self.tokenAccepted = _tokenAccepted;\n self.amountOutstanding = _amountDesired;\n self.amountDesired = _amountDesired;\n /* solhint-disable-next-line not-rely-on-time */\n self.startTime = block.timestamp;\n self.startTimeOffset = 0;\n self.auctionLength = _auctionLength;\n }\n\n /// @notice Takes an offer from an auction buyer.\n /// @dev There are two possible ways to take an offer from a buyer. The first\n /// one is to buy entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// WARNING: When calling this function directly, it might happen that\n /// the expected amount of tokens to seize from the coverage pool is\n /// different from the actual one. There are a couple of reasons for that\n /// such another bids taking this offer, claims or withdrawals on an\n /// Asset Pool that are executed in the same block. The recommended way\n /// for taking an offer is through 'AuctionBidder' contract with\n /// 'takeOfferWithMin' function, where a caller can specify the minimal\n /// value to receive from the coverage pool in exchange for its amount\n /// of tokenAccepted.\n /// @param amount the amount the taker is paying, denominated in tokenAccepted.\n /// In the scenario when amount exceeds the outstanding tokens\n /// for the auction to complete, only the amount outstanding will\n /// be taken from a caller.\n function takeOffer(uint256 amount) external override {\n require(amount > 0, \"Can't pay 0 tokens\");\n uint256 amountToTransfer = Math.min(amount, self.amountOutstanding);\n uint256 amountOnOffer = _onOffer();\n\n //slither-disable-next-line reentrancy-no-eth\n self.tokenAccepted.safeTransferFrom(\n msg.sender,\n address(self.auctioneer),\n amountToTransfer\n );\n\n uint256 portionToSeize = (amountOnOffer * amountToTransfer) /\n self.amountOutstanding;\n\n if (!isAuctionOver() && amountToTransfer != self.amountOutstanding) {\n // Time passed since the auction start or the last takeOffer call\n // with a partial fill.\n\n\n uint256 timePassed /* solhint-disable-next-line not-rely-on-time */\n = block.timestamp - self.startTime - self.startTimeOffset;\n\n // Ratio of the auction's amount included in this takeOffer call to\n // the whole outstanding auction amount.\n uint256 ratioAmountPaid = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * amountToTransfer) /\n self.amountOutstanding;\n // We will shift the start time offset and increase the velocity pool\n // depleting rate proportionally to the fraction of the outstanding\n // amount paid in this function call so that the auction can offer\n // no worse financial outcome for the next takers than the current\n // taker has.\n //\n //slither-disable-next-line divide-before-multiply\n self.startTimeOffset =\n self.startTimeOffset +\n ((timePassed * ratioAmountPaid) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n self.amountOutstanding -= amountToTransfer;\n\n //slither-disable-next-line incorrect-equality\n bool isFullyFilled = self.amountOutstanding == 0;\n\n // inform auctioneer of proceeds and winner. the auctioneer seizes funds\n // from the collateral pool in the name of the winner, and controls all\n // proceeds\n //\n //slither-disable-next-line reentrancy-no-eth\n self.auctioneer.offerTaken(\n msg.sender,\n self.tokenAccepted,\n amountToTransfer,\n portionToSeize,\n isFullyFilled\n );\n\n //slither-disable-next-line incorrect-equality\n if (isFullyFilled) {\n harikari();\n }\n }\n\n /// @notice Tears down the auction manually, before its entire amount\n /// is bought by takers.\n /// @dev Can be called only by the auctioneer which may decide to early\n // close the auction in case it is no longer needed.\n function earlyClose() external onlyAuctioneer {\n require(self.amountOutstanding > 0, \"Auction must be open\");\n\n harikari();\n }\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @dev _onOffer() / FLOATING_POINT_DIVISOR) returns a portion of the\n /// collateral pool. Ex. if 35% available of the collateral pool,\n /// then _onOffer() / FLOATING_POINT_DIVISOR) returns 0.35\n /// @return the ratio of the collateral pool currently on offer\n function onOffer() external view override returns (uint256, uint256) {\n return (_onOffer(), CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n function amountOutstanding() external view returns (uint256) {\n return self.amountOutstanding;\n }\n\n function amountTransferred() external view returns (uint256) {\n return self.amountDesired - self.amountOutstanding;\n }\n\n /// @dev Delete all storage and destroy the contract. Should only be called\n /// after an auction has closed.\n function harikari() internal {\n require(!isMasterContract(), \"Master contract can not harikari\");\n selfdestruct(payable(address(self.auctioneer)));\n }\n\n function _onOffer() internal view returns (uint256) {\n // when the auction is over, entire pool is on offer\n if (isAuctionOver()) {\n // Down the road, for determining a portion on offer, a value returned\n // by this function will be divided by FLOATING_POINT_DIVISOR. To\n // return the entire pool, we need to return just this divisor in order\n // to get 1.0 ie. FLOATING_POINT_DIVISOR / FLOATING_POINT_DIVISOR = 1.0\n return CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n\n // How fast portions of the collateral pool become available on offer.\n // It is needed to calculate the right portion value on offer at the\n // given moment before the auction is over.\n // Auction length once set is constant and what changes is the auction's\n // \"start time offset\" once the takeOffer() call has been processed for\n // partial fill. The auction's \"start time offset\" is updated every takeOffer().\n // velocityPoolDepletingRate = auctionLength / (auctionLength - startTimeOffset)\n // velocityPoolDepletingRate always starts at 1.0 and then can go up\n // depending on partial offer calls over auction life span to maintain\n // the right ratio between the remaining auction time and the remaining\n // portion of the collateral pool.\n //slither-disable-next-line divide-before-multiply\n uint256 velocityPoolDepletingRate = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * self.auctionLength) /\n (self.auctionLength - self.startTimeOffset);\n\n return\n /* solhint-disable-next-line not-rely-on-time */\n ((block.timestamp - (self.startTime + self.startTimeOffset)) *\n velocityPoolDepletingRate) / self.auctionLength;\n }\n\n function isAuctionOver() internal view returns (bool) {\n /* solhint-disable-next-line not-rely-on-time */\n return block.timestamp >= self.startTime + self.auctionLength;\n }\n\n function isMasterContract() internal view returns (bool) {\n return masterContract == address(this);\n }\n}\n" + }, + "contracts/AuctionBidder.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\n/// @title AuctionBidder\n/// @notice A contract for auction bidders for buying coverage pool auctions. This\n/// contract offers additional features for bidders to decide if their\n/// requirements for making a purchase are satisfied.\ncontract AuctionBidder {\n CoveragePool public immutable coveragePool;\n\n constructor(CoveragePool _coveragePool) {\n coveragePool = _coveragePool;\n }\n\n /// @notice Takes an offer from an auction buyer with a minimum required amount\n /// of tokens to seize from the coverage pool.\n /// @dev This contract is used only for KEEP coverage pool in v1 that was\n /// depricated. Going forward T coverage pool will be used for v2.\n /// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n ///\n /// 'minAmountToSeize' sets a minimum amount of tokens to seize in this\n /// transaction. A bidder can call `takeOffer` directly in the Auction\n /// contract but this function is a recommended way of taking coverage pool\n /// auctions. It might happen that the order of transactions might be changed\n /// for 'takeOffer' calls in the same block or claim and withdrawals from\n /// an AssetPool might occur. These reasons can affect a taker's expected\n /// amount of the coverage pool tokens to receive. Whereas if a minimum\n /// amount of tokens is specified but not satisfied, then the transaction\n /// will revert.\n /// @param auction coverage pool auction\n /// @param amount the amount a taker is paying, denominated in token accepted\n /// by the auction\n /// @param minAmountToSeize minimum amount of tokens to seize from the coverage\n /// pool\n function takeOfferWithMin(\n Auction auction,\n uint256 amount,\n uint256 minAmountToSeize\n ) external {\n uint256 auctionAmountOutstanding = auction.amountOutstanding();\n uint256 amountToPay = Math.min(amount, auctionAmountOutstanding);\n (uint256 amountOnOffer, ) = auction.onOffer();\n uint256 portionToSeize = (amountOnOffer * amountToPay) /\n auctionAmountOutstanding;\n\n uint256 amountToSeize = coveragePool.amountToSeize(portionToSeize);\n\n require(\n minAmountToSeize <= amountToSeize,\n \"Can't fulfill offer with a minimal amount to seize\"\n );\n\n auction.takeOffer(amount);\n }\n}\n" + }, + "contracts/Auctioneer.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\nimport \"@thesis/solidity-contracts/contracts/clone/CloneFactory.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Auctioneer\n/// @notice Factory for the creation of new auction clones and receiving proceeds.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// We avoid redeployment of auction contracts by using the clone factory.\n/// Proxy delegates calls to Auction and therefore does not affect auction state.\n/// This means that we only need to deploy the auction contracts once.\n/// The auctioneer provides clean state for every new auction clone.\ncontract Auctioneer is CloneFactory {\n // Holds the address of the auction contract\n // which will be used as a master contract for cloning.\n address public immutable masterAuction;\n mapping(address => bool) public openAuctions;\n uint256 public openAuctionsCount;\n\n CoveragePool public immutable coveragePool;\n\n event AuctionCreated(\n address indexed tokenAccepted,\n uint256 amount,\n address auctionAddress\n );\n event AuctionOfferTaken(\n address indexed auction,\n address indexed offerTaker,\n address tokenAccepted,\n uint256 amount,\n uint256 portionToSeize // This amount should be divided by FLOATING_POINT_DIVISOR\n );\n event AuctionClosed(address indexed auction);\n\n constructor(CoveragePool _coveragePool, address _masterAuction) {\n coveragePool = _coveragePool;\n // slither-disable-next-line missing-zero-check\n masterAuction = _masterAuction;\n }\n\n /// @notice Informs the auctioneer to seize funds and log appropriate events\n /// @dev This function is meant to be called from a cloned auction. It logs\n /// \"offer taken\" and \"auction closed\" events, seizes funds, and cleans\n /// up closed auctions.\n /// @param offerTaker The address of the taker of the auction offer,\n /// who will receive the pool's seized funds\n /// @param tokenPaid The token this auction is denominated in\n /// @param tokenAmountPaid The amount of the token the taker paid\n /// @param portionToSeize The portion of the pool the taker won at auction.\n /// This amount should be divided by FLOATING_POINT_DIVISOR\n /// to calculate how much of the pool should be set\n /// aside as the taker's winnings.\n /// @param fullyFilled Indicates whether the auction was taken fully or\n /// partially. If auction was fully filled, it is\n /// closed. If auction was partially filled, it is\n /// sill open and waiting for remaining bids.\n function offerTaken(\n address offerTaker,\n IERC20 tokenPaid,\n uint256 tokenAmountPaid,\n uint256 portionToSeize,\n bool fullyFilled\n ) external {\n require(openAuctions[msg.sender], \"Sender isn't an auction\");\n\n emit AuctionOfferTaken(\n msg.sender,\n offerTaker,\n address(tokenPaid),\n tokenAmountPaid,\n portionToSeize\n );\n\n // actually seize funds, setting them aside for the taker to withdraw\n // from the coverage pool.\n // `portionToSeize` will be divided by FLOATING_POINT_DIVISOR which is\n // defined in Auction.sol\n //\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n coveragePool.seizePortion(offerTaker, portionToSeize);\n\n Auction auction = Auction(msg.sender);\n if (fullyFilled) {\n onAuctionFullyFilled(auction);\n\n emit AuctionClosed(msg.sender);\n delete openAuctions[msg.sender];\n openAuctionsCount -= 1;\n } else {\n onAuctionPartiallyFilled(auction);\n }\n }\n\n /// @notice Opens a new auction against the coverage pool. The auction\n /// will remain open until filled.\n /// @dev Calls `Auction.initialize` to initialize the instance.\n /// @param tokenAccepted The token with which the auction can be taken\n /// @param amountDesired The amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param auctionLength The amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function createAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) internal returns (address) {\n address cloneAddress = createClone(masterAuction);\n require(cloneAddress != address(0), \"Cloned auction address is 0\");\n\n Auction auction = Auction(cloneAddress);\n //slither-disable-next-line reentrancy-benign,reentrancy-events\n auction.initialize(this, tokenAccepted, amountDesired, auctionLength);\n\n openAuctions[cloneAddress] = true;\n openAuctionsCount += 1;\n\n emit AuctionCreated(\n address(tokenAccepted),\n amountDesired,\n cloneAddress\n );\n\n return cloneAddress;\n }\n\n /// @notice Tears down an open auction with given address immediately.\n /// @dev Can be called by contract owner to early close an auction if it\n /// is no longer needed. Bear in mind that funds from the early closed\n /// auction last on the auctioneer contract. Calling code should take\n /// care of them.\n /// @return Amount of funds transferred to this contract by the Auction\n /// being early closed.\n function earlyCloseAuction(Auction auction) internal returns (uint256) {\n address auctionAddress = address(auction);\n\n require(openAuctions[auctionAddress], \"Address is not an open auction\");\n\n uint256 amountTransferred = auction.amountTransferred();\n\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n auction.earlyClose();\n\n emit AuctionClosed(auctionAddress);\n delete openAuctions[auctionAddress];\n openAuctionsCount -= 1;\n\n return amountTransferred;\n }\n\n /// @notice Auction lifecycle hook allowing to act on auction closed\n /// as fully filled. This function is not executed when an auction\n /// was partially filled. When this function is executed auction is\n /// already closed and funds from the coverage pool are seized.\n /// @dev Override this function to act on auction closed as fully filled.\n function onAuctionFullyFilled(Auction auction) internal virtual {}\n\n /// @notice Auction lifecycle hook allowing to act on auction partially\n /// filled. This function is not executed when an auction\n /// was fully filled.\n /// @dev Override this function to act on auction partially filled.\n function onAuctionPartiallyFilled(Auction auction) internal view virtual {}\n}\n" + }, + "contracts/BatchedPhasedEscrow.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Batched Phased Escrow Beneficiary\n/// @notice Interface expected from contracts receiving tokens from the\n/// BatchedPhasedEscrow.\ninterface IBeneficiaryContract {\n function __escrowSentTokens(uint256 amount) external;\n}\n\n/// @title BatchedPhasedEscrow\n/// @notice A token holder contract allowing contract owner to approve a set of\n/// beneficiaries of tokens held by the contract, to appoint a separate\n/// drawee role, and allowing that drawee to withdraw tokens to approved\n/// beneficiaries in phases.\ncontract BatchedPhasedEscrow is Ownable {\n using SafeERC20 for IERC20;\n\n event BeneficiaryApproved(address beneficiary);\n event TokensWithdrawn(address beneficiary, uint256 amount);\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\n\n IERC20 public token;\n address public drawee;\n mapping(address => bool) private approvedBeneficiaries;\n\n modifier onlyDrawee() {\n require(drawee == msg.sender, \"Caller is not the drawee\");\n _;\n }\n\n constructor(IERC20 _token) {\n token = _token;\n drawee = msg.sender;\n }\n\n /// @notice Approves the provided address as a beneficiary of tokens held by\n /// the escrow. Can be called only by escrow owner.\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\n external\n onlyOwner\n {\n address beneficiaryAddress = address(_beneficiary);\n require(\n beneficiaryAddress != address(0),\n \"Beneficiary can not be zero address\"\n );\n approvedBeneficiaries[beneficiaryAddress] = true;\n emit BeneficiaryApproved(beneficiaryAddress);\n }\n\n /// @notice Returns `true` if the given address has been approved as a\n /// beneficiary of the escrow, `false` otherwise.\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\n public\n view\n returns (bool)\n {\n return approvedBeneficiaries[address(_beneficiary)];\n }\n\n /// @notice Transfers the role of drawee to another address. Can be called\n /// only by the contract owner.\n function setDrawee(address newDrawee) external onlyOwner {\n require(newDrawee != address(0), \"New drawee can not be zero address\");\n emit DraweeRoleTransferred(drawee, newDrawee);\n drawee = newDrawee;\n }\n\n /// @notice Funds the escrow by transferring all of the approved tokens\n /// to the escrow.\n function receiveApproval(\n address _from,\n uint256 _value,\n address _token,\n bytes memory\n ) external {\n require(IERC20(_token) == token, \"Unsupported token\");\n token.safeTransferFrom(_from, address(this), _value);\n }\n\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\n /// transferring to each beneficiary the amount of tokens specified\n /// as a parameter. Only beneficiaries previously approved by escrow\n /// owner can receive funds.\n function batchedWithdraw(\n IBeneficiaryContract[] memory beneficiaries,\n uint256[] memory amounts\n ) external onlyDrawee {\n require(\n beneficiaries.length == amounts.length,\n \"Mismatched arrays length\"\n );\n\n for (uint256 i = 0; i < beneficiaries.length; i++) {\n IBeneficiaryContract beneficiary = beneficiaries[i];\n require(\n isBeneficiaryApproved(beneficiary),\n \"Beneficiary was not approved\"\n );\n withdraw(beneficiary, amounts[i]);\n }\n }\n\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\n private\n {\n emit TokensWithdrawn(address(beneficiary), amount);\n token.safeTransfer(address(beneficiary), amount);\n // slither-disable-next-line calls-loop\n beneficiary.__escrowSentTokens(amount);\n }\n}\n" + }, + "contracts/CoveragePool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./AssetPool.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Coverage Pool\n/// @notice A contract that manages a single asset pool. Handles approving and\n/// unapproving of risk managers and allows them to seize funds from the\n/// asset pool if they are approved.\n/// @dev Coverage pool contract is owned by the governance. Coverage pool is the\n/// owner of the asset pool contract.\ncontract CoveragePool is Ownable {\n AssetPool public immutable assetPool;\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n bool public firstRiskManagerApproved = false;\n\n // Currently approved risk managers\n mapping(address => bool) public approvedRiskManagers;\n // Timestamps of risk managers whose approvals have been initiated\n mapping(address => uint256) public riskManagerApprovalTimestamps;\n\n event RiskManagerApprovalStarted(address riskManager, uint256 timestamp);\n event RiskManagerApprovalCompleted(address riskManager, uint256 timestamp);\n event RiskManagerUnapproved(address riskManager, uint256 timestamp);\n\n /// @notice Reverts if called by a risk manager that is not approved\n modifier onlyApprovedRiskManager() {\n require(approvedRiskManagers[msg.sender], \"Risk manager not approved\");\n _;\n }\n\n constructor(AssetPool _assetPool) {\n assetPool = _assetPool;\n collateralToken = _assetPool.collateralToken();\n underwriterToken = _assetPool.underwriterToken();\n }\n\n /// @notice Approves the first risk manager\n /// @dev Can be called only by the contract owner. Can be called only once.\n /// Does not require any further calls to any functions.\n /// @param riskManager Risk manager that will be approved\n function approveFirstRiskManager(address riskManager) external onlyOwner {\n require(\n !firstRiskManagerApproved,\n \"The first risk manager was approved\"\n );\n approvedRiskManagers[riskManager] = true;\n firstRiskManagerApproved = true;\n }\n\n /// @notice Begins risk manager approval process.\n /// @dev Can be called only by the contract owner and only when the first\n /// risk manager is already approved. For a risk manager to be\n /// approved, a call to `finalizeRiskManagerApproval` must follow\n /// (after a governance delay).\n /// @param riskManager Risk manager that will be approved\n function beginRiskManagerApproval(address riskManager) external onlyOwner {\n require(\n firstRiskManagerApproved,\n \"The first risk manager is not yet approved; Please use \"\n \"approveFirstRiskManager instead\"\n );\n\n require(\n !approvedRiskManagers[riskManager],\n \"Risk manager already approved\"\n );\n\n /* solhint-disable-next-line not-rely-on-time */\n riskManagerApprovalTimestamps[riskManager] = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalStarted(riskManager, block.timestamp);\n }\n\n /// @notice Finalizes risk manager approval process.\n /// @dev Can be called only by the contract owner. Must be preceded with a\n /// call to beginRiskManagerApproval and a governance delay must elapse.\n /// @param riskManager Risk manager that will be approved\n function finalizeRiskManagerApproval(address riskManager)\n external\n onlyOwner\n {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0,\n \"Risk manager approval not initiated\"\n );\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - riskManagerApprovalTimestamps[riskManager] >=\n assetPool.withdrawalGovernanceDelay(),\n \"Risk manager governance delay has not elapsed\"\n );\n approvedRiskManagers[riskManager] = true;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalCompleted(riskManager, block.timestamp);\n delete riskManagerApprovalTimestamps[riskManager];\n }\n\n /// @notice Unapproves an already approved risk manager or cancels the\n /// approval process of a risk manager (the latter happens if called\n /// between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`).\n /// The change takes effect immediately.\n /// @dev Can be called only by the contract owner.\n /// @param riskManager Risk manager that will be unapproved\n function unapproveRiskManager(address riskManager) external onlyOwner {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0 ||\n approvedRiskManagers[riskManager],\n \"Risk manager is neither approved nor with a pending approval\"\n );\n delete riskManagerApprovalTimestamps[riskManager];\n delete approvedRiskManagers[riskManager];\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerUnapproved(riskManager, block.timestamp);\n }\n\n /// @notice Approves upgradeability to the new asset pool.\n /// Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n /// @param _newAssetPool New asset pool\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n assetPool.approveNewAssetPoolUpgrade(_newAssetPool);\n }\n\n /// @notice Lets the governance to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 newWithdrawalDelay)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalDelayUpdate(newWithdrawalDelay);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalDelayUpdate();\n }\n\n /// @notice Lets the governance to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 newWithdrawalTimeout)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalTimeoutUpdate(newWithdrawalTimeout);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalTimeoutUpdate();\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @dev `portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR`\n /// for calculation precision purposes. Further calculations in this\n /// function will need to take this divisor into account.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by `FLOATING_POINT_DIVISOR`\n function seizePortion(address recipient, uint256 portionToSeize)\n external\n onlyApprovedRiskManager\n {\n require(\n portionToSeize > 0 &&\n portionToSeize <= CoveragePoolConstants.FLOATING_POINT_DIVISOR,\n \"Portion to seize is not within the range (0, 1]\"\n );\n\n assetPool.claim(recipient, amountToSeize(portionToSeize));\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param amountToSeize Amount to be seized from the pool\n // slither-disable-next-line shadowing-local\n function seizeAmount(address recipient, uint256 amountToSeize)\n external\n onlyApprovedRiskManager\n {\n require(amountToSeize > 0, \"Amount to seize must be >0\");\n\n assetPool.claim(recipient, amountToSeize);\n }\n\n /// @notice Grants asset pool shares by minting a given amount of the\n /// underwriter tokens for the recipient address. In result, the\n /// recipient obtains part of the pool ownership without depositing\n /// any collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by an approved risk manager.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n onlyApprovedRiskManager\n {\n assetPool.grantShares(recipient, covAmount);\n }\n\n /// @notice Returns the time remaining until the risk manager approval\n /// process can be finalized\n /// @param riskManager Risk manager in the process of approval\n /// @return Remaining time in seconds.\n function getRemainingRiskManagerApprovalTime(address riskManager)\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n riskManagerApprovalTimestamps[riskManager],\n assetPool.withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Determine the prior number of DAO votes for the given coverage\n /// pool underwriter.\n /// @param account The underwriter address to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the underwriter had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96)\n {\n uint96 underwriterVotes = underwriterToken.getPastVotes(\n account,\n blockNumber\n );\n uint96 underwriterTokenSupply = underwriterToken.getPastTotalSupply(\n blockNumber\n );\n\n if (underwriterTokenSupply == 0) {\n return 0;\n }\n\n uint96 covPoolVotes = collateralToken.getPastVotes(\n address(assetPool),\n blockNumber\n );\n\n return\n uint96(\n (uint256(underwriterVotes) * covPoolVotes) /\n underwriterTokenSupply\n );\n }\n\n /// @notice Calculates amount of tokens to be seized from the coverage pool.\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by FLOATING_POINT_DIVISOR\n function amountToSeize(uint256 portionToSeize)\n public\n view\n returns (uint256)\n {\n return\n (collateralToken.balanceOf(address(assetPool)) * portionToSeize) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n}\n" + }, + "contracts/CoveragePoolBeneficiary.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./RewardsPool.sol\";\nimport \"./BatchedPhasedEscrow.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title CoveragePoolBeneficiary\n/// @notice A beneficiary contract that can receive a withdrawal phase from a\n/// BatchedPhasedEscrow contract.\n/// It immediately transfers the received tokens on a designated\n/// RewardsPool contract.\ncontract CoveragePoolBeneficiary is Ownable, IBeneficiaryContract {\n using SafeERC20 for IERC20;\n\n IERC20 public immutable token;\n RewardsPool public immutable rewards;\n\n constructor(IERC20 _token, RewardsPool _rewards) {\n token = _token;\n rewards = _rewards;\n }\n\n function __escrowSentTokens(uint256 amount) external override onlyOwner {\n token.safeApprove(address(rewards), amount);\n rewards.topUpReward(amount);\n }\n}\n" + }, + "contracts/CoveragePoolConstants.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary CoveragePoolConstants {\n // This divisor is for precision purposes only. We use this divisor around\n // auction related code to get the precise values without rounding it down\n // when dealing with floating numbers.\n uint256 public constant FLOATING_POINT_DIVISOR = 1e18;\n}\n" + }, + "contracts/GovernanceUtils.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary GovernanceUtils {\n /// @notice Gets the time remaining until the governable parameter update\n /// can be committed.\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\n /// @param delay Governance delay.\n /// @return Remaining time in seconds.\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\n internal\n view\n returns (uint256)\n {\n require(changeTimestamp > 0, \"Change not initiated\");\n /* solhint-disable-next-line not-rely-on-time */\n uint256 elapsed = block.timestamp - changeTimestamp;\n if (elapsed >= delay) {\n return 0;\n } else {\n return delay - elapsed;\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@threshold-network/solidity-contracts/contracts/token/T.sol';\n" + }, + "contracts/interfaces/IAssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool interface\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\n/// an underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool.\ninterface IAssetPool {\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amount) external returns (uint256);\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n returns (uint256);\n\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external;\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter) external returns (uint256);\n}\n" + }, + "contracts/interfaces/IAssetPoolUpgrade.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool upgrade interface\n/// @notice Interface that has to be implemented by an Asset Pool accepting\n/// upgrades from another asset pool.\ninterface IAssetPoolUpgrade {\n /// @notice Accepts the given underwriter with collateral tokens amount as a\n /// deposit. In exchange new underwriter tokens will be calculated,\n /// minted and then transferred back to the underwriter.\n function depositFor(address underwriter, uint256 amount) external;\n}\n" + }, + "contracts/interfaces/IAuction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Auction interface\n/// @notice Auction runs a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\ninterface IAuction {\n /// @notice Takes an offer from an auction buyer. There are two possible\n /// ways to take an offer from a buyer. The first one is to buy\n /// entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// @dev The implementation is not guaranteed to be protecting against\n /// frontrunning. See `AuctionBidder` for an example protection.\n function takeOffer(uint256 amount) external;\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @return The ratio of the collateral pool currently on offer and divisor\n /// for precision purposes.\n function onOffer() external view returns (uint256, uint256);\n}\n" + }, + "contracts/interfaces/ICollateralToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Collateral Token interface\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\n/// as a deposit token by underwriters. Collateral token positions of\n/// underwriters can be affected when the Risk Manager claims coverage.\n/// Collateral token needs to support DAO checkpoints and let to\n/// retrieve past number of votes for the given address so that\n/// Coverage Pool underwriters can participate in token holder DAO.\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\ninterface ICollateralToken is IERC20 {\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) external;\n\n /// @notice Determine the prior number of DAO votes for an account as of\n /// a block number.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "contracts/interfaces/IRiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Interface for tBTC v1 Risk Manager\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\ninterface IRiskManagerV1 {\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external;\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external;\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n /// @param amount Amount of signer bonds being withdrawn.\n function withdrawSignerBonds(uint256 amount) external;\n\n /// @notice Returns true if there are open auctions managed by the risk\n /// manager. Returns false otherwise.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n function hasOpenAuctions() external view returns (bool);\n}\n" + }, + "contracts/RewardsPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Rewards Pool\n/// @notice RewardsPool accepts a single reward token and releases it to the\n/// AssetPool over time in one week reward intervals. The owner of this\n/// contract is the reward distribution address funding it with reward\n/// tokens.\ncontract RewardsPool is Ownable {\n using SafeERC20 for IERC20;\n\n uint256 public constant DURATION = 7 days;\n\n IERC20 public immutable rewardToken;\n address public immutable assetPool;\n\n // timestamp of the current reward interval end or the timestamp of the\n // last interval end in case a new reward interval has not been allocated\n uint256 public intervalFinish = 0;\n // rate per second with which reward tokens are unlocked\n uint256 public rewardRate = 0;\n // amount of rewards accumulated and not yet withdrawn from the previous\n // reward interval(s)\n uint256 public rewardAccumulated = 0;\n // the last time information in this contract was updated\n uint256 public lastUpdateTime = 0;\n\n event RewardToppedUp(uint256 amount);\n event RewardWithdrawn(uint256 amount);\n\n constructor(\n IERC20 _rewardToken,\n address _assetPool,\n address owner\n ) {\n rewardToken = _rewardToken;\n // slither-disable-next-line missing-zero-check\n assetPool = _assetPool;\n transferOwnership(owner);\n }\n\n /// @notice Transfers the provided reward amount into RewardsPool and\n /// creates a new, one-week reward interval starting from now.\n /// Reward tokens from the previous reward interval that unlocked\n /// over the time will be available for withdrawal immediately.\n /// Reward tokens from the previous interval that has not been yet\n /// unlocked, are added to the new interval being created.\n /// @dev This function can be called only by the owner given that it creates\n /// a new interval with one week length, starting from now.\n function topUpReward(uint256 reward) external onlyOwner {\n rewardAccumulated = earned();\n\n /* solhint-disable not-rely-on-time */\n if (block.timestamp >= intervalFinish) {\n // see https://github.com/crytic/slither/issues/844\n // slither-disable-next-line divide-before-multiply\n rewardRate = reward / DURATION;\n } else {\n uint256 remaining = intervalFinish - block.timestamp;\n uint256 leftover = remaining * rewardRate;\n rewardRate = (reward + leftover) / DURATION;\n }\n intervalFinish = block.timestamp + DURATION;\n lastUpdateTime = block.timestamp;\n /* solhint-enable avoid-low-level-calls */\n\n emit RewardToppedUp(reward);\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\n }\n\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\n function withdraw() external {\n uint256 amount = earned();\n rewardAccumulated = 0;\n lastUpdateTime = lastTimeRewardApplicable();\n emit RewardWithdrawn(amount);\n rewardToken.safeTransfer(assetPool, amount);\n }\n\n /// @notice Returns the amount of earned and not yet withdrawn reward\n /// tokens.\n function earned() public view returns (uint256) {\n return\n rewardAccumulated +\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\n }\n\n /// @notice Returns the timestamp at which a reward was last time applicable.\n /// When reward interval is pending, returns current block's\n /// timestamp. If the last reward interval ended and no other reward\n /// interval had been allocated, returns the last reward interval's\n /// end timestamp.\n function lastTimeRewardApplicable() public view returns (uint256) {\n return Math.min(block.timestamp, intervalFinish);\n }\n}\n" + }, + "contracts/RiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./Auction.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title tBTC v1 Deposit contract interface\n/// @notice This is an interface with just a few function signatures of a main\n/// Deposit contract from tBTC. tBTC deposit contract functions declared in\n/// this interface are used by RiskManagerV1 contract to interact with tBTC\n/// v1 deposits. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface IDeposit {\n function withdrawFunds() external;\n\n function purchaseSignerBondsAtAuction() external;\n\n function currentState() external view returns (uint256);\n\n function lotSizeTbtc() external view returns (uint256);\n\n function withdrawableAmount() external view returns (uint256);\n\n function auctionValue() external view returns (uint256);\n}\n\n/// @title tBTC v1 deposit token (TDT) interface\n/// @notice This is an interface with just a few function signatures of a main\n/// contract from tBTC. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/system/TBTCDepositToken.sol\ninterface ITBTCDepositToken {\n function exists(uint256 _tokenId) external view returns (bool);\n}\n\n/// @title Signer bonds swap strategy\n/// @notice This interface is meant to abstract the underlying signer bonds\n/// swap strategy and make it interchangeable for the governance.\n/// Risk manager uses the strategy to swap ETH from tBTC deposit\n/// purchased signer bonds back into collateral token accepted by\n/// coverage pool.\ninterface ISignerBondsSwapStrategy {\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external;\n}\n\n/// @title Risk Manager for tBTC v1\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract RiskManagerV1 is IRiskManagerV1, Auctioneer, Ownable {\n using SafeERC20 for IERC20;\n using RiskManagerV1Rewards for RiskManagerV1Rewards.Storage;\n\n /// @notice Governance delay that needs to pass before any risk manager\n /// parameter change initiated by the governance takes effect.\n uint256 public constant GOVERNANCE_DELAY = 12 hours;\n\n // See https://github.com/keep-network/tbtc/blob/v1.1.0/solidity/contracts/deposit/DepositStates.sol\n uint256 public constant DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE = 9;\n uint256 public constant DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE = 10;\n uint256 public constant DEPOSIT_LIQUIDATED_STATE = 11;\n\n /// @notice Coverage pool auction will not be opened if the deposit's bond\n /// auction offers a bond percentage lower than this threshold.\n /// Risk manager should open a coverage pool auction for only those\n // tBTC deposits that nobody else is willing to purchase bonds\n /// from. The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public bondAuctionThreshold; // percentage\n uint256 public newBondAuctionThreshold;\n uint256 public bondAuctionThresholdChangeInitiated;\n\n /// @notice The length with which every new auction is opened. Auction length\n /// is the amount of time it takes for the auction to get to 100%\n /// of all collateral on offer, in seconds. This parameter value\n /// should be updated and kept up to date based on the coverage pool\n /// TVL and tBTC v1 minimum lot size allowed so that a new auction\n /// does not liquidate too much too early. Auction length is the\n /// same, no matter tBTC deposit lot size.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public auctionLength;\n uint256 public newAuctionLength;\n uint256 public auctionLengthChangeInitiated;\n\n /// @notice The strategy used to swap ETH from tBTC deposit purchased signer\n /// bonds into an asset accepted by coverage pool as collateral.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n ISignerBondsSwapStrategy public signerBondsSwapStrategy;\n ISignerBondsSwapStrategy public newSignerBondsSwapStrategy;\n uint256 public signerBondsSwapStrategyInitiated;\n\n IERC20 public immutable tbtcToken;\n ITBTCDepositToken public immutable tbtcDepositToken;\n\n /// @notice TBTC surplus collected from early closed auctions.\n /// When tBTC deposit gets liquidated outside of coverage pools and\n /// an auction was opened earlier by the risk manager for that\n /// deposit, it might happen that the auction was partially filled\n /// and some TBTC from that auction has accumulated. In such a case,\n /// TBTC surplus left on the risk manager can be used to purchase\n /// signer bonds from another liquidating tBTC deposit in the future\n /// assuming enough surplus will accumulate up to that point.\n uint256 public tbtcSurplus;\n\n /// @notice Keeps track of notifier rewards for those calling\n /// `notifyLiquidation` and `notifyLiquidated`.\n RiskManagerV1Rewards.Storage public rewards;\n\n // deposit in liquidation => opened coverage pool auction\n mapping(address => address) public depositToAuction;\n // opened coverage pool auction => deposit in liquidation\n mapping(address => address) public auctionToDeposit;\n\n event NotifiedLiquidated(address indexed deposit, address notifier);\n event NotifiedLiquidation(address indexed deposit, address notifier);\n\n event BondAuctionThresholdUpdateStarted(\n uint256 bondAuctionThreshold,\n uint256 timestamp\n );\n event BondAuctionThresholdUpdated(uint256 bondAuctionThreshold);\n\n event AuctionLengthUpdateStarted(uint256 auctionLength, uint256 timestamp);\n event AuctionLengthUpdated(uint256 auctionLength);\n\n event SignerBondsSwapStrategyUpdateStarted(\n address indexed signerBondsSwapStrategy,\n uint256 timestamp\n );\n event SignerBondsSwapStrategyUpdated(\n address indexed signerBondsSwapStrategy\n );\n\n event LiquidationNotifierRewardUpdateStarted(\n uint256 liquidationNotifierReward,\n uint256 timestamp\n );\n event LiquidationNotifierRewardUpdated(uint256 liquidationNotifierReward);\n\n event LiquidatedNotifierRewardUpdateStarted(\n uint256 liquidatedNotifierReward,\n uint256 timestamp\n );\n event LiquidatedNotifierRewardUpdated(uint256 liquidatedNotifierReward);\n\n /// @notice Reverts if called before the governance delay elapses.\n /// @param changeInitiatedTimestamp Timestamp indicating the beginning\n /// of the change.\n modifier onlyAfterGovernanceDelay(uint256 changeInitiatedTimestamp) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >= GOVERNANCE_DELAY,\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n /// @notice Reverts if called by any account other than the current signer\n /// bonds swap strategy.\n modifier onlySignerBondsSwapStrategy() {\n require(\n msg.sender == address(signerBondsSwapStrategy),\n \"Caller is not the signer bonds swap strategy\"\n );\n _;\n }\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n ) Auctioneer(_coveragePool, _masterAuction) {\n tbtcToken = _tbtcToken;\n tbtcDepositToken = _tbtcDepositToken;\n signerBondsSwapStrategy = _signerBondsSwapStrategy;\n auctionLength = _auctionLength;\n bondAuctionThreshold = _bondAuctionThreshold;\n }\n\n /// @notice Receives ETH from tBTC for purchasing and withdrawing deposit\n /// signer bonds.\n //slither-disable-next-line locked-ether\n receive() external payable {}\n\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external override {\n require(\n tbtcDepositToken.exists(uint256(uint160(depositAddress))),\n \"Address is not a deposit contract\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit is not in liquidation state\"\n );\n\n require(\n depositToAuction[depositAddress] == address(0),\n \"Already notified on the deposit in liquidation\"\n );\n\n require(\n deposit.auctionValue() >=\n (address(deposit).balance * bondAuctionThreshold) / 100,\n \"Deposit bond auction percentage is below the threshold level\"\n );\n\n uint256 lotSizeTbtc = deposit.lotSizeTbtc();\n\n emit NotifiedLiquidation(depositAddress, msg.sender);\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidationNotifierReward > 0) {\n // slither-disable-next-line reentrancy-benign\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidationNotifierReward\n );\n }\n\n // If the surplus can cover the deposit liquidation cost, liquidate\n // that deposit directly without the auction process.\n if (tbtcSurplus >= lotSizeTbtc) {\n tbtcSurplus -= lotSizeTbtc;\n liquidateDeposit(deposit);\n return;\n }\n\n // slither-disable-next-line reentrancy-no-eth\n address auctionAddress = createAuction(\n tbtcToken,\n lotSizeTbtc,\n auctionLength\n );\n depositToAuction[depositAddress] = auctionAddress;\n auctionToDeposit[auctionAddress] = depositAddress;\n }\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external override {\n require(\n depositToAuction[depositAddress] != address(0),\n \"No auction for given deposit\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n deposit.currentState() == DEPOSIT_LIQUIDATED_STATE,\n \"Deposit is not in liquidated state\"\n );\n emit NotifiedLiquidated(depositAddress, msg.sender);\n\n Auction auction = Auction(depositToAuction[depositAddress]);\n\n delete depositToAuction[depositAddress];\n delete auctionToDeposit[address(auction)];\n uint256 amountTransferred = earlyCloseAuction(auction);\n\n // Add auction's transferred amount to the surplus pool.\n // slither-disable-next-line reentrancy-benign\n tbtcSurplus += amountTransferred;\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidatedNotifierReward > 0) {\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidatedNotifierReward\n );\n }\n }\n\n /// @notice Begins the bond auction threshold update process. The value of\n /// the threshold must not be greater than 100. The threshold should\n /// be high enough so that the possibility of purchasing signer\n /// bonds outside of coverage pools after opening an auction is\n /// minimal.\n /// @dev Can be called only by the contract owner.\n /// @param _newBondAuctionThreshold New bond auction threshold in percent\n function beginBondAuctionThresholdUpdate(uint256 _newBondAuctionThreshold)\n external\n onlyOwner\n {\n require(\n _newBondAuctionThreshold <= 100,\n \"Bond auction threshold must be lower or equal to 100\"\n );\n newBondAuctionThreshold = _newBondAuctionThreshold;\n /* solhint-disable-next-line not-rely-on-time */\n bondAuctionThresholdChangeInitiated = block.timestamp;\n /* solhint-disable not-rely-on-time */\n emit BondAuctionThresholdUpdateStarted(\n _newBondAuctionThreshold,\n block.timestamp\n );\n }\n\n /// @notice Finalizes the bond auction threshold update process.\n /// @dev Can be called only by the contract owner, after the the\n /// governance delay elapses.\n function finalizeBondAuctionThresholdUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(bondAuctionThresholdChangeInitiated)\n {\n bondAuctionThreshold = newBondAuctionThreshold;\n emit BondAuctionThresholdUpdated(bondAuctionThreshold);\n bondAuctionThresholdChangeInitiated = 0;\n newBondAuctionThreshold = 0;\n }\n\n /// @notice Begins the auction length update process. The auction length\n /// should be adjusted very carefully. Total value locked of the\n /// coverage pool and minimum possible auction amount need to be\n /// taken into account. The goal is to find a \"sweet spot\" for\n /// auction length, not making it too short (which leads to big\n /// sums of coverage pool become available in a short time) and not\n /// making it too long (which leads to bidders waiting for too long\n /// until it will makes sense for them to bid on an auction).\n /// @dev Can be called only by the contract owner.\n /// @param _newAuctionLength New auction length in seconds\n function beginAuctionLengthUpdate(uint256 _newAuctionLength)\n external\n onlyOwner\n {\n newAuctionLength = _newAuctionLength;\n /* solhint-disable-next-line not-rely-on-time */\n auctionLengthChangeInitiated = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit AuctionLengthUpdateStarted(_newAuctionLength, block.timestamp);\n }\n\n /// @notice Finalizes the auction length update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeAuctionLengthUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(auctionLengthChangeInitiated)\n {\n auctionLength = newAuctionLength;\n emit AuctionLengthUpdated(newAuctionLength);\n newAuctionLength = 0;\n auctionLengthChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidation` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @dev Can be called only by the contract owner.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward\n function beginLiquidationNotifierRewardUpdate(\n uint256 _newLiquidationNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidationNotifierRewardUpdateStarted(\n _newLiquidationNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidationNotifierRewardUpdate(\n _newLiquidationNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeLiquidationNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidationNotifierRewardChangeInitiated\n )\n {\n emit LiquidationNotifierRewardUpdated(\n rewards.newLiquidationNotifierReward\n );\n\n rewards.finalizeLiquidationNotifierRewardUpdate();\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidated` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n uint256 _newLiquidatedNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidatedNotifierRewardUpdateStarted(\n _newLiquidatedNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidatedNotifierRewardUpdate(\n _newLiquidatedNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses\n function finalizeLiquidatedNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidatedNotifierRewardChangeInitiated\n )\n {\n emit LiquidatedNotifierRewardUpdated(\n rewards.newLiquidatedNotifierReward\n );\n\n rewards.finalizeLiquidatedNotifierRewardUpdate();\n }\n\n /// @notice Begins the signer bonds swap strategy update process.\n /// @dev Must be followed by a finalizeSignerBondsSwapStrategyUpdate after\n /// the governance delay elapses.\n /// @param _newSignerBondsSwapStrategy The new signer bonds swap strategy\n function beginSignerBondsSwapStrategyUpdate(\n ISignerBondsSwapStrategy _newSignerBondsSwapStrategy\n ) external onlyOwner {\n require(\n address(_newSignerBondsSwapStrategy) != address(0),\n \"Invalid signer bonds swap strategy address\"\n );\n newSignerBondsSwapStrategy = _newSignerBondsSwapStrategy;\n /* solhint-disable-next-line not-rely-on-time */\n signerBondsSwapStrategyInitiated = block.timestamp;\n emit SignerBondsSwapStrategyUpdateStarted(\n address(_newSignerBondsSwapStrategy),\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp\n );\n }\n\n /// @notice Finalizes the signer bonds swap strategy update.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeSignerBondsSwapStrategyUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(signerBondsSwapStrategyInitiated)\n {\n signerBondsSwapStrategy = newSignerBondsSwapStrategy;\n emit SignerBondsSwapStrategyUpdated(\n address(newSignerBondsSwapStrategy)\n );\n delete newSignerBondsSwapStrategy;\n signerBondsSwapStrategyInitiated = 0;\n }\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Can be called only by the signer bonds swap strategy itself.\n /// This method should typically be used as part of the swap logic.\n /// Third-party calls may block funds on the strategy contract in case\n /// that strategy is not able to perform the swap.\n /// @param amount Amount of signer bonds being withdrawn\n function withdrawSignerBonds(uint256 amount)\n external\n override\n onlySignerBondsSwapStrategy\n {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = address(signerBondsSwapStrategy).call{value: amount}(\n \"\"\n );\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n /// @notice Get the time remaining until the bond auction threshold\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingBondAuctionThresholdUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n bondAuctionThresholdChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the auction length parameter\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingAuctionLengthUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n auctionLengthChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidation notifier reward\n /// parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidationNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidationNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidated notifier reward\n /// amount parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidatedNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidatedNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the signer bonds swap strategy\n /// can be changed.\n /// @return Remaining time in seconds.\n function getRemainingSignerBondsSwapStrategyChangeTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n signerBondsSwapStrategyInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @return True if there are open auctions managed by the risk manager.\n /// Returns false otherwise.\n function hasOpenAuctions() external view override returns (bool) {\n return openAuctionsCount > 0;\n }\n\n /// @return Current value of the liquidation notifier reward.\n function liquidationNotifierReward() external view returns (uint256) {\n return rewards.liquidationNotifierReward;\n }\n\n /// @return Current value of the liquidated notifier reward.\n function liquidatedNotifierReward() external view returns (uint256) {\n return rewards.liquidatedNotifierReward;\n }\n\n /// @notice Cleans up auction and deposit data and executes deposit liquidation.\n /// @dev This function is invoked when Auctioneer determines that an auction\n /// is eligible to be closed. It cannot be called on-demand outside\n /// the Auctioneer contract. By the time this function is called, all\n /// the TBTC tokens for the coverage pool auction should be transferred\n /// to this contract in order to buy signer bonds.\n /// @param auction Coverage pool auction\n function onAuctionFullyFilled(Auction auction) internal override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n\n delete depositToAuction[address(deposit)];\n delete auctionToDeposit[address(auction)];\n\n liquidateDeposit(deposit);\n }\n\n /// @notice Purchases ETH from signer bonds and swaps obtained funds\n /// using the underlying signer bonds swap strategy.\n /// @dev By the time this function is called, TBTC token balance for this\n /// contract should be enough to buy signer bonds.\n /// @param deposit TBTC deposit which should be liquidated.\n function liquidateDeposit(IDeposit deposit) internal {\n uint256 approvedAmount = deposit.lotSizeTbtc();\n tbtcToken.safeApprove(address(deposit), approvedAmount);\n\n // Purchase signers bonds ETH with TBTC acquired from the auction or\n // taken from the surplus pool.\n deposit.purchaseSignerBondsAtAuction();\n\n uint256 withdrawableAmount = deposit.withdrawableAmount();\n deposit.withdrawFunds();\n\n signerBondsSwapStrategy.onSignerBondsPurchased(withdrawableAmount);\n }\n\n /// @notice Reverts if the deposit for which the auction was created is no\n /// longer in the liquidation state. This could happen if signer\n /// bonds were purchased from tBTC deposit directly, outside of\n /// coverage pool auction.\n /// @dev This function is invoked when the auctioneer is informed about the\n /// results of an auction and the auction was partially filled.\n /// @param auction Address of an auction whose deposit needs to be checked.\n function onAuctionPartiallyFilled(Auction auction) internal view override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n }\n\n function isDepositLiquidationInProgress(IDeposit deposit)\n internal\n view\n returns (bool)\n {\n uint256 state = deposit.currentState();\n\n return (state == DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE ||\n state == DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE);\n }\n}\n\n/// @title RiskManagerV1Rewards\n/// @notice Contains logic responsible for calculating notifier rewards for\n/// both deposit liquidation start and deposit liquidated events.\n/// All parameters can be updated using a two-phase process.\n/// @dev The client contract should take care of authorizations or governance\n/// delays according to their needs.\n/* solhint-disable-next-line ordering */\nlibrary RiskManagerV1Rewards {\n struct Storage {\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about the start of deposit liquidation process.\n uint256 liquidationNotifierReward;\n uint256 newLiquidationNotifierReward;\n uint256 liquidationNotifierRewardChangeInitiated;\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about a deposit being liquidated outside of the\n // coverage pool.\n uint256 liquidatedNotifierReward;\n uint256 newLiquidatedNotifierReward;\n uint256 liquidatedNotifierRewardChangeInitiated;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward.\n function beginLiquidationNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidationNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidationNotifierReward = _newLiquidationNotifierReward;\n self.liquidationNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n function finalizeLiquidationNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidationNotifierReward = self.newLiquidationNotifierReward;\n self.newLiquidationNotifierReward = 0;\n self.liquidationNotifierRewardChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidatedNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidatedNotifierReward = _newLiquidatedNotifierReward;\n self.liquidatedNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n function finalizeLiquidatedNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidatedNotifierReward = self.newLiquidatedNotifierReward;\n self.newLiquidatedNotifierReward = 0;\n self.liquidatedNotifierRewardChangeInitiated = 0;\n }\n}\n" + }, + "contracts/SignerBondsManualSwap.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title SignerBondsManualSwap\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsManualSwap strategy allows the governance to withdraw\n/// the bonds from the risk manager and do the swap manually.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsManualSwap is ISignerBondsSwapStrategy, Ownable {\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Withdraws collected bonds to the given target address.\n /// @dev Can be called by the governance only.\n /// @param recipient Arbitrary recipient address chosen by the governance\n /// that will be responsible for swapping ETH and depositing\n /// collateral to the coverage pool.\n function withdrawSignerBonds(\n IRiskManagerV1 riskManager,\n uint256 amount,\n address payable recipient\n ) external onlyOwner {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n require(recipient != address(0), \"Invalid recipient address\");\n\n riskManager.withdrawSignerBonds(amount);\n\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls,arbitrary-send\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n}\n" + }, + "contracts/SignerBondsUniswapV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\nimport \"./CoveragePool.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @notice Interface for the Uniswap v2 router.\n/// @dev This is an interface with just a few function signatures of the\n/// router contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/router02\ninterface IUniswapV2Router {\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function factory() external pure returns (address);\n\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure returns (address);\n}\n\n/// @notice Interface for the Uniswap v2 pair.\n/// @dev This is an interface with just a few function signatures of the\n/// pair contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/pair\ninterface IUniswapV2Pair {\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n}\n\n/// @title SignerBondsUniswapV2\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsUniswapV2 is a swap strategy implementation which\n/// can withdraw the given bonds amount from the risk manager, swap them\n/// on Uniswap v2 exchange and deposit as coverage pool collateral.\n/// The governance can set crucial swap parameters: max allowed\n/// percentage impact, slippage tolerance and swap deadline, to force\n/// reasonable swap outcomes. It is up to the governance to decide what\n/// these values should be.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsUniswapV2 is ISignerBondsSwapStrategy, Ownable {\n // One basis point is equivalent to 1/100th of a percent.\n uint256 public constant BASIS_POINTS_DIVISOR = 10000;\n\n IUniswapV2Router public immutable uniswapRouter;\n IUniswapV2Pair public immutable uniswapPair;\n address public immutable assetPool;\n address public immutable collateralToken;\n\n mapping(address => bool) public approvedSwappers;\n\n // Determines the maximum allowed price impact for the swap transaction.\n // If transaction's price impact is higher, transaction will be reverted.\n // Default value is 100 basis points (1%).\n uint256 public maxAllowedPriceImpact = 100;\n // Determines the slippage tolerance for the swap transaction.\n // If transaction's slippage is higher, transaction will be reverted.\n // Default value is 50 basis points (0.5%).\n uint256 public slippageTolerance = 50;\n // Determines the deadline in which the swap transaction has to be mined.\n // If that deadline is exceeded, transaction will be reverted.\n uint256 public swapDeadline = 20 minutes;\n // Determines if the swap should revert when open auctions exists. If true,\n // swaps cannot be performed if there is at least one open auction.\n // If false, open auctions are not taken into account.\n bool public revertIfAuctionOpen = true;\n\n event SignerBondsSwapperApproved(address swapper);\n event SignerBondsSwapperUnapproved(address swapper);\n event UniswapV2SwapExecuted(uint256[] amounts);\n\n /// @notice Reverts if called by a signer bonds swapper that is not approved\n modifier onlyApprovedSwapper() {\n require(\n approvedSwappers[msg.sender],\n \"Signer bonds swapper not approved\"\n );\n _;\n }\n\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool) {\n uniswapRouter = _uniswapRouter;\n assetPool = address(_coveragePool.assetPool());\n address _collateralToken = address(_coveragePool.collateralToken());\n collateralToken = _collateralToken;\n uniswapPair = IUniswapV2Pair(\n computePairAddress(\n _uniswapRouter.factory(),\n _uniswapRouter.WETH(),\n _collateralToken\n )\n );\n }\n\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n /// @dev Do not send arbitrary funds. They will be locked forever.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Sets the maximum price impact allowed for a swap transaction.\n /// @param _maxAllowedPriceImpact Maximum allowed price impact specified\n /// in basis points. Value of this parameter must be between\n /// 0 and 10000 (inclusive). It should be chosen carefully as\n /// high limit level will accept transactions with high volumes.\n /// Those transactions may result in poor execution prices. Very low\n /// limit will force low swap volumes. Limit equal to 0 will\n /// effectively make swaps impossible.\n function setMaxAllowedPriceImpact(uint256 _maxAllowedPriceImpact)\n external\n onlyOwner\n {\n require(\n _maxAllowedPriceImpact <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n maxAllowedPriceImpact = _maxAllowedPriceImpact;\n }\n\n /// @notice Sets the slippage tolerance for a swap transaction.\n /// @param _slippageTolerance Slippage tolerance in basis points. Value of\n /// this parameter must be between 0 and 10000 (inclusive). It\n /// should be chosen carefully as transactions with high slippage\n /// tolerance result in poor execution prices. On the other hand,\n /// very low slippage tolerance may cause transactions to be\n /// reverted frequently. Slippage tolerance equal to 0 is possible\n /// and disallows any slippage to happen on the swap at the cost\n /// of higher revert risk.\n function setSlippageTolerance(uint256 _slippageTolerance)\n external\n onlyOwner\n {\n require(\n _slippageTolerance <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n slippageTolerance = _slippageTolerance;\n }\n\n /// @notice Sets the deadline for a swap transaction.\n /// @param _swapDeadline Swap deadline in seconds. Value of this parameter\n /// should be equal or greater than 0. It should be chosen carefully\n /// as transactions with long deadlines may result in poor execution\n /// prices. On the other hand, very short deadlines may cause\n /// transactions to be reverted frequently, especially in a\n /// gas-expensive environment. Deadline equal to 0 will effectively\n // make swaps impossible.\n function setSwapDeadline(uint256 _swapDeadline) external onlyOwner {\n swapDeadline = _swapDeadline;\n }\n\n /// @notice Sets whether a swap should revert if at least one\n /// open auction exists.\n /// @param _revertIfAuctionOpen If true, revert the swap if there is at\n /// least one open auction. If false, open auctions won't be taken\n /// into account.\n function setRevertIfAuctionOpen(bool _revertIfAuctionOpen)\n external\n onlyOwner\n {\n revertIfAuctionOpen = _revertIfAuctionOpen;\n }\n\n /// @notice Swaps signer bonds on Uniswap v2 exchange.\n /// @dev Swaps the given ETH amount for the collateral token using the\n /// Uniswap exchange. The maximum ETH amount is capped by the\n /// contract balance. Some governance parameters are applied on the\n /// transaction. The swap's price impact must fit within the\n /// maximum allowed price impact and the transaction is constrained\n /// with the slippage tolerance and deadline. Acquired collateral\n /// tokens are sent to the asset pool address set during\n /// contract construction.\n /// @param riskManager Address of the risk manager which holds the bonds.\n /// @param amount Amount to swap.\n function swapSignerBondsOnUniswapV2(\n IRiskManagerV1 riskManager,\n uint256 amount\n ) external onlyApprovedSwapper {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n\n if (revertIfAuctionOpen) {\n require(!riskManager.hasOpenAuctions(), \"There are open auctions\");\n }\n\n riskManager.withdrawSignerBonds(amount);\n\n // Setup the swap path. WETH must be the first component.\n address[] memory path = new address[](2);\n path[0] = uniswapRouter.WETH();\n path[1] = collateralToken;\n\n // Calculate the maximum output token amount basing on pair reserves.\n // This value will be used as the minimum amount of output tokens that\n // must be received for the transaction not to revert.\n // This value includes liquidity fee equal to 0.3%.\n uint256 amountOutMin = uniswapRouter.getAmountsOut(amount, path)[1];\n\n require(\n isAllowedPriceImpact(amountOutMin),\n \"Price impact exceeds allowed limit\"\n );\n\n // Include slippage tolerance into the minimum amount of output tokens.\n amountOutMin =\n (amountOutMin * (BASIS_POINTS_DIVISOR - slippageTolerance)) /\n BASIS_POINTS_DIVISOR;\n\n // slither-disable-next-line arbitrary-send,reentrancy-events\n uint256[] memory amounts = uniswapRouter.swapExactETHForTokens{\n value: amount\n }(\n amountOutMin,\n path,\n assetPool,\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp + swapDeadline\n );\n\n emit UniswapV2SwapExecuted(amounts);\n }\n\n /// @notice Approves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be approved\n function approveSwapper(address swapper) external onlyOwner {\n require(\n !approvedSwappers[swapper],\n \"Signer bonds swapper has been already approved\"\n );\n emit SignerBondsSwapperApproved(swapper);\n approvedSwappers[swapper] = true;\n }\n\n /// @notice Unapproves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be unapproved\n function unapproveSwapper(address swapper) external onlyOwner {\n require(\n approvedSwappers[swapper],\n \"Signer bonds swapper is not approved\"\n );\n emit SignerBondsSwapperUnapproved(swapper);\n delete approvedSwappers[swapper];\n }\n\n /// @notice Checks the price impact of buying a given amount of tokens\n /// against the maximum allowed price impact limit.\n /// @param amount Amount of tokens.\n /// @return True if the price impact is allowed, false otherwise.\n function isAllowedPriceImpact(uint256 amount) public view returns (bool) {\n // Get reserve of the collateral token.\n address WETH = uniswapRouter.WETH();\n address token0 = WETH < collateralToken ? WETH : collateralToken;\n (uint256 reserve0, uint256 reserve1, ) = uniswapPair.getReserves();\n uint256 collateralTokenReserve = WETH == token0 ? reserve1 : reserve0;\n\n // Same as: priceImpact <= priceImpactLimit\n return\n amount * BASIS_POINTS_DIVISOR <=\n maxAllowedPriceImpact * collateralTokenReserve;\n }\n\n /// @notice Compute Uniswap v2 pair address.\n /// @param factory Address of the Uniswap v2 factory.\n /// @param tokenA Address of token A.\n /// @param tokenB Address of token B.\n /// @return Address of token pair.\n function computePairAddress(\n address factory,\n address tokenA,\n address tokenB\n ) internal pure returns (address) {\n (address token0, address token1) = tokenA < tokenB\n ? (tokenA, tokenB)\n : (tokenB, tokenA);\n\n return\n address(\n uint160(\n uint256(\n keccak256(\n abi.encodePacked(\n hex\"ff\",\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex\"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\"\n )\n )\n )\n )\n );\n }\n}\n" + }, + "contracts/test/AuctioneerStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../Auctioneer.sol\";\n\ncontract AuctioneerStub is Auctioneer {\n event AuctionEarlyClosed(uint256 transferredAmount);\n\n constructor(CoveragePool _coveragePool, address _masterAuction)\n Auctioneer(_coveragePool, _masterAuction)\n {}\n\n /// @dev This fallback function is needed by the `impersonateAccount`\n /// test helper function.\n receive() external payable {}\n\n function publicCreateAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) public {\n createAuction(tokenAccepted, amountDesired, auctionLength);\n }\n\n function publicEarlyCloseAuction(Auction auction) public {\n uint256 transferredAmount = earlyCloseAuction(auction);\n emit AuctionEarlyClosed(transferredAmount);\n }\n}\n" + }, + "contracts/test/AuctionStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAuction.sol\";\n\ncontract AuctionStub is IAuction {\n uint256 public divisor;\n uint256 public offer;\n uint256 public amountOutstanding;\n\n event TakeOffer(uint256 amount);\n\n /// @dev Simulates calling Auction.takeOffer(amount) from the\n /// AuctionBidder contract.\n function takeOffer(uint256 amount) external override {\n emit TakeOffer(amount);\n }\n\n function onOffer() external view override returns (uint256, uint256) {\n return (offer, divisor);\n }\n\n function setOnOffer(uint256 _onOffer) public {\n offer = _onOffer;\n }\n\n function setDivisor(uint256 _divisor) public {\n divisor = _divisor;\n }\n\n function setAmountOutstanding(uint256 _amountOutstanding) public {\n amountOutstanding = _amountOutstanding;\n }\n}\n" + }, + "contracts/test/CoveragePoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../CoveragePoolConstants.sol\";\n\ncontract CoveragePoolStub {\n uint256 public covTotalSupply;\n\n event PortionSeized(address indexed recipient, uint256 portionToSeize);\n event AssetPoolSharesGranted(address indexed recipient, uint256 covAmount);\n\n function seizePortion(address recipient, uint256 portionToSeize) external {\n emit PortionSeized(recipient, portionToSeize);\n }\n\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n {\n emit AssetPoolSharesGranted(recipient, covAmount);\n }\n}\n" + }, + "contracts/test/DepositStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../RiskManagerV1.sol\";\n\n/// @dev tBTC v1 deposit interface with a subset of functions used by unit and\n/// system tests. For more information about tBTC Deposit, please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface ITBTCDeposit is IDeposit {\n function notifyRedemptionSignatureTimedOut() external;\n}\n\n/// @dev Stub contract simulating - in a simplified way - behavior of tBTC v1\n/// deposit when it comes to purchasing signer bonds. This is _not_\n/// a complete tBTC v1 Deposit implementation.\ncontract DepositStub is ITBTCDeposit {\n using SafeERC20 for IERC20;\n\n enum States {\n // DOES NOT EXIST YET\n START,\n // FUNDING FLOW\n AWAITING_SIGNER_SETUP,\n AWAITING_BTC_FUNDING_PROOF,\n // FAILED SETUP\n FAILED_SETUP,\n // ACTIVE\n ACTIVE, // includes courtesy call\n // REDEMPTION FLOW\n AWAITING_WITHDRAWAL_SIGNATURE,\n AWAITING_WITHDRAWAL_PROOF,\n REDEEMED,\n // SIGNER LIQUIDATION FLOW\n COURTESY_CALL,\n FRAUD_LIQUIDATION_IN_PROGRESS,\n LIQUIDATION_IN_PROGRESS,\n LIQUIDATED\n }\n\n IERC20 public tbtcToken;\n uint256 public override lotSizeTbtc;\n uint256 public override currentState;\n uint256 public override auctionValue;\n\n address public buyer;\n\n constructor(IERC20 _tbtcToken, uint256 _lotSizeTbtc) {\n tbtcToken = _tbtcToken;\n lotSizeTbtc = _lotSizeTbtc;\n currentState = 4; // active by default\n }\n\n /// @dev Needed to receive ETH bonds at deposit setup.\n receive() external payable {}\n\n function withdrawFunds() external override {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = buyer.call{value: address(this).balance}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n function purchaseSignerBondsAtAuction() external override {\n require(\n currentState == uint256(States.LIQUIDATION_IN_PROGRESS),\n \"Not in liquidation\"\n );\n currentState = uint256(States.LIQUIDATED);\n buyer = msg.sender;\n tbtcToken.safeTransferFrom(buyer, address(this), lotSizeTbtc);\n }\n\n function notifyUndercollateralizedLiquidation() external {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n function notifyRedemptionSignatureTimedOut() external override {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function setAuctionValue(uint256 _auctionValue) external {\n auctionValue = _auctionValue;\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function notifyFraud() external {\n currentState = uint256(States.FRAUD_LIQUIDATION_IN_PROGRESS);\n }\n\n function withdrawableAmount() external view override returns (uint256) {\n return address(this).balance;\n }\n}\n" + }, + "contracts/test/KeepAssetPool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../AssetPool.sol\";\n\ncontract KeepAssetPool is AssetPool {\n constructor(\n ICollateralToken collateralToken,\n UnderwriterToken underwriterToken,\n address rewardsManager\n ) AssetPool(collateralToken, underwriterToken, rewardsManager) {}\n\n function initGovernance(ICollateralToken _collateralToken)\n internal\n override\n {\n // KEEP does not support DAO checkpoints\n }\n}\n" + }, + "contracts/test/NewAssetPoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAssetPool.sol\";\nimport \"../interfaces/IAssetPoolUpgrade.sol\";\nimport \"../UnderwriterToken.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract NewAssetPoolStub is IAssetPoolUpgrade {\n using SafeERC20 for IERC20;\n\n IERC20 public collateralToken;\n UnderwriterToken public newUnderwriterToken;\n\n constructor(IERC20 _collateralToken, UnderwriterToken _newUnderwriterToken)\n {\n collateralToken = _collateralToken;\n newUnderwriterToken = _newUnderwriterToken;\n }\n\n function depositFor(address underwriter, uint256 collateralAmount)\n external\n override\n {\n collateralToken.safeTransferFrom(\n msg.sender,\n address(this),\n collateralAmount\n );\n // In a real contract amount of new cov tokens will be calculated based\n // on certain rules.\n // For testing purposes, cov tokens amount = collateral tokens amount\n newUnderwriterToken.mint(underwriter, collateralAmount);\n }\n}\n" + }, + "contracts/test/RiskManagerV1Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract RiskManagerV1Stub is RiskManagerV1 {\n using SafeERC20 for IERC20;\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n )\n RiskManagerV1(\n _tbtcToken,\n _tbtcDepositToken,\n _coveragePool,\n _signerBondsSwapStrategy,\n _masterAuction,\n _auctionLength,\n _bondAuctionThreshold\n )\n {}\n\n function fundTbtcSurplus(uint256 amount) external {\n tbtcToken.safeTransferFrom(msg.sender, address(this), amount);\n tbtcSurplus = tbtcSurplus + amount;\n }\n}\n" + }, + "contracts/test/SignerBondsUniswapV2Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract SignerBondsUniswapV2Stub is SignerBondsUniswapV2 {\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool)\n SignerBondsUniswapV2(_uniswapRouter, _coveragePool)\n {}\n}\n" + }, + "contracts/test/TBTCDepositTokenStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract TBTCDepositTokenStub is ITBTCDepositToken {\n mapping(uint256 => bool) public tokenIds;\n\n function setExists(uint256 tokenId, bool _exists) external {\n tokenIds[tokenId] = _exists;\n }\n\n function exists(uint256 tokenId) external view override returns (bool) {\n return tokenIds[tokenId];\n }\n}\n" + }, + "contracts/test/TestSimpleBeneficiary.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n// Simple beneficiary that does nothing when notified that it has received\n// tokens.\ncontract TestSimpleBeneficiary {\n function __escrowSentTokens(uint256 amount) external {}\n}\n" + }, + "contracts/test/TestToken.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/ICollateralToken.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\n\n/// @title Test ERC-20 token\n/// @dev Token with unlimited minting capacity. It does implement DAO-related\n/// functions from ICollateralToken but with just a dummy code.\n/// Implementation of DAO checkpoints is complex. Even if we used\n/// `Checkpoints` contract from `threshold-network` here, it would require\n/// implementation for `delegate(address delegator, address delegatee)` and\n/// updating checkpoints in `beforeTokenTransfer(address from, address to, uint amount)`\n/// of TestToken. Every time DAO related functions need to be tested, please\n/// use real token with proper DAO implementation, such as `T`.\ncontract TestToken is ERC20WithPermit, ICollateralToken {\n mapping(address => address) public delegatee;\n\n /* solhint-disable-next-line no-empty-blocks */\n constructor() ERC20WithPermit(\"Test Token\", \"TT\") {}\n\n function delegate(address _delegatee) external virtual {\n delegatee[msg.sender] = _delegatee;\n }\n\n function getPastVotes(address, uint256) external pure returns (uint96) {\n return 0;\n }\n}\n" + }, + "contracts/test/UniswapV2RouterStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract UniswapV2RouterStub is IUniswapV2Router {\n // Settable fake exchange rate is defined here to avoid pair logic complexity.\n // It determines how much tokens can be received for 1 ETH.\n uint256 public exchangeRate = 1;\n\n event SwapExactETHForTokensExecuted(\n uint256 amountOutMin,\n address[] path,\n address to,\n uint256 deadline\n );\n\n function setExchangeRate(uint256 _exchangeRate) external {\n exchangeRate = _exchangeRate;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one. Emits an event with input parameters.\n /// Calculates returned amounts to behave like a real method.\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable override returns (uint256[] memory amounts) {\n require(msg.value > 0, \"Amount must be grater than zero\");\n\n emit SwapExactETHForTokensExecuted(amountOutMin, path, to, deadline);\n\n amounts = new uint256[](2);\n amounts[0] = msg.value;\n amounts[1] = (msg.value * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one.\n function getAmountsOut(uint256 amountIn, address[] calldata)\n external\n view\n override\n returns (uint256[] memory amounts)\n {\n amounts = new uint256[](2);\n amounts[0] = amountIn;\n amounts[1] = (amountIn * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n function factory() external pure override returns (address) {\n return 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure override returns (address) {\n return 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n }\n}\n" + }, + "contracts/UnderwriterToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\";\n\n/// @title UnderwriterToken\n/// @notice Underwriter tokens represent an ownership share in the underlying\n/// collateral of the asset-specific pool. Underwriter tokens are minted\n/// when a user deposits ERC20 tokens into asset-specific pool and they\n/// are burned when a user exits the position. Underwriter tokens\n/// natively support meta transactions. Users can authorize a transfer\n/// of their underwriter tokens with a signature conforming EIP712\n/// standard instead of an on-chain transaction from their address.\n/// Anyone can submit this signature on the user's behalf by calling the\n/// permit function, as specified in EIP2612 standard, paying gas fees,\n/// and possibly performing other actions in the same transaction.\n// slither-disable-next-line missing-inheritance\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor(string memory _name, string memory _symbol)\n ERC20WithPermit(_name, _symbol)\n {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n /// @notice Moves voting power when tokens are minted, burned or transferred.\n /// @dev Overrides the empty function from the parent contract.\n /// @param from The address that loses tokens and voting power\n /// @param to The address that gains tokens and voting power\n /// @param amount The amount of tokens and voting power that is transferred\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\n }\n\n moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /// @notice Delegate votes from `delegator` to `delegatee`.\n /// @param delegator The address to delegate votes from\n /// @param delegatee The address to delegate votes to\n function delegate(address delegator, address delegatee) internal override {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/v2/RewardsPoolV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title RewardTokenMinting\n/// @notice Implements minting of reward tokens for registered Asset Pools with\n/// a reward rate assigned individually for each Asset Pool.\n/// Each Asset Pool is assigned a relative rate establishing a way for\n/// Governance to incentivize different assets to target a particular\n/// Collateral Pool composition.\n/// @dev Contract is not meant to be deployed directly. It implements\n/// a specific part of the functionality of the RewardPool and should be\n/// used only as a RewardPool parent contract.\nabstract contract RewardTokenMinting {\n // Reward rate per Asset Pool address.\n // Reward rate is 1e18 precision number.\n mapping(address => uint256) public rewardRates;\n\n // The last time minting rates were updated.\n uint256 public lastUpdateTime;\n\n uint256 internal tokenPerRateUnitAccumulated;\n mapping(address => uint256) internal poolTokenPerRateUnitPaid;\n mapping(address => uint256) internal poolTokens;\n\n // TODO: should be internal and used by governance function with a delay\n function setRewardRate(address assetPool, uint256 rewardRate) external {\n updateReward(assetPool);\n rewardRates[assetPool] = rewardRate;\n }\n\n function earned(address assetPool) public view returns (uint256) {\n return\n rewardRates[assetPool] *\n (tokenPerRateUnit() - poolTokenPerRateUnitPaid[assetPool]) +\n poolTokens[assetPool];\n }\n\n function updateReward(address assetPool) internal {\n tokenPerRateUnitAccumulated = tokenPerRateUnit();\n /* solhint-disable-next-line not-rely-on-time */\n lastUpdateTime = block.timestamp;\n poolTokens[assetPool] = earned(assetPool);\n poolTokenPerRateUnitPaid[assetPool] = tokenPerRateUnitAccumulated;\n }\n\n function tokenPerRateUnit() internal view returns (uint256) {\n return\n tokenPerRateUnitAccumulated +\n (/* solhint-disable-next-line not-rely-on-time */\n block.timestamp - lastUpdateTime);\n }\n}\n\n/// @title RewardsPool\n/// @notice Rewards Pool is a contract that accepts arbitrary assets and mints\n/// a single reward token. Recipients of the reward token can at any\n/// time turn it in for a portion of the rewards in the pool.\n/// A rewards pool maintains a governable list of recipients and\n/// relative reward rates. For example, a rewards pool might have two\n/// recipients — a WETH Asset Pool, and a WBTC asset pool, with\n/// respective reward rates of 1 and 2. Rewards tokens are minted\n/// constantly over time and distributed according to the relative\n/// reward rates. Reward rates allows establishing a way for Governance\n/// to incentivize different assets to target a particular Collateral\n/// Pool composition.\ncontract RewardPoolV2 is RewardTokenMinting {\n // TODO: Add function to update reward rate with a governance delay.\n // TODO: Allow to withdraw rewards based on the amount of reward tokens.\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": false, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "storageLayout", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/.chainId b/deployments/mainnet/.chainId new file mode 100644 index 00000000..56a6051c --- /dev/null +++ b/deployments/mainnet/.chainId @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/deployments/mainnet/AssetPool.json b/deployments/mainnet/AssetPool.json new file mode 100644 index 00000000..a9c3d19c --- /dev/null +++ b/deployments/mainnet/AssetPool.json @@ -0,0 +1,1090 @@ +{ + "address": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ICollateralToken", + "name": "_collateralToken", + "type": "address" + }, + { + "internalType": "contract UnderwriterToken", + "name": "_underwriterToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardsManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newAssetPool", + "type": "address" + } + ], + "name": "ApprovedAssetPoolUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "collateralAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "AssetPoolUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "cancelledAssetPool", + "type": "address" + } + ], + "name": "CancelledAssetPoolUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "CoverageClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "Deposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalDelay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalDelayUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalDelay", + "type": "uint256" + } + ], + "name": "WithdrawalDelayUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalTimeout", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalTimeoutUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalTimeout", + "type": "uint256" + } + ], + "name": "WithdrawalTimeoutUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "approveNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newWithdrawalDelay", + "type": "uint256" + } + ], + "name": "beginWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newWithdrawalTimeout", + "type": "uint256" + } + ], + "name": "beginWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cancelNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "contract ICollateralToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underwriter", + "type": "address" + } + ], + "name": "completeWithdrawal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minAmountToMint", + "type": "uint256" + } + ], + "name": "depositWithMin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getRemainingWithdrawalDelayUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRemainingWithdrawalTimeoutUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "grantShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "initiateWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "newAssetPool", + "outputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newWithdrawalDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newWithdrawalTimeout", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingWithdrawal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsPool", + "outputs": [ + { + "internalType": "contract RewardsPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underwriterToken", + "outputs": [ + { + "internalType": "contract UnderwriterToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "upgradeToNewAssetPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalDelayChangeInitiated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalGovernanceDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "withdrawalInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalTimeout", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalTimeoutChangeInitiated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "transactionIndex": 71, + "gasUsed": "4745721", + "logsBloom": "0x08000000000000000000000000000000000020000000000000800000000000000000000800000000000010000000000000020400000000000000000000000400000000000000000000000000004000000001000000000000000000000000000000000000020000000000010000000800000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020800000000200000000000000000000000000000000000000000000000000400000000800000000000000000000000020000000000000000000000000000000000000000000000000000000008000000800", + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f", + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "logs": [ + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 98, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 99, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 100, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "topics": [ + "0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 101, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + } + ], + "blockNumber": 16327114, + "cumulativeGasUsed": "8956336", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "0x123694886DBf5Ac94DDA07135349534536D14cAf" + ], + "numDeployments": 1, + "solcInputHash": "b466ba551e3f54d5eed446f39b17a223", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ICollateralToken\",\"name\":\"_collateralToken\",\"type\":\"address\"},{\"internalType\":\"contract UnderwriterToken\",\"name\":\"_underwriterToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"rewardsManager\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAssetPool\",\"type\":\"address\"}],\"name\":\"ApprovedAssetPoolUpgrade\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"collateralAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"AssetPoolUpgraded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"cancelledAssetPool\",\"type\":\"address\"}],\"name\":\"CancelledAssetPoolUpgrade\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"CoverageClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"Deposited\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalDelay\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalDelayUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"WithdrawalDelayUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalInitiated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalTimeout\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"WithdrawalTimeoutUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"withdrawalTimeout\",\"type\":\"uint256\"}],\"name\":\"WithdrawalTimeoutUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IAssetPoolUpgrade\",\"name\":\"_newAssetPool\",\"type\":\"address\"}],\"name\":\"approveNewAssetPoolUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newWithdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_newWithdrawalTimeout\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cancelNewAssetPoolUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateralToken\",\"outputs\":[{\"internalType\":\"contract ICollateralToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"underwriter\",\"type\":\"address\"}],\"name\":\"completeWithdrawal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToDeposit\",\"type\":\"uint256\"}],\"name\":\"deposit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToDeposit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"minAmountToMint\",\"type\":\"uint256\"}],\"name\":\"depositWithMin\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRemainingWithdrawalDelayUpdateTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRemainingWithdrawalTimeoutUpdateTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"grantShares\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"initiateWithdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newAssetPool\",\"outputs\":[{\"internalType\":\"contract IAssetPoolUpgrade\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newWithdrawalDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newWithdrawalTimeout\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pendingWithdrawal\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rewardsPool\",\"outputs\":[{\"internalType\":\"contract RewardsPool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underwriterToken\",\"outputs\":[{\"internalType\":\"contract UnderwriterToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_newAssetPool\",\"type\":\"address\"}],\"name\":\"upgradeToNewAssetPool\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalDelayChangeInitiated\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalGovernanceDelay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"withdrawalInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalTimeout\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdrawalTimeoutChangeInitiated\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"beginWithdrawalDelayUpdate(uint256)\":{\"params\":{\"_newWithdrawalDelay\":\"The new value of withdrawal delay\"}},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"params\":{\"_newWithdrawalTimeout\":\"The new value of the withdrawal timeout\"}},\"completeWithdrawal(address)\":{\"returns\":{\"_0\":\"The amount of collateral withdrawn\"}},\"deposit(uint256)\":{\"details\":\"Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.\",\"params\":{\"amountToDeposit\":\"Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1\"},\"returns\":{\"_0\":\"The amount of minted underwriter tokens\"}},\"depositWithMin(uint256,uint256)\":{\"details\":\"Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.\",\"params\":{\"amountToDeposit\":\"Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1\",\"minAmountToMint\":\"Underwriter minimal tokens amount that a user expects to receive in exchange for the deposited collateral tokens\"},\"returns\":{\"_0\":\"The amount of minted underwriter tokens\"}},\"getRemainingWithdrawalDelayUpdateTime()\":{\"returns\":{\"_0\":\"The time left until withdrawal delay update can be finalized\"}},\"getRemainingWithdrawalTimeoutUpdateTime()\":{\"returns\":{\"_0\":\"The time left until withdrawal timeout update can be finalized\"}},\"grantShares(address,uint256)\":{\"details\":\"Can be called only by the contract owner.\",\"params\":{\"covAmount\":\"Amount of the underwriter tokens which should be minted\",\"recipient\":\"Address of the underwriter tokens recipient\"}},\"initiateWithdrawal(uint256)\":{\"details\":\"Before calling this function, underwriter token needs to have the required amount accepted to transfer to the asset pool.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"details\":\"This function is a shortcut for approve + deposit.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"totalValue()\":{\"returns\":{\"_0\":\"The total value of asset pool in collateral token.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgradeToNewAssetPool(uint256,address)\":{\"params\":{\"_newAssetPool\":\"New Asset Pool address to check validity with the one that was approved by the governance\",\"covAmount\":\"Amount of underwriter tokens used to calculate collateral tokens which are transferred to a new asset pool\"}},\"withdrawalGovernanceDelay()\":{\"returns\":{\"_0\":\"The withdrawal governance delay in seconds\"}}},\"title\":\"Asset Pool\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"approveNewAssetPoolUpgrade(address)\":{\"notice\":\"Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay.\"},\"beginWithdrawalDelayUpdate(uint256)\":{\"notice\":\"Lets the contract owner to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible.\"},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"notice\":\"Lets the contract owner to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value.\"},\"cancelNewAssetPoolUpgrade()\":{\"notice\":\"Allows governance to cancel already approved new asset pool in case of some misconfiguration.\"},\"claim(address,uint256)\":{\"notice\":\"Allows the coverage pool to demand coverage from the asset hold by this pool and send it to the provided recipient address.\"},\"completeWithdrawal(address)\":{\"notice\":\"Completes the previously initiated withdrawal for the underwriter. Anyone can complete the withdrawal for the underwriter. The withdrawal has to be completed before the withdrawal timeout elapses. Otherwise, the withdrawal has to be initiated again and the underwriter has to wait for the entire withdrawal delay again before being able to complete the withdrawal.\"},\"deposit(uint256)\":{\"notice\":\"Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts.\"},\"depositWithMin(uint256,uint256)\":{\"notice\":\"Accepts the given amount of collateral token as a deposit and mints at least a minAmountToMint underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts.\"},\"finalizeWithdrawalDelayUpdate()\":{\"notice\":\"Lets the contract owner to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass.\"},\"finalizeWithdrawalTimeoutUpdate()\":{\"notice\":\"Lets the contract owner to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass.\"},\"getRemainingWithdrawalDelayUpdateTime()\":{\"notice\":\"Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal delay update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum.\"},\"getRemainingWithdrawalTimeoutUpdateTime()\":{\"notice\":\"Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal timeout update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum.\"},\"grantShares(address,uint256)\":{\"notice\":\"Grants pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes.\"},\"initiateWithdrawal(uint256)\":{\"notice\":\"Initiates the withdrawal of collateral and rewards from the pool. Must be followed with completeWithdrawal call after the withdrawal delay passes. Accepts the amount of underwriter tokens representing the share of the pool that should be withdrawn. Can be called multiple times increasing the pool share to withdraw and resetting the withdrawal initiated timestamp for each call. Can be called with 0 covAmount to reset the withdrawal initiated timestamp if the underwriter has a pending withdrawal. In practice 0 covAmount should be used only to initiate the withdrawal again in case one did not complete the withdrawal before the withdrawal timeout elapsed.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts. Optional data in extraData may include a minimal amount of underwriter tokens expected to be minted for a depositor. There are cases when an amount of minted tokens matters for a depositor, as tokens might be used in third party exchanges.\"},\"totalValue()\":{\"notice\":\"Returns the current collateral token balance of the asset pool plus the reward amount (in collateral token) earned by the asset pool and not yet withdrawn to the asset pool.\"},\"upgradeToNewAssetPool(uint256,address)\":{\"notice\":\"Transfers collateral tokens to a new Asset Pool which previously was approved by the governance. Upgrade does not have to obey withdrawal delay. Old underwriter tokens are burned in favor of new tokens minted in a new Asset Pool. New tokens are sent directly to the underwriter from a new Asset Pool.\"},\"withdrawalDelay()\":{\"notice\":\"The time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim.\"},\"withdrawalGovernanceDelay()\":{\"notice\":\"The time it takes to initiate and complete the withdrawal from the pool plus 2 days to make a decision. This governance delay should be used for all changes directly affecting underwriter positions. This time is a minimum and the governance may choose to wait longer before finalizing the update.\"},\"withdrawalTimeout()\":{\"notice\":\"The time the underwriter has after the withdrawal delay passed to complete the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim. After the withdrawal timeout elapses, tokens stay in the pool and the underwriter has to initiate the withdrawal again and wait for the full withdrawal delay to complete the withdrawal.\"}},\"notice\":\"Asset pool is a component of a Coverage Pool. Asset Pool accepts a single ERC20 token as collateral, and returns an underwriter token. For example, an asset pool might accept deposits in KEEP in return for covKEEP underwriter tokens. Underwriter tokens represent an ownership share in the underlying collateral of the Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens as a deposit. It means that the total supply of the collateral token can not be greater than 2^96-1 or, if that supply is greater, it is acceptable that not all tokens can be deposited into the pool.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/AssetPool.sol\":\"AssetPool\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 /**\\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 / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xd0a917e32d1251a9b2f1dea15e932815d5382e64e6b0a18104664a6cc774cd70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"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\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./IVotesHistory.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\n/// @title Checkpoints\\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\\n/// delegation. This implementation supports token supply up to 2^96 - 1.\\n/// This contract keeps a history (checkpoints) of each account's vote\\n/// power. Vote power can be delegated either by calling the {delegate}\\n/// function directly, or by providing a signature to be used with\\n/// {delegateBySig}. Voting power can be publicly queried through\\n/// {getVotes} and {getPastVotes}.\\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\\n/// @dev This contract is upgrade-safe.\\nabstract contract Checkpoints is IVotesHistory {\\n struct Checkpoint {\\n uint32 fromBlock;\\n uint96 votes;\\n }\\n\\n // slither-disable-next-line uninitialized-state\\n mapping(address => address) internal _delegates;\\n mapping(address => uint128[]) internal _checkpoints;\\n uint128[] internal _totalSupplyCheckpoints;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n /// @notice Emitted when an account changes their delegate.\\n event DelegateChanged(\\n address indexed delegator,\\n address indexed fromDelegate,\\n address indexed toDelegate\\n );\\n\\n /// @notice Emitted when a balance or delegate change results in changes\\n /// to an account's voting power.\\n event DelegateVotesChanged(\\n address indexed delegate,\\n uint256 previousBalance,\\n uint256 newBalance\\n );\\n\\n function checkpoints(address account, uint32 pos)\\n public\\n view\\n virtual\\n returns (Checkpoint memory checkpoint)\\n {\\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\\n _checkpoints[account][pos]\\n );\\n checkpoint = Checkpoint(fromBlock, votes);\\n }\\n\\n /// @notice Get number of checkpoints for `account`.\\n function numCheckpoints(address account)\\n public\\n view\\n virtual\\n returns (uint32)\\n {\\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\\n }\\n\\n /// @notice Get the address `account` is currently delegating to.\\n function delegates(address account) public view virtual returns (address) {\\n return _delegates[account];\\n }\\n\\n /// @notice Gets the current votes balance for `account`.\\n /// @param account The address to get votes balance\\n /// @return The number of current votes for `account`\\n function getVotes(address account) public view returns (uint96) {\\n uint256 pos = _checkpoints[account].length;\\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\\n }\\n\\n /// @notice Determine the prior number of votes for an account as of\\n /// a block number.\\n /// @dev Block number must be a finalized block or else this function will\\n /// revert to prevent misinformation.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_checkpoints[account], blockNumber);\\n }\\n\\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\\n /// Note, this value is the sum of all balances, but it is NOT the\\n /// sum of all the delegated votes!\\n /// @param blockNumber The block number to get the total supply at\\n /// @dev `blockNumber` must have been already mined\\n function getPastTotalSupply(uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\\n }\\n\\n /// @notice Change delegation for `delegator` to `delegatee`.\\n // slither-disable-next-line dead-code\\n function delegate(address delegator, address delegatee) internal virtual;\\n\\n /// @notice Moves voting power from one delegate to another\\n /// @param src Address of old delegate\\n /// @param dst Address of new delegate\\n /// @param amount Voting power amount to transfer between delegates\\n function moveVotingPower(\\n address src,\\n address dst,\\n uint256 amount\\n ) internal {\\n if (src != dst && amount > 0) {\\n if (src != address(0)) {\\n // https://github.com/crytic/slither/issues/960\\n // slither-disable-next-line variable-scope\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[src],\\n subtract,\\n amount\\n );\\n emit DelegateVotesChanged(src, oldWeight, newWeight);\\n }\\n\\n if (dst != address(0)) {\\n // https://github.com/crytic/slither/issues/959\\n // slither-disable-next-line uninitialized-local\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[dst],\\n add,\\n amount\\n );\\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\\n }\\n }\\n }\\n\\n /// @notice Writes a new checkpoint based on operating last stored value\\n /// with a `delta`. Usually, said operation is the `add` or\\n /// `subtract` functions from this contract, but more complex\\n /// functions can be passed as parameters.\\n /// @param ckpts The checkpoints array to use\\n /// @param op The function to apply over the last value and the `delta`\\n /// @param delta Variation with respect to last stored value to be used\\n /// for new checkpoint\\n function writeCheckpoint(\\n uint128[] storage ckpts,\\n function(uint256, uint256) view returns (uint256) op,\\n uint256 delta\\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\\n uint256 pos = ckpts.length;\\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\\n newWeight = op(oldWeight, delta);\\n\\n if (pos > 0) {\\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\\n // slither-disable-next-line incorrect-equality\\n if (fromBlock == block.number) {\\n ckpts[pos - 1] = encodeCheckpoint(\\n fromBlock,\\n SafeCastUpgradeable.toUint96(newWeight)\\n );\\n return (oldWeight, newWeight);\\n }\\n }\\n\\n ckpts.push(\\n encodeCheckpoint(\\n SafeCastUpgradeable.toUint32(block.number),\\n SafeCastUpgradeable.toUint96(newWeight)\\n )\\n );\\n }\\n\\n /// @notice Lookup a value in a list of (sorted) checkpoints.\\n /// @param ckpts The checkpoints array to use\\n /// @param blockNumber Block number when we want to get the checkpoint at\\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\\n internal\\n view\\n returns (uint96)\\n {\\n // We run a binary search to look for the earliest checkpoint taken\\n // after `blockNumber`. During the loop, the index of the wanted\\n // checkpoint remains in the range [low-1, high). With each iteration,\\n // either `low` or `high` is moved towards the middle of the range to\\n // maintain the invariant.\\n // - If the middle checkpoint is after `blockNumber`,\\n // we look in [low, mid)\\n // - If the middle checkpoint is before or equal to `blockNumber`,\\n // we look in [mid+1, high)\\n // Once we reach a single value (when low == high), we've found the\\n // right checkpoint at the index high-1, if not out of bounds (in that\\n // case we're looking too far in the past and the result is 0).\\n // Note that if the latest checkpoint available is exactly for\\n // `blockNumber`, we end up with an index that is past the end of the\\n // array, so we technically don't find a checkpoint after\\n // `blockNumber`, but it works out the same.\\n require(blockNumber < block.number, \\\"Block not yet determined\\\");\\n\\n uint256 high = ckpts.length;\\n uint256 low = 0;\\n while (low < high) {\\n uint256 mid = MathUpgradeable.average(low, high);\\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\\n if (midBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\\n }\\n\\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\\n // slither-disable-next-line dead-code\\n function maxSupply() internal view virtual returns (uint96) {\\n return type(uint96).max;\\n }\\n\\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\\n /// checkpoint.\\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\\n /// remaining 96 bits.\\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\\n internal\\n pure\\n returns (uint128)\\n {\\n return (uint128(blockNumber) << 96) | uint128(value);\\n }\\n\\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\\n function decodeBlockNumber(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32)\\n {\\n return uint32(bytes4(bytes16(checkpoint)));\\n }\\n\\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\\n return uint96(checkpoint);\\n }\\n\\n /// @notice Decodes a block number and voting value from a `uint128`\\n /// `checkpoint`.\\n function decodeCheckpoint(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32 blockNumber, uint96 value)\\n {\\n blockNumber = decodeBlockNumber(checkpoint);\\n value = decodeValue(checkpoint);\\n }\\n\\n // slither-disable-next-line dead-code\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n // slither-disable-next-line dead-code\\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n}\\n\",\"keccak256\":\"0x67b28349e88afe7440c43df93ba5de56873d850a25147161e4469731750efb16\",\"license\":\"GPL-3.0-or-later\"},\"@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\ninterface IVotesHistory {\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n\\n function getPastTotalSupply(uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x535e87cf4c2e9a9439d99cf0918f013965fa6c4ddfbab07ff6ca4b195c8edc9f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/AssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./interfaces/IAssetPool.sol\\\";\\nimport \\\"./interfaces/IAssetPoolUpgrade.sol\\\";\\nimport \\\"./interfaces/ICollateralToken.sol\\\";\\nimport \\\"./RewardsPool.sol\\\";\\nimport \\\"./UnderwriterToken.sol\\\";\\nimport \\\"./GovernanceUtils.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Asset Pool\\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\\n/// accepts a single ERC20 token as collateral, and returns an\\n/// underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\\n/// as a deposit. It means that the total supply of the collateral token\\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\\n/// acceptable that not all tokens can be deposited into the pool.\\ncontract AssetPool is Ownable, IAssetPool {\\n using SafeERC20 for ICollateralToken;\\n using SafeERC20 for UnderwriterToken;\\n\\n ICollateralToken public immutable collateralToken;\\n UnderwriterToken public immutable underwriterToken;\\n\\n RewardsPool public immutable rewardsPool;\\n\\n IAssetPoolUpgrade public newAssetPool;\\n\\n /// @notice The time it takes the underwriter to withdraw their collateral\\n /// and rewards from the pool. This is the time that needs to pass\\n /// between initiating and completing the withdrawal. During that\\n /// time, underwriter is still earning rewards and their share of\\n /// the pool is still a subject of a possible coverage claim.\\n uint256 public withdrawalDelay = 21 days;\\n uint256 public newWithdrawalDelay;\\n uint256 public withdrawalDelayChangeInitiated;\\n\\n /// @notice The time the underwriter has after the withdrawal delay passed\\n /// to complete the withdrawal. During that time, underwriter is\\n /// still earning rewards and their share of the pool is still\\n /// a subject of a possible coverage claim.\\n /// After the withdrawal timeout elapses, tokens stay in the pool\\n /// and the underwriter has to initiate the withdrawal again and\\n /// wait for the full withdrawal delay to complete the withdrawal.\\n uint256 public withdrawalTimeout = 2 days;\\n uint256 public newWithdrawalTimeout;\\n uint256 public withdrawalTimeoutChangeInitiated;\\n\\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\\n mapping(address => uint256) public pendingWithdrawal;\\n\\n event Deposited(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount\\n );\\n\\n event CoverageClaimed(\\n address indexed recipient,\\n uint256 amount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalInitiated(\\n address indexed underwriter,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n event WithdrawalCompleted(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event ApprovedAssetPoolUpgrade(address newAssetPool);\\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\\n event AssetPoolUpgraded(\\n address indexed underwriter,\\n uint256 collateralAmount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalDelayUpdateStarted(\\n uint256 withdrawalDelay,\\n uint256 timestamp\\n );\\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\\n event WithdrawalTimeoutUpdateStarted(\\n uint256 withdrawalTimeout,\\n uint256 timestamp\\n );\\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\\n\\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\\n /// if the change was not yet initiated.\\n /// @param changeInitiatedTimestamp The timestamp at which the change has\\n /// been initiated\\n modifier onlyAfterWithdrawalGovernanceDelay(\\n uint256 changeInitiatedTimestamp\\n ) {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - changeInitiatedTimestamp >=\\n withdrawalGovernanceDelay(),\\n \\\"Governance delay has not elapsed\\\"\\n );\\n _;\\n }\\n\\n constructor(\\n ICollateralToken _collateralToken,\\n UnderwriterToken _underwriterToken,\\n address rewardsManager\\n ) {\\n collateralToken = _collateralToken;\\n underwriterToken = _underwriterToken;\\n\\n rewardsPool = new RewardsPool(\\n _collateralToken,\\n address(this),\\n rewardsManager\\n );\\n\\n initGovernance(_collateralToken);\\n }\\n\\n /// @dev Overwrite to empty if collateral token used by the AssetPool\\n /// does not support DAO checkpoints. Used for tests with KEEP token.\\n function initGovernance(ICollateralToken _collateralToken)\\n internal\\n virtual\\n {\\n _collateralToken.delegate(address(this));\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// Optional data in extraData may include a minimal amount of\\n /// underwriter tokens expected to be minted for a depositor. There\\n /// are cases when an amount of minted tokens matters for a\\n /// depositor, as tokens might be used in third party exchanges.\\n /// @dev This function is a shortcut for approve + deposit.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external {\\n require(\\n amount + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n require(msg.sender == token, \\\"Only token caller allowed\\\");\\n require(\\n token == address(collateralToken),\\n \\\"Unsupported collateral token\\\"\\n );\\n\\n uint256 toMint = _calculateTokensToMint(amount);\\n if (extraData.length != 0) {\\n require(extraData.length == 32, \\\"Unexpected data length\\\");\\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n }\\n\\n _deposit(from, amount, toMint);\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal to\\n /// 2^96-1\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amountToDeposit)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership. The amount locked in the pool after accepting\\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\\n /// function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal\\n /// to 2^96-1\\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\\n /// expects to receive in exchange for the deposited\\n /// collateral tokens\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the\\n /// pool. Must be followed with completeWithdrawal call after the\\n /// withdrawal delay passes. Accepts the amount of underwriter\\n /// tokens representing the share of the pool that should be\\n /// withdrawn. Can be called multiple times increasing the pool share\\n /// to withdraw and resetting the withdrawal initiated timestamp for\\n /// each call. Can be called with 0 covAmount to reset the\\n /// withdrawal initiated timestamp if the underwriter has a pending\\n /// withdrawal. In practice 0 covAmount should be used only to\\n /// initiate the withdrawal again in case one did not complete the\\n /// withdrawal before the withdrawal timeout elapsed.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external override {\\n uint256 pending = pendingWithdrawal[msg.sender];\\n require(\\n covAmount > 0 || pending > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n pending += covAmount;\\n pendingWithdrawal[msg.sender] = pending;\\n /* solhint-disable not-rely-on-time */\\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\\n\\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\\n /* solhint-enable not-rely-on-time */\\n\\n if (covAmount > 0) {\\n underwriterToken.safeTransferFrom(\\n msg.sender,\\n address(this),\\n covAmount\\n );\\n }\\n }\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter. Anyone can complete the withdrawal for the\\n /// underwriter. The withdrawal has to be completed before the\\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\\n /// be initiated again and the underwriter has to wait for the\\n /// entire withdrawal delay again before being able to complete\\n /// the withdrawal.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter)\\n external\\n override\\n returns (uint256)\\n {\\n /* solhint-disable not-rely-on-time */\\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\\n require(initiatedAt > 0, \\\"No withdrawal initiated for the underwriter\\\");\\n\\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\\n require(\\n withdrawalDelayEndTimestamp < block.timestamp,\\n \\\"Withdrawal delay has not elapsed\\\"\\n );\\n\\n require(\\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\\n \\\"Withdrawal timeout elapsed\\\"\\n );\\n\\n uint256 covAmount = pendingWithdrawal[underwriter];\\n uint256 covSupply = underwriterToken.totalSupply();\\n delete withdrawalInitiatedTimestamp[underwriter];\\n delete pendingWithdrawal[underwriter];\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\\n\\n emit WithdrawalCompleted(\\n underwriter,\\n amountToWithdraw,\\n covAmount,\\n block.timestamp\\n );\\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\\n\\n /* solhint-enable not-rely-on-time */\\n underwriterToken.burn(covAmount);\\n\\n return amountToWithdraw;\\n }\\n\\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\\n /// was approved by the governance. Upgrade does not have to obey\\n /// withdrawal delay.\\n /// Old underwriter tokens are burned in favor of new tokens minted\\n /// in a new Asset Pool. New tokens are sent directly to the\\n /// underwriter from a new Asset Pool.\\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\\n /// tokens which are transferred to a new asset pool\\n /// @param _newAssetPool New Asset Pool address to check validity with the one\\n /// that was approved by the governance\\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\\n external\\n {\\n /* solhint-disable not-rely-on-time */\\n require(\\n address(newAssetPool) != address(0),\\n \\\"New asset pool must be assigned\\\"\\n );\\n\\n require(\\n address(newAssetPool) == _newAssetPool,\\n \\\"Addresses of a new asset pool must match\\\"\\n );\\n\\n require(\\n covAmount > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\\n covSupply;\\n\\n collateralToken.safeApprove(\\n address(newAssetPool),\\n collateralToTransfer\\n );\\n // old underwriter tokens are burned in favor of new minted in a new\\n // asset pool\\n underwriterToken.burnFrom(msg.sender, covAmount);\\n // collateralToTransfer will be sent to a new AssetPool and new\\n // underwriter tokens will be minted and transferred back to the underwriter\\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\\n\\n emit AssetPoolUpgraded(\\n msg.sender,\\n collateralToTransfer,\\n covAmount,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Allows governance to set a new asset pool so the underwriters\\n /// can move their collateral tokens to a new asset pool without\\n /// having to wait for the withdrawal delay.\\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\\n external\\n onlyOwner\\n {\\n require(\\n address(_newAssetPool) != address(0),\\n \\\"New asset pool can't be zero address\\\"\\n );\\n\\n newAssetPool = _newAssetPool;\\n\\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\\n }\\n\\n /// @notice Allows governance to cancel already approved new asset pool\\n /// in case of some misconfiguration.\\n function cancelNewAssetPoolUpgrade() external onlyOwner {\\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\\n\\n newAssetPool = IAssetPoolUpgrade(address(0));\\n }\\n\\n /// @notice Allows the coverage pool to demand coverage from the asset hold\\n /// by this pool and send it to the provided recipient address.\\n function claim(address recipient, uint256 amount) external onlyOwner {\\n emit CoverageClaimed(recipient, amount, block.timestamp);\\n rewardsPool.withdraw();\\n require(\\n amount <= collateralToken.balanceOf(address(this)),\\n \\\"Amount to seize exceeds the pool balance\\\"\\n );\\n collateralToken.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal delay\\n /// parameter value. Withdrawal delay is the time it takes the\\n /// underwriter to withdraw their collateral and rewards from the\\n /// pool. This is the time that needs to pass between initiating and\\n /// completing the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalDelayUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal delay value should be but it should\\n /// be long enough so that the possibility of having free-riding\\n /// underwriters escaping from a potential coverage claim by\\n /// withdrawing their positions from the pool is negligible.\\n /// @param _newWithdrawalDelay The new value of withdrawal delay\\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\\n external\\n onlyOwner\\n {\\n newWithdrawalDelay = _newWithdrawalDelay;\\n withdrawalDelayChangeInitiated = block.timestamp;\\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// delay parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalDelayUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalDelayUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\\n {\\n withdrawalDelay = newWithdrawalDelay;\\n emit WithdrawalDelayUpdated(withdrawalDelay);\\n newWithdrawalDelay = 0;\\n withdrawalDelayChangeInitiated = 0;\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\\n /// parameter value. The withdrawal timeout is the time the\\n /// underwriter has - after the withdrawal delay passed - to\\n /// complete the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal timeout value should be but it should\\n /// be short enough so that the time of free-riding by being able to\\n /// immediately escape from the claim is minimal and long enough so\\n /// that honest underwriters have a possibility to finalize the\\n /// withdrawal. It is all about the right proportions with\\n /// a relation to withdrawal delay value.\\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\\n external\\n onlyOwner\\n {\\n newWithdrawalTimeout = _newWithdrawalTimeout;\\n withdrawalTimeoutChangeInitiated = block.timestamp;\\n emit WithdrawalTimeoutUpdateStarted(\\n _newWithdrawalTimeout,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// timeout parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalTimeoutUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\\n {\\n withdrawalTimeout = newWithdrawalTimeout;\\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\\n newWithdrawalTimeout = 0;\\n withdrawalTimeoutChangeInitiated = 0;\\n }\\n\\n /// @notice Grants pool shares by minting a given amount of the underwriter\\n /// tokens for the recipient address. In result, the recipient\\n /// obtains part of the pool ownership without depositing any\\n /// collateral tokens. Shares are usually granted for notifiers\\n /// reporting about various contract state changes.\\n /// @dev Can be called only by the contract owner.\\n /// @param recipient Address of the underwriter tokens recipient\\n /// @param covAmount Amount of the underwriter tokens which should be minted\\n function grantShares(address recipient, uint256 covAmount)\\n external\\n onlyOwner\\n {\\n rewardsPool.withdraw();\\n underwriterToken.mint(recipient, covAmount);\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal delay update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal delay update can be finalized\\n function getRemainingWithdrawalDelayUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalDelayChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal timeout update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal timeout update can be finalized\\n function getRemainingWithdrawalTimeoutUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalTimeoutChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the current collateral token balance of the asset pool\\n /// plus the reward amount (in collateral token) earned by the asset\\n /// pool and not yet withdrawn to the asset pool.\\n /// @return The total value of asset pool in collateral token.\\n function totalValue() public view returns (uint256) {\\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\\n }\\n\\n /// @notice The time it takes to initiate and complete the withdrawal from\\n /// the pool plus 2 days to make a decision. This governance delay\\n /// should be used for all changes directly affecting underwriter\\n /// positions. This time is a minimum and the governance may choose\\n /// to wait longer before finalizing the update.\\n /// @return The withdrawal governance delay in seconds\\n function withdrawalGovernanceDelay() public view returns (uint256) {\\n return withdrawalDelay + withdrawalTimeout + 2 days;\\n }\\n\\n /// @dev Calculates underwriter tokens to mint.\\n function _calculateTokensToMint(uint256 amountToDeposit)\\n internal\\n returns (uint256)\\n {\\n rewardsPool.withdraw();\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n if (covSupply == 0) {\\n return amountToDeposit;\\n }\\n\\n return (amountToDeposit * covSupply) / collateralBalance;\\n }\\n\\n function _deposit(\\n address depositor,\\n uint256 amountToDeposit,\\n uint256 amountToMint\\n ) internal {\\n require(depositor != address(this), \\\"Self-deposit not allowed\\\");\\n\\n require(\\n amountToMint > 0,\\n \\\"Minted tokens amount must be greater than 0\\\"\\n );\\n\\n emit Deposited(depositor, amountToDeposit, amountToMint);\\n\\n underwriterToken.mint(depositor, amountToMint);\\n collateralToken.safeTransferFrom(\\n depositor,\\n address(this),\\n amountToDeposit\\n );\\n }\\n}\\n\",\"keccak256\":\"0x41be5f1b06ae8b9b722c642030127cce94f571b63c4a782b155f5f42e5d61ccc\",\"license\":\"MIT\"},\"contracts/GovernanceUtils.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nlibrary GovernanceUtils {\\n /// @notice Gets the time remaining until the governable parameter update\\n /// can be committed.\\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\\n /// @param delay Governance delay.\\n /// @return Remaining time in seconds.\\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\\n internal\\n view\\n returns (uint256)\\n {\\n require(changeTimestamp > 0, \\\"Change not initiated\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n uint256 elapsed = block.timestamp - changeTimestamp;\\n if (elapsed >= delay) {\\n return 0;\\n } else {\\n return delay - elapsed;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x991d317527b08149a0e263c4c951e5969b29d48fd3aa64b2807de70fc766fd91\",\"license\":\"MIT\"},\"contracts/RewardsPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Rewards Pool\\n/// @notice RewardsPool accepts a single reward token and releases it to the\\n/// AssetPool over time in one week reward intervals. The owner of this\\n/// contract is the reward distribution address funding it with reward\\n/// tokens.\\ncontract RewardsPool is Ownable {\\n using SafeERC20 for IERC20;\\n\\n uint256 public constant DURATION = 7 days;\\n\\n IERC20 public immutable rewardToken;\\n address public immutable assetPool;\\n\\n // timestamp of the current reward interval end or the timestamp of the\\n // last interval end in case a new reward interval has not been allocated\\n uint256 public intervalFinish = 0;\\n // rate per second with which reward tokens are unlocked\\n uint256 public rewardRate = 0;\\n // amount of rewards accumulated and not yet withdrawn from the previous\\n // reward interval(s)\\n uint256 public rewardAccumulated = 0;\\n // the last time information in this contract was updated\\n uint256 public lastUpdateTime = 0;\\n\\n event RewardToppedUp(uint256 amount);\\n event RewardWithdrawn(uint256 amount);\\n\\n constructor(\\n IERC20 _rewardToken,\\n address _assetPool,\\n address owner\\n ) {\\n rewardToken = _rewardToken;\\n // slither-disable-next-line missing-zero-check\\n assetPool = _assetPool;\\n transferOwnership(owner);\\n }\\n\\n /// @notice Transfers the provided reward amount into RewardsPool and\\n /// creates a new, one-week reward interval starting from now.\\n /// Reward tokens from the previous reward interval that unlocked\\n /// over the time will be available for withdrawal immediately.\\n /// Reward tokens from the previous interval that has not been yet\\n /// unlocked, are added to the new interval being created.\\n /// @dev This function can be called only by the owner given that it creates\\n /// a new interval with one week length, starting from now.\\n function topUpReward(uint256 reward) external onlyOwner {\\n rewardAccumulated = earned();\\n\\n /* solhint-disable not-rely-on-time */\\n if (block.timestamp >= intervalFinish) {\\n // see https://github.com/crytic/slither/issues/844\\n // slither-disable-next-line divide-before-multiply\\n rewardRate = reward / DURATION;\\n } else {\\n uint256 remaining = intervalFinish - block.timestamp;\\n uint256 leftover = remaining * rewardRate;\\n rewardRate = (reward + leftover) / DURATION;\\n }\\n intervalFinish = block.timestamp + DURATION;\\n lastUpdateTime = block.timestamp;\\n /* solhint-enable avoid-low-level-calls */\\n\\n emit RewardToppedUp(reward);\\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\\n function withdraw() external {\\n uint256 amount = earned();\\n rewardAccumulated = 0;\\n lastUpdateTime = lastTimeRewardApplicable();\\n emit RewardWithdrawn(amount);\\n rewardToken.safeTransfer(assetPool, amount);\\n }\\n\\n /// @notice Returns the amount of earned and not yet withdrawn reward\\n /// tokens.\\n function earned() public view returns (uint256) {\\n return\\n rewardAccumulated +\\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\\n }\\n\\n /// @notice Returns the timestamp at which a reward was last time applicable.\\n /// When reward interval is pending, returns current block's\\n /// timestamp. If the last reward interval ended and no other reward\\n /// interval had been allocated, returns the last reward interval's\\n /// end timestamp.\\n function lastTimeRewardApplicable() public view returns (uint256) {\\n return Math.min(block.timestamp, intervalFinish);\\n }\\n}\\n\",\"keccak256\":\"0xe56e8c35bbafad758cc66473f113ea9fd3ffa9c44c6139fc3196dbbead2a4054\",\"license\":\"MIT\"},\"contracts/UnderwriterToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\\";\\n\\n/// @title UnderwriterToken\\n/// @notice Underwriter tokens represent an ownership share in the underlying\\n/// collateral of the asset-specific pool. Underwriter tokens are minted\\n/// when a user deposits ERC20 tokens into asset-specific pool and they\\n/// are burned when a user exits the position. Underwriter tokens\\n/// natively support meta transactions. Users can authorize a transfer\\n/// of their underwriter tokens with a signature conforming EIP712\\n/// standard instead of an on-chain transaction from their address.\\n/// Anyone can submit this signature on the user's behalf by calling the\\n/// permit function, as specified in EIP2612 standard, paying gas fees,\\n/// and possibly performing other actions in the same transaction.\\n// slither-disable-next-line missing-inheritance\\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\\n /// @notice The EIP-712 typehash for the delegation struct used by\\n /// `delegateBySig`.\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\n \\\"Delegation(address delegatee,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n constructor(string memory _name, string memory _symbol)\\n ERC20WithPermit(_name, _symbol)\\n {}\\n\\n /// @notice Delegates votes from signatory to `delegatee`\\n /// @param delegatee The address to delegate votes to\\n /// @param deadline The time at which to expire the signature\\n /// @param v The recovery byte of the signature\\n /// @param r Half of the ECDSA signature pair\\n /// @param s Half of the ECDSA signature pair\\n function delegateBySig(\\n address signatory,\\n address delegatee,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Delegation expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n DELEGATION_TYPEHASH,\\n delegatee,\\n nonce[signatory]++,\\n deadline\\n )\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == signatory,\\n \\\"Invalid signature\\\"\\n );\\n\\n return delegate(signatory, delegatee);\\n }\\n\\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) public virtual {\\n return delegate(msg.sender, delegatee);\\n }\\n\\n /// @notice Moves voting power when tokens are minted, burned or transferred.\\n /// @dev Overrides the empty function from the parent contract.\\n /// @param from The address that loses tokens and voting power\\n /// @param to The address that gains tokens and voting power\\n /// @param amount The amount of tokens and voting power that is transferred\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal override {\\n // When minting:\\n if (from == address(0)) {\\n // Does not allow to mint more than uint96 can fit. Otherwise, the\\n // Checkpoint might not fit the balance.\\n require(\\n totalSupply + amount <= maxSupply(),\\n \\\"Maximum total supply exceeded\\\"\\n );\\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\\n }\\n\\n // When burning:\\n if (to == address(0)) {\\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\\n }\\n\\n moveVotingPower(delegates(from), delegates(to), amount);\\n }\\n\\n /// @notice Delegate votes from `delegator` to `delegatee`.\\n /// @param delegator The address to delegate votes from\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegator, address delegatee) internal override {\\n address currentDelegate = delegates(delegator);\\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\\n _delegates[delegator] = delegatee;\\n\\n emit DelegateChanged(delegator, currentDelegate, delegatee);\\n\\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\\n }\\n}\\n\",\"keccak256\":\"0x73aa9781275a0e35c0c80873bfbb3b4b42692fa56f785a3eb4bf0471fb3c277d\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool interface\\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\\n/// an underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool.\\ninterface IAssetPool {\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amount) external returns (uint256);\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n returns (uint256);\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external;\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x5b4f1ad0d424a3de30a85a0ef1639c556073bc2eb58dc493b84c3d39a4c01847\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPoolUpgrade.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool upgrade interface\\n/// @notice Interface that has to be implemented by an Asset Pool accepting\\n/// upgrades from another asset pool.\\ninterface IAssetPoolUpgrade {\\n /// @notice Accepts the given underwriter with collateral tokens amount as a\\n /// deposit. In exchange new underwriter tokens will be calculated,\\n /// minted and then transferred back to the underwriter.\\n function depositFor(address underwriter, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0xcba05501e84b0c914619e2df9e30a6013254440013783f28deed9fc6698c58bd\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/// @title Collateral Token interface\\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\\n/// as a deposit token by underwriters. Collateral token positions of\\n/// underwriters can be affected when the Risk Manager claims coverage.\\n/// Collateral token needs to support DAO checkpoints and let to\\n/// retrieve past number of votes for the given address so that\\n/// Coverage Pool underwriters can participate in token holder DAO.\\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\ninterface ICollateralToken is IERC20 {\\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) external;\\n\\n /// @notice Determine the prior number of DAO votes for an account as of\\n /// a block number.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x7eee350d9c04b671643621258db266b65f46eea752acd7183f0bccac0eb1e233\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60e0604052621baf806002556202a3006005553480156200001f57600080fd5b5060405162005ca938038062005ca9833981810160405281019062000045919062000397565b62000065620000596200015760201b60201c565b6200015f60201b60201c565b8273ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050823082604051620000de9062000295565b620000ec939291906200046f565b604051809103906000f08015801562000109573d6000803e3d6000fd5b5073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250506200014e836200022360201b60201c565b505050620004c9565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8073ffffffffffffffffffffffffffffffffffffffff16635c19a95c306040518263ffffffff1660e01b81526004016200025e9190620004ac565b600060405180830381600087803b1580156200027957600080fd5b505af11580156200028e573d6000803e3d6000fd5b5050505050565b61180a806200449f83390190565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620002d582620002a8565b9050919050565b6000620002e982620002c8565b9050919050565b620002fb81620002dc565b81146200030757600080fd5b50565b6000815190506200031b81620002f0565b92915050565b60006200032e82620002c8565b9050919050565b620003408162000321565b81146200034c57600080fd5b50565b600081519050620003608162000335565b92915050565b6200037181620002c8565b81146200037d57600080fd5b50565b600081519050620003918162000366565b92915050565b600080600060608486031215620003b357620003b2620002a3565b5b6000620003c3868287016200030a565b9350506020620003d6868287016200034f565b9250506040620003e98682870162000380565b9150509250925092565b6000819050919050565b60006200041e620004186200041284620002a8565b620003f3565b620002a8565b9050919050565b60006200043282620003fd565b9050919050565b6000620004468262000425565b9050919050565b620004588162000439565b82525050565b6200046981620002c8565b82525050565b60006060820190506200048660008301866200044d565b6200049560208301856200045e565b620004a460408301846200045e565b949350505050565b6000602082019050620004c360008301846200045e565b92915050565b60805160a05160c051613efe620005a1600039600081816105d801528181610efb015281816114c6015281816117f501528181611bd601528181611f08015261219d01526000818161089f01528181610dd5015281816110e0015281816117cf01528181611b3601528181611d8b01528181611f880152818161221f01526124a2015260008181610f7d0152818161109a015281816112a10152818161154601528181611636015281816116800152818161189301528181611c5801528181611d45015281816122c101526125350152613efe6000f3fe608060405234801561001057600080fd5b50600436106101fb5760003560e01c8063715018a61161011a578063aad3ec96116100ad578063cc5398041161007c578063cc53980414610546578063d4c3eea014610564578063f2fde38b14610582578063fca555621461059e578063ff603d22146105ba576101fb565b8063aad3ec96146104d2578063b2016bd4146104ee578063b6b55f251461050c578063c2ef0dd61461053c576101fb565b80639ac9e7e5116100e95780639ac9e7e51461044a578063a6a56fa314610466578063a7ab696114610484578063a84f0f3f146104a2576101fb565b8063715018a6146103e85780638b4bcc4a146103f25780638da5cb5b146104105780638f4ffcb11461042e576101fb565b80632d2545e71161019257806347a5cfdb1161016157806347a5cfdb1461034e57806369da62f41461036c5780636c51741c146103885780636dbaf9ee146103b8576101fb565b80632d2545e7146102d65780633366b20b146102f45780633642110d146103125780634265117014610330576101fb565b80630964c95b116101ce5780630964c95b1461026457806312edde5e1461029457806315245857146102b05780632828fdb1146102ba576101fb565b80630359fea9146102005780630535f3bd1461021e57806307e039301461023c578063092b7eb51461025a575b600080fd5b6102086105d6565b6040516102159190612b43565b60405180910390f35b6102266105fa565b6040516102339190612b77565b60405180910390f35b610244610600565b6040516102519190612b77565b60405180910390f35b610262610606565b005b61027e60048036038101906102799190612bda565b6106fe565b60405161028b9190612b77565b60405180910390f35b6102ae60048036038101906102a99190612c33565b610716565b005b6102b86108e9565b005b6102d460048036038101906102cf9190612c33565b6109e1565b005b6102de610a33565b6040516102eb9190612b77565b60405180910390f35b6102fc610a58565b6040516103099190612c81565b60405180910390f35b61031a610a7e565b6040516103279190612b77565b60405180910390f35b610338610a98565b6040516103459190612b77565b60405180910390f35b610356610a9e565b6040516103639190612b77565b60405180910390f35b61038660048036038101906103819190612cda565b610aa4565b005b6103a2600480360381019061039d9190612d07565b610b97565b6040516103af9190612b77565b60405180910390f35b6103d260048036038101906103cd9190612bda565b610c61565b6040516103df9190612b77565b60405180910390f35b6103f0611177565b005b6103fa61118b565b6040516104079190612b77565b60405180910390f35b6104186111a5565b6040516104259190612d56565b60405180910390f35b61044860048036038101906104439190612dd6565b6111ce565b005b610464600480360381019061045f9190612c33565b6113f6565b005b61046e611448565b60405161047b9190612b77565b60405180910390f35b61048c61144e565b6040516104999190612b77565b60405180910390f35b6104bc60048036038101906104b79190612bda565b611454565b6040516104c99190612b77565b60405180910390f35b6104ec60048036038101906104e79190612e5e565b61146c565b005b6104f661167e565b6040516105039190612ebf565b60405180910390f35b61052660048036038101906105219190612c33565b6116a2565b6040516105339190612b77565b60405180910390f35b610544611728565b005b61054e6117cd565b60405161055b9190612efb565b60405180910390f35b61056c6117f1565b6040516105799190612b77565b60405180910390f35b61059c60048036038101906105979190612bda565b611949565b005b6105b860048036038101906105b39190612f16565b6119cd565b005b6105d460048036038101906105cf9190612e5e565b611efe565b005b7f000000000000000000000000000000000000000000000000000000000000000081565b60035481565b60065481565b61060e612017565b60045460008111610654576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064b90612fb3565b60405180910390fd5b61065c610a33565b81426106689190613002565b10156106a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a090613082565b60405180910390fd5b6003546002819055507fb34b8e54226bc5e8f4a9d846e344e0c42d09eeb1c79798df7ce7460c16071e2d6002546040516106e39190612b77565b60405180910390a16000600381905550600060048190555050565b60096020528060005260406000206000915090505481565b6000600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008211806107695750600081115b6107a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079f90613114565b60405180910390fd5b81816107b49190613134565b905080600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555042600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401824260405161088692919061318a565b60405180910390a260008211156108e5576108e43330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b5b5050565b6108f1612017565b60075460008111610937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092e90612fb3565b60405180910390fd5b61093f610a33565b814261094b9190613002565b101561098c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098390613082565b60405180910390fd5b6006546005819055507f9598c02e95262720ac8491c6255a4e2cfdabfb1595e7db4075699a286c0e51786005546040516109c69190612b77565b60405180910390a16000600681905550600060078190555050565b6109e9612017565b80600681905550426007819055507fea7f37aef8286a6784bab40be2b2b8d865d3a302ebaa9554a93393f0af4991be8142604051610a2892919061318a565b60405180910390a150565b60006202a300600554600254610a499190613134565b610a539190613134565b905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610a93600754610a8e610a33565b61211e565b905090565b60055481565b60045481565b610aac612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1390613225565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f798c873acf96c84f872a0ba8ab09b2eda82566b35ec01de0053dddc703294bd581604051610b8c9190612d56565b60405180910390a150565b60006bffffffffffffffffffffffff8016610bb06117f1565b84610bbb9190613134565b1115610bfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf390613291565b60405180910390fd5b6000610c0784612199565b905080831115610c4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4390613323565b60405180910390fd5b610c5733858361239e565b8091505092915050565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111610ce9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce0906133b5565b60405180910390fd5b600060025482610cf99190613134565b9050428110610d3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3490613421565b60405180910390fd5b4260055482610d4c9190613134565b1015610d8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d849061348d565b60405180910390fd5b6000600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3957600080fd5b505afa158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7191906134c2565b9050600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090557f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f6157600080fd5b505af1158015610f75573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610fd49190612d56565b60206040518083038186803b158015610fec57600080fd5b505afa158015611000573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102491906134c2565b9050600082828561103591906134ef565b61103f9190613578565b90508773ffffffffffffffffffffffffffffffffffffffff167fabed221d0c46913d6cc666ed64634168e3f1cc2638e31c6bdae1cba0b3681e4682864260405161108b939291906135a9565b60405180910390a26110de88827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b81526004016111379190612b77565b600060405180830381600087803b15801561115157600080fd5b505af1158015611165573d6000803e3d6000fd5b50505050809650505050505050919050565b61117f612017565b6111896000612605565b565b60006111a060045461119b610a33565b61211e565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6bffffffffffffffffffffffff80166111e56117f1565b856111f09190613134565b1115611231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122890613291565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461129f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112969061362c565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132490613698565b60405180910390fd5b600061133885612199565b9050600083839050146113e3576020838390501461138b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138290613704565b60405180910390fd5b6000838381019061139c9190612c33565b9050818111156113e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d890613323565b60405180910390fd5b505b6113ee86868361239e565b505050505050565b6113fe612017565b80600381905550426004819055507fad53a24a52f2d7f29240a9dbf89503d658764ecda61f09dc6fc99f8384b40a51814260405161143d92919061318a565b60405180910390a150565b60075481565b60025481565b60086020528060005260406000206000915090505481565b611474612017565b8173ffffffffffffffffffffffffffffffffffffffff167f954df0664683c9ae1eee78683930912208efdac997b3c0454ac72a9262e4e37c82426040516114bc92919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561152c57600080fd5b505af1158015611540573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161159d9190612d56565b60206040518083038186803b1580156115b557600080fd5b505afa1580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed91906134c2565b81111561162f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162690613796565b60405180910390fd5b61167a82827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b5050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006bffffffffffffffffffffffff80166116bb6117f1565b836116c69190613134565b1115611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe90613291565b60405180910390fd5b600061171283612199565b905061171f33848361239e565b80915050919050565b611730612017565b7fc5b126eaad8719040f9f4a97c3fee33e39511a07b0c7506940708ea84da3cbb5600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516117819190612d56565b60405180910390a16000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d6f192626040518163ffffffff1660e01b815260040160206040518083038186803b15801561185957600080fd5b505afa15801561186d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189191906134c2565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016118ea9190612d56565b60206040518083038186803b15801561190257600080fd5b505afa158015611916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193a91906134c2565b6119449190613134565b905090565b611951612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b890613828565b60405180910390fd5b6119ca81612605565b50565b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5690613894565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611aef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae690613926565b60405180910390fd5b60008211611b32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2990613114565b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b9a57600080fd5b505afa158015611bae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd291906134c2565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611c3c57600080fd5b505af1158015611c50573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611caf9190612d56565b60206040518083038186803b158015611cc757600080fd5b505afa158015611cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cff91906134c2565b90506000828286611d1091906134ef565b611d1a9190613578565b9050611d89600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166126c99092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166379cc679033876040518363ffffffff1660e01b8152600401611de4929190613946565b600060405180830381600087803b158015611dfe57600080fd5b505af1158015611e12573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632f4f21e233836040518363ffffffff1660e01b8152600401611e73929190613946565b600060405180830381600087803b158015611e8d57600080fd5b505af1158015611ea1573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167f52a02543e8a884453eaf1c2c5bec12d4f9e7ad29faa4ce468387ea34cef9a911828742604051611eef939291906135a9565b60405180910390a25050505050565b611f06612017565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401611fe1929190613946565b600060405180830381600087803b158015611ffb57600080fd5b505af115801561200f573d6000803e3d6000fd5b505050505050565b61201f612827565b73ffffffffffffffffffffffffffffffffffffffff1661203d6111a5565b73ffffffffffffffffffffffffffffffffffffffff1614612093576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208a906139bb565b60405180910390fd5b565b612118846323b872dd60e01b8585856040516024016120b6939291906139db565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b50505050565b6000808311612162576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161215990612fb3565b60405180910390fd5b600083426121709190613002565b9050828110612183576000915050612193565b808361218f9190613002565b9150505b92915050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561220357600080fd5b505af1158015612217573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561228357600080fd5b505afa158015612297573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122bb91906134c2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016123189190612d56565b60206040518083038186803b15801561233057600080fd5b505afa158015612344573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236891906134c2565b9050600082141561237d578392505050612399565b80828561238a91906134ef565b6123949190613578565b925050505b919050565b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561240d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240490613a5e565b60405180910390fd5b60008111612450576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161244790613af0565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff167f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca838360405161249892919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1984836040518363ffffffff1660e01b81526004016124fb929190613946565b600060405180830381600087803b15801561251557600080fd5b505af1158015612529573d6000803e3d6000fd5b5050505061257a8330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b505050565b6126008363a9059cbb60e01b848460405160240161259e929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000811480612762575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b8152600401612710929190613b10565b60206040518083038186803b15801561272857600080fd5b505afa15801561273c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276091906134c2565b145b6127a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161279890613bab565b60405180910390fd5b6128228363095ea7b360e01b84846040516024016127c0929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b600033905090565b6000612891826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166128f69092919063ffffffff16565b90506000815111156128f157808060200190518101906128b19190613c03565b6128f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128e790613ca2565b60405180910390fd5b5b505050565b6060612905848460008561290e565b90509392505050565b606082471015612953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294a90613d34565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161297c9190613dce565b60006040518083038185875af1925050503d80600081146129b9576040519150601f19603f3d011682016040523d82523d6000602084013e6129be565b606091505b50915091506129cf878383876129db565b92505050949350505050565b60608315612a3e57600083511415612a36576129f685612a51565b612a35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2c90613e31565b60405180910390fd5b5b829050612a49565b612a488383612a74565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115612a875781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612abb9190613ea6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000612b09612b04612aff84612ac4565b612ae4565b612ac4565b9050919050565b6000612b1b82612aee565b9050919050565b6000612b2d82612b10565b9050919050565b612b3d81612b22565b82525050565b6000602082019050612b586000830184612b34565b92915050565b6000819050919050565b612b7181612b5e565b82525050565b6000602082019050612b8c6000830184612b68565b92915050565b600080fd5b600080fd5b6000612ba782612ac4565b9050919050565b612bb781612b9c565b8114612bc257600080fd5b50565b600081359050612bd481612bae565b92915050565b600060208284031215612bf057612bef612b92565b5b6000612bfe84828501612bc5565b91505092915050565b612c1081612b5e565b8114612c1b57600080fd5b50565b600081359050612c2d81612c07565b92915050565b600060208284031215612c4957612c48612b92565b5b6000612c5784828501612c1e565b91505092915050565b6000612c6b82612b10565b9050919050565b612c7b81612c60565b82525050565b6000602082019050612c966000830184612c72565b92915050565b6000612ca782612b9c565b9050919050565b612cb781612c9c565b8114612cc257600080fd5b50565b600081359050612cd481612cae565b92915050565b600060208284031215612cf057612cef612b92565b5b6000612cfe84828501612cc5565b91505092915050565b60008060408385031215612d1e57612d1d612b92565b5b6000612d2c85828601612c1e565b9250506020612d3d85828601612c1e565b9150509250929050565b612d5081612b9c565b82525050565b6000602082019050612d6b6000830184612d47565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112612d9657612d95612d71565b5b8235905067ffffffffffffffff811115612db357612db2612d76565b5b602083019150836001820283011115612dcf57612dce612d7b565b5b9250929050565b600080600080600060808688031215612df257612df1612b92565b5b6000612e0088828901612bc5565b9550506020612e1188828901612c1e565b9450506040612e2288828901612bc5565b935050606086013567ffffffffffffffff811115612e4357612e42612b97565b5b612e4f88828901612d80565b92509250509295509295909350565b60008060408385031215612e7557612e74612b92565b5b6000612e8385828601612bc5565b9250506020612e9485828601612c1e565b9150509250929050565b6000612ea982612b10565b9050919050565b612eb981612e9e565b82525050565b6000602082019050612ed46000830184612eb0565b92915050565b6000612ee582612b10565b9050919050565b612ef581612eda565b82525050565b6000602082019050612f106000830184612eec565b92915050565b60008060408385031215612f2d57612f2c612b92565b5b6000612f3b85828601612c1e565b9250506020612f4c85828601612bc5565b9150509250929050565b600082825260208201905092915050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b6000612f9d601483612f56565b9150612fa882612f67565b602082019050919050565b60006020820190508181036000830152612fcc81612f90565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061300d82612b5e565b915061301883612b5e565b92508282101561302b5761302a612fd3565b5b828203905092915050565b7f476f7665726e616e63652064656c617920686173206e6f7420656c6170736564600082015250565b600061306c602083612f56565b915061307782613036565b602082019050919050565b6000602082019050818103600083015261309b8161305f565b9050919050565b7f556e64657277726974657220746f6b656e20616d6f756e74206d75737420626560008201527f2067726561746572207468616e20300000000000000000000000000000000000602082015250565b60006130fe602f83612f56565b9150613109826130a2565b604082019050919050565b6000602082019050818103600083015261312d816130f1565b9050919050565b600061313f82612b5e565b915061314a83612b5e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561317f5761317e612fd3565b5b828201905092915050565b600060408201905061319f6000830185612b68565b6131ac6020830184612b68565b9392505050565b7f4e657720617373657420706f6f6c2063616e2774206265207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061320f602483612f56565b915061321a826131b3565b604082019050919050565b6000602082019050818103600083015261323e81613202565b9050919050565b7f506f6f6c20636170616369747920657863656564656400000000000000000000600082015250565b600061327b601683612f56565b915061328682613245565b602082019050919050565b600060208201905081810360008301526132aa8161326e565b9050919050565b7f416d6f756e7420746f206d696e7420697320736d616c6c6572207468616e207460008201527f6865207265717569726564206d696e696d756d00000000000000000000000000602082015250565b600061330d603383612f56565b9150613318826132b1565b604082019050919050565b6000602082019050818103600083015261333c81613300565b9050919050565b7f4e6f207769746864726177616c20696e6974696174656420666f72207468652060008201527f756e646572777269746572000000000000000000000000000000000000000000602082015250565b600061339f602b83612f56565b91506133aa82613343565b604082019050919050565b600060208201905081810360008301526133ce81613392565b9050919050565b7f5769746864726177616c2064656c617920686173206e6f7420656c6170736564600082015250565b600061340b602083612f56565b9150613416826133d5565b602082019050919050565b6000602082019050818103600083015261343a816133fe565b9050919050565b7f5769746864726177616c2074696d656f757420656c6170736564000000000000600082015250565b6000613477601a83612f56565b915061348282613441565b602082019050919050565b600060208201905081810360008301526134a68161346a565b9050919050565b6000815190506134bc81612c07565b92915050565b6000602082840312156134d8576134d7612b92565b5b60006134e6848285016134ad565b91505092915050565b60006134fa82612b5e565b915061350583612b5e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561353e5761353d612fd3565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061358382612b5e565b915061358e83612b5e565b92508261359e5761359d613549565b5b828204905092915050565b60006060820190506135be6000830186612b68565b6135cb6020830185612b68565b6135d86040830184612b68565b949350505050565b7f4f6e6c7920746f6b656e2063616c6c657220616c6c6f77656400000000000000600082015250565b6000613616601983612f56565b9150613621826135e0565b602082019050919050565b6000602082019050818103600083015261364581613609565b9050919050565b7f556e737570706f7274656420636f6c6c61746572616c20746f6b656e00000000600082015250565b6000613682601c83612f56565b915061368d8261364c565b602082019050919050565b600060208201905081810360008301526136b181613675565b9050919050565b7f556e65787065637465642064617461206c656e67746800000000000000000000600082015250565b60006136ee601683612f56565b91506136f9826136b8565b602082019050919050565b6000602082019050818103600083015261371d816136e1565b9050919050565b7f416d6f756e7420746f207365697a6520657863656564732074686520706f6f6c60008201527f2062616c616e6365000000000000000000000000000000000000000000000000602082015250565b6000613780602883612f56565b915061378b82613724565b604082019050919050565b600060208201905081810360008301526137af81613773565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613812602683612f56565b915061381d826137b6565b604082019050919050565b6000602082019050818103600083015261384181613805565b9050919050565b7f4e657720617373657420706f6f6c206d7573742062652061737369676e656400600082015250565b600061387e601f83612f56565b915061388982613848565b602082019050919050565b600060208201905081810360008301526138ad81613871565b9050919050565b7f416464726573736573206f662061206e657720617373657420706f6f6c206d7560008201527f7374206d61746368000000000000000000000000000000000000000000000000602082015250565b6000613910602883612f56565b915061391b826138b4565b604082019050919050565b6000602082019050818103600083015261393f81613903565b9050919050565b600060408201905061395b6000830185612d47565b6139686020830184612b68565b9392505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006139a5602083612f56565b91506139b08261396f565b602082019050919050565b600060208201905081810360008301526139d481613998565b9050919050565b60006060820190506139f06000830186612d47565b6139fd6020830185612d47565b613a0a6040830184612b68565b949350505050565b7f53656c662d6465706f736974206e6f7420616c6c6f7765640000000000000000600082015250565b6000613a48601883612f56565b9150613a5382613a12565b602082019050919050565b60006020820190508181036000830152613a7781613a3b565b9050919050565b7f4d696e74656420746f6b656e7320616d6f756e74206d7573742062652067726560008201527f61746572207468616e2030000000000000000000000000000000000000000000602082015250565b6000613ada602b83612f56565b9150613ae582613a7e565b604082019050919050565b60006020820190508181036000830152613b0981613acd565b9050919050565b6000604082019050613b256000830185612d47565b613b326020830184612d47565b9392505050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000613b95603683612f56565b9150613ba082613b39565b604082019050919050565b60006020820190508181036000830152613bc481613b88565b9050919050565b60008115159050919050565b613be081613bcb565b8114613beb57600080fd5b50565b600081519050613bfd81613bd7565b92915050565b600060208284031215613c1957613c18612b92565b5b6000613c2784828501613bee565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000613c8c602a83612f56565b9150613c9782613c30565b604082019050919050565b60006020820190508181036000830152613cbb81613c7f565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000613d1e602683612f56565b9150613d2982613cc2565b604082019050919050565b60006020820190508181036000830152613d4d81613d11565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015613d88578082015181840152602081019050613d6d565b83811115613d97576000848401525b50505050565b6000613da882613d54565b613db28185613d5f565b9350613dc2818560208601613d6a565b80840191505092915050565b6000613dda8284613d9d565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000613e1b601d83612f56565b9150613e2682613de5565b602082019050919050565b60006020820190508181036000830152613e4a81613e0e565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000613e7882613e51565b613e828185612f56565b9350613e92818560208601613d6a565b613e9b81613e5c565b840191505092915050565b60006020820190508181036000830152613ec08184613e6d565b90509291505056fea26469706673582212206a2ec90cc79772da4ef337390a89355334ec5a1da50a012e1cd808863f30122d64736f6c6343000809003360c060405260006001556000600255600060035560006004553480156200002557600080fd5b506040516200180a3803806200180a83398181016040528101906200004b9190620003b9565b6200006b6200005f620000ed60201b60201c565b620000f560201b60201c565b8273ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050620000e481620001b960201b60201c565b50505062000530565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b620001c96200025060201b60201c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156200023c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000233906200049c565b60405180910390fd5b6200024d81620000f560201b60201c565b50565b62000260620000ed60201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1662000286620002e160201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1614620002df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620002d6906200050e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200033c826200030f565b9050919050565b600062000350826200032f565b9050919050565b620003628162000343565b81146200036e57600080fd5b50565b600081519050620003828162000357565b92915050565b62000393816200032f565b81146200039f57600080fd5b50565b600081519050620003b38162000388565b92915050565b600080600060608486031215620003d557620003d46200030a565b5b6000620003e58682870162000371565b9350506020620003f886828701620003a2565b92505060406200040b86828701620003a2565b9150509250925092565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006200048460268362000415565b9150620004918262000426565b604082019050919050565b60006020820190508181036000830152620004b78162000475565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000620004f660208362000415565b91506200050382620004be565b602082019050919050565b600060208201905081810360008301526200052981620004e7565b9050919050565b60805160a05161129f6200056b6000396000818161039301526104130152600081816103420152818161043501526105a0015261129f6000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c806380faa57d1161008c578063c910d95011610066578063c910d950146101f1578063d6f192621461020f578063f2fde38b1461022d578063f7c618c114610249576100ea565b806380faa57d146101975780638da5cb5b146101b5578063c8f33c91146101d3576100ea565b80633ccfd60b116100c85780633ccfd60b146101475780636e9a204b14610151578063715018a61461016f5780637b0a47ee14610179576100ea565b80630e807056146100ef5780631be052891461010b5780632ec939f914610129575b600080fd5b61010960048036038101906101049190610b04565b610267565b005b61011361038a565b6040516101209190610b40565b60405180910390f35b610131610391565b60405161013e9190610b9c565b60405180910390f35b61014f6103b5565b005b61015961047c565b6040516101669190610b40565b60405180910390f35b610177610482565b005b610181610496565b60405161018e9190610b40565b60405180910390f35b61019f61049c565b6040516101ac9190610b40565b60405180910390f35b6101bd6104af565b6040516101ca9190610b9c565b60405180910390f35b6101db6104d8565b6040516101e89190610b40565b60405180910390f35b6101f96104de565b6040516102069190610b40565b60405180910390f35b6102176104e4565b6040516102249190610b40565b60405180910390f35b61024760048036038101906102429190610be3565b61051a565b005b61025161059e565b60405161025e9190610c6f565b60405180910390f35b61026f6105c2565b6102776104e4565b60038190555060015442106102a05762093a80816102959190610ce8565b6002819055506102e7565b6000426001546102b09190610d19565b90506000600254826102c29190610d4d565b905062093a8081846102d49190610da7565b6102de9190610ce8565b60028190555050505b62093a80426102f69190610da7565b600181905550426004819055507fb32714d475c9d2f568d4ff24e88d0056b93256b5a04fbdb53a57f26bb765fbed816040516103329190610b40565b60405180910390a16103873330837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610640909392919063ffffffff16565b50565b62093a8081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006103bf6104e4565b905060006003819055506103d161049c565b6004819055507f150a6ec0e6f4e9ddcaaaa1674f157d91165a42d60653016f87a9fc870a39f050816040516104069190610b40565b60405180910390a16104797f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106c99092919063ffffffff16565b50565b60035481565b61048a6105c2565b610494600061074f565b565b60025481565b60006104aa42600154610813565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b60015481565b60006002546004546104f461049c565b6104fe9190610d19565b6105089190610d4d565b6003546105159190610da7565b905090565b6105226105c2565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610592576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058990610e80565b60405180910390fd5b61059b8161074f565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6105ca61082c565b73ffffffffffffffffffffffffffffffffffffffff166105e86104af565b73ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063590610eec565b60405180910390fd5b565b6106c3846323b872dd60e01b85858560405160240161066193929190610f0c565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b50505050565b61074a8363a9059cbb60e01b84846040516024016106e8929190610f43565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183106108225781610824565b825b905092915050565b600033905090565b6000610896826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108fb9092919063ffffffff16565b90506000815111156108f657808060200190518101906108b69190610fa4565b6108f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ec90611043565b60405180910390fd5b5b505050565b606061090a8484600085610913565b90509392505050565b606082471015610958576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094f906110d5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610981919061116f565b60006040518083038185875af1925050503d80600081146109be576040519150601f19603f3d011682016040523d82523d6000602084013e6109c3565b606091505b50915091506109d4878383876109e0565b92505050949350505050565b60608315610a4357600083511415610a3b576109fb85610a56565b610a3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a31906111d2565b60405180910390fd5b5b829050610a4e565b610a4d8383610a79565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610a8c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac09190611247565b60405180910390fd5b600080fd5b6000819050919050565b610ae181610ace565b8114610aec57600080fd5b50565b600081359050610afe81610ad8565b92915050565b600060208284031215610b1a57610b19610ac9565b5b6000610b2884828501610aef565b91505092915050565b610b3a81610ace565b82525050565b6000602082019050610b556000830184610b31565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8682610b5b565b9050919050565b610b9681610b7b565b82525050565b6000602082019050610bb16000830184610b8d565b92915050565b610bc081610b7b565b8114610bcb57600080fd5b50565b600081359050610bdd81610bb7565b92915050565b600060208284031215610bf957610bf8610ac9565b5b6000610c0784828501610bce565b91505092915050565b6000819050919050565b6000610c35610c30610c2b84610b5b565b610c10565b610b5b565b9050919050565b6000610c4782610c1a565b9050919050565b6000610c5982610c3c565b9050919050565b610c6981610c4e565b82525050565b6000602082019050610c846000830184610c60565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610cf382610ace565b9150610cfe83610ace565b925082610d0e57610d0d610c8a565b5b828204905092915050565b6000610d2482610ace565b9150610d2f83610ace565b925082821015610d4257610d41610cb9565b5b828203905092915050565b6000610d5882610ace565b9150610d6383610ace565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610d9c57610d9b610cb9565b5b828202905092915050565b6000610db282610ace565b9150610dbd83610ace565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610df257610df1610cb9565b5b828201905092915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610e6a602683610dfd565b9150610e7582610e0e565b604082019050919050565b60006020820190508181036000830152610e9981610e5d565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610ed6602083610dfd565b9150610ee182610ea0565b602082019050919050565b60006020820190508181036000830152610f0581610ec9565b9050919050565b6000606082019050610f216000830186610b8d565b610f2e6020830185610b8d565b610f3b6040830184610b31565b949350505050565b6000604082019050610f586000830185610b8d565b610f656020830184610b31565b9392505050565b60008115159050919050565b610f8181610f6c565b8114610f8c57600080fd5b50565b600081519050610f9e81610f78565b92915050565b600060208284031215610fba57610fb9610ac9565b5b6000610fc884828501610f8f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061102d602a83610dfd565b915061103882610fd1565b604082019050919050565b6000602082019050818103600083015261105c81611020565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006110bf602683610dfd565b91506110ca82611063565b604082019050919050565b600060208201905081810360008301526110ee816110b2565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561112957808201518184015260208101905061110e565b83811115611138576000848401525b50505050565b6000611149826110f5565b6111538185611100565b935061116381856020860161110b565b80840191505092915050565b600061117b828461113e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b60006111bc601d83610dfd565b91506111c782611186565b602082019050919050565b600060208201905081810360008301526111eb816111af565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000611219826111f2565b6112238185610dfd565b935061123381856020860161110b565b61123c816111fd565b840191505092915050565b60006020820190508181036000830152611261818461120e565b90509291505056fea2646970667358221220c5bae390803cc3f1622719d99fad44d96dace0eca188c3ba7313821ca78e23e664736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c8063715018a61161011a578063aad3ec96116100ad578063cc5398041161007c578063cc53980414610546578063d4c3eea014610564578063f2fde38b14610582578063fca555621461059e578063ff603d22146105ba576101fb565b8063aad3ec96146104d2578063b2016bd4146104ee578063b6b55f251461050c578063c2ef0dd61461053c576101fb565b80639ac9e7e5116100e95780639ac9e7e51461044a578063a6a56fa314610466578063a7ab696114610484578063a84f0f3f146104a2576101fb565b8063715018a6146103e85780638b4bcc4a146103f25780638da5cb5b146104105780638f4ffcb11461042e576101fb565b80632d2545e71161019257806347a5cfdb1161016157806347a5cfdb1461034e57806369da62f41461036c5780636c51741c146103885780636dbaf9ee146103b8576101fb565b80632d2545e7146102d65780633366b20b146102f45780633642110d146103125780634265117014610330576101fb565b80630964c95b116101ce5780630964c95b1461026457806312edde5e1461029457806315245857146102b05780632828fdb1146102ba576101fb565b80630359fea9146102005780630535f3bd1461021e57806307e039301461023c578063092b7eb51461025a575b600080fd5b6102086105d6565b6040516102159190612b43565b60405180910390f35b6102266105fa565b6040516102339190612b77565b60405180910390f35b610244610600565b6040516102519190612b77565b60405180910390f35b610262610606565b005b61027e60048036038101906102799190612bda565b6106fe565b60405161028b9190612b77565b60405180910390f35b6102ae60048036038101906102a99190612c33565b610716565b005b6102b86108e9565b005b6102d460048036038101906102cf9190612c33565b6109e1565b005b6102de610a33565b6040516102eb9190612b77565b60405180910390f35b6102fc610a58565b6040516103099190612c81565b60405180910390f35b61031a610a7e565b6040516103279190612b77565b60405180910390f35b610338610a98565b6040516103459190612b77565b60405180910390f35b610356610a9e565b6040516103639190612b77565b60405180910390f35b61038660048036038101906103819190612cda565b610aa4565b005b6103a2600480360381019061039d9190612d07565b610b97565b6040516103af9190612b77565b60405180910390f35b6103d260048036038101906103cd9190612bda565b610c61565b6040516103df9190612b77565b60405180910390f35b6103f0611177565b005b6103fa61118b565b6040516104079190612b77565b60405180910390f35b6104186111a5565b6040516104259190612d56565b60405180910390f35b61044860048036038101906104439190612dd6565b6111ce565b005b610464600480360381019061045f9190612c33565b6113f6565b005b61046e611448565b60405161047b9190612b77565b60405180910390f35b61048c61144e565b6040516104999190612b77565b60405180910390f35b6104bc60048036038101906104b79190612bda565b611454565b6040516104c99190612b77565b60405180910390f35b6104ec60048036038101906104e79190612e5e565b61146c565b005b6104f661167e565b6040516105039190612ebf565b60405180910390f35b61052660048036038101906105219190612c33565b6116a2565b6040516105339190612b77565b60405180910390f35b610544611728565b005b61054e6117cd565b60405161055b9190612efb565b60405180910390f35b61056c6117f1565b6040516105799190612b77565b60405180910390f35b61059c60048036038101906105979190612bda565b611949565b005b6105b860048036038101906105b39190612f16565b6119cd565b005b6105d460048036038101906105cf9190612e5e565b611efe565b005b7f000000000000000000000000000000000000000000000000000000000000000081565b60035481565b60065481565b61060e612017565b60045460008111610654576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064b90612fb3565b60405180910390fd5b61065c610a33565b81426106689190613002565b10156106a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106a090613082565b60405180910390fd5b6003546002819055507fb34b8e54226bc5e8f4a9d846e344e0c42d09eeb1c79798df7ce7460c16071e2d6002546040516106e39190612b77565b60405180910390a16000600381905550600060048190555050565b60096020528060005260406000206000915090505481565b6000600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008211806107695750600081115b6107a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079f90613114565b60405180910390fd5b81816107b49190613134565b905080600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555042600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff167f31f69201fab7912e3ec9850e3ab705964bf46d9d4276bdcbb6d05e965e5f5401824260405161088692919061318a565b60405180910390a260008211156108e5576108e43330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b5b5050565b6108f1612017565b60075460008111610937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092e90612fb3565b60405180910390fd5b61093f610a33565b814261094b9190613002565b101561098c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098390613082565b60405180910390fd5b6006546005819055507f9598c02e95262720ac8491c6255a4e2cfdabfb1595e7db4075699a286c0e51786005546040516109c69190612b77565b60405180910390a16000600681905550600060078190555050565b6109e9612017565b80600681905550426007819055507fea7f37aef8286a6784bab40be2b2b8d865d3a302ebaa9554a93393f0af4991be8142604051610a2892919061318a565b60405180910390a150565b60006202a300600554600254610a499190613134565b610a539190613134565b905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610a93600754610a8e610a33565b61211e565b905090565b60055481565b60045481565b610aac612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610b1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b1390613225565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f798c873acf96c84f872a0ba8ab09b2eda82566b35ec01de0053dddc703294bd581604051610b8c9190612d56565b60405180910390a150565b60006bffffffffffffffffffffffff8016610bb06117f1565b84610bbb9190613134565b1115610bfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf390613291565b60405180910390fd5b6000610c0784612199565b905080831115610c4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4390613323565b60405180910390fd5b610c5733858361239e565b8091505092915050565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111610ce9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce0906133b5565b60405180910390fd5b600060025482610cf99190613134565b9050428110610d3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3490613421565b60405180910390fd5b4260055482610d4c9190613134565b1015610d8d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d849061348d565b60405180910390fd5b6000600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3957600080fd5b505afa158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7191906134c2565b9050600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600960008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090557f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f6157600080fd5b505af1158015610f75573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610fd49190612d56565b60206040518083038186803b158015610fec57600080fd5b505afa158015611000573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102491906134c2565b9050600082828561103591906134ef565b61103f9190613578565b90508773ffffffffffffffffffffffffffffffffffffffff167fabed221d0c46913d6cc666ed64634168e3f1cc2638e31c6bdae1cba0b3681e4682864260405161108b939291906135a9565b60405180910390a26110de88827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166342966c68856040518263ffffffff1660e01b81526004016111379190612b77565b600060405180830381600087803b15801561115157600080fd5b505af1158015611165573d6000803e3d6000fd5b50505050809650505050505050919050565b61117f612017565b6111896000612605565b565b60006111a060045461119b610a33565b61211e565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6bffffffffffffffffffffffff80166111e56117f1565b856111f09190613134565b1115611231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161122890613291565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461129f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112969061362c565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132490613698565b60405180910390fd5b600061133885612199565b9050600083839050146113e3576020838390501461138b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138290613704565b60405180910390fd5b6000838381019061139c9190612c33565b9050818111156113e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d890613323565b60405180910390fd5b505b6113ee86868361239e565b505050505050565b6113fe612017565b80600381905550426004819055507fad53a24a52f2d7f29240a9dbf89503d658764ecda61f09dc6fc99f8384b40a51814260405161143d92919061318a565b60405180910390a150565b60075481565b60025481565b60086020528060005260406000206000915090505481565b611474612017565b8173ffffffffffffffffffffffffffffffffffffffff167f954df0664683c9ae1eee78683930912208efdac997b3c0454ac72a9262e4e37c82426040516114bc92919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561152c57600080fd5b505af1158015611540573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161159d9190612d56565b60206040518083038186803b1580156115b557600080fd5b505afa1580156115c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ed91906134c2565b81111561162f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162690613796565b60405180910390fd5b61167a82827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661257f9092919063ffffffff16565b5050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006bffffffffffffffffffffffff80166116bb6117f1565b836116c69190613134565b1115611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe90613291565b60405180910390fd5b600061171283612199565b905061171f33848361239e565b80915050919050565b611730612017565b7fc5b126eaad8719040f9f4a97c3fee33e39511a07b0c7506940708ea84da3cbb5600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516117819190612d56565b60405180910390a16000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d6f192626040518163ffffffff1660e01b815260040160206040518083038186803b15801561185957600080fd5b505afa15801561186d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189191906134c2565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016118ea9190612d56565b60206040518083038186803b15801561190257600080fd5b505afa158015611916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193a91906134c2565b6119449190613134565b905090565b611951612017565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156119c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b890613828565b60405180910390fd5b6119ca81612605565b50565b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611a5f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a5690613894565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611aef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ae690613926565b60405180910390fd5b60008211611b32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b2990613114565b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b9a57600080fd5b505afa158015611bae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd291906134c2565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611c3c57600080fd5b505af1158015611c50573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401611caf9190612d56565b60206040518083038186803b158015611cc757600080fd5b505afa158015611cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cff91906134c2565b90506000828286611d1091906134ef565b611d1a9190613578565b9050611d89600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166126c99092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166379cc679033876040518363ffffffff1660e01b8152600401611de4929190613946565b600060405180830381600087803b158015611dfe57600080fd5b505af1158015611e12573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632f4f21e233836040518363ffffffff1660e01b8152600401611e73929190613946565b600060405180830381600087803b158015611e8d57600080fd5b505af1158015611ea1573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff167f52a02543e8a884453eaf1c2c5bec12d4f9e7ad29faa4ce468387ea34cef9a911828742604051611eef939291906135a9565b60405180910390a25050505050565b611f06612017565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611f6e57600080fd5b505af1158015611f82573d6000803e3d6000fd5b505050507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401611fe1929190613946565b600060405180830381600087803b158015611ffb57600080fd5b505af115801561200f573d6000803e3d6000fd5b505050505050565b61201f612827565b73ffffffffffffffffffffffffffffffffffffffff1661203d6111a5565b73ffffffffffffffffffffffffffffffffffffffff1614612093576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208a906139bb565b60405180910390fd5b565b612118846323b872dd60e01b8585856040516024016120b6939291906139db565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b50505050565b6000808311612162576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161215990612fb3565b60405180910390fd5b600083426121709190613002565b9050828110612183576000915050612193565b808361218f9190613002565b9150505b92915050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633ccfd60b6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561220357600080fd5b505af1158015612217573d6000803e3d6000fd5b5050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561228357600080fd5b505afa158015612297573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122bb91906134c2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016123189190612d56565b60206040518083038186803b15801561233057600080fd5b505afa158015612344573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061236891906134c2565b9050600082141561237d578392505050612399565b80828561238a91906134ef565b6123949190613578565b925050505b919050565b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561240d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161240490613a5e565b60405180910390fd5b60008111612450576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161244790613af0565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff167f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca838360405161249892919061318a565b60405180910390a27f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166340c10f1984836040518363ffffffff1660e01b81526004016124fb929190613946565b600060405180830381600087803b15801561251557600080fd5b505af1158015612529573d6000803e3d6000fd5b5050505061257a8330847f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16612095909392919063ffffffff16565b505050565b6126008363a9059cbb60e01b848460405160240161259e929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000811480612762575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b8152600401612710929190613b10565b60206040518083038186803b15801561272857600080fd5b505afa15801561273c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276091906134c2565b145b6127a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161279890613bab565b60405180910390fd5b6128228363095ea7b360e01b84846040516024016127c0929190613946565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061282f565b505050565b600033905090565b6000612891826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166128f69092919063ffffffff16565b90506000815111156128f157808060200190518101906128b19190613c03565b6128f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128e790613ca2565b60405180910390fd5b5b505050565b6060612905848460008561290e565b90509392505050565b606082471015612953576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161294a90613d34565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161297c9190613dce565b60006040518083038185875af1925050503d80600081146129b9576040519150601f19603f3d011682016040523d82523d6000602084013e6129be565b606091505b50915091506129cf878383876129db565b92505050949350505050565b60608315612a3e57600083511415612a36576129f685612a51565b612a35576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a2c90613e31565b60405180910390fd5b5b829050612a49565b612a488383612a74565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115612a875781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612abb9190613ea6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000612b09612b04612aff84612ac4565b612ae4565b612ac4565b9050919050565b6000612b1b82612aee565b9050919050565b6000612b2d82612b10565b9050919050565b612b3d81612b22565b82525050565b6000602082019050612b586000830184612b34565b92915050565b6000819050919050565b612b7181612b5e565b82525050565b6000602082019050612b8c6000830184612b68565b92915050565b600080fd5b600080fd5b6000612ba782612ac4565b9050919050565b612bb781612b9c565b8114612bc257600080fd5b50565b600081359050612bd481612bae565b92915050565b600060208284031215612bf057612bef612b92565b5b6000612bfe84828501612bc5565b91505092915050565b612c1081612b5e565b8114612c1b57600080fd5b50565b600081359050612c2d81612c07565b92915050565b600060208284031215612c4957612c48612b92565b5b6000612c5784828501612c1e565b91505092915050565b6000612c6b82612b10565b9050919050565b612c7b81612c60565b82525050565b6000602082019050612c966000830184612c72565b92915050565b6000612ca782612b9c565b9050919050565b612cb781612c9c565b8114612cc257600080fd5b50565b600081359050612cd481612cae565b92915050565b600060208284031215612cf057612cef612b92565b5b6000612cfe84828501612cc5565b91505092915050565b60008060408385031215612d1e57612d1d612b92565b5b6000612d2c85828601612c1e565b9250506020612d3d85828601612c1e565b9150509250929050565b612d5081612b9c565b82525050565b6000602082019050612d6b6000830184612d47565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112612d9657612d95612d71565b5b8235905067ffffffffffffffff811115612db357612db2612d76565b5b602083019150836001820283011115612dcf57612dce612d7b565b5b9250929050565b600080600080600060808688031215612df257612df1612b92565b5b6000612e0088828901612bc5565b9550506020612e1188828901612c1e565b9450506040612e2288828901612bc5565b935050606086013567ffffffffffffffff811115612e4357612e42612b97565b5b612e4f88828901612d80565b92509250509295509295909350565b60008060408385031215612e7557612e74612b92565b5b6000612e8385828601612bc5565b9250506020612e9485828601612c1e565b9150509250929050565b6000612ea982612b10565b9050919050565b612eb981612e9e565b82525050565b6000602082019050612ed46000830184612eb0565b92915050565b6000612ee582612b10565b9050919050565b612ef581612eda565b82525050565b6000602082019050612f106000830184612eec565b92915050565b60008060408385031215612f2d57612f2c612b92565b5b6000612f3b85828601612c1e565b9250506020612f4c85828601612bc5565b9150509250929050565b600082825260208201905092915050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b6000612f9d601483612f56565b9150612fa882612f67565b602082019050919050565b60006020820190508181036000830152612fcc81612f90565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061300d82612b5e565b915061301883612b5e565b92508282101561302b5761302a612fd3565b5b828203905092915050565b7f476f7665726e616e63652064656c617920686173206e6f7420656c6170736564600082015250565b600061306c602083612f56565b915061307782613036565b602082019050919050565b6000602082019050818103600083015261309b8161305f565b9050919050565b7f556e64657277726974657220746f6b656e20616d6f756e74206d75737420626560008201527f2067726561746572207468616e20300000000000000000000000000000000000602082015250565b60006130fe602f83612f56565b9150613109826130a2565b604082019050919050565b6000602082019050818103600083015261312d816130f1565b9050919050565b600061313f82612b5e565b915061314a83612b5e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561317f5761317e612fd3565b5b828201905092915050565b600060408201905061319f6000830185612b68565b6131ac6020830184612b68565b9392505050565b7f4e657720617373657420706f6f6c2063616e2774206265207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061320f602483612f56565b915061321a826131b3565b604082019050919050565b6000602082019050818103600083015261323e81613202565b9050919050565b7f506f6f6c20636170616369747920657863656564656400000000000000000000600082015250565b600061327b601683612f56565b915061328682613245565b602082019050919050565b600060208201905081810360008301526132aa8161326e565b9050919050565b7f416d6f756e7420746f206d696e7420697320736d616c6c6572207468616e207460008201527f6865207265717569726564206d696e696d756d00000000000000000000000000602082015250565b600061330d603383612f56565b9150613318826132b1565b604082019050919050565b6000602082019050818103600083015261333c81613300565b9050919050565b7f4e6f207769746864726177616c20696e6974696174656420666f72207468652060008201527f756e646572777269746572000000000000000000000000000000000000000000602082015250565b600061339f602b83612f56565b91506133aa82613343565b604082019050919050565b600060208201905081810360008301526133ce81613392565b9050919050565b7f5769746864726177616c2064656c617920686173206e6f7420656c6170736564600082015250565b600061340b602083612f56565b9150613416826133d5565b602082019050919050565b6000602082019050818103600083015261343a816133fe565b9050919050565b7f5769746864726177616c2074696d656f757420656c6170736564000000000000600082015250565b6000613477601a83612f56565b915061348282613441565b602082019050919050565b600060208201905081810360008301526134a68161346a565b9050919050565b6000815190506134bc81612c07565b92915050565b6000602082840312156134d8576134d7612b92565b5b60006134e6848285016134ad565b91505092915050565b60006134fa82612b5e565b915061350583612b5e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561353e5761353d612fd3565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061358382612b5e565b915061358e83612b5e565b92508261359e5761359d613549565b5b828204905092915050565b60006060820190506135be6000830186612b68565b6135cb6020830185612b68565b6135d86040830184612b68565b949350505050565b7f4f6e6c7920746f6b656e2063616c6c657220616c6c6f77656400000000000000600082015250565b6000613616601983612f56565b9150613621826135e0565b602082019050919050565b6000602082019050818103600083015261364581613609565b9050919050565b7f556e737570706f7274656420636f6c6c61746572616c20746f6b656e00000000600082015250565b6000613682601c83612f56565b915061368d8261364c565b602082019050919050565b600060208201905081810360008301526136b181613675565b9050919050565b7f556e65787065637465642064617461206c656e67746800000000000000000000600082015250565b60006136ee601683612f56565b91506136f9826136b8565b602082019050919050565b6000602082019050818103600083015261371d816136e1565b9050919050565b7f416d6f756e7420746f207365697a6520657863656564732074686520706f6f6c60008201527f2062616c616e6365000000000000000000000000000000000000000000000000602082015250565b6000613780602883612f56565b915061378b82613724565b604082019050919050565b600060208201905081810360008301526137af81613773565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613812602683612f56565b915061381d826137b6565b604082019050919050565b6000602082019050818103600083015261384181613805565b9050919050565b7f4e657720617373657420706f6f6c206d7573742062652061737369676e656400600082015250565b600061387e601f83612f56565b915061388982613848565b602082019050919050565b600060208201905081810360008301526138ad81613871565b9050919050565b7f416464726573736573206f662061206e657720617373657420706f6f6c206d7560008201527f7374206d61746368000000000000000000000000000000000000000000000000602082015250565b6000613910602883612f56565b915061391b826138b4565b604082019050919050565b6000602082019050818103600083015261393f81613903565b9050919050565b600060408201905061395b6000830185612d47565b6139686020830184612b68565b9392505050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006139a5602083612f56565b91506139b08261396f565b602082019050919050565b600060208201905081810360008301526139d481613998565b9050919050565b60006060820190506139f06000830186612d47565b6139fd6020830185612d47565b613a0a6040830184612b68565b949350505050565b7f53656c662d6465706f736974206e6f7420616c6c6f7765640000000000000000600082015250565b6000613a48601883612f56565b9150613a5382613a12565b602082019050919050565b60006020820190508181036000830152613a7781613a3b565b9050919050565b7f4d696e74656420746f6b656e7320616d6f756e74206d7573742062652067726560008201527f61746572207468616e2030000000000000000000000000000000000000000000602082015250565b6000613ada602b83612f56565b9150613ae582613a7e565b604082019050919050565b60006020820190508181036000830152613b0981613acd565b9050919050565b6000604082019050613b256000830185612d47565b613b326020830184612d47565b9392505050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000613b95603683612f56565b9150613ba082613b39565b604082019050919050565b60006020820190508181036000830152613bc481613b88565b9050919050565b60008115159050919050565b613be081613bcb565b8114613beb57600080fd5b50565b600081519050613bfd81613bd7565b92915050565b600060208284031215613c1957613c18612b92565b5b6000613c2784828501613bee565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000613c8c602a83612f56565b9150613c9782613c30565b604082019050919050565b60006020820190508181036000830152613cbb81613c7f565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000613d1e602683612f56565b9150613d2982613cc2565b604082019050919050565b60006020820190508181036000830152613d4d81613d11565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015613d88578082015181840152602081019050613d6d565b83811115613d97576000848401525b50505050565b6000613da882613d54565b613db28185613d5f565b9350613dc2818560208601613d6a565b80840191505092915050565b6000613dda8284613d9d565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000613e1b601d83612f56565b9150613e2682613de5565b602082019050919050565b60006020820190508181036000830152613e4a81613e0e565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000613e7882613e51565b613e828185612f56565b9350613e92818560208601613d6a565b613e9b81613e5c565b840191505092915050565b60006020820190508181036000830152613ec08184613e6d565b90509291505056fea26469706673582212206a2ec90cc79772da4ef337390a89355334ec5a1da50a012e1cd808863f30122d64736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "beginWithdrawalDelayUpdate(uint256)": { + "params": { + "_newWithdrawalDelay": "The new value of withdrawal delay" + } + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "params": { + "_newWithdrawalTimeout": "The new value of the withdrawal timeout" + } + }, + "completeWithdrawal(address)": { + "returns": { + "_0": "The amount of collateral withdrawn" + } + }, + "deposit(uint256)": { + "details": "Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.", + "params": { + "amountToDeposit": "Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1" + }, + "returns": { + "_0": "The amount of minted underwriter tokens" + } + }, + "depositWithMin(uint256,uint256)": { + "details": "Before calling this function, collateral token needs to have the required amount accepted to transfer to the asset pool.", + "params": { + "amountToDeposit": "Collateral tokens amount that a user deposits to the asset pool; must be smaller or equal to 2^96-1", + "minAmountToMint": "Underwriter minimal tokens amount that a user expects to receive in exchange for the deposited collateral tokens" + }, + "returns": { + "_0": "The amount of minted underwriter tokens" + } + }, + "getRemainingWithdrawalDelayUpdateTime()": { + "returns": { + "_0": "The time left until withdrawal delay update can be finalized" + } + }, + "getRemainingWithdrawalTimeoutUpdateTime()": { + "returns": { + "_0": "The time left until withdrawal timeout update can be finalized" + } + }, + "grantShares(address,uint256)": { + "details": "Can be called only by the contract owner.", + "params": { + "covAmount": "Amount of the underwriter tokens which should be minted", + "recipient": "Address of the underwriter tokens recipient" + } + }, + "initiateWithdrawal(uint256)": { + "details": "Before calling this function, underwriter token needs to have the required amount accepted to transfer to the asset pool." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "receiveApproval(address,uint256,address,bytes)": { + "details": "This function is a shortcut for approve + deposit." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "totalValue()": { + "returns": { + "_0": "The total value of asset pool in collateral token." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "upgradeToNewAssetPool(uint256,address)": { + "params": { + "_newAssetPool": "New Asset Pool address to check validity with the one that was approved by the governance", + "covAmount": "Amount of underwriter tokens used to calculate collateral tokens which are transferred to a new asset pool" + } + }, + "withdrawalGovernanceDelay()": { + "returns": { + "_0": "The withdrawal governance delay in seconds" + } + } + }, + "title": "Asset Pool", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "approveNewAssetPoolUpgrade(address)": { + "notice": "Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay." + }, + "beginWithdrawalDelayUpdate(uint256)": { + "notice": "Lets the contract owner to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible." + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "notice": "Lets the contract owner to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the contract owner to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value." + }, + "cancelNewAssetPoolUpgrade()": { + "notice": "Allows governance to cancel already approved new asset pool in case of some misconfiguration." + }, + "claim(address,uint256)": { + "notice": "Allows the coverage pool to demand coverage from the asset hold by this pool and send it to the provided recipient address." + }, + "completeWithdrawal(address)": { + "notice": "Completes the previously initiated withdrawal for the underwriter. Anyone can complete the withdrawal for the underwriter. The withdrawal has to be completed before the withdrawal timeout elapses. Otherwise, the withdrawal has to be initiated again and the underwriter has to wait for the entire withdrawal delay again before being able to complete the withdrawal." + }, + "deposit(uint256)": { + "notice": "Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts." + }, + "depositWithMin(uint256,uint256)": { + "notice": "Accepts the given amount of collateral token as a deposit and mints at least a minAmountToMint underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts." + }, + "finalizeWithdrawalDelayUpdate()": { + "notice": "Lets the contract owner to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass." + }, + "finalizeWithdrawalTimeoutUpdate()": { + "notice": "Lets the contract owner to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass." + }, + "getRemainingWithdrawalDelayUpdateTime()": { + "notice": "Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal delay update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum." + }, + "getRemainingWithdrawalTimeoutUpdateTime()": { + "notice": "Returns the remaining time that has to pass before the contract owner will be able to finalize withdrawal timeout update. Bear in mind the contract owner may decide to wait longer and this value is just an absolute minimum." + }, + "grantShares(address,uint256)": { + "notice": "Grants pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes." + }, + "initiateWithdrawal(uint256)": { + "notice": "Initiates the withdrawal of collateral and rewards from the pool. Must be followed with completeWithdrawal call after the withdrawal delay passes. Accepts the amount of underwriter tokens representing the share of the pool that should be withdrawn. Can be called multiple times increasing the pool share to withdraw and resetting the withdrawal initiated timestamp for each call. Can be called with 0 covAmount to reset the withdrawal initiated timestamp if the underwriter has a pending withdrawal. In practice 0 covAmount should be used only to initiate the withdrawal again in case one did not complete the withdrawal before the withdrawal timeout elapsed." + }, + "receiveApproval(address,uint256,address,bytes)": { + "notice": "Accepts the given amount of collateral token as a deposit and mints underwriter tokens representing pool's ownership. The amount locked in the pool after accepting this deposit must be smaller or equal to 2^96-1; otherwise, the function reverts. Optional data in extraData may include a minimal amount of underwriter tokens expected to be minted for a depositor. There are cases when an amount of minted tokens matters for a depositor, as tokens might be used in third party exchanges." + }, + "totalValue()": { + "notice": "Returns the current collateral token balance of the asset pool plus the reward amount (in collateral token) earned by the asset pool and not yet withdrawn to the asset pool." + }, + "upgradeToNewAssetPool(uint256,address)": { + "notice": "Transfers collateral tokens to a new Asset Pool which previously was approved by the governance. Upgrade does not have to obey withdrawal delay. Old underwriter tokens are burned in favor of new tokens minted in a new Asset Pool. New tokens are sent directly to the underwriter from a new Asset Pool." + }, + "withdrawalDelay()": { + "notice": "The time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim." + }, + "withdrawalGovernanceDelay()": { + "notice": "The time it takes to initiate and complete the withdrawal from the pool plus 2 days to make a decision. This governance delay should be used for all changes directly affecting underwriter positions. This time is a minimum and the governance may choose to wait longer before finalizing the update." + }, + "withdrawalTimeout()": { + "notice": "The time the underwriter has after the withdrawal delay passed to complete the withdrawal. During that time, underwriter is still earning rewards and their share of the pool is still a subject of a possible coverage claim. After the withdrawal timeout elapses, tokens stay in the pool and the underwriter has to initiate the withdrawal again and wait for the full withdrawal delay to complete the withdrawal." + } + }, + "notice": "Asset pool is a component of a Coverage Pool. Asset Pool accepts a single ERC20 token as collateral, and returns an underwriter token. For example, an asset pool might accept deposits in KEEP in return for covKEEP underwriter tokens. Underwriter tokens represent an ownership share in the underlying collateral of the Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens as a deposit. It means that the total supply of the collateral token can not be greater than 2^96-1 or, if that supply is greater, it is acceptable that not all tokens can be deposited into the pool.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 5629, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "newAssetPool", + "offset": 0, + "slot": "1", + "type": "t_contract(IAssetPoolUpgrade)10558" + }, + { + "astId": 5633, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalDelay", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 5635, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "newWithdrawalDelay", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 5637, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalDelayChangeInitiated", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 5641, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalTimeout", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 5643, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "newWithdrawalTimeout", + "offset": 0, + "slot": "6", + "type": "t_uint256" + }, + { + "astId": 5645, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalTimeoutChangeInitiated", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 5649, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "withdrawalInitiatedTimestamp", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 5653, + "contract": "contracts/AssetPool.sol:AssetPool", + "label": "pendingWithdrawal", + "offset": 0, + "slot": "9", + "type": "t_mapping(t_address,t_uint256)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_contract(IAssetPoolUpgrade)10558": { + "encoding": "inplace", + "label": "contract IAssetPoolUpgrade", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/BatchedPhasedEscrow.json b/deployments/mainnet/BatchedPhasedEscrow.json new file mode 100644 index 00000000..9311ca64 --- /dev/null +++ b/deployments/mainnet/BatchedPhasedEscrow.json @@ -0,0 +1,373 @@ +{ + "address": "0xa96AD7889ef29D4978e00B0cB31cD41F77bFD8A6", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "beneficiary", + "type": "address" + } + ], + "name": "BeneficiaryApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldDrawee", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newDrawee", + "type": "address" + } + ], + "name": "DraweeRoleTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensWithdrawn", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract", + "name": "_beneficiary", + "type": "address" + } + ], + "name": "approveBeneficiary", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract[]", + "name": "beneficiaries", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "batchedWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "drawee", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract", + "name": "_beneficiary", + "type": "address" + } + ], + "name": "isBeneficiaryApproved", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newDrawee", + "type": "address" + } + ], + "name": "setDrawee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x0d0e587cc0652ec111ae9d92db0ff1f92d2952cd0a6362263e37dd9ff55721b9", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0xa96AD7889ef29D4978e00B0cB31cD41F77bFD8A6", + "transactionIndex": 90, + "gasUsed": "1661630", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000800000000000000000000000000000000000402000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x5271f05403ff0f6054c6896a5344ff57cebaf1a1a50c19d82fc5f8983a2256a7", + "transactionHash": "0x0d0e587cc0652ec111ae9d92db0ff1f92d2952cd0a6362263e37dd9ff55721b9", + "logs": [ + { + "transactionIndex": 90, + "blockNumber": 16327124, + "transactionHash": "0x0d0e587cc0652ec111ae9d92db0ff1f92d2952cd0a6362263e37dd9ff55721b9", + "address": "0xa96AD7889ef29D4978e00B0cB31cD41F77bFD8A6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 177, + "blockHash": "0x5271f05403ff0f6054c6896a5344ff57cebaf1a1a50c19d82fc5f8983a2256a7" + } + ], + "blockNumber": 16327124, + "cumulativeGasUsed": "10257008", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5" + ], + "numDeployments": 1, + "solcInputHash": "1f648bbc62fc09e530210f2d58cb219e", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"}],\"name\":\"BeneficiaryApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldDrawee\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newDrawee\",\"type\":\"address\"}],\"name\":\"DraweeRoleTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"beneficiary\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"TokensWithdrawn\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract IBeneficiaryContract\",\"name\":\"_beneficiary\",\"type\":\"address\"}],\"name\":\"approveBeneficiary\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IBeneficiaryContract[]\",\"name\":\"beneficiaries\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"amounts\",\"type\":\"uint256[]\"}],\"name\":\"batchedWithdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"drawee\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IBeneficiaryContract\",\"name\":\"_beneficiary\",\"type\":\"address\"}],\"name\":\"isBeneficiaryApproved\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newDrawee\",\"type\":\"address\"}],\"name\":\"setDrawee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"BatchedPhasedEscrow\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"approveBeneficiary(address)\":{\"notice\":\"Approves the provided address as a beneficiary of tokens held by the escrow. Can be called only by escrow owner.\"},\"batchedWithdraw(address[],uint256[])\":{\"notice\":\"Withdraws tokens from escrow to selected beneficiaries, transferring to each beneficiary the amount of tokens specified as a parameter. Only beneficiaries previously approved by escrow owner can receive funds.\"},\"isBeneficiaryApproved(address)\":{\"notice\":\"Returns `true` if the given address has been approved as a beneficiary of the escrow, `false` otherwise.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Funds the escrow by transferring all of the approved tokens to the escrow.\"},\"setDrawee(address)\":{\"notice\":\"Transfers the role of drawee to another address. Can be called only by the contract owner.\"}},\"notice\":\"A token holder contract allowing contract owner to approve a set of beneficiaries of tokens held by the contract, to appoint a separate drawee role, and allowing that drawee to withdraw tokens to approved beneficiaries in phases.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/BatchedPhasedEscrow.sol\":\"BatchedPhasedEscrow\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/BatchedPhasedEscrow.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Batched Phased Escrow Beneficiary\\n/// @notice Interface expected from contracts receiving tokens from the\\n/// BatchedPhasedEscrow.\\ninterface IBeneficiaryContract {\\n function __escrowSentTokens(uint256 amount) external;\\n}\\n\\n/// @title BatchedPhasedEscrow\\n/// @notice A token holder contract allowing contract owner to approve a set of\\n/// beneficiaries of tokens held by the contract, to appoint a separate\\n/// drawee role, and allowing that drawee to withdraw tokens to approved\\n/// beneficiaries in phases.\\ncontract BatchedPhasedEscrow is Ownable {\\n using SafeERC20 for IERC20;\\n\\n event BeneficiaryApproved(address beneficiary);\\n event TokensWithdrawn(address beneficiary, uint256 amount);\\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\\n\\n IERC20 public token;\\n address public drawee;\\n mapping(address => bool) private approvedBeneficiaries;\\n\\n modifier onlyDrawee() {\\n require(drawee == msg.sender, \\\"Caller is not the drawee\\\");\\n _;\\n }\\n\\n constructor(IERC20 _token) {\\n token = _token;\\n drawee = msg.sender;\\n }\\n\\n /// @notice Approves the provided address as a beneficiary of tokens held by\\n /// the escrow. Can be called only by escrow owner.\\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\\n external\\n onlyOwner\\n {\\n address beneficiaryAddress = address(_beneficiary);\\n require(\\n beneficiaryAddress != address(0),\\n \\\"Beneficiary can not be zero address\\\"\\n );\\n approvedBeneficiaries[beneficiaryAddress] = true;\\n emit BeneficiaryApproved(beneficiaryAddress);\\n }\\n\\n /// @notice Returns `true` if the given address has been approved as a\\n /// beneficiary of the escrow, `false` otherwise.\\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\\n public\\n view\\n returns (bool)\\n {\\n return approvedBeneficiaries[address(_beneficiary)];\\n }\\n\\n /// @notice Transfers the role of drawee to another address. Can be called\\n /// only by the contract owner.\\n function setDrawee(address newDrawee) external onlyOwner {\\n require(newDrawee != address(0), \\\"New drawee can not be zero address\\\");\\n emit DraweeRoleTransferred(drawee, newDrawee);\\n drawee = newDrawee;\\n }\\n\\n /// @notice Funds the escrow by transferring all of the approved tokens\\n /// to the escrow.\\n function receiveApproval(\\n address _from,\\n uint256 _value,\\n address _token,\\n bytes memory\\n ) external {\\n require(IERC20(_token) == token, \\\"Unsupported token\\\");\\n token.safeTransferFrom(_from, address(this), _value);\\n }\\n\\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\\n /// transferring to each beneficiary the amount of tokens specified\\n /// as a parameter. Only beneficiaries previously approved by escrow\\n /// owner can receive funds.\\n function batchedWithdraw(\\n IBeneficiaryContract[] memory beneficiaries,\\n uint256[] memory amounts\\n ) external onlyDrawee {\\n require(\\n beneficiaries.length == amounts.length,\\n \\\"Mismatched arrays length\\\"\\n );\\n\\n for (uint256 i = 0; i < beneficiaries.length; i++) {\\n IBeneficiaryContract beneficiary = beneficiaries[i];\\n require(\\n isBeneficiaryApproved(beneficiary),\\n \\\"Beneficiary was not approved\\\"\\n );\\n withdraw(beneficiary, amounts[i]);\\n }\\n }\\n\\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\\n private\\n {\\n emit TokensWithdrawn(address(beneficiary), amount);\\n token.safeTransfer(address(beneficiary), amount);\\n // slither-disable-next-line calls-loop\\n beneficiary.__escrowSentTokens(amount);\\n }\\n}\\n\",\"keccak256\":\"0xd1ed7b9149ea0672c94e22812ca723751c2be7546b1d23ffb12d9595a14a8f50\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b5060405162001e3e38038062001e3e83398181016040528101906200003791906200022a565b620000576200004b620000e060201b60201c565b620000e860201b60201c565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506200025c565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001de82620001b1565b9050919050565b6000620001f282620001d1565b9050919050565b6200020481620001e5565b81146200021057600080fd5b50565b6000815190506200022481620001f9565b92915050565b600060208284031215620002435762000242620001ac565b5b6000620002538482850162000213565b91505092915050565b611bd2806200026c6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063ba07075011610066578063ba0707501461011f578063d6d0aa411461013b578063f2fde38b14610159578063f70cb38e14610175578063fc0c546a146101a55761009e565b8063431714c3146100a3578063715018a6146100bf5780638da5cb5b146100c95780638f4ffcb1146100e7578063a1c9b08014610103575b600080fd5b6100bd60048036038101906100b89190610e1d565b6101c3565b005b6100c76102d3565b005b6100d16102e7565b6040516100de9190610e59565b60405180910390f35b61010160048036038101906100fc919061101c565b610310565b005b61011d6004803603810190610118919061122a565b6103f5565b005b610139600480360381019061013491906112a2565b610579565b005b610143610690565b6040516101509190610e59565b60405180910390f35b610173600480360381019061016e91906112a2565b6106b6565b005b61018f600480360381019061018a9190610e1d565b61073a565b60405161019c91906112ea565b60405180910390f35b6101ad610790565b6040516101ba9190611364565b60405180910390f35b6101cb6107b6565b6000819050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023790611402565b60405180910390fd5b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fae756b0a5bd1fbe0871906ac484a39752d357561ca291b46f52c068408c39a96816040516102c79190610e59565b60405180910390a15050565b6102db6107b6565b6102e56000610834565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146103a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103979061146e565b60405180910390fd5b6103ef843085600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108f8909392919063ffffffff16565b50505050565b3373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610485576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047c906114da565b60405180910390fd5b80518251146104c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c090611546565b60405180910390fd5b60005b82518110156105745760008382815181106104ea576104e9611566565b5b602002602001015190506104fd8161073a565b61053c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610533906115e1565b60405180910390fd5b6105608184848151811061055357610552611566565b5b6020026020010151610981565b50808061056c90611630565b9150506104cc565b505050565b6105816107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156105f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e8906116eb565b60405180910390fd5b7f2cd645351aa758b6871e153e13b27063dc3eefbf1a8acc38b31486f099cb7510600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168260405161064492919061170b565b60405180910390a180600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106be6107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561072e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610725906117a6565b60405180910390fd5b61073781610834565b50565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6107be610a76565b73ffffffffffffffffffffffffffffffffffffffff166107dc6102e7565b73ffffffffffffffffffffffffffffffffffffffff1614610832576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082990611812565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61097b846323b872dd60e01b85858560405160240161091993929190611841565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b50505050565b7f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b82826040516109b2929190611878565b60405180910390a1610a078282600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b459092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff16634a5f5456826040518263ffffffff1660e01b8152600401610a4091906118a1565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b505050505050565b600033905090565b6000610ae0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610bcb9092919063ffffffff16565b9050600081511115610b405780806020019051810190610b0091906118e8565b610b3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3690611987565b60405180910390fd5b5b505050565b610bc68363a9059cbb60e01b8484604051602401610b64929190611878565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b505050565b6060610bda8484600085610be3565b90509392505050565b606082471015610c28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1f90611a19565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610c519190611ab3565b60006040518083038185875af1925050503d8060008114610c8e576040519150601f19603f3d011682016040523d82523d6000602084013e610c93565b606091505b5091509150610ca487838387610cb0565b92505050949350505050565b60608315610d1357600083511415610d0b57610ccb85610d26565b610d0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0190611b16565b60405180910390fd5b5b829050610d1e565b610d1d8383610d49565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610d5c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d909190611b7a565b60405180910390fd5b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610dd882610dad565b9050919050565b6000610dea82610dcd565b9050919050565b610dfa81610ddf565b8114610e0557600080fd5b50565b600081359050610e1781610df1565b92915050565b600060208284031215610e3357610e32610da3565b5b6000610e4184828501610e08565b91505092915050565b610e5381610dcd565b82525050565b6000602082019050610e6e6000830184610e4a565b92915050565b610e7d81610dcd565b8114610e8857600080fd5b50565b600081359050610e9a81610e74565b92915050565b6000819050919050565b610eb381610ea0565b8114610ebe57600080fd5b50565b600081359050610ed081610eaa565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610f2982610ee0565b810181811067ffffffffffffffff82111715610f4857610f47610ef1565b5b80604052505050565b6000610f5b610d99565b9050610f678282610f20565b919050565b600067ffffffffffffffff821115610f8757610f86610ef1565b5b610f9082610ee0565b9050602081019050919050565b82818337600083830152505050565b6000610fbf610fba84610f6c565b610f51565b905082815260208101848484011115610fdb57610fda610edb565b5b610fe6848285610f9d565b509392505050565b600082601f83011261100357611002610ed6565b5b8135611013848260208601610fac565b91505092915050565b6000806000806080858703121561103657611035610da3565b5b600061104487828801610e8b565b945050602061105587828801610ec1565b935050604061106687828801610e8b565b925050606085013567ffffffffffffffff81111561108757611086610da8565b5b61109387828801610fee565b91505092959194509250565b600067ffffffffffffffff8211156110ba576110b9610ef1565b5b602082029050602081019050919050565b600080fd5b60006110e36110de8461109f565b610f51565b90508083825260208201905060208402830185811115611106576111056110cb565b5b835b8181101561112f578061111b8882610e08565b845260208401935050602081019050611108565b5050509392505050565b600082601f83011261114e5761114d610ed6565b5b813561115e8482602086016110d0565b91505092915050565b600067ffffffffffffffff82111561118257611181610ef1565b5b602082029050602081019050919050565b60006111a66111a184611167565b610f51565b905080838252602082019050602084028301858111156111c9576111c86110cb565b5b835b818110156111f257806111de8882610ec1565b8452602084019350506020810190506111cb565b5050509392505050565b600082601f83011261121157611210610ed6565b5b8135611221848260208601611193565b91505092915050565b6000806040838503121561124157611240610da3565b5b600083013567ffffffffffffffff81111561125f5761125e610da8565b5b61126b85828601611139565b925050602083013567ffffffffffffffff81111561128c5761128b610da8565b5b611298858286016111fc565b9150509250929050565b6000602082840312156112b8576112b7610da3565b5b60006112c684828501610e8b565b91505092915050565b60008115159050919050565b6112e4816112cf565b82525050565b60006020820190506112ff60008301846112db565b92915050565b6000819050919050565b600061132a61132561132084610dad565b611305565b610dad565b9050919050565b600061133c8261130f565b9050919050565b600061134e82611331565b9050919050565b61135e81611343565b82525050565b60006020820190506113796000830184611355565b92915050565b600082825260208201905092915050565b7f42656e65666963696172792063616e206e6f74206265207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006113ec60238361137f565b91506113f782611390565b604082019050919050565b6000602082019050818103600083015261141b816113df565b9050919050565b7f556e737570706f7274656420746f6b656e000000000000000000000000000000600082015250565b600061145860118361137f565b915061146382611422565b602082019050919050565b600060208201905081810360008301526114878161144b565b9050919050565b7f43616c6c6572206973206e6f7420746865206472617765650000000000000000600082015250565b60006114c460188361137f565b91506114cf8261148e565b602082019050919050565b600060208201905081810360008301526114f3816114b7565b9050919050565b7f4d69736d61746368656420617272617973206c656e6774680000000000000000600082015250565b600061153060188361137f565b915061153b826114fa565b602082019050919050565b6000602082019050818103600083015261155f81611523565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f42656e656669636961727920776173206e6f7420617070726f76656400000000600082015250565b60006115cb601c8361137f565b91506115d682611595565b602082019050919050565b600060208201905081810360008301526115fa816115be565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061163b82610ea0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561166e5761166d611601565b5b600182019050919050565b7f4e6577206472617765652063616e206e6f74206265207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006116d560228361137f565b91506116e082611679565b604082019050919050565b60006020820190508181036000830152611704816116c8565b9050919050565b60006040820190506117206000830185610e4a565b61172d6020830184610e4a565b9392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061179060268361137f565b915061179b82611734565b604082019050919050565b600060208201905081810360008301526117bf81611783565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006117fc60208361137f565b9150611807826117c6565b602082019050919050565b6000602082019050818103600083015261182b816117ef565b9050919050565b61183b81610ea0565b82525050565b60006060820190506118566000830186610e4a565b6118636020830185610e4a565b6118706040830184611832565b949350505050565b600060408201905061188d6000830185610e4a565b61189a6020830184611832565b9392505050565b60006020820190506118b66000830184611832565b92915050565b6118c5816112cf565b81146118d057600080fd5b50565b6000815190506118e2816118bc565b92915050565b6000602082840312156118fe576118fd610da3565b5b600061190c848285016118d3565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000611971602a8361137f565b915061197c82611915565b604082019050919050565b600060208201905081810360008301526119a081611964565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000611a0360268361137f565b9150611a0e826119a7565b604082019050919050565b60006020820190508181036000830152611a32816119f6565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015611a6d578082015181840152602081019050611a52565b83811115611a7c576000848401525b50505050565b6000611a8d82611a39565b611a978185611a44565b9350611aa7818560208601611a4f565b80840191505092915050565b6000611abf8284611a82565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000611b00601d8361137f565b9150611b0b82611aca565b602082019050919050565b60006020820190508181036000830152611b2f81611af3565b9050919050565b600081519050919050565b6000611b4c82611b36565b611b56818561137f565b9350611b66818560208601611a4f565b611b6f81610ee0565b840191505092915050565b60006020820190508181036000830152611b948184611b41565b90509291505056fea2646970667358221220e866eaf732d163a6a7078656998c3165d0dec06cf5a3aff327d7470ab2fc616f64736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063ba07075011610066578063ba0707501461011f578063d6d0aa411461013b578063f2fde38b14610159578063f70cb38e14610175578063fc0c546a146101a55761009e565b8063431714c3146100a3578063715018a6146100bf5780638da5cb5b146100c95780638f4ffcb1146100e7578063a1c9b08014610103575b600080fd5b6100bd60048036038101906100b89190610e1d565b6101c3565b005b6100c76102d3565b005b6100d16102e7565b6040516100de9190610e59565b60405180910390f35b61010160048036038101906100fc919061101c565b610310565b005b61011d6004803603810190610118919061122a565b6103f5565b005b610139600480360381019061013491906112a2565b610579565b005b610143610690565b6040516101509190610e59565b60405180910390f35b610173600480360381019061016e91906112a2565b6106b6565b005b61018f600480360381019061018a9190610e1d565b61073a565b60405161019c91906112ea565b60405180910390f35b6101ad610790565b6040516101ba9190611364565b60405180910390f35b6101cb6107b6565b6000819050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023790611402565b60405180910390fd5b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fae756b0a5bd1fbe0871906ac484a39752d357561ca291b46f52c068408c39a96816040516102c79190610e59565b60405180910390a15050565b6102db6107b6565b6102e56000610834565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146103a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103979061146e565b60405180910390fd5b6103ef843085600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108f8909392919063ffffffff16565b50505050565b3373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610485576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047c906114da565b60405180910390fd5b80518251146104c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c090611546565b60405180910390fd5b60005b82518110156105745760008382815181106104ea576104e9611566565b5b602002602001015190506104fd8161073a565b61053c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610533906115e1565b60405180910390fd5b6105608184848151811061055357610552611566565b5b6020026020010151610981565b50808061056c90611630565b9150506104cc565b505050565b6105816107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156105f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e8906116eb565b60405180910390fd5b7f2cd645351aa758b6871e153e13b27063dc3eefbf1a8acc38b31486f099cb7510600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168260405161064492919061170b565b60405180910390a180600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6106be6107b6565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561072e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610725906117a6565b60405180910390fd5b61073781610834565b50565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6107be610a76565b73ffffffffffffffffffffffffffffffffffffffff166107dc6102e7565b73ffffffffffffffffffffffffffffffffffffffff1614610832576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082990611812565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61097b846323b872dd60e01b85858560405160240161091993929190611841565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b50505050565b7f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b82826040516109b2929190611878565b60405180910390a1610a078282600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b459092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff16634a5f5456826040518263ffffffff1660e01b8152600401610a4091906118a1565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b505050505050565b600033905090565b6000610ae0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610bcb9092919063ffffffff16565b9050600081511115610b405780806020019051810190610b0091906118e8565b610b3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b3690611987565b60405180910390fd5b5b505050565b610bc68363a9059cbb60e01b8484604051602401610b64929190611878565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610a7e565b505050565b6060610bda8484600085610be3565b90509392505050565b606082471015610c28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1f90611a19565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610c519190611ab3565b60006040518083038185875af1925050503d8060008114610c8e576040519150601f19603f3d011682016040523d82523d6000602084013e610c93565b606091505b5091509150610ca487838387610cb0565b92505050949350505050565b60608315610d1357600083511415610d0b57610ccb85610d26565b610d0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0190611b16565b60405180910390fd5b5b829050610d1e565b610d1d8383610d49565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610d5c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d909190611b7a565b60405180910390fd5b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610dd882610dad565b9050919050565b6000610dea82610dcd565b9050919050565b610dfa81610ddf565b8114610e0557600080fd5b50565b600081359050610e1781610df1565b92915050565b600060208284031215610e3357610e32610da3565b5b6000610e4184828501610e08565b91505092915050565b610e5381610dcd565b82525050565b6000602082019050610e6e6000830184610e4a565b92915050565b610e7d81610dcd565b8114610e8857600080fd5b50565b600081359050610e9a81610e74565b92915050565b6000819050919050565b610eb381610ea0565b8114610ebe57600080fd5b50565b600081359050610ed081610eaa565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610f2982610ee0565b810181811067ffffffffffffffff82111715610f4857610f47610ef1565b5b80604052505050565b6000610f5b610d99565b9050610f678282610f20565b919050565b600067ffffffffffffffff821115610f8757610f86610ef1565b5b610f9082610ee0565b9050602081019050919050565b82818337600083830152505050565b6000610fbf610fba84610f6c565b610f51565b905082815260208101848484011115610fdb57610fda610edb565b5b610fe6848285610f9d565b509392505050565b600082601f83011261100357611002610ed6565b5b8135611013848260208601610fac565b91505092915050565b6000806000806080858703121561103657611035610da3565b5b600061104487828801610e8b565b945050602061105587828801610ec1565b935050604061106687828801610e8b565b925050606085013567ffffffffffffffff81111561108757611086610da8565b5b61109387828801610fee565b91505092959194509250565b600067ffffffffffffffff8211156110ba576110b9610ef1565b5b602082029050602081019050919050565b600080fd5b60006110e36110de8461109f565b610f51565b90508083825260208201905060208402830185811115611106576111056110cb565b5b835b8181101561112f578061111b8882610e08565b845260208401935050602081019050611108565b5050509392505050565b600082601f83011261114e5761114d610ed6565b5b813561115e8482602086016110d0565b91505092915050565b600067ffffffffffffffff82111561118257611181610ef1565b5b602082029050602081019050919050565b60006111a66111a184611167565b610f51565b905080838252602082019050602084028301858111156111c9576111c86110cb565b5b835b818110156111f257806111de8882610ec1565b8452602084019350506020810190506111cb565b5050509392505050565b600082601f83011261121157611210610ed6565b5b8135611221848260208601611193565b91505092915050565b6000806040838503121561124157611240610da3565b5b600083013567ffffffffffffffff81111561125f5761125e610da8565b5b61126b85828601611139565b925050602083013567ffffffffffffffff81111561128c5761128b610da8565b5b611298858286016111fc565b9150509250929050565b6000602082840312156112b8576112b7610da3565b5b60006112c684828501610e8b565b91505092915050565b60008115159050919050565b6112e4816112cf565b82525050565b60006020820190506112ff60008301846112db565b92915050565b6000819050919050565b600061132a61132561132084610dad565b611305565b610dad565b9050919050565b600061133c8261130f565b9050919050565b600061134e82611331565b9050919050565b61135e81611343565b82525050565b60006020820190506113796000830184611355565b92915050565b600082825260208201905092915050565b7f42656e65666963696172792063616e206e6f74206265207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006113ec60238361137f565b91506113f782611390565b604082019050919050565b6000602082019050818103600083015261141b816113df565b9050919050565b7f556e737570706f7274656420746f6b656e000000000000000000000000000000600082015250565b600061145860118361137f565b915061146382611422565b602082019050919050565b600060208201905081810360008301526114878161144b565b9050919050565b7f43616c6c6572206973206e6f7420746865206472617765650000000000000000600082015250565b60006114c460188361137f565b91506114cf8261148e565b602082019050919050565b600060208201905081810360008301526114f3816114b7565b9050919050565b7f4d69736d61746368656420617272617973206c656e6774680000000000000000600082015250565b600061153060188361137f565b915061153b826114fa565b602082019050919050565b6000602082019050818103600083015261155f81611523565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f42656e656669636961727920776173206e6f7420617070726f76656400000000600082015250565b60006115cb601c8361137f565b91506115d682611595565b602082019050919050565b600060208201905081810360008301526115fa816115be565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061163b82610ea0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561166e5761166d611601565b5b600182019050919050565b7f4e6577206472617765652063616e206e6f74206265207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006116d560228361137f565b91506116e082611679565b604082019050919050565b60006020820190508181036000830152611704816116c8565b9050919050565b60006040820190506117206000830185610e4a565b61172d6020830184610e4a565b9392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b600061179060268361137f565b915061179b82611734565b604082019050919050565b600060208201905081810360008301526117bf81611783565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006117fc60208361137f565b9150611807826117c6565b602082019050919050565b6000602082019050818103600083015261182b816117ef565b9050919050565b61183b81610ea0565b82525050565b60006060820190506118566000830186610e4a565b6118636020830185610e4a565b6118706040830184611832565b949350505050565b600060408201905061188d6000830185610e4a565b61189a6020830184611832565b9392505050565b60006020820190506118b66000830184611832565b92915050565b6118c5816112cf565b81146118d057600080fd5b50565b6000815190506118e2816118bc565b92915050565b6000602082840312156118fe576118fd610da3565b5b600061190c848285016118d3565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000611971602a8361137f565b915061197c82611915565b604082019050919050565b600060208201905081810360008301526119a081611964565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000611a0360268361137f565b9150611a0e826119a7565b604082019050919050565b60006020820190508181036000830152611a32816119f6565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015611a6d578082015181840152602081019050611a52565b83811115611a7c576000848401525b50505050565b6000611a8d82611a39565b611a978185611a44565b9350611aa7818560208601611a4f565b80840191505092915050565b6000611abf8284611a82565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000611b00601d8361137f565b9150611b0b82611aca565b602082019050919050565b60006020820190508181036000830152611b2f81611af3565b9050919050565b600081519050919050565b6000611b4c82611b36565b611b56818561137f565b9350611b66818560208601611a4f565b611b6f81610ee0565b840191505092915050565b60006020820190508181036000830152611b948184611b41565b90509291505056fea2646970667358221220e866eaf732d163a6a7078656998c3165d0dec06cf5a3aff327d7470ab2fc616f64736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "BatchedPhasedEscrow", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "approveBeneficiary(address)": { + "notice": "Approves the provided address as a beneficiary of tokens held by the escrow. Can be called only by escrow owner." + }, + "batchedWithdraw(address[],uint256[])": { + "notice": "Withdraws tokens from escrow to selected beneficiaries, transferring to each beneficiary the amount of tokens specified as a parameter. Only beneficiaries previously approved by escrow owner can receive funds." + }, + "isBeneficiaryApproved(address)": { + "notice": "Returns `true` if the given address has been approved as a beneficiary of the escrow, `false` otherwise." + }, + "receiveApproval(address,uint256,address,bytes)": { + "notice": "Funds the escrow by transferring all of the approved tokens to the escrow." + }, + "setDrawee(address)": { + "notice": "Transfers the role of drawee to another address. Can be called only by the contract owner." + } + }, + "notice": "A token holder contract allowing contract owner to approve a set of beneficiaries of tokens held by the contract, to appoint a separate drawee role, and allowing that drawee to withdraw tokens to approved beneficiaries in phases.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 7479, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "token", + "offset": 0, + "slot": "1", + "type": "t_contract(IERC20)671" + }, + { + "astId": 7481, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "drawee", + "offset": 0, + "slot": "2", + "type": "t_address" + }, + { + "astId": 7485, + "contract": "contracts/BatchedPhasedEscrow.sol:BatchedPhasedEscrow", + "label": "approvedBeneficiaries", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_bool)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_contract(IERC20)671": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + } + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/CoveragePool.json b/deployments/mainnet/CoveragePool.json new file mode 100644 index 00000000..7857fddf --- /dev/null +++ b/deployments/mainnet/CoveragePool.json @@ -0,0 +1,692 @@ +{ + "address": "0x7D7B622C07f216d99eFc3EfB9Cf71872F46D811A", + "abi": [ + { + "inputs": [ + { + "internalType": "contract AssetPool", + "name": "_assetPool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerApprovalCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerApprovalStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerUnapproved", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "portionToSeize", + "type": "uint256" + } + ], + "name": "amountToSeize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "approveFirstRiskManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "approveNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "approvedRiskManagers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "assetPool", + "outputs": [ + { + "internalType": "contract AssetPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "beginRiskManagerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newWithdrawalDelay", + "type": "uint256" + } + ], + "name": "beginWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newWithdrawalTimeout", + "type": "uint256" + } + ], + "name": "beginWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "contract ICollateralToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "finalizeRiskManagerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "firstRiskManagerApproved", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "getRemainingRiskManagerApprovalTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "grantAssetPoolShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "riskManagerApprovalTimestamps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountToSeize", + "type": "uint256" + } + ], + "name": "seizeAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "portionToSeize", + "type": "uint256" + } + ], + "name": "seizePortion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "unapproveRiskManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underwriterToken", + "outputs": [ + { + "internalType": "contract UnderwriterToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x1e59f22dcdfd1aaed6b0eacc5bf8b4ff69552a813fa12ff6c8ae72a462d0f434", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x7D7B622C07f216d99eFc3EfB9Cf71872F46D811A", + "transactionIndex": 79, + "gasUsed": "2140640", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000004000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000010000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3d4c6d85742f5a15b38a53d4eb9e47911401718ba2e49ac50dc580581588614f", + "transactionHash": "0x1e59f22dcdfd1aaed6b0eacc5bf8b4ff69552a813fa12ff6c8ae72a462d0f434", + "logs": [ + { + "transactionIndex": 79, + "blockNumber": 16327120, + "transactionHash": "0x1e59f22dcdfd1aaed6b0eacc5bf8b4ff69552a813fa12ff6c8ae72a462d0f434", + "address": "0x7D7B622C07f216d99eFc3EfB9Cf71872F46D811A", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 180, + "blockHash": "0x3d4c6d85742f5a15b38a53d4eb9e47911401718ba2e49ac50dc580581588614f" + } + ], + "blockNumber": 16327120, + "cumulativeGasUsed": "9586576", + "status": 1, + "byzantium": true + }, + "args": [ + "0x21b86FDC93F23fD52022A283828dF8E808D28D5D" + ], + "numDeployments": 1, + "solcInputHash": "1f648bbc62fc09e530210f2d58cb219e", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract AssetPool\",\"name\":\"_assetPool\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"RiskManagerApprovalCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"RiskManagerApprovalStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"RiskManagerUnapproved\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"portionToSeize\",\"type\":\"uint256\"}],\"name\":\"amountToSeize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"approveFirstRiskManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IAssetPoolUpgrade\",\"name\":\"_newAssetPool\",\"type\":\"address\"}],\"name\":\"approveNewAssetPoolUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"approvedRiskManagers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"assetPool\",\"outputs\":[{\"internalType\":\"contract AssetPool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"beginRiskManagerApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newWithdrawalDelay\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newWithdrawalTimeout\",\"type\":\"uint256\"}],\"name\":\"beginWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"collateralToken\",\"outputs\":[{\"internalType\":\"contract ICollateralToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"finalizeRiskManagerApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeWithdrawalTimeoutUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"firstRiskManagerApproved\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"getRemainingRiskManagerApprovalTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"covAmount\",\"type\":\"uint256\"}],\"name\":\"grantAssetPoolShares\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"riskManagerApprovalTimestamps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amountToSeize\",\"type\":\"uint256\"}],\"name\":\"seizeAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"portionToSeize\",\"type\":\"uint256\"}],\"name\":\"seizePortion\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"riskManager\",\"type\":\"address\"}],\"name\":\"unapproveRiskManager\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"underwriterToken\",\"outputs\":[{\"internalType\":\"contract UnderwriterToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Coverage pool contract is owned by the governance. Coverage pool is the owner of the asset pool contract.\",\"kind\":\"dev\",\"methods\":{\"amountToSeize(uint256)\":{\"params\":{\"portionToSeize\":\"Portion of the pool to seize in the range (0, 1] multiplied by FLOATING_POINT_DIVISOR\"}},\"approveFirstRiskManager(address)\":{\"details\":\"Can be called only by the contract owner. Can be called only once. Does not require any further calls to any functions.\",\"params\":{\"riskManager\":\"Risk manager that will be approved\"}},\"approveNewAssetPoolUpgrade(address)\":{\"params\":{\"_newAssetPool\":\"New asset pool\"}},\"beginRiskManagerApproval(address)\":{\"details\":\"Can be called only by the contract owner and only when the first risk manager is already approved. For a risk manager to be approved, a call to `finalizeRiskManagerApproval` must follow (after a governance delay).\",\"params\":{\"riskManager\":\"Risk manager that will be approved\"}},\"beginWithdrawalDelayUpdate(uint256)\":{\"params\":{\"newWithdrawalDelay\":\"The new value of withdrawal delay\"}},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"params\":{\"newWithdrawalTimeout\":\"The new value of the withdrawal timeout\"}},\"finalizeRiskManagerApproval(address)\":{\"details\":\"Can be called only by the contract owner. Must be preceded with a call to beginRiskManagerApproval and a governance delay must elapse.\",\"params\":{\"riskManager\":\"Risk manager that will be approved\"}},\"getPastVotes(address,uint256)\":{\"params\":{\"account\":\"The underwriter address to check\",\"blockNumber\":\"The block number to get the vote balance at\"},\"returns\":{\"_0\":\"The number of votes the underwriter had as of the given block\"}},\"getRemainingRiskManagerApprovalTime(address)\":{\"params\":{\"riskManager\":\"Risk manager in the process of approval\"},\"returns\":{\"_0\":\"Remaining time in seconds.\"}},\"grantAssetPoolShares(address,uint256)\":{\"details\":\"Can be called only by an approved risk manager.\",\"params\":{\"covAmount\":\"Amount of the underwriter tokens which should be minted\",\"recipient\":\"Address of the underwriter tokens recipient\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"seizeAmount(address,uint256)\":{\"params\":{\"amountToSeize\":\"Amount to be seized from the pool\",\"recipient\":\"Address that will receive the pool's seized funds\"}},\"seizePortion(address,uint256)\":{\"details\":\"`portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR` for calculation precision purposes. Further calculations in this function will need to take this divisor into account.\",\"params\":{\"portionToSeize\":\"Portion of the pool to seize in the range (0, 1] multiplied by `FLOATING_POINT_DIVISOR`\",\"recipient\":\"Address that will receive the pool's seized funds\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unapproveRiskManager(address)\":{\"details\":\"Can be called only by the contract owner.\",\"params\":{\"riskManager\":\"Risk manager that will be unapproved\"}}},\"title\":\"Coverage Pool\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"amountToSeize(uint256)\":{\"notice\":\"Calculates amount of tokens to be seized from the coverage pool.\"},\"approveFirstRiskManager(address)\":{\"notice\":\"Approves the first risk manager\"},\"approveNewAssetPoolUpgrade(address)\":{\"notice\":\"Approves upgradeability to the new asset pool. Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay.\"},\"beginRiskManagerApproval(address)\":{\"notice\":\"Begins risk manager approval process.\"},\"beginWithdrawalDelayUpdate(uint256)\":{\"notice\":\"Lets the governance to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible.\"},\"beginWithdrawalTimeoutUpdate(uint256)\":{\"notice\":\"Lets the governance to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value.\"},\"finalizeRiskManagerApproval(address)\":{\"notice\":\"Finalizes risk manager approval process.\"},\"finalizeWithdrawalDelayUpdate()\":{\"notice\":\"Lets the governance to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass.\"},\"finalizeWithdrawalTimeoutUpdate()\":{\"notice\":\"Lets the governance to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass.\"},\"getPastVotes(address,uint256)\":{\"notice\":\"Determine the prior number of DAO votes for the given coverage pool underwriter.\"},\"getRemainingRiskManagerApprovalTime(address)\":{\"notice\":\"Returns the time remaining until the risk manager approval process can be finalized\"},\"grantAssetPoolShares(address,uint256)\":{\"notice\":\"Grants asset pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes.\"},\"seizeAmount(address,uint256)\":{\"notice\":\"Seizes funds from the coverage pool and sends them to the `recipient`.\"},\"seizePortion(address,uint256)\":{\"notice\":\"Seizes funds from the coverage pool and sends them to the `recipient`.\"},\"unapproveRiskManager(address)\":{\"notice\":\"Unapproves an already approved risk manager or cancels the approval process of a risk manager (the latter happens if called between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`). The change takes effect immediately.\"}},\"notice\":\"A contract that manages a single asset pool. Handles approving and unapproving of risk managers and allows them to seize funds from the asset pool if they are approved.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/CoveragePool.sol\":\"CoveragePool\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 /**\\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 / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xd0a917e32d1251a9b2f1dea15e932815d5382e64e6b0a18104664a6cc774cd70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"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\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./IVotesHistory.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\n/// @title Checkpoints\\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\\n/// delegation. This implementation supports token supply up to 2^96 - 1.\\n/// This contract keeps a history (checkpoints) of each account's vote\\n/// power. Vote power can be delegated either by calling the {delegate}\\n/// function directly, or by providing a signature to be used with\\n/// {delegateBySig}. Voting power can be publicly queried through\\n/// {getVotes} and {getPastVotes}.\\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\\n/// @dev This contract is upgrade-safe.\\nabstract contract Checkpoints is IVotesHistory {\\n struct Checkpoint {\\n uint32 fromBlock;\\n uint96 votes;\\n }\\n\\n // slither-disable-next-line uninitialized-state\\n mapping(address => address) internal _delegates;\\n mapping(address => uint128[]) internal _checkpoints;\\n uint128[] internal _totalSupplyCheckpoints;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n /// @notice Emitted when an account changes their delegate.\\n event DelegateChanged(\\n address indexed delegator,\\n address indexed fromDelegate,\\n address indexed toDelegate\\n );\\n\\n /// @notice Emitted when a balance or delegate change results in changes\\n /// to an account's voting power.\\n event DelegateVotesChanged(\\n address indexed delegate,\\n uint256 previousBalance,\\n uint256 newBalance\\n );\\n\\n function checkpoints(address account, uint32 pos)\\n public\\n view\\n virtual\\n returns (Checkpoint memory checkpoint)\\n {\\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\\n _checkpoints[account][pos]\\n );\\n checkpoint = Checkpoint(fromBlock, votes);\\n }\\n\\n /// @notice Get number of checkpoints for `account`.\\n function numCheckpoints(address account)\\n public\\n view\\n virtual\\n returns (uint32)\\n {\\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\\n }\\n\\n /// @notice Get the address `account` is currently delegating to.\\n function delegates(address account) public view virtual returns (address) {\\n return _delegates[account];\\n }\\n\\n /// @notice Gets the current votes balance for `account`.\\n /// @param account The address to get votes balance\\n /// @return The number of current votes for `account`\\n function getVotes(address account) public view returns (uint96) {\\n uint256 pos = _checkpoints[account].length;\\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\\n }\\n\\n /// @notice Determine the prior number of votes for an account as of\\n /// a block number.\\n /// @dev Block number must be a finalized block or else this function will\\n /// revert to prevent misinformation.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_checkpoints[account], blockNumber);\\n }\\n\\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\\n /// Note, this value is the sum of all balances, but it is NOT the\\n /// sum of all the delegated votes!\\n /// @param blockNumber The block number to get the total supply at\\n /// @dev `blockNumber` must have been already mined\\n function getPastTotalSupply(uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\\n }\\n\\n /// @notice Change delegation for `delegator` to `delegatee`.\\n // slither-disable-next-line dead-code\\n function delegate(address delegator, address delegatee) internal virtual;\\n\\n /// @notice Moves voting power from one delegate to another\\n /// @param src Address of old delegate\\n /// @param dst Address of new delegate\\n /// @param amount Voting power amount to transfer between delegates\\n function moveVotingPower(\\n address src,\\n address dst,\\n uint256 amount\\n ) internal {\\n if (src != dst && amount > 0) {\\n if (src != address(0)) {\\n // https://github.com/crytic/slither/issues/960\\n // slither-disable-next-line variable-scope\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[src],\\n subtract,\\n amount\\n );\\n emit DelegateVotesChanged(src, oldWeight, newWeight);\\n }\\n\\n if (dst != address(0)) {\\n // https://github.com/crytic/slither/issues/959\\n // slither-disable-next-line uninitialized-local\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[dst],\\n add,\\n amount\\n );\\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\\n }\\n }\\n }\\n\\n /// @notice Writes a new checkpoint based on operating last stored value\\n /// with a `delta`. Usually, said operation is the `add` or\\n /// `subtract` functions from this contract, but more complex\\n /// functions can be passed as parameters.\\n /// @param ckpts The checkpoints array to use\\n /// @param op The function to apply over the last value and the `delta`\\n /// @param delta Variation with respect to last stored value to be used\\n /// for new checkpoint\\n function writeCheckpoint(\\n uint128[] storage ckpts,\\n function(uint256, uint256) view returns (uint256) op,\\n uint256 delta\\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\\n uint256 pos = ckpts.length;\\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\\n newWeight = op(oldWeight, delta);\\n\\n if (pos > 0) {\\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\\n // slither-disable-next-line incorrect-equality\\n if (fromBlock == block.number) {\\n ckpts[pos - 1] = encodeCheckpoint(\\n fromBlock,\\n SafeCastUpgradeable.toUint96(newWeight)\\n );\\n return (oldWeight, newWeight);\\n }\\n }\\n\\n ckpts.push(\\n encodeCheckpoint(\\n SafeCastUpgradeable.toUint32(block.number),\\n SafeCastUpgradeable.toUint96(newWeight)\\n )\\n );\\n }\\n\\n /// @notice Lookup a value in a list of (sorted) checkpoints.\\n /// @param ckpts The checkpoints array to use\\n /// @param blockNumber Block number when we want to get the checkpoint at\\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\\n internal\\n view\\n returns (uint96)\\n {\\n // We run a binary search to look for the earliest checkpoint taken\\n // after `blockNumber`. During the loop, the index of the wanted\\n // checkpoint remains in the range [low-1, high). With each iteration,\\n // either `low` or `high` is moved towards the middle of the range to\\n // maintain the invariant.\\n // - If the middle checkpoint is after `blockNumber`,\\n // we look in [low, mid)\\n // - If the middle checkpoint is before or equal to `blockNumber`,\\n // we look in [mid+1, high)\\n // Once we reach a single value (when low == high), we've found the\\n // right checkpoint at the index high-1, if not out of bounds (in that\\n // case we're looking too far in the past and the result is 0).\\n // Note that if the latest checkpoint available is exactly for\\n // `blockNumber`, we end up with an index that is past the end of the\\n // array, so we technically don't find a checkpoint after\\n // `blockNumber`, but it works out the same.\\n require(blockNumber < block.number, \\\"Block not yet determined\\\");\\n\\n uint256 high = ckpts.length;\\n uint256 low = 0;\\n while (low < high) {\\n uint256 mid = MathUpgradeable.average(low, high);\\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\\n if (midBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\\n }\\n\\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\\n // slither-disable-next-line dead-code\\n function maxSupply() internal view virtual returns (uint96) {\\n return type(uint96).max;\\n }\\n\\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\\n /// checkpoint.\\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\\n /// remaining 96 bits.\\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\\n internal\\n pure\\n returns (uint128)\\n {\\n return (uint128(blockNumber) << 96) | uint128(value);\\n }\\n\\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\\n function decodeBlockNumber(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32)\\n {\\n return uint32(bytes4(bytes16(checkpoint)));\\n }\\n\\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\\n return uint96(checkpoint);\\n }\\n\\n /// @notice Decodes a block number and voting value from a `uint128`\\n /// `checkpoint`.\\n function decodeCheckpoint(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32 blockNumber, uint96 value)\\n {\\n blockNumber = decodeBlockNumber(checkpoint);\\n value = decodeValue(checkpoint);\\n }\\n\\n // slither-disable-next-line dead-code\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n // slither-disable-next-line dead-code\\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n}\\n\",\"keccak256\":\"0x67b28349e88afe7440c43df93ba5de56873d850a25147161e4469731750efb16\",\"license\":\"GPL-3.0-or-later\"},\"@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\ninterface IVotesHistory {\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n\\n function getPastTotalSupply(uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x535e87cf4c2e9a9439d99cf0918f013965fa6c4ddfbab07ff6ca4b195c8edc9f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/AssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./interfaces/IAssetPool.sol\\\";\\nimport \\\"./interfaces/IAssetPoolUpgrade.sol\\\";\\nimport \\\"./interfaces/ICollateralToken.sol\\\";\\nimport \\\"./RewardsPool.sol\\\";\\nimport \\\"./UnderwriterToken.sol\\\";\\nimport \\\"./GovernanceUtils.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Asset Pool\\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\\n/// accepts a single ERC20 token as collateral, and returns an\\n/// underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\\n/// as a deposit. It means that the total supply of the collateral token\\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\\n/// acceptable that not all tokens can be deposited into the pool.\\ncontract AssetPool is Ownable, IAssetPool {\\n using SafeERC20 for ICollateralToken;\\n using SafeERC20 for UnderwriterToken;\\n\\n ICollateralToken public immutable collateralToken;\\n UnderwriterToken public immutable underwriterToken;\\n\\n RewardsPool public immutable rewardsPool;\\n\\n IAssetPoolUpgrade public newAssetPool;\\n\\n /// @notice The time it takes the underwriter to withdraw their collateral\\n /// and rewards from the pool. This is the time that needs to pass\\n /// between initiating and completing the withdrawal. During that\\n /// time, underwriter is still earning rewards and their share of\\n /// the pool is still a subject of a possible coverage claim.\\n uint256 public withdrawalDelay = 21 days;\\n uint256 public newWithdrawalDelay;\\n uint256 public withdrawalDelayChangeInitiated;\\n\\n /// @notice The time the underwriter has after the withdrawal delay passed\\n /// to complete the withdrawal. During that time, underwriter is\\n /// still earning rewards and their share of the pool is still\\n /// a subject of a possible coverage claim.\\n /// After the withdrawal timeout elapses, tokens stay in the pool\\n /// and the underwriter has to initiate the withdrawal again and\\n /// wait for the full withdrawal delay to complete the withdrawal.\\n uint256 public withdrawalTimeout = 2 days;\\n uint256 public newWithdrawalTimeout;\\n uint256 public withdrawalTimeoutChangeInitiated;\\n\\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\\n mapping(address => uint256) public pendingWithdrawal;\\n\\n event Deposited(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount\\n );\\n\\n event CoverageClaimed(\\n address indexed recipient,\\n uint256 amount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalInitiated(\\n address indexed underwriter,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n event WithdrawalCompleted(\\n address indexed underwriter,\\n uint256 amount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event ApprovedAssetPoolUpgrade(address newAssetPool);\\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\\n event AssetPoolUpgraded(\\n address indexed underwriter,\\n uint256 collateralAmount,\\n uint256 covAmount,\\n uint256 timestamp\\n );\\n\\n event WithdrawalDelayUpdateStarted(\\n uint256 withdrawalDelay,\\n uint256 timestamp\\n );\\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\\n event WithdrawalTimeoutUpdateStarted(\\n uint256 withdrawalTimeout,\\n uint256 timestamp\\n );\\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\\n\\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\\n /// if the change was not yet initiated.\\n /// @param changeInitiatedTimestamp The timestamp at which the change has\\n /// been initiated\\n modifier onlyAfterWithdrawalGovernanceDelay(\\n uint256 changeInitiatedTimestamp\\n ) {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - changeInitiatedTimestamp >=\\n withdrawalGovernanceDelay(),\\n \\\"Governance delay has not elapsed\\\"\\n );\\n _;\\n }\\n\\n constructor(\\n ICollateralToken _collateralToken,\\n UnderwriterToken _underwriterToken,\\n address rewardsManager\\n ) {\\n collateralToken = _collateralToken;\\n underwriterToken = _underwriterToken;\\n\\n rewardsPool = new RewardsPool(\\n _collateralToken,\\n address(this),\\n rewardsManager\\n );\\n\\n initGovernance(_collateralToken);\\n }\\n\\n /// @dev Overwrite to empty if collateral token used by the AssetPool\\n /// does not support DAO checkpoints. Used for tests with KEEP token.\\n function initGovernance(ICollateralToken _collateralToken)\\n internal\\n virtual\\n {\\n _collateralToken.delegate(address(this));\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// Optional data in extraData may include a minimal amount of\\n /// underwriter tokens expected to be minted for a depositor. There\\n /// are cases when an amount of minted tokens matters for a\\n /// depositor, as tokens might be used in third party exchanges.\\n /// @dev This function is a shortcut for approve + deposit.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external {\\n require(\\n amount + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n require(msg.sender == token, \\\"Only token caller allowed\\\");\\n require(\\n token == address(collateralToken),\\n \\\"Unsupported collateral token\\\"\\n );\\n\\n uint256 toMint = _calculateTokensToMint(amount);\\n if (extraData.length != 0) {\\n require(extraData.length == 32, \\\"Unexpected data length\\\");\\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n }\\n\\n _deposit(from, amount, toMint);\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership. The\\n /// amount locked in the pool after accepting this deposit must\\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal to\\n /// 2^96-1\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amountToDeposit)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership. The amount locked in the pool after accepting\\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\\n /// function reverts.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\\n /// the asset pool; must be smaller or equal\\n /// to 2^96-1\\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\\n /// expects to receive in exchange for the deposited\\n /// collateral tokens\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n override\\n returns (uint256)\\n {\\n require(\\n amountToDeposit + totalValue() <= type(uint96).max,\\n \\\"Pool capacity exceeded\\\"\\n );\\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\\n\\n require(\\n minAmountToMint <= toMint,\\n \\\"Amount to mint is smaller than the required minimum\\\"\\n );\\n\\n _deposit(msg.sender, amountToDeposit, toMint);\\n return toMint;\\n }\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the\\n /// pool. Must be followed with completeWithdrawal call after the\\n /// withdrawal delay passes. Accepts the amount of underwriter\\n /// tokens representing the share of the pool that should be\\n /// withdrawn. Can be called multiple times increasing the pool share\\n /// to withdraw and resetting the withdrawal initiated timestamp for\\n /// each call. Can be called with 0 covAmount to reset the\\n /// withdrawal initiated timestamp if the underwriter has a pending\\n /// withdrawal. In practice 0 covAmount should be used only to\\n /// initiate the withdrawal again in case one did not complete the\\n /// withdrawal before the withdrawal timeout elapsed.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external override {\\n uint256 pending = pendingWithdrawal[msg.sender];\\n require(\\n covAmount > 0 || pending > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n pending += covAmount;\\n pendingWithdrawal[msg.sender] = pending;\\n /* solhint-disable not-rely-on-time */\\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\\n\\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\\n /* solhint-enable not-rely-on-time */\\n\\n if (covAmount > 0) {\\n underwriterToken.safeTransferFrom(\\n msg.sender,\\n address(this),\\n covAmount\\n );\\n }\\n }\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter. Anyone can complete the withdrawal for the\\n /// underwriter. The withdrawal has to be completed before the\\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\\n /// be initiated again and the underwriter has to wait for the\\n /// entire withdrawal delay again before being able to complete\\n /// the withdrawal.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter)\\n external\\n override\\n returns (uint256)\\n {\\n /* solhint-disable not-rely-on-time */\\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\\n require(initiatedAt > 0, \\\"No withdrawal initiated for the underwriter\\\");\\n\\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\\n require(\\n withdrawalDelayEndTimestamp < block.timestamp,\\n \\\"Withdrawal delay has not elapsed\\\"\\n );\\n\\n require(\\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\\n \\\"Withdrawal timeout elapsed\\\"\\n );\\n\\n uint256 covAmount = pendingWithdrawal[underwriter];\\n uint256 covSupply = underwriterToken.totalSupply();\\n delete withdrawalInitiatedTimestamp[underwriter];\\n delete pendingWithdrawal[underwriter];\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\\n\\n emit WithdrawalCompleted(\\n underwriter,\\n amountToWithdraw,\\n covAmount,\\n block.timestamp\\n );\\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\\n\\n /* solhint-enable not-rely-on-time */\\n underwriterToken.burn(covAmount);\\n\\n return amountToWithdraw;\\n }\\n\\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\\n /// was approved by the governance. Upgrade does not have to obey\\n /// withdrawal delay.\\n /// Old underwriter tokens are burned in favor of new tokens minted\\n /// in a new Asset Pool. New tokens are sent directly to the\\n /// underwriter from a new Asset Pool.\\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\\n /// tokens which are transferred to a new asset pool\\n /// @param _newAssetPool New Asset Pool address to check validity with the one\\n /// that was approved by the governance\\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\\n external\\n {\\n /* solhint-disable not-rely-on-time */\\n require(\\n address(newAssetPool) != address(0),\\n \\\"New asset pool must be assigned\\\"\\n );\\n\\n require(\\n address(newAssetPool) == _newAssetPool,\\n \\\"Addresses of a new asset pool must match\\\"\\n );\\n\\n require(\\n covAmount > 0,\\n \\\"Underwriter token amount must be greater than 0\\\"\\n );\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n\\n // slither-disable-next-line reentrancy-events\\n rewardsPool.withdraw();\\n\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\\n covSupply;\\n\\n collateralToken.safeApprove(\\n address(newAssetPool),\\n collateralToTransfer\\n );\\n // old underwriter tokens are burned in favor of new minted in a new\\n // asset pool\\n underwriterToken.burnFrom(msg.sender, covAmount);\\n // collateralToTransfer will be sent to a new AssetPool and new\\n // underwriter tokens will be minted and transferred back to the underwriter\\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\\n\\n emit AssetPoolUpgraded(\\n msg.sender,\\n collateralToTransfer,\\n covAmount,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Allows governance to set a new asset pool so the underwriters\\n /// can move their collateral tokens to a new asset pool without\\n /// having to wait for the withdrawal delay.\\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\\n external\\n onlyOwner\\n {\\n require(\\n address(_newAssetPool) != address(0),\\n \\\"New asset pool can't be zero address\\\"\\n );\\n\\n newAssetPool = _newAssetPool;\\n\\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\\n }\\n\\n /// @notice Allows governance to cancel already approved new asset pool\\n /// in case of some misconfiguration.\\n function cancelNewAssetPoolUpgrade() external onlyOwner {\\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\\n\\n newAssetPool = IAssetPoolUpgrade(address(0));\\n }\\n\\n /// @notice Allows the coverage pool to demand coverage from the asset hold\\n /// by this pool and send it to the provided recipient address.\\n function claim(address recipient, uint256 amount) external onlyOwner {\\n emit CoverageClaimed(recipient, amount, block.timestamp);\\n rewardsPool.withdraw();\\n require(\\n amount <= collateralToken.balanceOf(address(this)),\\n \\\"Amount to seize exceeds the pool balance\\\"\\n );\\n collateralToken.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal delay\\n /// parameter value. Withdrawal delay is the time it takes the\\n /// underwriter to withdraw their collateral and rewards from the\\n /// pool. This is the time that needs to pass between initiating and\\n /// completing the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalDelayUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal delay value should be but it should\\n /// be long enough so that the possibility of having free-riding\\n /// underwriters escaping from a potential coverage claim by\\n /// withdrawing their positions from the pool is negligible.\\n /// @param _newWithdrawalDelay The new value of withdrawal delay\\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\\n external\\n onlyOwner\\n {\\n newWithdrawalDelay = _newWithdrawalDelay;\\n withdrawalDelayChangeInitiated = block.timestamp;\\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// delay parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalDelayUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalDelayUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\\n {\\n withdrawalDelay = newWithdrawalDelay;\\n emit WithdrawalDelayUpdated(withdrawalDelay);\\n newWithdrawalDelay = 0;\\n withdrawalDelayChangeInitiated = 0;\\n }\\n\\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\\n /// parameter value. The withdrawal timeout is the time the\\n /// underwriter has - after the withdrawal delay passed - to\\n /// complete the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\\n /// governance delay passes. It is up to the contract owner to\\n /// decide what the withdrawal timeout value should be but it should\\n /// be short enough so that the time of free-riding by being able to\\n /// immediately escape from the claim is minimal and long enough so\\n /// that honest underwriters have a possibility to finalize the\\n /// withdrawal. It is all about the right proportions with\\n /// a relation to withdrawal delay value.\\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\\n external\\n onlyOwner\\n {\\n newWithdrawalTimeout = _newWithdrawalTimeout;\\n withdrawalTimeoutChangeInitiated = block.timestamp;\\n emit WithdrawalTimeoutUpdateStarted(\\n _newWithdrawalTimeout,\\n block.timestamp\\n );\\n }\\n\\n /// @notice Lets the contract owner to finalize an update of withdrawal\\n /// timeout parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalTimeoutUpdate()\\n external\\n onlyOwner\\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\\n {\\n withdrawalTimeout = newWithdrawalTimeout;\\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\\n newWithdrawalTimeout = 0;\\n withdrawalTimeoutChangeInitiated = 0;\\n }\\n\\n /// @notice Grants pool shares by minting a given amount of the underwriter\\n /// tokens for the recipient address. In result, the recipient\\n /// obtains part of the pool ownership without depositing any\\n /// collateral tokens. Shares are usually granted for notifiers\\n /// reporting about various contract state changes.\\n /// @dev Can be called only by the contract owner.\\n /// @param recipient Address of the underwriter tokens recipient\\n /// @param covAmount Amount of the underwriter tokens which should be minted\\n function grantShares(address recipient, uint256 covAmount)\\n external\\n onlyOwner\\n {\\n rewardsPool.withdraw();\\n underwriterToken.mint(recipient, covAmount);\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal delay update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal delay update can be finalized\\n function getRemainingWithdrawalDelayUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalDelayChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the remaining time that has to pass before the contract\\n /// owner will be able to finalize withdrawal timeout update.\\n /// Bear in mind the contract owner may decide to wait longer and\\n /// this value is just an absolute minimum.\\n /// @return The time left until withdrawal timeout update can be finalized\\n function getRemainingWithdrawalTimeoutUpdateTime()\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n withdrawalTimeoutChangeInitiated,\\n withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Returns the current collateral token balance of the asset pool\\n /// plus the reward amount (in collateral token) earned by the asset\\n /// pool and not yet withdrawn to the asset pool.\\n /// @return The total value of asset pool in collateral token.\\n function totalValue() public view returns (uint256) {\\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\\n }\\n\\n /// @notice The time it takes to initiate and complete the withdrawal from\\n /// the pool plus 2 days to make a decision. This governance delay\\n /// should be used for all changes directly affecting underwriter\\n /// positions. This time is a minimum and the governance may choose\\n /// to wait longer before finalizing the update.\\n /// @return The withdrawal governance delay in seconds\\n function withdrawalGovernanceDelay() public view returns (uint256) {\\n return withdrawalDelay + withdrawalTimeout + 2 days;\\n }\\n\\n /// @dev Calculates underwriter tokens to mint.\\n function _calculateTokensToMint(uint256 amountToDeposit)\\n internal\\n returns (uint256)\\n {\\n rewardsPool.withdraw();\\n\\n uint256 covSupply = underwriterToken.totalSupply();\\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\\n\\n if (covSupply == 0) {\\n return amountToDeposit;\\n }\\n\\n return (amountToDeposit * covSupply) / collateralBalance;\\n }\\n\\n function _deposit(\\n address depositor,\\n uint256 amountToDeposit,\\n uint256 amountToMint\\n ) internal {\\n require(depositor != address(this), \\\"Self-deposit not allowed\\\");\\n\\n require(\\n amountToMint > 0,\\n \\\"Minted tokens amount must be greater than 0\\\"\\n );\\n\\n emit Deposited(depositor, amountToDeposit, amountToMint);\\n\\n underwriterToken.mint(depositor, amountToMint);\\n collateralToken.safeTransferFrom(\\n depositor,\\n address(this),\\n amountToDeposit\\n );\\n }\\n}\\n\",\"keccak256\":\"0x41be5f1b06ae8b9b722c642030127cce94f571b63c4a782b155f5f42e5d61ccc\",\"license\":\"MIT\"},\"contracts/CoveragePool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./interfaces/IAssetPoolUpgrade.sol\\\";\\nimport \\\"./interfaces/ICollateralToken.sol\\\";\\nimport \\\"./AssetPool.sol\\\";\\nimport \\\"./CoveragePoolConstants.sol\\\";\\nimport \\\"./GovernanceUtils.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Coverage Pool\\n/// @notice A contract that manages a single asset pool. Handles approving and\\n/// unapproving of risk managers and allows them to seize funds from the\\n/// asset pool if they are approved.\\n/// @dev Coverage pool contract is owned by the governance. Coverage pool is the\\n/// owner of the asset pool contract.\\ncontract CoveragePool is Ownable {\\n AssetPool public immutable assetPool;\\n ICollateralToken public immutable collateralToken;\\n UnderwriterToken public immutable underwriterToken;\\n\\n bool public firstRiskManagerApproved = false;\\n\\n // Currently approved risk managers\\n mapping(address => bool) public approvedRiskManagers;\\n // Timestamps of risk managers whose approvals have been initiated\\n mapping(address => uint256) public riskManagerApprovalTimestamps;\\n\\n event RiskManagerApprovalStarted(address riskManager, uint256 timestamp);\\n event RiskManagerApprovalCompleted(address riskManager, uint256 timestamp);\\n event RiskManagerUnapproved(address riskManager, uint256 timestamp);\\n\\n /// @notice Reverts if called by a risk manager that is not approved\\n modifier onlyApprovedRiskManager() {\\n require(approvedRiskManagers[msg.sender], \\\"Risk manager not approved\\\");\\n _;\\n }\\n\\n constructor(AssetPool _assetPool) {\\n assetPool = _assetPool;\\n collateralToken = _assetPool.collateralToken();\\n underwriterToken = _assetPool.underwriterToken();\\n }\\n\\n /// @notice Approves the first risk manager\\n /// @dev Can be called only by the contract owner. Can be called only once.\\n /// Does not require any further calls to any functions.\\n /// @param riskManager Risk manager that will be approved\\n function approveFirstRiskManager(address riskManager) external onlyOwner {\\n require(\\n !firstRiskManagerApproved,\\n \\\"The first risk manager was approved\\\"\\n );\\n approvedRiskManagers[riskManager] = true;\\n firstRiskManagerApproved = true;\\n }\\n\\n /// @notice Begins risk manager approval process.\\n /// @dev Can be called only by the contract owner and only when the first\\n /// risk manager is already approved. For a risk manager to be\\n /// approved, a call to `finalizeRiskManagerApproval` must follow\\n /// (after a governance delay).\\n /// @param riskManager Risk manager that will be approved\\n function beginRiskManagerApproval(address riskManager) external onlyOwner {\\n require(\\n firstRiskManagerApproved,\\n \\\"The first risk manager is not yet approved; Please use \\\"\\n \\\"approveFirstRiskManager instead\\\"\\n );\\n\\n require(\\n !approvedRiskManagers[riskManager],\\n \\\"Risk manager already approved\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n riskManagerApprovalTimestamps[riskManager] = block.timestamp;\\n /* solhint-disable-next-line not-rely-on-time */\\n emit RiskManagerApprovalStarted(riskManager, block.timestamp);\\n }\\n\\n /// @notice Finalizes risk manager approval process.\\n /// @dev Can be called only by the contract owner. Must be preceded with a\\n /// call to beginRiskManagerApproval and a governance delay must elapse.\\n /// @param riskManager Risk manager that will be approved\\n function finalizeRiskManagerApproval(address riskManager)\\n external\\n onlyOwner\\n {\\n require(\\n riskManagerApprovalTimestamps[riskManager] > 0,\\n \\\"Risk manager approval not initiated\\\"\\n );\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - riskManagerApprovalTimestamps[riskManager] >=\\n assetPool.withdrawalGovernanceDelay(),\\n \\\"Risk manager governance delay has not elapsed\\\"\\n );\\n approvedRiskManagers[riskManager] = true;\\n /* solhint-disable-next-line not-rely-on-time */\\n emit RiskManagerApprovalCompleted(riskManager, block.timestamp);\\n delete riskManagerApprovalTimestamps[riskManager];\\n }\\n\\n /// @notice Unapproves an already approved risk manager or cancels the\\n /// approval process of a risk manager (the latter happens if called\\n /// between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`).\\n /// The change takes effect immediately.\\n /// @dev Can be called only by the contract owner.\\n /// @param riskManager Risk manager that will be unapproved\\n function unapproveRiskManager(address riskManager) external onlyOwner {\\n require(\\n riskManagerApprovalTimestamps[riskManager] > 0 ||\\n approvedRiskManagers[riskManager],\\n \\\"Risk manager is neither approved nor with a pending approval\\\"\\n );\\n delete riskManagerApprovalTimestamps[riskManager];\\n delete approvedRiskManagers[riskManager];\\n /* solhint-disable-next-line not-rely-on-time */\\n emit RiskManagerUnapproved(riskManager, block.timestamp);\\n }\\n\\n /// @notice Approves upgradeability to the new asset pool.\\n /// Allows governance to set a new asset pool so the underwriters\\n /// can move their collateral tokens to a new asset pool without\\n /// having to wait for the withdrawal delay.\\n /// @param _newAssetPool New asset pool\\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\\n external\\n onlyOwner\\n {\\n assetPool.approveNewAssetPoolUpgrade(_newAssetPool);\\n }\\n\\n /// @notice Lets the governance to begin an update of withdrawal delay\\n /// parameter value. Withdrawal delay is the time it takes the\\n /// underwriter to withdraw their collateral and rewards from the\\n /// pool. This is the time that needs to pass between initiating and\\n /// completing the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalDelayUpdate after the required\\n /// governance delay passes. It is up to the governance to\\n /// decide what the withdrawal delay value should be but it should\\n /// be long enough so that the possibility of having free-riding\\n /// underwriters escaping from a potential coverage claim by\\n /// withdrawing their positions from the pool is negligible.\\n /// @param newWithdrawalDelay The new value of withdrawal delay\\n function beginWithdrawalDelayUpdate(uint256 newWithdrawalDelay)\\n external\\n onlyOwner\\n {\\n assetPool.beginWithdrawalDelayUpdate(newWithdrawalDelay);\\n }\\n\\n /// @notice Lets the governance to finalize an update of withdrawal\\n /// delay parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalDelayUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalDelayUpdate() external onlyOwner {\\n assetPool.finalizeWithdrawalDelayUpdate();\\n }\\n\\n /// @notice Lets the governance to begin an update of withdrawal timeout\\n /// parameter value. The withdrawal timeout is the time the\\n /// underwriter has - after the withdrawal delay passed - to\\n /// complete the withdrawal. The change needs to be finalized with\\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\\n /// governance delay passes. It is up to the governance to\\n /// decide what the withdrawal timeout value should be but it should\\n /// be short enough so that the time of free-riding by being able to\\n /// immediately escape from the claim is minimal and long enough so\\n /// that honest underwriters have a possibility to finalize the\\n /// withdrawal. It is all about the right proportions with\\n /// a relation to withdrawal delay value.\\n /// @param newWithdrawalTimeout The new value of the withdrawal timeout\\n function beginWithdrawalTimeoutUpdate(uint256 newWithdrawalTimeout)\\n external\\n onlyOwner\\n {\\n assetPool.beginWithdrawalTimeoutUpdate(newWithdrawalTimeout);\\n }\\n\\n /// @notice Lets the governance to finalize an update of withdrawal\\n /// timeout parameter value. This call has to be preceded with\\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\\n /// has to pass.\\n function finalizeWithdrawalTimeoutUpdate() external onlyOwner {\\n assetPool.finalizeWithdrawalTimeoutUpdate();\\n }\\n\\n /// @notice Seizes funds from the coverage pool and sends them to the\\n /// `recipient`.\\n /// @dev `portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR`\\n /// for calculation precision purposes. Further calculations in this\\n /// function will need to take this divisor into account.\\n /// @param recipient Address that will receive the pool's seized funds\\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\\n /// multiplied by `FLOATING_POINT_DIVISOR`\\n function seizePortion(address recipient, uint256 portionToSeize)\\n external\\n onlyApprovedRiskManager\\n {\\n require(\\n portionToSeize > 0 &&\\n portionToSeize <= CoveragePoolConstants.FLOATING_POINT_DIVISOR,\\n \\\"Portion to seize is not within the range (0, 1]\\\"\\n );\\n\\n assetPool.claim(recipient, amountToSeize(portionToSeize));\\n }\\n\\n /// @notice Seizes funds from the coverage pool and sends them to the\\n /// `recipient`.\\n /// @param recipient Address that will receive the pool's seized funds\\n /// @param amountToSeize Amount to be seized from the pool\\n // slither-disable-next-line shadowing-local\\n function seizeAmount(address recipient, uint256 amountToSeize)\\n external\\n onlyApprovedRiskManager\\n {\\n require(amountToSeize > 0, \\\"Amount to seize must be >0\\\");\\n\\n assetPool.claim(recipient, amountToSeize);\\n }\\n\\n /// @notice Grants asset pool shares by minting a given amount of the\\n /// underwriter tokens for the recipient address. In result, the\\n /// recipient obtains part of the pool ownership without depositing\\n /// any collateral tokens. Shares are usually granted for notifiers\\n /// reporting about various contract state changes.\\n /// @dev Can be called only by an approved risk manager.\\n /// @param recipient Address of the underwriter tokens recipient\\n /// @param covAmount Amount of the underwriter tokens which should be minted\\n function grantAssetPoolShares(address recipient, uint256 covAmount)\\n external\\n onlyApprovedRiskManager\\n {\\n assetPool.grantShares(recipient, covAmount);\\n }\\n\\n /// @notice Returns the time remaining until the risk manager approval\\n /// process can be finalized\\n /// @param riskManager Risk manager in the process of approval\\n /// @return Remaining time in seconds.\\n function getRemainingRiskManagerApprovalTime(address riskManager)\\n external\\n view\\n returns (uint256)\\n {\\n return\\n GovernanceUtils.getRemainingChangeTime(\\n riskManagerApprovalTimestamps[riskManager],\\n assetPool.withdrawalGovernanceDelay()\\n );\\n }\\n\\n /// @notice Determine the prior number of DAO votes for the given coverage\\n /// pool underwriter.\\n /// @param account The underwriter address to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the underwriter had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96)\\n {\\n uint96 underwriterVotes = underwriterToken.getPastVotes(\\n account,\\n blockNumber\\n );\\n uint96 underwriterTokenSupply = underwriterToken.getPastTotalSupply(\\n blockNumber\\n );\\n\\n if (underwriterTokenSupply == 0) {\\n return 0;\\n }\\n\\n uint96 covPoolVotes = collateralToken.getPastVotes(\\n address(assetPool),\\n blockNumber\\n );\\n\\n return\\n uint96(\\n (uint256(underwriterVotes) * covPoolVotes) /\\n underwriterTokenSupply\\n );\\n }\\n\\n /// @notice Calculates amount of tokens to be seized from the coverage pool.\\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\\n /// multiplied by FLOATING_POINT_DIVISOR\\n function amountToSeize(uint256 portionToSeize)\\n public\\n view\\n returns (uint256)\\n {\\n return\\n (collateralToken.balanceOf(address(assetPool)) * portionToSeize) /\\n CoveragePoolConstants.FLOATING_POINT_DIVISOR;\\n }\\n}\\n\",\"keccak256\":\"0x84ac20c2bdc5f1a66783ca7bd607e8042e8fda4c37c4ac33502dcbbc7fee9432\",\"license\":\"MIT\"},\"contracts/CoveragePoolConstants.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nlibrary CoveragePoolConstants {\\n // This divisor is for precision purposes only. We use this divisor around\\n // auction related code to get the precise values without rounding it down\\n // when dealing with floating numbers.\\n uint256 public constant FLOATING_POINT_DIVISOR = 1e18;\\n}\\n\",\"keccak256\":\"0x6762b84f1f678a93a7714dc1c91288f935255cf729569e1fa976d9172a4e3c6e\",\"license\":\"MIT\"},\"contracts/GovernanceUtils.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nlibrary GovernanceUtils {\\n /// @notice Gets the time remaining until the governable parameter update\\n /// can be committed.\\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\\n /// @param delay Governance delay.\\n /// @return Remaining time in seconds.\\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\\n internal\\n view\\n returns (uint256)\\n {\\n require(changeTimestamp > 0, \\\"Change not initiated\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n uint256 elapsed = block.timestamp - changeTimestamp;\\n if (elapsed >= delay) {\\n return 0;\\n } else {\\n return delay - elapsed;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x991d317527b08149a0e263c4c951e5969b29d48fd3aa64b2807de70fc766fd91\",\"license\":\"MIT\"},\"contracts/RewardsPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Rewards Pool\\n/// @notice RewardsPool accepts a single reward token and releases it to the\\n/// AssetPool over time in one week reward intervals. The owner of this\\n/// contract is the reward distribution address funding it with reward\\n/// tokens.\\ncontract RewardsPool is Ownable {\\n using SafeERC20 for IERC20;\\n\\n uint256 public constant DURATION = 7 days;\\n\\n IERC20 public immutable rewardToken;\\n address public immutable assetPool;\\n\\n // timestamp of the current reward interval end or the timestamp of the\\n // last interval end in case a new reward interval has not been allocated\\n uint256 public intervalFinish = 0;\\n // rate per second with which reward tokens are unlocked\\n uint256 public rewardRate = 0;\\n // amount of rewards accumulated and not yet withdrawn from the previous\\n // reward interval(s)\\n uint256 public rewardAccumulated = 0;\\n // the last time information in this contract was updated\\n uint256 public lastUpdateTime = 0;\\n\\n event RewardToppedUp(uint256 amount);\\n event RewardWithdrawn(uint256 amount);\\n\\n constructor(\\n IERC20 _rewardToken,\\n address _assetPool,\\n address owner\\n ) {\\n rewardToken = _rewardToken;\\n // slither-disable-next-line missing-zero-check\\n assetPool = _assetPool;\\n transferOwnership(owner);\\n }\\n\\n /// @notice Transfers the provided reward amount into RewardsPool and\\n /// creates a new, one-week reward interval starting from now.\\n /// Reward tokens from the previous reward interval that unlocked\\n /// over the time will be available for withdrawal immediately.\\n /// Reward tokens from the previous interval that has not been yet\\n /// unlocked, are added to the new interval being created.\\n /// @dev This function can be called only by the owner given that it creates\\n /// a new interval with one week length, starting from now.\\n function topUpReward(uint256 reward) external onlyOwner {\\n rewardAccumulated = earned();\\n\\n /* solhint-disable not-rely-on-time */\\n if (block.timestamp >= intervalFinish) {\\n // see https://github.com/crytic/slither/issues/844\\n // slither-disable-next-line divide-before-multiply\\n rewardRate = reward / DURATION;\\n } else {\\n uint256 remaining = intervalFinish - block.timestamp;\\n uint256 leftover = remaining * rewardRate;\\n rewardRate = (reward + leftover) / DURATION;\\n }\\n intervalFinish = block.timestamp + DURATION;\\n lastUpdateTime = block.timestamp;\\n /* solhint-enable avoid-low-level-calls */\\n\\n emit RewardToppedUp(reward);\\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\\n function withdraw() external {\\n uint256 amount = earned();\\n rewardAccumulated = 0;\\n lastUpdateTime = lastTimeRewardApplicable();\\n emit RewardWithdrawn(amount);\\n rewardToken.safeTransfer(assetPool, amount);\\n }\\n\\n /// @notice Returns the amount of earned and not yet withdrawn reward\\n /// tokens.\\n function earned() public view returns (uint256) {\\n return\\n rewardAccumulated +\\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\\n }\\n\\n /// @notice Returns the timestamp at which a reward was last time applicable.\\n /// When reward interval is pending, returns current block's\\n /// timestamp. If the last reward interval ended and no other reward\\n /// interval had been allocated, returns the last reward interval's\\n /// end timestamp.\\n function lastTimeRewardApplicable() public view returns (uint256) {\\n return Math.min(block.timestamp, intervalFinish);\\n }\\n}\\n\",\"keccak256\":\"0xe56e8c35bbafad758cc66473f113ea9fd3ffa9c44c6139fc3196dbbead2a4054\",\"license\":\"MIT\"},\"contracts/UnderwriterToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\\";\\n\\n/// @title UnderwriterToken\\n/// @notice Underwriter tokens represent an ownership share in the underlying\\n/// collateral of the asset-specific pool. Underwriter tokens are minted\\n/// when a user deposits ERC20 tokens into asset-specific pool and they\\n/// are burned when a user exits the position. Underwriter tokens\\n/// natively support meta transactions. Users can authorize a transfer\\n/// of their underwriter tokens with a signature conforming EIP712\\n/// standard instead of an on-chain transaction from their address.\\n/// Anyone can submit this signature on the user's behalf by calling the\\n/// permit function, as specified in EIP2612 standard, paying gas fees,\\n/// and possibly performing other actions in the same transaction.\\n// slither-disable-next-line missing-inheritance\\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\\n /// @notice The EIP-712 typehash for the delegation struct used by\\n /// `delegateBySig`.\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\n \\\"Delegation(address delegatee,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n constructor(string memory _name, string memory _symbol)\\n ERC20WithPermit(_name, _symbol)\\n {}\\n\\n /// @notice Delegates votes from signatory to `delegatee`\\n /// @param delegatee The address to delegate votes to\\n /// @param deadline The time at which to expire the signature\\n /// @param v The recovery byte of the signature\\n /// @param r Half of the ECDSA signature pair\\n /// @param s Half of the ECDSA signature pair\\n function delegateBySig(\\n address signatory,\\n address delegatee,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Delegation expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n DELEGATION_TYPEHASH,\\n delegatee,\\n nonce[signatory]++,\\n deadline\\n )\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == signatory,\\n \\\"Invalid signature\\\"\\n );\\n\\n return delegate(signatory, delegatee);\\n }\\n\\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) public virtual {\\n return delegate(msg.sender, delegatee);\\n }\\n\\n /// @notice Moves voting power when tokens are minted, burned or transferred.\\n /// @dev Overrides the empty function from the parent contract.\\n /// @param from The address that loses tokens and voting power\\n /// @param to The address that gains tokens and voting power\\n /// @param amount The amount of tokens and voting power that is transferred\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal override {\\n // When minting:\\n if (from == address(0)) {\\n // Does not allow to mint more than uint96 can fit. Otherwise, the\\n // Checkpoint might not fit the balance.\\n require(\\n totalSupply + amount <= maxSupply(),\\n \\\"Maximum total supply exceeded\\\"\\n );\\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\\n }\\n\\n // When burning:\\n if (to == address(0)) {\\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\\n }\\n\\n moveVotingPower(delegates(from), delegates(to), amount);\\n }\\n\\n /// @notice Delegate votes from `delegator` to `delegatee`.\\n /// @param delegator The address to delegate votes from\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegator, address delegatee) internal override {\\n address currentDelegate = delegates(delegator);\\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\\n _delegates[delegator] = delegatee;\\n\\n emit DelegateChanged(delegator, currentDelegate, delegatee);\\n\\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\\n }\\n}\\n\",\"keccak256\":\"0x73aa9781275a0e35c0c80873bfbb3b4b42692fa56f785a3eb4bf0471fb3c277d\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool interface\\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\\n/// an underwriter token. For example, an asset pool might accept deposits\\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\\n/// represent an ownership share in the underlying collateral of the\\n/// Asset Pool.\\ninterface IAssetPool {\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints underwriter tokens representing pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function deposit(uint256 amount) external returns (uint256);\\n\\n /// @notice Accepts the given amount of collateral token as a deposit and\\n /// mints at least a minAmountToMint underwriter tokens representing\\n /// pool's ownership.\\n /// @dev Before calling this function, collateral token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n /// @return The amount of minted underwriter tokens\\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\\n external\\n returns (uint256);\\n\\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\\n /// @dev Before calling this function, underwriter token needs to have the\\n /// required amount accepted to transfer to the asset pool.\\n function initiateWithdrawal(uint256 covAmount) external;\\n\\n /// @notice Completes the previously initiated withdrawal for the\\n /// underwriter.\\n /// @return The amount of collateral withdrawn\\n function completeWithdrawal(address underwriter) external returns (uint256);\\n}\\n\",\"keccak256\":\"0x5b4f1ad0d424a3de30a85a0ef1639c556073bc2eb58dc493b84c3d39a4c01847\",\"license\":\"MIT\"},\"contracts/interfaces/IAssetPoolUpgrade.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\n/// @title Asset Pool upgrade interface\\n/// @notice Interface that has to be implemented by an Asset Pool accepting\\n/// upgrades from another asset pool.\\ninterface IAssetPoolUpgrade {\\n /// @notice Accepts the given underwriter with collateral tokens amount as a\\n /// deposit. In exchange new underwriter tokens will be calculated,\\n /// minted and then transferred back to the underwriter.\\n function depositFor(address underwriter, uint256 amount) external;\\n}\\n\",\"keccak256\":\"0xcba05501e84b0c914619e2df9e30a6013254440013783f28deed9fc6698c58bd\",\"license\":\"MIT\"},\"contracts/interfaces/ICollateralToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\n\\n/// @title Collateral Token interface\\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\\n/// as a deposit token by underwriters. Collateral token positions of\\n/// underwriters can be affected when the Risk Manager claims coverage.\\n/// Collateral token needs to support DAO checkpoints and let to\\n/// retrieve past number of votes for the given address so that\\n/// Coverage Pool underwriters can participate in token holder DAO.\\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\ninterface ICollateralToken is IERC20 {\\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) external;\\n\\n /// @notice Determine the prior number of DAO votes for an account as of\\n /// a block number.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x7eee350d9c04b671643621258db266b65f46eea752acd7183f0bccac0eb1e233\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60e060405260008060146101000a81548160ff0219169083151502179055503480156200002b57600080fd5b5060405162002a4238038062002a42833981810160405281019062000051919062000360565b62000071620000656200021660201b60201c565b6200021e60201b60201c565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1663b2016bd46040518163ffffffff1660e01b815260040160206040518083038186803b158015620000ec57600080fd5b505afa15801562000101573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001279190620003d7565b73ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1663cc5398046040518163ffffffff1660e01b815260040160206040518083038186803b158015620001a157600080fd5b505afa158015620001b6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001dc91906200044e565b73ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250505062000480565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200031482620002e7565b9050919050565b6000620003288262000307565b9050919050565b6200033a816200031b565b81146200034657600080fd5b50565b6000815190506200035a816200032f565b92915050565b600060208284031215620003795762000378620002e2565b5b6000620003898482850162000349565b91505092915050565b60006200039f8262000307565b9050919050565b620003b18162000392565b8114620003bd57600080fd5b50565b600081519050620003d181620003a6565b92915050565b600060208284031215620003f057620003ef620002e2565b5b60006200040084828501620003c0565b91505092915050565b6000620004168262000307565b9050919050565b620004288162000409565b81146200043457600080fd5b50565b60008151905062000448816200041d565b92915050565b600060208284031215620004675762000466620002e2565b5b6000620004778482850162000437565b91505092915050565b60805160a05160c05161252262000520600039600081816108e40152818161099301526115b2015260008181610a6201528181610c7701526112ca015260008181610452015281816104dc01528181610566015281816106800152818161071101528181610a9e01528181610bc101528181610cb301528181610d6301528181610ee80152818161100b0152818161123c01526113bd01526125226000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c806376b6a1af116100c3578063c753e5801161007c578063c753e58014610363578063cc5398041461037f578063ccfbf30a1461039d578063e1e92fcf146103cd578063efec39a0146103fd578063f2fde38b1461041957610158565b806376b6a1af146102b757806384e1c564146102d35780638da5cb5b146102ef5780639ac9e7e51461030d578063b2016bd414610329578063bdceb0e21461034757610158565b806333f29dd01161011557806333f29dd0146101e55780633a46b1a814610201578063465b43e6146102315780635d6f5ddb1461026157806369da62f414610291578063715018a6146102ad57610158565b80630647cada1461015d578063092b7eb51461017b57806315245857146101855780632828fdb11461018f5780632b9d0579146101ab5780632ec939f9146101c7575b600080fd5b610165610435565b604051610172919061193d565b60405180910390f35b610183610448565b005b61018d6104d2565b005b6101a960048036038101906101a49190611993565b61055c565b005b6101c560048036038101906101c09190611a1e565b6105f2565b005b6101cf61070f565b6040516101dc9190611abd565b60405180910390f35b6101ff60048036038101906101fa9190611ad8565b610733565b005b61021b60048036038101906102169190611a1e565b6108df565b6040516102289190611b2c565b60405180910390f35b61024b60048036038101906102469190611ad8565b610b7a565b6040516102589190611b56565b60405180910390f35b61027b60048036038101906102769190611993565b610c69565b6040516102889190611b56565b60405180910390f35b6102ab60048036038101906102a69190611baf565b610d59565b005b6102b5610def565b005b6102d160048036038101906102cc9190611a1e565b610e03565b005b6102ed60048036038101906102e89190611ad8565b610f7f565b005b6102f7611209565b6040516103049190611beb565b60405180910390f35b61032760048036038101906103229190611993565b611232565b005b6103316112c8565b60405161033e9190611c27565b60405180910390f35b610361600480360381019061035c9190611a1e565b6112ec565b005b61037d60048036038101906103789190611ad8565b61144c565b005b6103876115b0565b6040516103949190611c63565b60405180910390f35b6103b760048036038101906103b29190611ad8565b6115d4565b6040516103c4919061193d565b60405180910390f35b6103e760048036038101906103e29190611ad8565b6115f4565b6040516103f49190611b56565b60405180910390f35b61041760048036038101906104129190611ad8565b61160c565b005b610433600480360381019061042e9190611ad8565b6116d9565b005b600060149054906101000a900460ff1681565b61045061175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663092b7eb56040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156104b857600080fd5b505af11580156104cc573d6000803e3d6000fd5b50505050565b6104da61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663152458576040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561054257600080fd5b505af1158015610556573d6000803e3d6000fd5b50505050565b61056461175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632828fdb1826040518263ffffffff1660e01b81526004016105bd9190611b56565b600060405180830381600087803b1580156105d757600080fd5b505af11580156105eb573d6000803e3d6000fd5b5050505050565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661067e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067590611cdb565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ff603d2283836040518363ffffffff1660e01b81526004016106d9929190611cfb565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b61073b61175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411806107d25750600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b610811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080890611d96565b60405180910390fd5b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690557f9bf9ec07f4d3e134e1a799a215cf4c47dbf1c427fe348f3c0d3994ef1c2e295781426040516108d4929190611cfb565b60405180910390a150565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a885856040518363ffffffff1660e01b815260040161093d929190611cfb565b60206040518083038186803b15801561095557600080fd5b505afa158015610969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098d9190611de2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16638e539e8c856040518263ffffffff1660e01b81526004016109ea9190611b56565b60206040518083038186803b158015610a0257600080fd5b505afa158015610a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3a9190611de2565b90506000816bffffffffffffffffffffffff161415610a5e57600092505050610b74565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a87f0000000000000000000000000000000000000000000000000000000000000000876040518363ffffffff1660e01b8152600401610adb929190611cfb565b60206040518083038186803b158015610af357600080fd5b505afa158015610b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b9190611de2565b9050816bffffffffffffffffffffffff16816bffffffffffffffffffffffff16846bffffffffffffffffffffffff16610b649190611e3e565b610b6e9190611ec7565b93505050505b92915050565b6000610c62600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020547f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2557600080fd5b505afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d9190611f0d565b6117db565b9050919050565b6000670de0b6b3a7640000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a082317f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b8152600401610cee9190611beb565b60206040518083038186803b158015610d0657600080fd5b505afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190611f0d565b610d489190611e3e565b610d529190611ec7565b9050919050565b610d6161175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166369da62f4826040518263ffffffff1660e01b8152600401610dba9190611f5b565b600060405180830381600087803b158015610dd457600080fd5b505af1158015610de8573d6000803e3d6000fd5b5050505050565b610df761175d565b610e016000611856565b565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610e8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8690611cdb565b60405180910390fd5b600081118015610ea75750670de0b6b3a76400008111155b610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd90611fe8565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683610f2c84610c69565b6040518363ffffffff1660e01b8152600401610f49929190611cfb565b600060405180830381600087803b158015610f6357600080fd5b505af1158015610f77573d6000803e3d6000fd5b505050505050565b610f8761175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411611009576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110009061207a565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b15801561106f57600080fd5b505afa158015611083573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a79190611f0d565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054426110f2919061209a565b1015611133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112a90612140565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f8499a35b7f2bbd8a5de334eed2665f0f7ea74bf1c4785bb3fb2c6a9b97fe1c5481426040516111bb929190611cfb565b60405180910390a1600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61123a61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16639ac9e7e5826040518263ffffffff1660e01b81526004016112939190611b56565b600060405180830381600087803b1580156112ad57600080fd5b505af11580156112c1573d6000803e3d6000fd5b5050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611378576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136f90611cdb565b60405180910390fd5b600081116113bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b2906121ac565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683836040518363ffffffff1660e01b8152600401611416929190611cfb565b600060405180830381600087803b15801561143057600080fd5b505af1158015611444573d6000803e3d6000fd5b505050505050565b61145461175d565b600060149054906101000a900460ff166114a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149a90612264565b60405180910390fd5b600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611530576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611527906122d0565b60405180910390fd5b42600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f981f6bdfdbe336d34d32ee17135d9517e6a5ffb574159f7ceaf02b3e2ed255b281426040516115a5929190611cfb565b60405180910390a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b60016020528060005260406000206000915054906101000a900460ff1681565b60026020528060005260406000206000915090505481565b61161461175d565b600060149054906101000a900460ff1615611664576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165b90612362565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600060146101000a81548160ff02191690831515021790555050565b6116e161175d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611751576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611748906123f4565b60405180910390fd5b61175a81611856565b50565b61176561191a565b73ffffffffffffffffffffffffffffffffffffffff16611783611209565b73ffffffffffffffffffffffffffffffffffffffff16146117d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d090612460565b60405180910390fd5b565b600080831161181f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611816906124cc565b60405180910390fd5b6000834261182d919061209a565b9050828110611840576000915050611850565b808361184c919061209a565b9150505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b60008115159050919050565b61193781611922565b82525050565b6000602082019050611952600083018461192e565b92915050565b600080fd5b6000819050919050565b6119708161195d565b811461197b57600080fd5b50565b60008135905061198d81611967565b92915050565b6000602082840312156119a9576119a8611958565b5b60006119b78482850161197e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119eb826119c0565b9050919050565b6119fb816119e0565b8114611a0657600080fd5b50565b600081359050611a18816119f2565b92915050565b60008060408385031215611a3557611a34611958565b5b6000611a4385828601611a09565b9250506020611a548582860161197e565b9150509250929050565b6000819050919050565b6000611a83611a7e611a79846119c0565b611a5e565b6119c0565b9050919050565b6000611a9582611a68565b9050919050565b6000611aa782611a8a565b9050919050565b611ab781611a9c565b82525050565b6000602082019050611ad26000830184611aae565b92915050565b600060208284031215611aee57611aed611958565b5b6000611afc84828501611a09565b91505092915050565b60006bffffffffffffffffffffffff82169050919050565b611b2681611b05565b82525050565b6000602082019050611b416000830184611b1d565b92915050565b611b508161195d565b82525050565b6000602082019050611b6b6000830184611b47565b92915050565b6000611b7c826119e0565b9050919050565b611b8c81611b71565b8114611b9757600080fd5b50565b600081359050611ba981611b83565b92915050565b600060208284031215611bc557611bc4611958565b5b6000611bd384828501611b9a565b91505092915050565b611be5816119e0565b82525050565b6000602082019050611c006000830184611bdc565b92915050565b6000611c1182611a8a565b9050919050565b611c2181611c06565b82525050565b6000602082019050611c3c6000830184611c18565b92915050565b6000611c4d82611a8a565b9050919050565b611c5d81611c42565b82525050565b6000602082019050611c786000830184611c54565b92915050565b600082825260208201905092915050565b7f5269736b206d616e61676572206e6f7420617070726f76656400000000000000600082015250565b6000611cc5601983611c7e565b9150611cd082611c8f565b602082019050919050565b60006020820190508181036000830152611cf481611cb8565b9050919050565b6000604082019050611d106000830185611bdc565b611d1d6020830184611b47565b9392505050565b7f5269736b206d616e61676572206973206e65697468657220617070726f76656460008201527f206e6f72207769746820612070656e64696e6720617070726f76616c00000000602082015250565b6000611d80603c83611c7e565b9150611d8b82611d24565b604082019050919050565b60006020820190508181036000830152611daf81611d73565b9050919050565b611dbf81611b05565b8114611dca57600080fd5b50565b600081519050611ddc81611db6565b92915050565b600060208284031215611df857611df7611958565b5b6000611e0684828501611dcd565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611e498261195d565b9150611e548361195d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611e8d57611e8c611e0f565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611ed28261195d565b9150611edd8361195d565b925082611eed57611eec611e98565b5b828204905092915050565b600081519050611f0781611967565b92915050565b600060208284031215611f2357611f22611958565b5b6000611f3184828501611ef8565b91505092915050565b6000611f4582611a8a565b9050919050565b611f5581611f3a565b82525050565b6000602082019050611f706000830184611f4c565b92915050565b7f506f7274696f6e20746f207365697a65206973206e6f742077697468696e207460008201527f68652072616e67652028302c20315d0000000000000000000000000000000000602082015250565b6000611fd2602f83611c7e565b9150611fdd82611f76565b604082019050919050565b6000602082019050818103600083015261200181611fc5565b9050919050565b7f5269736b206d616e6167657220617070726f76616c206e6f7420696e6974696160008201527f7465640000000000000000000000000000000000000000000000000000000000602082015250565b6000612064602383611c7e565b915061206f82612008565b604082019050919050565b6000602082019050818103600083015261209381612057565b9050919050565b60006120a58261195d565b91506120b08361195d565b9250828210156120c3576120c2611e0f565b5b828203905092915050565b7f5269736b206d616e6167657220676f7665726e616e63652064656c617920686160008201527f73206e6f7420656c617073656400000000000000000000000000000000000000602082015250565b600061212a602d83611c7e565b9150612135826120ce565b604082019050919050565b600060208201905081810360008301526121598161211d565b9050919050565b7f416d6f756e7420746f207365697a65206d757374206265203e30000000000000600082015250565b6000612196601a83611c7e565b91506121a182612160565b602082019050919050565b600060208201905081810360008301526121c581612189565b9050919050565b7f546865206669727374207269736b206d616e61676572206973206e6f7420796560008201527f7420617070726f7665643b20506c656173652075736520617070726f7665466960208201527f7273745269736b4d616e6167657220696e737465616400000000000000000000604082015250565b600061224e605683611c7e565b9150612259826121cc565b606082019050919050565b6000602082019050818103600083015261227d81612241565b9050919050565b7f5269736b206d616e6167657220616c726561647920617070726f766564000000600082015250565b60006122ba601d83611c7e565b91506122c582612284565b602082019050919050565b600060208201905081810360008301526122e9816122ad565b9050919050565b7f546865206669727374207269736b206d616e616765722077617320617070726f60008201527f7665640000000000000000000000000000000000000000000000000000000000602082015250565b600061234c602383611c7e565b9150612357826122f0565b604082019050919050565b6000602082019050818103600083015261237b8161233f565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006123de602683611c7e565b91506123e982612382565b604082019050919050565b6000602082019050818103600083015261240d816123d1565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061244a602083611c7e565b915061245582612414565b602082019050919050565b600060208201905081810360008301526124798161243d565b9050919050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b60006124b6601483611c7e565b91506124c182612480565b602082019050919050565b600060208201905081810360008301526124e5816124a9565b905091905056fea2646970667358221220ec205cb71546993cf5a2a6b6040e8c2992a7fa4c20445f6280393e2db7e83c8864736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101585760003560e01c806376b6a1af116100c3578063c753e5801161007c578063c753e58014610363578063cc5398041461037f578063ccfbf30a1461039d578063e1e92fcf146103cd578063efec39a0146103fd578063f2fde38b1461041957610158565b806376b6a1af146102b757806384e1c564146102d35780638da5cb5b146102ef5780639ac9e7e51461030d578063b2016bd414610329578063bdceb0e21461034757610158565b806333f29dd01161011557806333f29dd0146101e55780633a46b1a814610201578063465b43e6146102315780635d6f5ddb1461026157806369da62f414610291578063715018a6146102ad57610158565b80630647cada1461015d578063092b7eb51461017b57806315245857146101855780632828fdb11461018f5780632b9d0579146101ab5780632ec939f9146101c7575b600080fd5b610165610435565b604051610172919061193d565b60405180910390f35b610183610448565b005b61018d6104d2565b005b6101a960048036038101906101a49190611993565b61055c565b005b6101c560048036038101906101c09190611a1e565b6105f2565b005b6101cf61070f565b6040516101dc9190611abd565b60405180910390f35b6101ff60048036038101906101fa9190611ad8565b610733565b005b61021b60048036038101906102169190611a1e565b6108df565b6040516102289190611b2c565b60405180910390f35b61024b60048036038101906102469190611ad8565b610b7a565b6040516102589190611b56565b60405180910390f35b61027b60048036038101906102769190611993565b610c69565b6040516102889190611b56565b60405180910390f35b6102ab60048036038101906102a69190611baf565b610d59565b005b6102b5610def565b005b6102d160048036038101906102cc9190611a1e565b610e03565b005b6102ed60048036038101906102e89190611ad8565b610f7f565b005b6102f7611209565b6040516103049190611beb565b60405180910390f35b61032760048036038101906103229190611993565b611232565b005b6103316112c8565b60405161033e9190611c27565b60405180910390f35b610361600480360381019061035c9190611a1e565b6112ec565b005b61037d60048036038101906103789190611ad8565b61144c565b005b6103876115b0565b6040516103949190611c63565b60405180910390f35b6103b760048036038101906103b29190611ad8565b6115d4565b6040516103c4919061193d565b60405180910390f35b6103e760048036038101906103e29190611ad8565b6115f4565b6040516103f49190611b56565b60405180910390f35b61041760048036038101906104129190611ad8565b61160c565b005b610433600480360381019061042e9190611ad8565b6116d9565b005b600060149054906101000a900460ff1681565b61045061175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663092b7eb56040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156104b857600080fd5b505af11580156104cc573d6000803e3d6000fd5b50505050565b6104da61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663152458576040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561054257600080fd5b505af1158015610556573d6000803e3d6000fd5b50505050565b61056461175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632828fdb1826040518263ffffffff1660e01b81526004016105bd9190611b56565b600060405180830381600087803b1580156105d757600080fd5b505af11580156105eb573d6000803e3d6000fd5b5050505050565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661067e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067590611cdb565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ff603d2283836040518363ffffffff1660e01b81526004016106d9929190611cfb565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b61073b61175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411806107d25750600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b610811576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080890611d96565b60405180910390fd5b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690557f9bf9ec07f4d3e134e1a799a215cf4c47dbf1c427fe348f3c0d3994ef1c2e295781426040516108d4929190611cfb565b60405180910390a150565b6000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a885856040518363ffffffff1660e01b815260040161093d929190611cfb565b60206040518083038186803b15801561095557600080fd5b505afa158015610969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098d9190611de2565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16638e539e8c856040518263ffffffff1660e01b81526004016109ea9190611b56565b60206040518083038186803b158015610a0257600080fd5b505afa158015610a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3a9190611de2565b90506000816bffffffffffffffffffffffff161415610a5e57600092505050610b74565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16633a46b1a87f0000000000000000000000000000000000000000000000000000000000000000876040518363ffffffff1660e01b8152600401610adb929190611cfb565b60206040518083038186803b158015610af357600080fd5b505afa158015610b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b9190611de2565b9050816bffffffffffffffffffffffff16816bffffffffffffffffffffffff16846bffffffffffffffffffffffff16610b649190611e3e565b610b6e9190611ec7565b93505050505b92915050565b6000610c62600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020547f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b158015610c2557600080fd5b505afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d9190611f0d565b6117db565b9050919050565b6000670de0b6b3a7640000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a082317f00000000000000000000000000000000000000000000000000000000000000006040518263ffffffff1660e01b8152600401610cee9190611beb565b60206040518083038186803b158015610d0657600080fd5b505afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190611f0d565b610d489190611e3e565b610d529190611ec7565b9050919050565b610d6161175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166369da62f4826040518263ffffffff1660e01b8152600401610dba9190611f5b565b600060405180830381600087803b158015610dd457600080fd5b505af1158015610de8573d6000803e3d6000fd5b5050505050565b610df761175d565b610e016000611856565b565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610e8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e8690611cdb565b60405180910390fd5b600081118015610ea75750670de0b6b3a76400008111155b610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd90611fe8565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683610f2c84610c69565b6040518363ffffffff1660e01b8152600401610f49929190611cfb565b600060405180830381600087803b158015610f6357600080fd5b505af1158015610f77573d6000803e3d6000fd5b505050505050565b610f8761175d565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411611009576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110009061207a565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632d2545e76040518163ffffffff1660e01b815260040160206040518083038186803b15801561106f57600080fd5b505afa158015611083573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a79190611f0d565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054426110f2919061209a565b1015611133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161112a90612140565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f8499a35b7f2bbd8a5de334eed2665f0f7ea74bf1c4785bb3fb2c6a9b97fe1c5481426040516111bb929190611cfb565b60405180910390a1600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61123a61175d565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16639ac9e7e5826040518263ffffffff1660e01b81526004016112939190611b56565b600060405180830381600087803b1580156112ad57600080fd5b505af11580156112c1573d6000803e3d6000fd5b5050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611378576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136f90611cdb565b60405180910390fd5b600081116113bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b2906121ac565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aad3ec9683836040518363ffffffff1660e01b8152600401611416929190611cfb565b600060405180830381600087803b15801561143057600080fd5b505af1158015611444573d6000803e3d6000fd5b505050505050565b61145461175d565b600060149054906101000a900460ff166114a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149a90612264565b60405180910390fd5b600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611530576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611527906122d0565b60405180910390fd5b42600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f981f6bdfdbe336d34d32ee17135d9517e6a5ffb574159f7ceaf02b3e2ed255b281426040516115a5929190611cfb565b60405180910390a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b60016020528060005260406000206000915054906101000a900460ff1681565b60026020528060005260406000206000915090505481565b61161461175d565b600060149054906101000a900460ff1615611664576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165b90612362565b60405180910390fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600060146101000a81548160ff02191690831515021790555050565b6116e161175d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611751576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611748906123f4565b60405180910390fd5b61175a81611856565b50565b61176561191a565b73ffffffffffffffffffffffffffffffffffffffff16611783611209565b73ffffffffffffffffffffffffffffffffffffffff16146117d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d090612460565b60405180910390fd5b565b600080831161181f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611816906124cc565b60405180910390fd5b6000834261182d919061209a565b9050828110611840576000915050611850565b808361184c919061209a565b9150505b92915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b60008115159050919050565b61193781611922565b82525050565b6000602082019050611952600083018461192e565b92915050565b600080fd5b6000819050919050565b6119708161195d565b811461197b57600080fd5b50565b60008135905061198d81611967565b92915050565b6000602082840312156119a9576119a8611958565b5b60006119b78482850161197e565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119eb826119c0565b9050919050565b6119fb816119e0565b8114611a0657600080fd5b50565b600081359050611a18816119f2565b92915050565b60008060408385031215611a3557611a34611958565b5b6000611a4385828601611a09565b9250506020611a548582860161197e565b9150509250929050565b6000819050919050565b6000611a83611a7e611a79846119c0565b611a5e565b6119c0565b9050919050565b6000611a9582611a68565b9050919050565b6000611aa782611a8a565b9050919050565b611ab781611a9c565b82525050565b6000602082019050611ad26000830184611aae565b92915050565b600060208284031215611aee57611aed611958565b5b6000611afc84828501611a09565b91505092915050565b60006bffffffffffffffffffffffff82169050919050565b611b2681611b05565b82525050565b6000602082019050611b416000830184611b1d565b92915050565b611b508161195d565b82525050565b6000602082019050611b6b6000830184611b47565b92915050565b6000611b7c826119e0565b9050919050565b611b8c81611b71565b8114611b9757600080fd5b50565b600081359050611ba981611b83565b92915050565b600060208284031215611bc557611bc4611958565b5b6000611bd384828501611b9a565b91505092915050565b611be5816119e0565b82525050565b6000602082019050611c006000830184611bdc565b92915050565b6000611c1182611a8a565b9050919050565b611c2181611c06565b82525050565b6000602082019050611c3c6000830184611c18565b92915050565b6000611c4d82611a8a565b9050919050565b611c5d81611c42565b82525050565b6000602082019050611c786000830184611c54565b92915050565b600082825260208201905092915050565b7f5269736b206d616e61676572206e6f7420617070726f76656400000000000000600082015250565b6000611cc5601983611c7e565b9150611cd082611c8f565b602082019050919050565b60006020820190508181036000830152611cf481611cb8565b9050919050565b6000604082019050611d106000830185611bdc565b611d1d6020830184611b47565b9392505050565b7f5269736b206d616e61676572206973206e65697468657220617070726f76656460008201527f206e6f72207769746820612070656e64696e6720617070726f76616c00000000602082015250565b6000611d80603c83611c7e565b9150611d8b82611d24565b604082019050919050565b60006020820190508181036000830152611daf81611d73565b9050919050565b611dbf81611b05565b8114611dca57600080fd5b50565b600081519050611ddc81611db6565b92915050565b600060208284031215611df857611df7611958565b5b6000611e0684828501611dcd565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611e498261195d565b9150611e548361195d565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615611e8d57611e8c611e0f565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000611ed28261195d565b9150611edd8361195d565b925082611eed57611eec611e98565b5b828204905092915050565b600081519050611f0781611967565b92915050565b600060208284031215611f2357611f22611958565b5b6000611f3184828501611ef8565b91505092915050565b6000611f4582611a8a565b9050919050565b611f5581611f3a565b82525050565b6000602082019050611f706000830184611f4c565b92915050565b7f506f7274696f6e20746f207365697a65206973206e6f742077697468696e207460008201527f68652072616e67652028302c20315d0000000000000000000000000000000000602082015250565b6000611fd2602f83611c7e565b9150611fdd82611f76565b604082019050919050565b6000602082019050818103600083015261200181611fc5565b9050919050565b7f5269736b206d616e6167657220617070726f76616c206e6f7420696e6974696160008201527f7465640000000000000000000000000000000000000000000000000000000000602082015250565b6000612064602383611c7e565b915061206f82612008565b604082019050919050565b6000602082019050818103600083015261209381612057565b9050919050565b60006120a58261195d565b91506120b08361195d565b9250828210156120c3576120c2611e0f565b5b828203905092915050565b7f5269736b206d616e6167657220676f7665726e616e63652064656c617920686160008201527f73206e6f7420656c617073656400000000000000000000000000000000000000602082015250565b600061212a602d83611c7e565b9150612135826120ce565b604082019050919050565b600060208201905081810360008301526121598161211d565b9050919050565b7f416d6f756e7420746f207365697a65206d757374206265203e30000000000000600082015250565b6000612196601a83611c7e565b91506121a182612160565b602082019050919050565b600060208201905081810360008301526121c581612189565b9050919050565b7f546865206669727374207269736b206d616e61676572206973206e6f7420796560008201527f7420617070726f7665643b20506c656173652075736520617070726f7665466960208201527f7273745269736b4d616e6167657220696e737465616400000000000000000000604082015250565b600061224e605683611c7e565b9150612259826121cc565b606082019050919050565b6000602082019050818103600083015261227d81612241565b9050919050565b7f5269736b206d616e6167657220616c726561647920617070726f766564000000600082015250565b60006122ba601d83611c7e565b91506122c582612284565b602082019050919050565b600060208201905081810360008301526122e9816122ad565b9050919050565b7f546865206669727374207269736b206d616e616765722077617320617070726f60008201527f7665640000000000000000000000000000000000000000000000000000000000602082015250565b600061234c602383611c7e565b9150612357826122f0565b604082019050919050565b6000602082019050818103600083015261237b8161233f565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006123de602683611c7e565b91506123e982612382565b604082019050919050565b6000602082019050818103600083015261240d816123d1565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061244a602083611c7e565b915061245582612414565b602082019050919050565b600060208201905081810360008301526124798161243d565b9050919050565b7f4368616e6765206e6f7420696e69746961746564000000000000000000000000600082015250565b60006124b6601483611c7e565b91506124c182612480565b602082019050919050565b600060208201905081810360008301526124e5816124a9565b905091905056fea2646970667358221220ec205cb71546993cf5a2a6b6040e8c2992a7fa4c20445f6280393e2db7e83c8864736f6c63430008090033", + "devdoc": { + "details": "Coverage pool contract is owned by the governance. Coverage pool is the owner of the asset pool contract.", + "kind": "dev", + "methods": { + "amountToSeize(uint256)": { + "params": { + "portionToSeize": "Portion of the pool to seize in the range (0, 1] multiplied by FLOATING_POINT_DIVISOR" + } + }, + "approveFirstRiskManager(address)": { + "details": "Can be called only by the contract owner. Can be called only once. Does not require any further calls to any functions.", + "params": { + "riskManager": "Risk manager that will be approved" + } + }, + "approveNewAssetPoolUpgrade(address)": { + "params": { + "_newAssetPool": "New asset pool" + } + }, + "beginRiskManagerApproval(address)": { + "details": "Can be called only by the contract owner and only when the first risk manager is already approved. For a risk manager to be approved, a call to `finalizeRiskManagerApproval` must follow (after a governance delay).", + "params": { + "riskManager": "Risk manager that will be approved" + } + }, + "beginWithdrawalDelayUpdate(uint256)": { + "params": { + "newWithdrawalDelay": "The new value of withdrawal delay" + } + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "params": { + "newWithdrawalTimeout": "The new value of the withdrawal timeout" + } + }, + "finalizeRiskManagerApproval(address)": { + "details": "Can be called only by the contract owner. Must be preceded with a call to beginRiskManagerApproval and a governance delay must elapse.", + "params": { + "riskManager": "Risk manager that will be approved" + } + }, + "getPastVotes(address,uint256)": { + "params": { + "account": "The underwriter address to check", + "blockNumber": "The block number to get the vote balance at" + }, + "returns": { + "_0": "The number of votes the underwriter had as of the given block" + } + }, + "getRemainingRiskManagerApprovalTime(address)": { + "params": { + "riskManager": "Risk manager in the process of approval" + }, + "returns": { + "_0": "Remaining time in seconds." + } + }, + "grantAssetPoolShares(address,uint256)": { + "details": "Can be called only by an approved risk manager.", + "params": { + "covAmount": "Amount of the underwriter tokens which should be minted", + "recipient": "Address of the underwriter tokens recipient" + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "seizeAmount(address,uint256)": { + "params": { + "amountToSeize": "Amount to be seized from the pool", + "recipient": "Address that will receive the pool's seized funds" + } + }, + "seizePortion(address,uint256)": { + "details": "`portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR` for calculation precision purposes. Further calculations in this function will need to take this divisor into account.", + "params": { + "portionToSeize": "Portion of the pool to seize in the range (0, 1] multiplied by `FLOATING_POINT_DIVISOR`", + "recipient": "Address that will receive the pool's seized funds" + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "unapproveRiskManager(address)": { + "details": "Can be called only by the contract owner.", + "params": { + "riskManager": "Risk manager that will be unapproved" + } + } + }, + "title": "Coverage Pool", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "amountToSeize(uint256)": { + "notice": "Calculates amount of tokens to be seized from the coverage pool." + }, + "approveFirstRiskManager(address)": { + "notice": "Approves the first risk manager" + }, + "approveNewAssetPoolUpgrade(address)": { + "notice": "Approves upgradeability to the new asset pool. Allows governance to set a new asset pool so the underwriters can move their collateral tokens to a new asset pool without having to wait for the withdrawal delay." + }, + "beginRiskManagerApproval(address)": { + "notice": "Begins risk manager approval process." + }, + "beginWithdrawalDelayUpdate(uint256)": { + "notice": "Lets the governance to begin an update of withdrawal delay parameter value. Withdrawal delay is the time it takes the underwriter to withdraw their collateral and rewards from the pool. This is the time that needs to pass between initiating and completing the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalDelayUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal delay value should be but it should be long enough so that the possibility of having free-riding underwriters escaping from a potential coverage claim by withdrawing their positions from the pool is negligible." + }, + "beginWithdrawalTimeoutUpdate(uint256)": { + "notice": "Lets the governance to begin an update of withdrawal timeout parameter value. The withdrawal timeout is the time the underwriter has - after the withdrawal delay passed - to complete the withdrawal. The change needs to be finalized with a call to finalizeWithdrawalTimeoutUpdate after the required governance delay passes. It is up to the governance to decide what the withdrawal timeout value should be but it should be short enough so that the time of free-riding by being able to immediately escape from the claim is minimal and long enough so that honest underwriters have a possibility to finalize the withdrawal. It is all about the right proportions with a relation to withdrawal delay value." + }, + "finalizeRiskManagerApproval(address)": { + "notice": "Finalizes risk manager approval process." + }, + "finalizeWithdrawalDelayUpdate()": { + "notice": "Lets the governance to finalize an update of withdrawal delay parameter value. This call has to be preceded with a call to beginWithdrawalDelayUpdate and the governance delay has to pass." + }, + "finalizeWithdrawalTimeoutUpdate()": { + "notice": "Lets the governance to finalize an update of withdrawal timeout parameter value. This call has to be preceded with a call to beginWithdrawalTimeoutUpdate and the governance delay has to pass." + }, + "getPastVotes(address,uint256)": { + "notice": "Determine the prior number of DAO votes for the given coverage pool underwriter." + }, + "getRemainingRiskManagerApprovalTime(address)": { + "notice": "Returns the time remaining until the risk manager approval process can be finalized" + }, + "grantAssetPoolShares(address,uint256)": { + "notice": "Grants asset pool shares by minting a given amount of the underwriter tokens for the recipient address. In result, the recipient obtains part of the pool ownership without depositing any collateral tokens. Shares are usually granted for notifiers reporting about various contract state changes." + }, + "seizeAmount(address,uint256)": { + "notice": "Seizes funds from the coverage pool and sends them to the `recipient`." + }, + "seizePortion(address,uint256)": { + "notice": "Seizes funds from the coverage pool and sends them to the `recipient`." + }, + "unapproveRiskManager(address)": { + "notice": "Unapproves an already approved risk manager or cancels the approval process of a risk manager (the latter happens if called between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`). The change takes effect immediately." + } + }, + "notice": "A contract that manages a single asset pool. Handles approving and unapproving of risk managers and allows them to seize funds from the asset pool if they are approved.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 7742, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "firstRiskManagerApproved", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 7746, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "approvedRiskManagers", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 7750, + "contract": "contracts/CoveragePool.sol:CoveragePool", + "label": "riskManagerApprovalTimestamps", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_uint256)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/CoveragePoolBeneficiary.json b/deployments/mainnet/CoveragePoolBeneficiary.json new file mode 100644 index 00000000..538c3814 --- /dev/null +++ b/deployments/mainnet/CoveragePoolBeneficiary.json @@ -0,0 +1,193 @@ +{ + "address": "0xE8372cab8d06a607E374cC549d8F68648ef67263", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + }, + { + "internalType": "contract RewardsPool", + "name": "_rewards", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "__escrowSentTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewards", + "outputs": [ + { + "internalType": "contract RewardsPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x5951d8f75599e2c73b4e74143cfb332b547d9f23e7c53c07a1ba1f6dd1a72aa4", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0xE8372cab8d06a607E374cC549d8F68648ef67263", + "transactionIndex": 87, + "gasUsed": "950588", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000008000000000000000000000000000000000000000000000080000000000000000400000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800200000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x8fb3b4f85e35081ccca8048280fd9425afa2d92a91aea37193ef53d94f10a9ad", + "transactionHash": "0x5951d8f75599e2c73b4e74143cfb332b547d9f23e7c53c07a1ba1f6dd1a72aa4", + "logs": [ + { + "transactionIndex": 87, + "blockNumber": 16327130, + "transactionHash": "0x5951d8f75599e2c73b4e74143cfb332b547d9f23e7c53c07a1ba1f6dd1a72aa4", + "address": "0xE8372cab8d06a607E374cC549d8F68648ef67263", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 152, + "blockHash": "0x8fb3b4f85e35081ccca8048280fd9425afa2d92a91aea37193ef53d94f10a9ad" + } + ], + "blockNumber": 16327130, + "cumulativeGasUsed": "8431270", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "0xD4FD81D7a16320Ca029389a728327918bdc086b6" + ], + "numDeployments": 1, + "solcInputHash": "1f648bbc62fc09e530210f2d58cb219e", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"contract RewardsPool\",\"name\":\"_rewards\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"__escrowSentTokens\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rewards\",\"outputs\":[{\"internalType\":\"contract RewardsPool\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"CoveragePoolBeneficiary\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A beneficiary contract that can receive a withdrawal phase from a BatchedPhasedEscrow contract. It immediately transfers the received tokens on a designated RewardsPool contract.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/CoveragePoolBeneficiary.sol\":\"CoveragePoolBeneficiary\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0xf41ca991f30855bf80ffd11e9347856a517b977f0a6c2d52e6421a99b7840329\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../extensions/draft-IERC20Permit.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n function safePermit(\\n IERC20Permit token,\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal {\\n uint256 nonceBefore = token.nonces(owner);\\n token.permit(owner, spender, value, deadline, v, r, s);\\n uint256 nonceAfter = token.nonces(owner);\\n require(nonceAfter == nonceBefore + 1, \\\"SafeERC20: permit did not succeed\\\");\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9b72f93be69ca894d8492c244259615c4a742afc8d63720dbc8bb81087d9b238\",\"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/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"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/BatchedPhasedEscrow.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Batched Phased Escrow Beneficiary\\n/// @notice Interface expected from contracts receiving tokens from the\\n/// BatchedPhasedEscrow.\\ninterface IBeneficiaryContract {\\n function __escrowSentTokens(uint256 amount) external;\\n}\\n\\n/// @title BatchedPhasedEscrow\\n/// @notice A token holder contract allowing contract owner to approve a set of\\n/// beneficiaries of tokens held by the contract, to appoint a separate\\n/// drawee role, and allowing that drawee to withdraw tokens to approved\\n/// beneficiaries in phases.\\ncontract BatchedPhasedEscrow is Ownable {\\n using SafeERC20 for IERC20;\\n\\n event BeneficiaryApproved(address beneficiary);\\n event TokensWithdrawn(address beneficiary, uint256 amount);\\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\\n\\n IERC20 public token;\\n address public drawee;\\n mapping(address => bool) private approvedBeneficiaries;\\n\\n modifier onlyDrawee() {\\n require(drawee == msg.sender, \\\"Caller is not the drawee\\\");\\n _;\\n }\\n\\n constructor(IERC20 _token) {\\n token = _token;\\n drawee = msg.sender;\\n }\\n\\n /// @notice Approves the provided address as a beneficiary of tokens held by\\n /// the escrow. Can be called only by escrow owner.\\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\\n external\\n onlyOwner\\n {\\n address beneficiaryAddress = address(_beneficiary);\\n require(\\n beneficiaryAddress != address(0),\\n \\\"Beneficiary can not be zero address\\\"\\n );\\n approvedBeneficiaries[beneficiaryAddress] = true;\\n emit BeneficiaryApproved(beneficiaryAddress);\\n }\\n\\n /// @notice Returns `true` if the given address has been approved as a\\n /// beneficiary of the escrow, `false` otherwise.\\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\\n public\\n view\\n returns (bool)\\n {\\n return approvedBeneficiaries[address(_beneficiary)];\\n }\\n\\n /// @notice Transfers the role of drawee to another address. Can be called\\n /// only by the contract owner.\\n function setDrawee(address newDrawee) external onlyOwner {\\n require(newDrawee != address(0), \\\"New drawee can not be zero address\\\");\\n emit DraweeRoleTransferred(drawee, newDrawee);\\n drawee = newDrawee;\\n }\\n\\n /// @notice Funds the escrow by transferring all of the approved tokens\\n /// to the escrow.\\n function receiveApproval(\\n address _from,\\n uint256 _value,\\n address _token,\\n bytes memory\\n ) external {\\n require(IERC20(_token) == token, \\\"Unsupported token\\\");\\n token.safeTransferFrom(_from, address(this), _value);\\n }\\n\\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\\n /// transferring to each beneficiary the amount of tokens specified\\n /// as a parameter. Only beneficiaries previously approved by escrow\\n /// owner can receive funds.\\n function batchedWithdraw(\\n IBeneficiaryContract[] memory beneficiaries,\\n uint256[] memory amounts\\n ) external onlyDrawee {\\n require(\\n beneficiaries.length == amounts.length,\\n \\\"Mismatched arrays length\\\"\\n );\\n\\n for (uint256 i = 0; i < beneficiaries.length; i++) {\\n IBeneficiaryContract beneficiary = beneficiaries[i];\\n require(\\n isBeneficiaryApproved(beneficiary),\\n \\\"Beneficiary was not approved\\\"\\n );\\n withdraw(beneficiary, amounts[i]);\\n }\\n }\\n\\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\\n private\\n {\\n emit TokensWithdrawn(address(beneficiary), amount);\\n token.safeTransfer(address(beneficiary), amount);\\n // slither-disable-next-line calls-loop\\n beneficiary.__escrowSentTokens(amount);\\n }\\n}\\n\",\"keccak256\":\"0xd1ed7b9149ea0672c94e22812ca723751c2be7546b1d23ffb12d9595a14a8f50\",\"license\":\"MIT\"},\"contracts/CoveragePoolBeneficiary.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./RewardsPool.sol\\\";\\nimport \\\"./BatchedPhasedEscrow.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\n\\n/// @title CoveragePoolBeneficiary\\n/// @notice A beneficiary contract that can receive a withdrawal phase from a\\n/// BatchedPhasedEscrow contract.\\n/// It immediately transfers the received tokens on a designated\\n/// RewardsPool contract.\\ncontract CoveragePoolBeneficiary is Ownable, IBeneficiaryContract {\\n using SafeERC20 for IERC20;\\n\\n IERC20 public immutable token;\\n RewardsPool public immutable rewards;\\n\\n constructor(IERC20 _token, RewardsPool _rewards) {\\n token = _token;\\n rewards = _rewards;\\n }\\n\\n function __escrowSentTokens(uint256 amount) external override onlyOwner {\\n token.safeApprove(address(rewards), amount);\\n rewards.topUpReward(amount);\\n }\\n}\\n\",\"keccak256\":\"0xff7a0970054716949a23c460b0b818d6d0a46ad0d7b53c1d9c8fcfefec124d8c\",\"license\":\"MIT\"},\"contracts/RewardsPool.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\n/// @title Rewards Pool\\n/// @notice RewardsPool accepts a single reward token and releases it to the\\n/// AssetPool over time in one week reward intervals. The owner of this\\n/// contract is the reward distribution address funding it with reward\\n/// tokens.\\ncontract RewardsPool is Ownable {\\n using SafeERC20 for IERC20;\\n\\n uint256 public constant DURATION = 7 days;\\n\\n IERC20 public immutable rewardToken;\\n address public immutable assetPool;\\n\\n // timestamp of the current reward interval end or the timestamp of the\\n // last interval end in case a new reward interval has not been allocated\\n uint256 public intervalFinish = 0;\\n // rate per second with which reward tokens are unlocked\\n uint256 public rewardRate = 0;\\n // amount of rewards accumulated and not yet withdrawn from the previous\\n // reward interval(s)\\n uint256 public rewardAccumulated = 0;\\n // the last time information in this contract was updated\\n uint256 public lastUpdateTime = 0;\\n\\n event RewardToppedUp(uint256 amount);\\n event RewardWithdrawn(uint256 amount);\\n\\n constructor(\\n IERC20 _rewardToken,\\n address _assetPool,\\n address owner\\n ) {\\n rewardToken = _rewardToken;\\n // slither-disable-next-line missing-zero-check\\n assetPool = _assetPool;\\n transferOwnership(owner);\\n }\\n\\n /// @notice Transfers the provided reward amount into RewardsPool and\\n /// creates a new, one-week reward interval starting from now.\\n /// Reward tokens from the previous reward interval that unlocked\\n /// over the time will be available for withdrawal immediately.\\n /// Reward tokens from the previous interval that has not been yet\\n /// unlocked, are added to the new interval being created.\\n /// @dev This function can be called only by the owner given that it creates\\n /// a new interval with one week length, starting from now.\\n function topUpReward(uint256 reward) external onlyOwner {\\n rewardAccumulated = earned();\\n\\n /* solhint-disable not-rely-on-time */\\n if (block.timestamp >= intervalFinish) {\\n // see https://github.com/crytic/slither/issues/844\\n // slither-disable-next-line divide-before-multiply\\n rewardRate = reward / DURATION;\\n } else {\\n uint256 remaining = intervalFinish - block.timestamp;\\n uint256 leftover = remaining * rewardRate;\\n rewardRate = (reward + leftover) / DURATION;\\n }\\n intervalFinish = block.timestamp + DURATION;\\n lastUpdateTime = block.timestamp;\\n /* solhint-enable avoid-low-level-calls */\\n\\n emit RewardToppedUp(reward);\\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\\n }\\n\\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\\n function withdraw() external {\\n uint256 amount = earned();\\n rewardAccumulated = 0;\\n lastUpdateTime = lastTimeRewardApplicable();\\n emit RewardWithdrawn(amount);\\n rewardToken.safeTransfer(assetPool, amount);\\n }\\n\\n /// @notice Returns the amount of earned and not yet withdrawn reward\\n /// tokens.\\n function earned() public view returns (uint256) {\\n return\\n rewardAccumulated +\\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\\n }\\n\\n /// @notice Returns the timestamp at which a reward was last time applicable.\\n /// When reward interval is pending, returns current block's\\n /// timestamp. If the last reward interval ended and no other reward\\n /// interval had been allocated, returns the last reward interval's\\n /// end timestamp.\\n function lastTimeRewardApplicable() public view returns (uint256) {\\n return Math.min(block.timestamp, intervalFinish);\\n }\\n}\\n\",\"keccak256\":\"0xe56e8c35bbafad758cc66473f113ea9fd3ffa9c44c6139fc3196dbbead2a4054\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b506040516200128738038062001287833981810160405281019062000037919062000256565b620000576200004b620000c760201b60201c565b620000cf60201b60201c565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff168152505050506200029d565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001c58262000198565b9050919050565b6000620001d982620001b8565b9050919050565b620001eb81620001cc565b8114620001f757600080fd5b50565b6000815190506200020b81620001e0565b92915050565b60006200021e82620001b8565b9050919050565b620002308162000211565b81146200023c57600080fd5b50565b600081519050620002508162000225565b92915050565b6000806040838503121562000270576200026f62000193565b5b60006200028085828601620001fa565b925050602062000293858286016200023f565b9150509250929050565b60805160a051610faf620002d86000396000818161011001528181610178015261024301526000818161013201526102eb0152610faf6000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80634a5f545614610067578063715018a6146100835780638da5cb5b1461008d5780639ec5a894146100ab578063f2fde38b146100c9578063fc0c546a146100e5575b600080fd5b610081600480360381019061007c9190610885565b610103565b005b61008b610204565b005b610095610218565b6040516100a291906108f3565b60405180910390f35b6100b3610241565b6040516100c0919061096d565b60405180910390f35b6100e360048036038101906100de91906109b4565b610265565b005b6100ed6102e9565b6040516100fa9190610a02565b60405180910390f35b61010b61030d565b6101767f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661038b9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630e807056826040518263ffffffff1660e01b81526004016101cf9190610a2c565b600060405180830381600087803b1580156101e957600080fd5b505af11580156101fd573d6000803e3d6000fd5b5050505050565b61020c61030d565b61021660006104e9565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b61026d61030d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156102dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d490610aca565b60405180910390fd5b6102e6816104e9565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6103156105ad565b73ffffffffffffffffffffffffffffffffffffffff16610333610218565b73ffffffffffffffffffffffffffffffffffffffff1614610389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038090610b36565b60405180910390fd5b565b6000811480610424575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b81526004016103d2929190610b56565b60206040518083038186803b1580156103ea57600080fd5b505afa1580156103fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104229190610b94565b145b610463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045a90610c33565b60405180910390fd5b6104e48363095ea7b360e01b8484604051602401610482929190610c53565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506105b5565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000610617826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661067c9092919063ffffffff16565b905060008151111561067757808060200190518101906106379190610cb4565b610676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066d90610d53565b60405180910390fd5b5b505050565b606061068b8484600085610694565b90509392505050565b6060824710156106d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d090610de5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516107029190610e7f565b60006040518083038185875af1925050503d806000811461073f576040519150601f19603f3d011682016040523d82523d6000602084013e610744565b606091505b509150915061075587838387610761565b92505050949350505050565b606083156107c4576000835114156107bc5761077c856107d7565b6107bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b290610ee2565b60405180910390fd5b5b8290506107cf565b6107ce83836107fa565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008251111561080d5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108419190610f57565b60405180910390fd5b600080fd5b6000819050919050565b6108628161084f565b811461086d57600080fd5b50565b60008135905061087f81610859565b92915050565b60006020828403121561089b5761089a61084a565b5b60006108a984828501610870565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108dd826108b2565b9050919050565b6108ed816108d2565b82525050565b600060208201905061090860008301846108e4565b92915050565b6000819050919050565b600061093361092e610929846108b2565b61090e565b6108b2565b9050919050565b600061094582610918565b9050919050565b60006109578261093a565b9050919050565b6109678161094c565b82525050565b6000602082019050610982600083018461095e565b92915050565b610991816108d2565b811461099c57600080fd5b50565b6000813590506109ae81610988565b92915050565b6000602082840312156109ca576109c961084a565b5b60006109d88482850161099f565b91505092915050565b60006109ec8261093a565b9050919050565b6109fc816109e1565b82525050565b6000602082019050610a1760008301846109f3565b92915050565b610a268161084f565b82525050565b6000602082019050610a416000830184610a1d565b92915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610ab4602683610a47565b9150610abf82610a58565b604082019050919050565b60006020820190508181036000830152610ae381610aa7565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610b20602083610a47565b9150610b2b82610aea565b602082019050919050565b60006020820190508181036000830152610b4f81610b13565b9050919050565b6000604082019050610b6b60008301856108e4565b610b7860208301846108e4565b9392505050565b600081519050610b8e81610859565b92915050565b600060208284031215610baa57610ba961084a565b5b6000610bb884828501610b7f565b91505092915050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000610c1d603683610a47565b9150610c2882610bc1565b604082019050919050565b60006020820190508181036000830152610c4c81610c10565b9050919050565b6000604082019050610c6860008301856108e4565b610c756020830184610a1d565b9392505050565b60008115159050919050565b610c9181610c7c565b8114610c9c57600080fd5b50565b600081519050610cae81610c88565b92915050565b600060208284031215610cca57610cc961084a565b5b6000610cd884828501610c9f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000610d3d602a83610a47565b9150610d4882610ce1565b604082019050919050565b60006020820190508181036000830152610d6c81610d30565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000610dcf602683610a47565b9150610dda82610d73565b604082019050919050565b60006020820190508181036000830152610dfe81610dc2565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015610e39578082015181840152602081019050610e1e565b83811115610e48576000848401525b50505050565b6000610e5982610e05565b610e638185610e10565b9350610e73818560208601610e1b565b80840191505092915050565b6000610e8b8284610e4e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000610ecc601d83610a47565b9150610ed782610e96565b602082019050919050565b60006020820190508181036000830152610efb81610ebf565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000610f2982610f02565b610f338185610a47565b9350610f43818560208601610e1b565b610f4c81610f0d565b840191505092915050565b60006020820190508181036000830152610f718184610f1e565b90509291505056fea264697066735822122046d9f4d7eee93e39cedc274a139f45dd1982cd384c8a667cced62ef5224b96ab64736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c80634a5f545614610067578063715018a6146100835780638da5cb5b1461008d5780639ec5a894146100ab578063f2fde38b146100c9578063fc0c546a146100e5575b600080fd5b610081600480360381019061007c9190610885565b610103565b005b61008b610204565b005b610095610218565b6040516100a291906108f3565b60405180910390f35b6100b3610241565b6040516100c0919061096d565b60405180910390f35b6100e360048036038101906100de91906109b4565b610265565b005b6100ed6102e9565b6040516100fa9190610a02565b60405180910390f35b61010b61030d565b6101767f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1661038b9092919063ffffffff16565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630e807056826040518263ffffffff1660e01b81526004016101cf9190610a2c565b600060405180830381600087803b1580156101e957600080fd5b505af11580156101fd573d6000803e3d6000fd5b5050505050565b61020c61030d565b61021660006104e9565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b61026d61030d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156102dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d490610aca565b60405180910390fd5b6102e6816104e9565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6103156105ad565b73ffffffffffffffffffffffffffffffffffffffff16610333610218565b73ffffffffffffffffffffffffffffffffffffffff1614610389576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038090610b36565b60405180910390fd5b565b6000811480610424575060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30856040518363ffffffff1660e01b81526004016103d2929190610b56565b60206040518083038186803b1580156103ea57600080fd5b505afa1580156103fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104229190610b94565b145b610463576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161045a90610c33565b60405180910390fd5b6104e48363095ea7b360e01b8484604051602401610482929190610c53565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506105b5565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000610617826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661067c9092919063ffffffff16565b905060008151111561067757808060200190518101906106379190610cb4565b610676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066d90610d53565b60405180910390fd5b5b505050565b606061068b8484600085610694565b90509392505050565b6060824710156106d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d090610de5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516107029190610e7f565b60006040518083038185875af1925050503d806000811461073f576040519150601f19603f3d011682016040523d82523d6000602084013e610744565b606091505b509150915061075587838387610761565b92505050949350505050565b606083156107c4576000835114156107bc5761077c856107d7565b6107bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b290610ee2565b60405180910390fd5b5b8290506107cf565b6107ce83836107fa565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008251111561080d5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108419190610f57565b60405180910390fd5b600080fd5b6000819050919050565b6108628161084f565b811461086d57600080fd5b50565b60008135905061087f81610859565b92915050565b60006020828403121561089b5761089a61084a565b5b60006108a984828501610870565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108dd826108b2565b9050919050565b6108ed816108d2565b82525050565b600060208201905061090860008301846108e4565b92915050565b6000819050919050565b600061093361092e610929846108b2565b61090e565b6108b2565b9050919050565b600061094582610918565b9050919050565b60006109578261093a565b9050919050565b6109678161094c565b82525050565b6000602082019050610982600083018461095e565b92915050565b610991816108d2565b811461099c57600080fd5b50565b6000813590506109ae81610988565b92915050565b6000602082840312156109ca576109c961084a565b5b60006109d88482850161099f565b91505092915050565b60006109ec8261093a565b9050919050565b6109fc816109e1565b82525050565b6000602082019050610a1760008301846109f3565b92915050565b610a268161084f565b82525050565b6000602082019050610a416000830184610a1d565b92915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610ab4602683610a47565b9150610abf82610a58565b604082019050919050565b60006020820190508181036000830152610ae381610aa7565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610b20602083610a47565b9150610b2b82610aea565b602082019050919050565b60006020820190508181036000830152610b4f81610b13565b9050919050565b6000604082019050610b6b60008301856108e4565b610b7860208301846108e4565b9392505050565b600081519050610b8e81610859565b92915050565b600060208284031215610baa57610ba961084a565b5b6000610bb884828501610b7f565b91505092915050565b7f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60008201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000602082015250565b6000610c1d603683610a47565b9150610c2882610bc1565b604082019050919050565b60006020820190508181036000830152610c4c81610c10565b9050919050565b6000604082019050610c6860008301856108e4565b610c756020830184610a1d565b9392505050565b60008115159050919050565b610c9181610c7c565b8114610c9c57600080fd5b50565b600081519050610cae81610c88565b92915050565b600060208284031215610cca57610cc961084a565b5b6000610cd884828501610c9f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000610d3d602a83610a47565b9150610d4882610ce1565b604082019050919050565b60006020820190508181036000830152610d6c81610d30565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000610dcf602683610a47565b9150610dda82610d73565b604082019050919050565b60006020820190508181036000830152610dfe81610dc2565b9050919050565b600081519050919050565b600081905092915050565b60005b83811015610e39578082015181840152602081019050610e1e565b83811115610e48576000848401525b50505050565b6000610e5982610e05565b610e638185610e10565b9350610e73818560208601610e1b565b80840191505092915050565b6000610e8b8284610e4e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000610ecc601d83610a47565b9150610ed782610e96565b602082019050919050565b60006020820190508181036000830152610efb81610ebf565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000610f2982610f02565b610f338185610a47565b9350610f43818560208601610e1b565b610f4c81610f0d565b840191505092915050565b60006020820190508181036000830152610f718184610f1e565b90509291505056fea264697066735822122046d9f4d7eee93e39cedc274a139f45dd1982cd384c8a667cced62ef5224b96ab64736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "owner()": { + "details": "Returns the address of the current owner." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "CoveragePoolBeneficiary", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "notice": "A beneficiary contract that can receive a withdrawal phase from a BatchedPhasedEscrow contract. It immediately transfers the received tokens on a designated RewardsPool contract.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/CoveragePoolBeneficiary.sol:CoveragePoolBeneficiary", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/RewardsPool.json b/deployments/mainnet/RewardsPool.json new file mode 100644 index 00000000..695bd5e6 --- /dev/null +++ b/deployments/mainnet/RewardsPool.json @@ -0,0 +1,323 @@ +{ + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_assetPool", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardToppedUp", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardWithdrawn", + "type": "event" + }, + { + "inputs": [], + "name": "DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "assetPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "earned", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "intervalFinish", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastTimeRewardApplicable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardAccumulated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "name": "topUpReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "transactionIndex": 71, + "gasUsed": "4745721", + "logsBloom": "0x08000000000000000000000000000000000020000000000000800000000000000000000800000000000010000000000000020400000000000000000000000400000000000000000000000000004000000001000000000000000000000000000000000000020000000000010000000800000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020800000000200000000000000000000000000000000000000000000000000400000000800000000000000000000000020000000000000000000000000000000000000000000000000000000008000000800", + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f", + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "logs": [ + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 98, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 99, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 100, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + }, + { + "transactionIndex": 71, + "blockNumber": 16327114, + "transactionHash": "0xbae34bc7500798b756037272f79a4915c2f85cdfa12b073732a9b804d3d7de36", + "address": "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "topics": [ + "0x3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000021b86fdc93f23fd52022a283828df8e808d28d5d" + ], + "data": "0x", + "logIndex": 101, + "blockHash": "0x32ea8477272d8aa14c210e2f2349c16e2a679a456b99ae786fbd1e69bfb2284f" + } + ], + "blockNumber": 16327114, + "cumulativeGasUsed": "8956336", + "status": 1, + "byzantium": true + }, + "args": [ + "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "0x123694886DBf5Ac94DDA07135349534536D14cAf" + ], + "numDeployments": 1, + "bytecode": "0x60c060405260006001556000600255600060035560006004553480156200002557600080fd5b506040516200180a3803806200180a83398181016040528101906200004b9190620003b9565b6200006b6200005f620000ed60201b60201c565b620000f560201b60201c565b8273ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050620000e481620001b960201b60201c565b50505062000530565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b620001c96200025060201b60201c565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156200023c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040162000233906200049c565b60405180910390fd5b6200024d81620000f560201b60201c565b50565b62000260620000ed60201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1662000286620002e160201b60201c565b73ffffffffffffffffffffffffffffffffffffffff1614620002df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620002d6906200050e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200033c826200030f565b9050919050565b600062000350826200032f565b9050919050565b620003628162000343565b81146200036e57600080fd5b50565b600081519050620003828162000357565b92915050565b62000393816200032f565b81146200039f57600080fd5b50565b600081519050620003b38162000388565b92915050565b600080600060608486031215620003d557620003d46200030a565b5b6000620003e58682870162000371565b9350506020620003f886828701620003a2565b92505060406200040b86828701620003a2565b9150509250925092565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006200048460268362000415565b9150620004918262000426565b604082019050919050565b60006020820190508181036000830152620004b78162000475565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000620004f660208362000415565b91506200050382620004be565b602082019050919050565b600060208201905081810360008301526200052981620004e7565b9050919050565b60805160a05161129f6200056b6000396000818161039301526104130152600081816103420152818161043501526105a0015261129f6000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c806380faa57d1161008c578063c910d95011610066578063c910d950146101f1578063d6f192621461020f578063f2fde38b1461022d578063f7c618c114610249576100ea565b806380faa57d146101975780638da5cb5b146101b5578063c8f33c91146101d3576100ea565b80633ccfd60b116100c85780633ccfd60b146101475780636e9a204b14610151578063715018a61461016f5780637b0a47ee14610179576100ea565b80630e807056146100ef5780631be052891461010b5780632ec939f914610129575b600080fd5b61010960048036038101906101049190610b04565b610267565b005b61011361038a565b6040516101209190610b40565b60405180910390f35b610131610391565b60405161013e9190610b9c565b60405180910390f35b61014f6103b5565b005b61015961047c565b6040516101669190610b40565b60405180910390f35b610177610482565b005b610181610496565b60405161018e9190610b40565b60405180910390f35b61019f61049c565b6040516101ac9190610b40565b60405180910390f35b6101bd6104af565b6040516101ca9190610b9c565b60405180910390f35b6101db6104d8565b6040516101e89190610b40565b60405180910390f35b6101f96104de565b6040516102069190610b40565b60405180910390f35b6102176104e4565b6040516102249190610b40565b60405180910390f35b61024760048036038101906102429190610be3565b61051a565b005b61025161059e565b60405161025e9190610c6f565b60405180910390f35b61026f6105c2565b6102776104e4565b60038190555060015442106102a05762093a80816102959190610ce8565b6002819055506102e7565b6000426001546102b09190610d19565b90506000600254826102c29190610d4d565b905062093a8081846102d49190610da7565b6102de9190610ce8565b60028190555050505b62093a80426102f69190610da7565b600181905550426004819055507fb32714d475c9d2f568d4ff24e88d0056b93256b5a04fbdb53a57f26bb765fbed816040516103329190610b40565b60405180910390a16103873330837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610640909392919063ffffffff16565b50565b62093a8081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006103bf6104e4565b905060006003819055506103d161049c565b6004819055507f150a6ec0e6f4e9ddcaaaa1674f157d91165a42d60653016f87a9fc870a39f050816040516104069190610b40565b60405180910390a16104797f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106c99092919063ffffffff16565b50565b60035481565b61048a6105c2565b610494600061074f565b565b60025481565b60006104aa42600154610813565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b60015481565b60006002546004546104f461049c565b6104fe9190610d19565b6105089190610d4d565b6003546105159190610da7565b905090565b6105226105c2565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610592576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058990610e80565b60405180910390fd5b61059b8161074f565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6105ca61082c565b73ffffffffffffffffffffffffffffffffffffffff166105e86104af565b73ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063590610eec565b60405180910390fd5b565b6106c3846323b872dd60e01b85858560405160240161066193929190610f0c565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b50505050565b61074a8363a9059cbb60e01b84846040516024016106e8929190610f43565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183106108225781610824565b825b905092915050565b600033905090565b6000610896826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108fb9092919063ffffffff16565b90506000815111156108f657808060200190518101906108b69190610fa4565b6108f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ec90611043565b60405180910390fd5b5b505050565b606061090a8484600085610913565b90509392505050565b606082471015610958576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094f906110d5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610981919061116f565b60006040518083038185875af1925050503d80600081146109be576040519150601f19603f3d011682016040523d82523d6000602084013e6109c3565b606091505b50915091506109d4878383876109e0565b92505050949350505050565b60608315610a4357600083511415610a3b576109fb85610a56565b610a3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a31906111d2565b60405180910390fd5b5b829050610a4e565b610a4d8383610a79565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610a8c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac09190611247565b60405180910390fd5b600080fd5b6000819050919050565b610ae181610ace565b8114610aec57600080fd5b50565b600081359050610afe81610ad8565b92915050565b600060208284031215610b1a57610b19610ac9565b5b6000610b2884828501610aef565b91505092915050565b610b3a81610ace565b82525050565b6000602082019050610b556000830184610b31565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8682610b5b565b9050919050565b610b9681610b7b565b82525050565b6000602082019050610bb16000830184610b8d565b92915050565b610bc081610b7b565b8114610bcb57600080fd5b50565b600081359050610bdd81610bb7565b92915050565b600060208284031215610bf957610bf8610ac9565b5b6000610c0784828501610bce565b91505092915050565b6000819050919050565b6000610c35610c30610c2b84610b5b565b610c10565b610b5b565b9050919050565b6000610c4782610c1a565b9050919050565b6000610c5982610c3c565b9050919050565b610c6981610c4e565b82525050565b6000602082019050610c846000830184610c60565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610cf382610ace565b9150610cfe83610ace565b925082610d0e57610d0d610c8a565b5b828204905092915050565b6000610d2482610ace565b9150610d2f83610ace565b925082821015610d4257610d41610cb9565b5b828203905092915050565b6000610d5882610ace565b9150610d6383610ace565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610d9c57610d9b610cb9565b5b828202905092915050565b6000610db282610ace565b9150610dbd83610ace565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610df257610df1610cb9565b5b828201905092915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610e6a602683610dfd565b9150610e7582610e0e565b604082019050919050565b60006020820190508181036000830152610e9981610e5d565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610ed6602083610dfd565b9150610ee182610ea0565b602082019050919050565b60006020820190508181036000830152610f0581610ec9565b9050919050565b6000606082019050610f216000830186610b8d565b610f2e6020830185610b8d565b610f3b6040830184610b31565b949350505050565b6000604082019050610f586000830185610b8d565b610f656020830184610b31565b9392505050565b60008115159050919050565b610f8181610f6c565b8114610f8c57600080fd5b50565b600081519050610f9e81610f78565b92915050565b600060208284031215610fba57610fb9610ac9565b5b6000610fc884828501610f8f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061102d602a83610dfd565b915061103882610fd1565b604082019050919050565b6000602082019050818103600083015261105c81611020565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006110bf602683610dfd565b91506110ca82611063565b604082019050919050565b600060208201905081810360008301526110ee816110b2565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561112957808201518184015260208101905061110e565b83811115611138576000848401525b50505050565b6000611149826110f5565b6111538185611100565b935061116381856020860161110b565b80840191505092915050565b600061117b828461113e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b60006111bc601d83610dfd565b91506111c782611186565b602082019050919050565b600060208201905081810360008301526111eb816111af565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000611219826111f2565b6112238185610dfd565b935061123381856020860161110b565b61123c816111fd565b840191505092915050565b60006020820190508181036000830152611261818461120e565b90509291505056fea2646970667358221220c5bae390803cc3f1622719d99fad44d96dace0eca188c3ba7313821ca78e23e664736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806380faa57d1161008c578063c910d95011610066578063c910d950146101f1578063d6f192621461020f578063f2fde38b1461022d578063f7c618c114610249576100ea565b806380faa57d146101975780638da5cb5b146101b5578063c8f33c91146101d3576100ea565b80633ccfd60b116100c85780633ccfd60b146101475780636e9a204b14610151578063715018a61461016f5780637b0a47ee14610179576100ea565b80630e807056146100ef5780631be052891461010b5780632ec939f914610129575b600080fd5b61010960048036038101906101049190610b04565b610267565b005b61011361038a565b6040516101209190610b40565b60405180910390f35b610131610391565b60405161013e9190610b9c565b60405180910390f35b61014f6103b5565b005b61015961047c565b6040516101669190610b40565b60405180910390f35b610177610482565b005b610181610496565b60405161018e9190610b40565b60405180910390f35b61019f61049c565b6040516101ac9190610b40565b60405180910390f35b6101bd6104af565b6040516101ca9190610b9c565b60405180910390f35b6101db6104d8565b6040516101e89190610b40565b60405180910390f35b6101f96104de565b6040516102069190610b40565b60405180910390f35b6102176104e4565b6040516102249190610b40565b60405180910390f35b61024760048036038101906102429190610be3565b61051a565b005b61025161059e565b60405161025e9190610c6f565b60405180910390f35b61026f6105c2565b6102776104e4565b60038190555060015442106102a05762093a80816102959190610ce8565b6002819055506102e7565b6000426001546102b09190610d19565b90506000600254826102c29190610d4d565b905062093a8081846102d49190610da7565b6102de9190610ce8565b60028190555050505b62093a80426102f69190610da7565b600181905550426004819055507fb32714d475c9d2f568d4ff24e88d0056b93256b5a04fbdb53a57f26bb765fbed816040516103329190610b40565b60405180910390a16103873330837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610640909392919063ffffffff16565b50565b62093a8081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006103bf6104e4565b905060006003819055506103d161049c565b6004819055507f150a6ec0e6f4e9ddcaaaa1674f157d91165a42d60653016f87a9fc870a39f050816040516104069190610b40565b60405180910390a16104797f0000000000000000000000000000000000000000000000000000000000000000827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106c99092919063ffffffff16565b50565b60035481565b61048a6105c2565b610494600061074f565b565b60025481565b60006104aa42600154610813565b905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b60015481565b60006002546004546104f461049c565b6104fe9190610d19565b6105089190610d4d565b6003546105159190610da7565b905090565b6105226105c2565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610592576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161058990610e80565b60405180910390fd5b61059b8161074f565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6105ca61082c565b73ffffffffffffffffffffffffffffffffffffffff166105e86104af565b73ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063590610eec565b60405180910390fd5b565b6106c3846323b872dd60e01b85858560405160240161066193929190610f0c565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b50505050565b61074a8363a9059cbb60e01b84846040516024016106e8929190610f43565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610834565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008183106108225781610824565b825b905092915050565b600033905090565b6000610896826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166108fb9092919063ffffffff16565b90506000815111156108f657808060200190518101906108b69190610fa4565b6108f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ec90611043565b60405180910390fd5b5b505050565b606061090a8484600085610913565b90509392505050565b606082471015610958576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094f906110d5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610981919061116f565b60006040518083038185875af1925050503d80600081146109be576040519150601f19603f3d011682016040523d82523d6000602084013e6109c3565b606091505b50915091506109d4878383876109e0565b92505050949350505050565b60608315610a4357600083511415610a3b576109fb85610a56565b610a3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a31906111d2565b60405180910390fd5b5b829050610a4e565b610a4d8383610a79565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115610a8c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ac09190611247565b60405180910390fd5b600080fd5b6000819050919050565b610ae181610ace565b8114610aec57600080fd5b50565b600081359050610afe81610ad8565b92915050565b600060208284031215610b1a57610b19610ac9565b5b6000610b2884828501610aef565b91505092915050565b610b3a81610ace565b82525050565b6000602082019050610b556000830184610b31565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610b8682610b5b565b9050919050565b610b9681610b7b565b82525050565b6000602082019050610bb16000830184610b8d565b92915050565b610bc081610b7b565b8114610bcb57600080fd5b50565b600081359050610bdd81610bb7565b92915050565b600060208284031215610bf957610bf8610ac9565b5b6000610c0784828501610bce565b91505092915050565b6000819050919050565b6000610c35610c30610c2b84610b5b565b610c10565b610b5b565b9050919050565b6000610c4782610c1a565b9050919050565b6000610c5982610c3c565b9050919050565b610c6981610c4e565b82525050565b6000602082019050610c846000830184610c60565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610cf382610ace565b9150610cfe83610ace565b925082610d0e57610d0d610c8a565b5b828204905092915050565b6000610d2482610ace565b9150610d2f83610ace565b925082821015610d4257610d41610cb9565b5b828203905092915050565b6000610d5882610ace565b9150610d6383610ace565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615610d9c57610d9b610cb9565b5b828202905092915050565b6000610db282610ace565b9150610dbd83610ace565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610df257610df1610cb9565b5b828201905092915050565b600082825260208201905092915050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610e6a602683610dfd565b9150610e7582610e0e565b604082019050919050565b60006020820190508181036000830152610e9981610e5d565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610ed6602083610dfd565b9150610ee182610ea0565b602082019050919050565b60006020820190508181036000830152610f0581610ec9565b9050919050565b6000606082019050610f216000830186610b8d565b610f2e6020830185610b8d565b610f3b6040830184610b31565b949350505050565b6000604082019050610f586000830185610b8d565b610f656020830184610b31565b9392505050565b60008115159050919050565b610f8181610f6c565b8114610f8c57600080fd5b50565b600081519050610f9e81610f78565b92915050565b600060208284031215610fba57610fb9610ac9565b5b6000610fc884828501610f8f565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061102d602a83610dfd565b915061103882610fd1565b604082019050919050565b6000602082019050818103600083015261105c81611020565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b60006110bf602683610dfd565b91506110ca82611063565b604082019050919050565b600060208201905081810360008301526110ee816110b2565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561112957808201518184015260208101905061110e565b83811115611138576000848401525b50505050565b6000611149826110f5565b6111538185611100565b935061116381856020860161110b565b80840191505092915050565b600061117b828461113e565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b60006111bc601d83610dfd565b91506111c782611186565b602082019050919050565b600060208201905081810360008301526111eb816111af565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000611219826111f2565b6112238185610dfd565b935061123381856020860161110b565b61123c816111fd565b840191505092915050565b60006020820190508181036000830152611261818461120e565b90509291505056fea2646970667358221220c5bae390803cc3f1622719d99fad44d96dace0eca188c3ba7313821ca78e23e664736f6c63430008090033" +} \ No newline at end of file diff --git a/deployments/mainnet/UnderwriterToken.json b/deployments/mainnet/UnderwriterToken.json new file mode 100644 index 00000000..6b203191 --- /dev/null +++ b/deployments/mainnet/UnderwriterToken.json @@ -0,0 +1,1111 @@ +{ + "address": "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cachedChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cachedDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32", + "name": "pos", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "fromBlock", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct Checkpoints.Checkpoint", + "name": "checkpoint", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signatory", + "type": "address" + }, + { + "internalType": "address", + "name": "delegatee", + "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" + } + ], + "name": "delegateBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastTotalSupply", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x88c54a8d4b60d2ffd05143aa5916af40cbba8a52123001d3f2d9811fd0779633", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "transactionIndex": 77, + "gasUsed": "3654333", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000480000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xdaf32ccfa0f9d599c5a9436a2b6b7ad001071b0b761269ca955f83f54c645634", + "transactionHash": "0x88c54a8d4b60d2ffd05143aa5916af40cbba8a52123001d3f2d9811fd0779633", + "logs": [ + { + "transactionIndex": 77, + "blockNumber": 16327110, + "transactionHash": "0x88c54a8d4b60d2ffd05143aa5916af40cbba8a52123001d3f2d9811fd0779633", + "address": "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 100, + "blockHash": "0xdaf32ccfa0f9d599c5a9436a2b6b7ad001071b0b761269ca955f83f54c645634" + } + ], + "blockNumber": 16327110, + "cumulativeGasUsed": "8325197", + "status": 1, + "byzantium": true + }, + "args": [ + "covT underwriter token", + "covT" + ], + "numDeployments": 1, + "solcInputHash": "b466ba551e3f54d5eed446f39b17a223", + "metadata": "{\"compiler\":{\"version\":\"0.8.9+commit.e5eed63a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegator\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"fromDelegate\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"toDelegate\",\"type\":\"address\"}],\"name\":\"DelegateChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"delegate\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"previousBalance\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newBalance\",\"type\":\"uint256\"}],\"name\":\"DelegateVotesChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DELEGATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedDomainSeparator\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint32\",\"name\":\"pos\",\"type\":\"uint32\"}],\"name\":\"checkpoints\",\"outputs\":[{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fromBlock\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"votes\",\"type\":\"uint96\"}],\"internalType\":\"struct Checkpoints.Checkpoint\",\"name\":\"checkpoint\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"delegatee\",\"type\":\"address\"}],\"name\":\"delegate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"signatory\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"delegatee\",\"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\"}],\"name\":\"delegateBySig\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"delegates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastTotalSupply\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"getPastVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"getVotes\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"numCheckpoints\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\",\"returns\":{\"_0\":\"True if the operation succeeded.\"}},\"approveAndCall(address,uint256,bytes)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\",\"returns\":{\"_0\":\"True if both approval and `receiveApproval` calls succeeded.\"}},\"burn(uint256)\":{\"details\":\"Requirements: - the caller must have a balance of at least `amount`.\"},\"burnFrom(address,uint256)\":{\"details\":\"Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`.\"},\"delegate(address)\":{\"params\":{\"delegatee\":\"The address to delegate votes to\"}},\"delegateBySig(address,address,uint256,uint8,bytes32,bytes32)\":{\"params\":{\"deadline\":\"The time at which to expire the signature\",\"delegatee\":\"The address to delegate votes to\",\"r\":\"Half of the ECDSA signature pair\",\"s\":\"Half of the ECDSA signature pair\",\"v\":\"The recovery byte of the signature\"}},\"getPastTotalSupply(uint256)\":{\"details\":\"`blockNumber` must have been already mined\",\"params\":{\"blockNumber\":\"The block number to get the total supply at\"}},\"getPastVotes(address,uint256)\":{\"details\":\"Block number must be a finalized block or else this function will revert to prevent misinformation.\",\"params\":{\"account\":\"The address of the account to check\",\"blockNumber\":\"The block number to get the vote balance at\"},\"returns\":{\"_0\":\"The number of votes the account had as of the given block\"}},\"getVotes(address)\":{\"params\":{\"account\":\"The address to get votes balance\"},\"returns\":{\"_0\":\"The number of current votes for `account`\"}},\"mint(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"details\":\"The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transfer(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferFrom(address,address,uint256)\":{\"details\":\"Requirements: - `spender` and `recipient` cannot be the zero address, - `spender` must have a balance of at least `amount`, - the caller must have allowance for `spender`'s tokens of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"UnderwriterToken\",\"version\":1},\"userdoc\":{\"events\":{\"DelegateChanged(address,address,address)\":{\"notice\":\"Emitted when an account changes their delegate.\"},\"DelegateVotesChanged(address,uint256,uint256)\":{\"notice\":\"Emitted when a balance or delegate change results in changes to an account's voting power.\"}},\"kind\":\"user\",\"methods\":{\"DELEGATION_TYPEHASH()\":{\"notice\":\"The EIP-712 typehash for the delegation struct used by `delegateBySig`.\"},\"DOMAIN_SEPARATOR()\":{\"notice\":\"Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function.\"},\"PERMIT_TYPEHASH()\":{\"notice\":\"Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function.\"},\"allowance(address,address)\":{\"notice\":\"The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default.\"},\"approve(address,uint256)\":{\"notice\":\"Sets `amount` as the allowance of `spender` over the caller's tokens.\"},\"approveAndCall(address,uint256,bytes)\":{\"notice\":\"Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted.\"},\"balanceOf(address)\":{\"notice\":\"The amount of tokens owned by the given account.\"},\"burn(uint256)\":{\"notice\":\"Destroys `amount` tokens from the caller.\"},\"burnFrom(address,uint256)\":{\"notice\":\"Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"},\"decimals()\":{\"notice\":\"The decimals places of the token.\"},\"delegate(address)\":{\"notice\":\"Delegate votes from `msg.sender` to `delegatee`.\"},\"delegateBySig(address,address,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"Delegates votes from signatory to `delegatee`\"},\"delegates(address)\":{\"notice\":\"Get the address `account` is currently delegating to.\"},\"getPastTotalSupply(uint256)\":{\"notice\":\"Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances, but it is NOT the sum of all the delegated votes!\"},\"getPastVotes(address,uint256)\":{\"notice\":\"Determine the prior number of votes for an account as of a block number.\"},\"getVotes(address)\":{\"notice\":\"Gets the current votes balance for `account`.\"},\"mint(address,uint256)\":{\"notice\":\"Creates `amount` tokens and assigns them to `account`, increasing the total supply.\"},\"name()\":{\"notice\":\"The name of the token.\"},\"nonce(address)\":{\"notice\":\"Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function.\"},\"numCheckpoints(address)\":{\"notice\":\"Get number of checkpoints for `account`.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction.\"},\"symbol()\":{\"notice\":\"The symbol of the token.\"},\"totalSupply()\":{\"notice\":\"The amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"notice\":\"Moves `amount` tokens from the caller's account to `recipient`.\"},\"transferFrom(address,address,uint256)\":{\"notice\":\"Moves `amount` tokens from `spender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"}},\"notice\":\"Underwriter tokens represent an ownership share in the underlying collateral of the asset-specific pool. Underwriter tokens are minted when a user deposits ERC20 tokens into asset-specific pool and they are burned when a user exits the position. Underwriter tokens natively support meta transactions. Users can authorize a transfer of their underwriter tokens with a signature conforming EIP712 standard instead of an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, as specified in EIP2612 standard, paying gas fees, and possibly performing other actions in the same transaction.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/UnderwriterToken.sol\":\"UnderwriterToken\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.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 /**\\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 / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xd0a917e32d1251a9b2f1dea15e932815d5382e64e6b0a18104664a6cc774cd70\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xa94b34880e3c1b0b931662cb1c09e5dfa6662f31cba80e07c5ee71cd135c9673\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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 Context {\\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\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n require(value <= type(uint248).max, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n require(value <= type(uint240).max, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n require(value <= type(uint232).max, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n require(value <= type(uint216).max, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n require(value <= type(uint208).max, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n require(value <= type(uint200).max, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n require(value <= type(uint192).max, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n require(value <= type(uint184).max, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n require(value <= type(uint176).max, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n require(value <= type(uint168).max, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n require(value <= type(uint160).max, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n require(value <= type(uint152).max, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n require(value <= type(uint144).max, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n require(value <= type(uint136).max, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n require(value <= type(uint120).max, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n require(value <= type(uint112).max, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n require(value <= type(uint104).max, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.2._\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n require(value <= type(uint88).max, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n require(value <= type(uint80).max, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n require(value <= type(uint72).max, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n require(value <= type(uint56).max, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n require(value <= type(uint48).max, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n require(value <= type(uint40).max, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n require(value <= type(uint24).max, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v2.5._\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n *\\n * _Available since v3.0._\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 248 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 240 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 232 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 216 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 208 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 200 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 192 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 184 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 176 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 168 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 160 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 152 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 144 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 136 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 120 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 112 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 104 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 88 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 80 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 72 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 56 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 48 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 40 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n *\\n * _Available since v4.7._\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 24 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n require(downcasted == value, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n *\\n * _Available since v3.0._\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0x52a8cfb0f5239d11b457dcdd1b326992ef672714ca8da71a157255bddd13f3ad\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"./IVotesHistory.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\n/// @title Checkpoints\\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\\n/// delegation. This implementation supports token supply up to 2^96 - 1.\\n/// This contract keeps a history (checkpoints) of each account's vote\\n/// power. Vote power can be delegated either by calling the {delegate}\\n/// function directly, or by providing a signature to be used with\\n/// {delegateBySig}. Voting power can be publicly queried through\\n/// {getVotes} and {getPastVotes}.\\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\\n/// @dev This contract is upgrade-safe.\\nabstract contract Checkpoints is IVotesHistory {\\n struct Checkpoint {\\n uint32 fromBlock;\\n uint96 votes;\\n }\\n\\n // slither-disable-next-line uninitialized-state\\n mapping(address => address) internal _delegates;\\n mapping(address => uint128[]) internal _checkpoints;\\n uint128[] internal _totalSupplyCheckpoints;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n /// @notice Emitted when an account changes their delegate.\\n event DelegateChanged(\\n address indexed delegator,\\n address indexed fromDelegate,\\n address indexed toDelegate\\n );\\n\\n /// @notice Emitted when a balance or delegate change results in changes\\n /// to an account's voting power.\\n event DelegateVotesChanged(\\n address indexed delegate,\\n uint256 previousBalance,\\n uint256 newBalance\\n );\\n\\n function checkpoints(address account, uint32 pos)\\n public\\n view\\n virtual\\n returns (Checkpoint memory checkpoint)\\n {\\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\\n _checkpoints[account][pos]\\n );\\n checkpoint = Checkpoint(fromBlock, votes);\\n }\\n\\n /// @notice Get number of checkpoints for `account`.\\n function numCheckpoints(address account)\\n public\\n view\\n virtual\\n returns (uint32)\\n {\\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\\n }\\n\\n /// @notice Get the address `account` is currently delegating to.\\n function delegates(address account) public view virtual returns (address) {\\n return _delegates[account];\\n }\\n\\n /// @notice Gets the current votes balance for `account`.\\n /// @param account The address to get votes balance\\n /// @return The number of current votes for `account`\\n function getVotes(address account) public view returns (uint96) {\\n uint256 pos = _checkpoints[account].length;\\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\\n }\\n\\n /// @notice Determine the prior number of votes for an account as of\\n /// a block number.\\n /// @dev Block number must be a finalized block or else this function will\\n /// revert to prevent misinformation.\\n /// @param account The address of the account to check\\n /// @param blockNumber The block number to get the vote balance at\\n /// @return The number of votes the account had as of the given block\\n function getPastVotes(address account, uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_checkpoints[account], blockNumber);\\n }\\n\\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\\n /// Note, this value is the sum of all balances, but it is NOT the\\n /// sum of all the delegated votes!\\n /// @param blockNumber The block number to get the total supply at\\n /// @dev `blockNumber` must have been already mined\\n function getPastTotalSupply(uint256 blockNumber)\\n public\\n view\\n returns (uint96)\\n {\\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\\n }\\n\\n /// @notice Change delegation for `delegator` to `delegatee`.\\n // slither-disable-next-line dead-code\\n function delegate(address delegator, address delegatee) internal virtual;\\n\\n /// @notice Moves voting power from one delegate to another\\n /// @param src Address of old delegate\\n /// @param dst Address of new delegate\\n /// @param amount Voting power amount to transfer between delegates\\n function moveVotingPower(\\n address src,\\n address dst,\\n uint256 amount\\n ) internal {\\n if (src != dst && amount > 0) {\\n if (src != address(0)) {\\n // https://github.com/crytic/slither/issues/960\\n // slither-disable-next-line variable-scope\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[src],\\n subtract,\\n amount\\n );\\n emit DelegateVotesChanged(src, oldWeight, newWeight);\\n }\\n\\n if (dst != address(0)) {\\n // https://github.com/crytic/slither/issues/959\\n // slither-disable-next-line uninitialized-local\\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\\n _checkpoints[dst],\\n add,\\n amount\\n );\\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\\n }\\n }\\n }\\n\\n /// @notice Writes a new checkpoint based on operating last stored value\\n /// with a `delta`. Usually, said operation is the `add` or\\n /// `subtract` functions from this contract, but more complex\\n /// functions can be passed as parameters.\\n /// @param ckpts The checkpoints array to use\\n /// @param op The function to apply over the last value and the `delta`\\n /// @param delta Variation with respect to last stored value to be used\\n /// for new checkpoint\\n function writeCheckpoint(\\n uint128[] storage ckpts,\\n function(uint256, uint256) view returns (uint256) op,\\n uint256 delta\\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\\n uint256 pos = ckpts.length;\\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\\n newWeight = op(oldWeight, delta);\\n\\n if (pos > 0) {\\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\\n // slither-disable-next-line incorrect-equality\\n if (fromBlock == block.number) {\\n ckpts[pos - 1] = encodeCheckpoint(\\n fromBlock,\\n SafeCastUpgradeable.toUint96(newWeight)\\n );\\n return (oldWeight, newWeight);\\n }\\n }\\n\\n ckpts.push(\\n encodeCheckpoint(\\n SafeCastUpgradeable.toUint32(block.number),\\n SafeCastUpgradeable.toUint96(newWeight)\\n )\\n );\\n }\\n\\n /// @notice Lookup a value in a list of (sorted) checkpoints.\\n /// @param ckpts The checkpoints array to use\\n /// @param blockNumber Block number when we want to get the checkpoint at\\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\\n internal\\n view\\n returns (uint96)\\n {\\n // We run a binary search to look for the earliest checkpoint taken\\n // after `blockNumber`. During the loop, the index of the wanted\\n // checkpoint remains in the range [low-1, high). With each iteration,\\n // either `low` or `high` is moved towards the middle of the range to\\n // maintain the invariant.\\n // - If the middle checkpoint is after `blockNumber`,\\n // we look in [low, mid)\\n // - If the middle checkpoint is before or equal to `blockNumber`,\\n // we look in [mid+1, high)\\n // Once we reach a single value (when low == high), we've found the\\n // right checkpoint at the index high-1, if not out of bounds (in that\\n // case we're looking too far in the past and the result is 0).\\n // Note that if the latest checkpoint available is exactly for\\n // `blockNumber`, we end up with an index that is past the end of the\\n // array, so we technically don't find a checkpoint after\\n // `blockNumber`, but it works out the same.\\n require(blockNumber < block.number, \\\"Block not yet determined\\\");\\n\\n uint256 high = ckpts.length;\\n uint256 low = 0;\\n while (low < high) {\\n uint256 mid = MathUpgradeable.average(low, high);\\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\\n if (midBlock > blockNumber) {\\n high = mid;\\n } else {\\n low = mid + 1;\\n }\\n }\\n\\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\\n }\\n\\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\\n // slither-disable-next-line dead-code\\n function maxSupply() internal view virtual returns (uint96) {\\n return type(uint96).max;\\n }\\n\\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\\n /// checkpoint.\\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\\n /// remaining 96 bits.\\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\\n internal\\n pure\\n returns (uint128)\\n {\\n return (uint128(blockNumber) << 96) | uint128(value);\\n }\\n\\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\\n function decodeBlockNumber(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32)\\n {\\n return uint32(bytes4(bytes16(checkpoint)));\\n }\\n\\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\\n return uint96(checkpoint);\\n }\\n\\n /// @notice Decodes a block number and voting value from a `uint128`\\n /// `checkpoint`.\\n function decodeCheckpoint(uint128 checkpoint)\\n internal\\n pure\\n returns (uint32 blockNumber, uint96 value)\\n {\\n blockNumber = decodeBlockNumber(checkpoint);\\n value = decodeValue(checkpoint);\\n }\\n\\n // slither-disable-next-line dead-code\\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a + b;\\n }\\n\\n // slither-disable-next-line dead-code\\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a - b;\\n }\\n}\\n\",\"keccak256\":\"0x67b28349e88afe7440c43df93ba5de56873d850a25147161e4469731750efb16\",\"license\":\"GPL-3.0-or-later\"},\"@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-or-later\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.9;\\n\\ninterface IVotesHistory {\\n function getPastVotes(address account, uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n\\n function getPastTotalSupply(uint256 blockNumber)\\n external\\n view\\n returns (uint96);\\n}\\n\",\"keccak256\":\"0x535e87cf4c2e9a9439d99cf0918f013965fa6c4ddfbab07ff6ca4b195c8edc9f\",\"license\":\"GPL-3.0-or-later\"},\"contracts/UnderwriterToken.sol\":{\"content\":\"// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.9;\\n\\nimport \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\\\";\\n\\n/// @title UnderwriterToken\\n/// @notice Underwriter tokens represent an ownership share in the underlying\\n/// collateral of the asset-specific pool. Underwriter tokens are minted\\n/// when a user deposits ERC20 tokens into asset-specific pool and they\\n/// are burned when a user exits the position. Underwriter tokens\\n/// natively support meta transactions. Users can authorize a transfer\\n/// of their underwriter tokens with a signature conforming EIP712\\n/// standard instead of an on-chain transaction from their address.\\n/// Anyone can submit this signature on the user's behalf by calling the\\n/// permit function, as specified in EIP2612 standard, paying gas fees,\\n/// and possibly performing other actions in the same transaction.\\n// slither-disable-next-line missing-inheritance\\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\\n /// @notice The EIP-712 typehash for the delegation struct used by\\n /// `delegateBySig`.\\n bytes32 public constant DELEGATION_TYPEHASH =\\n keccak256(\\n \\\"Delegation(address delegatee,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n constructor(string memory _name, string memory _symbol)\\n ERC20WithPermit(_name, _symbol)\\n {}\\n\\n /// @notice Delegates votes from signatory to `delegatee`\\n /// @param delegatee The address to delegate votes to\\n /// @param deadline The time at which to expire the signature\\n /// @param v The recovery byte of the signature\\n /// @param r Half of the ECDSA signature pair\\n /// @param s Half of the ECDSA signature pair\\n function delegateBySig(\\n address signatory,\\n address delegatee,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Delegation expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n DELEGATION_TYPEHASH,\\n delegatee,\\n nonce[signatory]++,\\n deadline\\n )\\n )\\n )\\n );\\n\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == signatory,\\n \\\"Invalid signature\\\"\\n );\\n\\n return delegate(signatory, delegatee);\\n }\\n\\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegatee) public virtual {\\n return delegate(msg.sender, delegatee);\\n }\\n\\n /// @notice Moves voting power when tokens are minted, burned or transferred.\\n /// @dev Overrides the empty function from the parent contract.\\n /// @param from The address that loses tokens and voting power\\n /// @param to The address that gains tokens and voting power\\n /// @param amount The amount of tokens and voting power that is transferred\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal override {\\n // When minting:\\n if (from == address(0)) {\\n // Does not allow to mint more than uint96 can fit. Otherwise, the\\n // Checkpoint might not fit the balance.\\n require(\\n totalSupply + amount <= maxSupply(),\\n \\\"Maximum total supply exceeded\\\"\\n );\\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\\n }\\n\\n // When burning:\\n if (to == address(0)) {\\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\\n }\\n\\n moveVotingPower(delegates(from), delegates(to), amount);\\n }\\n\\n /// @notice Delegate votes from `delegator` to `delegatee`.\\n /// @param delegator The address to delegate votes from\\n /// @param delegatee The address to delegate votes to\\n function delegate(address delegator, address delegatee) internal override {\\n address currentDelegate = delegates(delegator);\\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\\n _delegates[delegator] = delegatee;\\n\\n emit DelegateChanged(delegator, currentDelegate, delegatee);\\n\\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\\n }\\n}\\n\",\"keccak256\":\"0x73aa9781275a0e35c0c80873bfbb3b4b42692fa56f785a3eb4bf0471fb3c277d\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b50604051620046d1380380620046d1833981810160405281019062000037919062000479565b8181620000596200004d620000b460201b60201c565b620000bc60201b60201c565b8160059080519060200190620000719291906200022c565b5080600690805190602001906200008a9291906200022c565b504660808181525050620000a36200018060201b60201c565b60a0818152505050505050620006ff565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051620001b491906200060e565b60405180910390206040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525080519060200120463060405160200162000211959493929190620006a2565b60405160208183030381529060405280519060200120905090565b8280546200023a906200052d565b90600052602060002090601f0160209004810192826200025e5760008555620002aa565b82601f106200027957805160ff1916838001178555620002aa565b82800160010185558215620002aa579182015b82811115620002a95782518255916020019190600101906200028c565b5b509050620002b99190620002bd565b5090565b5b80821115620002d8576000816000905550600101620002be565b5090565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200034582620002fa565b810181811067ffffffffffffffff821117156200036757620003666200030b565b5b80604052505050565b60006200037c620002dc565b90506200038a82826200033a565b919050565b600067ffffffffffffffff821115620003ad57620003ac6200030b565b5b620003b882620002fa565b9050602081019050919050565b60005b83811015620003e5578082015181840152602081019050620003c8565b83811115620003f5576000848401525b50505050565b6000620004126200040c846200038f565b62000370565b905082815260208101848484011115620004315762000430620002f5565b5b6200043e848285620003c5565b509392505050565b600082601f8301126200045e576200045d620002f0565b5b815162000470848260208601620003fb565b91505092915050565b60008060408385031215620004935762000492620002e6565b5b600083015167ffffffffffffffff811115620004b457620004b3620002eb565b5b620004c28582860162000446565b925050602083015167ffffffffffffffff811115620004e657620004e5620002eb565b5b620004f48582860162000446565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200054657607f821691505b602082108114156200055d576200055c620004fe565b5b50919050565b600081905092915050565b60008190508160005260206000209050919050565b6000815462000592816200052d565b6200059e818662000563565b94506001821660008114620005bc5760018114620005ce5762000605565b60ff1983168652818601935062000605565b620005d9856200056e565b60005b83811015620005fd57815481890152600182019150602081019050620005dc565b838801955050505b50505092915050565b60006200061c828462000583565b915081905092915050565b6000819050919050565b6200063c8162000627565b82525050565b6000819050919050565b620006578162000642565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200068a826200065d565b9050919050565b6200069c816200067d565b82525050565b600060a082019050620006b9600083018862000631565b620006c8602083018762000631565b620006d7604083018662000631565b620006e660608301856200064c565b620006f5608083018462000691565b9695505050505050565b60805160a051613f9e620007336000396000818161086e015261115a0152600081816108460152610b6e0152613f9e6000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c8063715018a61161010f578063b20d7fa9116100a2578063dd62ed3e11610071578063dd62ed3e146105ba578063e7a324dc146105ea578063f1127ed814610608578063f2fde38b14610638576101e5565b8063b20d7fa914610534578063b4f94b2e14610550578063cae9ca511461056e578063d505accf1461059e576101e5565b80638e539e8c116100de5780638e539e8c1461048657806395d89b41146104b65780639ab24eb0146104d4578063a9059cbb14610504576101e5565b8063715018a614610424578063771da5c51461042e57806379cc67901461044c5780638da5cb5b14610468576101e5565b80633a46b1a8116101875780635c19a95c116101565780635c19a95c146103785780636fcfff451461039457806370a08231146103c457806370ae92d2146103f4576101e5565b80633a46b1a8146102e057806340c10f191461031057806342966c681461032c578063587cde1e14610348576101e5565b806323b872dd116101c357806323b872dd1461025657806330adf81f14610286578063313ce567146102a45780633644e515146102c2576101e5565b806306fdde03146101ea578063095ea7b31461020857806318160ddd14610238575b600080fd5b6101f2610654565b6040516101ff919061292e565b60405180910390f35b610222600480360381019061021d91906129f8565b6106e2565b60405161022f9190612a53565b60405180910390f35b6102406106f9565b60405161024d9190612a7d565b60405180910390f35b610270600480360381019061026b9190612a98565b6106ff565b60405161027d9190612a53565b60405180910390f35b61028e610819565b60405161029b9190612b04565b60405180910390f35b6102ac61083d565b6040516102b99190612b3b565b60405180910390f35b6102ca610842565b6040516102d79190612b04565b60405180910390f35b6102fa60048036038101906102f591906129f8565b6108a2565b6040516103079190612b7d565b60405180910390f35b61032a600480360381019061032591906129f8565b6108f4565b005b61034660048036038101906103419190612b98565b610a51565b005b610362600480360381019061035d9190612bc5565b610a5e565b60405161036f9190612c01565b60405180910390f35b610392600480360381019061038d9190612bc5565b610ac7565b005b6103ae60048036038101906103a99190612bc5565b610ad4565b6040516103bb9190612c3b565b60405180910390f35b6103de60048036038101906103d99190612bc5565b610b28565b6040516103eb9190612a7d565b60405180910390f35b61040e60048036038101906104099190612bc5565b610b40565b60405161041b9190612a7d565b60405180910390f35b61042c610b58565b005b610436610b6c565b6040516104439190612a7d565b60405180910390f35b610466600480360381019061046191906129f8565b610b90565b005b610470610ca1565b60405161047d9190612c01565b60405180910390f35b6104a0600480360381019061049b9190612b98565b610cca565b6040516104ad9190612b7d565b60405180910390f35b6104be610cde565b6040516104cb919061292e565b60405180910390f35b6104ee60048036038101906104e99190612bc5565b610d6c565b6040516104fb9190612b7d565b60405180910390f35b61051e600480360381019061051991906129f8565b610e63565b60405161052b9190612a53565b60405180910390f35b61054e60048036038101906105499190612cae565b610e7a565b005b610558611158565b6040516105659190612b04565b60405180910390f35b61058860048036038101906105839190612e70565b61117c565b6040516105959190612a53565b60405180910390f35b6105b860048036038101906105b39190612edf565b611213565b005b6105d460048036038101906105cf9190612f81565b6114f7565b6040516105e19190612a7d565b60405180910390f35b6105f261151c565b6040516105ff9190612b04565b60405180910390f35b610622600480360381019061061d9190612fed565b611540565b60405161062f919061307a565b60405180910390f35b610652600480360381019061064d9190612bc5565b611613565b005b60058054610661906130c4565b80601f016020809104026020016040519081016040528092919081815260200182805461068d906130c4565b80156106da5780601f106106af576101008083540402835291602001916106da565b820191906000526020600020905b8154815290600101906020018083116106bd57829003601f168201915b505050505081565b60006106ef338484611697565b6001905092915050565b60045481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461080257828110156107eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e290613168565b60405180910390fd5b610801853385846107fc91906131b7565b611697565b5b61080d858585611862565b60019150509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60007f0000000000000000000000000000000000000000000000000000000000000000461415610894577f0000000000000000000000000000000000000000000000000000000000000000905061089f565b61089c611b53565b90505b90565b60006108ec600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083611bfb565b905092915050565b6108fc611d52565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561096c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096390613237565b60405180910390fd5b61097860008383611dd0565b806004600082825461098a9190613257565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109e09190613257565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610a459190612a7d565b60405180910390a35050565b610a5b3382611ee1565b50565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610ad13382612047565b50565b6000610b21600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506121ae565b9050919050565b60016020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b610b60611d52565b610b6a6000612201565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610c925781811015610c7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c72906132f9565b60405180910390fd5b610c9183338484610c8c91906131b7565b611697565b5b610c9c8383611ee1565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000610cd7600983611bfb565b9050919050565b60068054610ceb906130c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610d17906130c4565b8015610d645780601f10610d3957610100808354040283529160200191610d64565b820191906000526020600020905b815481529060010190602001808311610d4757829003601f168201915b505050505081565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050905060008114610e5857610e53600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600183610e0b91906131b7565b81548110610e1c57610e1b613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b610e5b565b60005b915050919050565b6000610e70338484611862565b6001905092915050565b42841015610ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb490613394565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c1115610f23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1a90613400565b60405180910390fd5b601b8360ff161480610f385750601c8360ff16145b610f77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6e9061346c565b60405180910390fd5b6000610f81610842565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e287600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610ff39061348c565b919050558860405160200161100b94939291906134d5565b60405160208183030381529060405280519060200120604051602001611032929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161106f94939291906135c9565b6020604051602081039080840390855afa158015611091573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561110557508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611144576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113b9061365a565b60405180910390fd5b61114e8888612047565b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061118884846106e2565b15611207578373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b81526004016111cc94939291906136cf565b600060405180830381600087803b1580156111e657600080fd5b505af11580156111fa573d6000803e3d6000fd5b505050506001905061120c565b600090505b9392505050565b42841015611256576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124d90613767565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c11156112bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b390613400565b60405180910390fd5b601b8360ff1614806112d15750601c8360ff16145b611310576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113079061346c565b60405180910390fd5b600061131a610842565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9898989600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061138e9061348c565b919050558a6040516020016113a896959493929190613787565b604051602081830303815290604052805190602001206040516020016113cf929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161140c94939291906135c9565b6020604051602081039080840390855afa15801561142e573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156114a257508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b6114e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d89061365a565b60405180910390fd5b6114ec898989611697565b505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e281565b611548612867565b6000806115dc600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208563ffffffff16815481106115a5576115a4613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122cf565b9150915060405180604001604052808363ffffffff168152602001826bffffffffffffffffffffffff168152509250505092915050565b61161b611d52565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561168b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116829061385a565b60405180910390fd5b61169481612201565b50565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe906138c6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176e90613932565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516118559190612a7d565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156118d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c99061399e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611942576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193990613a0a565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a890613a76565b60405180910390fd5b6119bc838383611dd0565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611a43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a3a90613ae2565b60405180910390fd5b8181611a4f91906131b7565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611ae19190613257565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611b459190612a7d565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051611b859190613ba1565b60405180910390206040518060400160405280600181526020017f3100000000000000000000000000000000000000000000000000000000000000815250805190602001204630604051602001611be0959493929190613bb8565b60405160208183030381529060405280519060200120905090565b6000438210611c3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3690613c57565b60405180910390fd5b60008380549050905060005b81811015611cdf576000611c5f82846122ed565b90506000611cb0878381548110611c7957611c78613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050858163ffffffff161115611cc857819350611cd8565b600182611cd59190613257565b92505b5050611c4b565b60008214611d4557611d4085600184611cf891906131b7565b81548110611d0957611d08613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b611d48565b60005b9250505092915050565b611d5a612323565b73ffffffffffffffffffffffffffffffffffffffff16611d78610ca1565b73ffffffffffffffffffffffffffffffffffffffff1614611dce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dc590613cc3565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e7b57611e0d61232b565b6bffffffffffffffffffffffff1681600454611e299190613257565b1115611e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6190613d2f565b60405180910390fd5b611e78600961233f83612355565b50505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ec157611ebe600961256b83612355565b50505b611edc611ecd84610a5e565b611ed684610a5e565b83612581565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611f68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5f90613d9b565b60405180910390fd5b611f7483600084611dd0565b8181611f8091906131b7565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160046000828254611fd591906131b7565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161203a9190612a7d565b60405180910390a3505050565b600061205283610a5e565b9050600061209e600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461277a565b905082600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a46121a88284836bffffffffffffffffffffffff16612581565b50505050565b600063ffffffff80168211156121f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f090613e2d565b60405180910390fd5b819050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000819050919050565b6000806122db83612313565b91506122e6836122c5565b9050915091565b600060028284186122fe9190613e7c565b82841661230b9190613257565b905092915050565b60008160801b60e01c9050919050565b600033905090565b60006bffffffffffffffffffffffff905090565b6000818361234d9190613257565b905092915050565b600080600085805490509050600081146123c7576123c28660018361237a91906131b7565b8154811061238b5761238a613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b6123ca565b60005b6bffffffffffffffffffffffff1692506123e883858763ffffffff16565b915060008111156124e357600061244e8760018461240691906131b7565b8154811061241757612416613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050438163ffffffff1614156124e1576124708161246b856127d5565b612830565b8760018461247e91906131b7565b8154811061248f5761248e613319565b5b90600052602060002090600291828204019190066010026101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055505050612563565b505b856124fe6124f0436121ae565b6124f9856127d5565b612830565b90806001815401808255809150506001900390600052602060002090600291828204019190066010029091909190916101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505b935093915050565b6000818361257991906131b7565b905092915050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156125bd5750600081115b1561277557600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461269b57600080612644600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061256b85612355565b915091508473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612690929190613ead565b60405180910390a250505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146127745760008061271d600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061233f85612355565b915091508373ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612769929190613ead565b60405180910390a250505b5b505050565b60006bffffffffffffffffffffffff80168211156127cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127c490613f48565b60405180910390fd5b819050919050565b60006bffffffffffffffffffffffff8016821115612828576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281f90613f48565b60405180910390fd5b819050919050565b6000816bffffffffffffffffffffffff1660608463ffffffff166fffffffffffffffffffffffffffffffff16901b17905092915050565b6040518060400160405280600063ffffffff16815260200160006bffffffffffffffffffffffff1681525090565b600081519050919050565b600082825260208201905092915050565b60005b838110156128cf5780820151818401526020810190506128b4565b838111156128de576000848401525b50505050565b6000601f19601f8301169050919050565b600061290082612895565b61290a81856128a0565b935061291a8185602086016128b1565b612923816128e4565b840191505092915050565b6000602082019050818103600083015261294881846128f5565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061298f82612964565b9050919050565b61299f81612984565b81146129aa57600080fd5b50565b6000813590506129bc81612996565b92915050565b6000819050919050565b6129d5816129c2565b81146129e057600080fd5b50565b6000813590506129f2816129cc565b92915050565b60008060408385031215612a0f57612a0e61295a565b5b6000612a1d858286016129ad565b9250506020612a2e858286016129e3565b9150509250929050565b60008115159050919050565b612a4d81612a38565b82525050565b6000602082019050612a686000830184612a44565b92915050565b612a77816129c2565b82525050565b6000602082019050612a926000830184612a6e565b92915050565b600080600060608486031215612ab157612ab061295a565b5b6000612abf868287016129ad565b9350506020612ad0868287016129ad565b9250506040612ae1868287016129e3565b9150509250925092565b6000819050919050565b612afe81612aeb565b82525050565b6000602082019050612b196000830184612af5565b92915050565b600060ff82169050919050565b612b3581612b1f565b82525050565b6000602082019050612b506000830184612b2c565b92915050565b60006bffffffffffffffffffffffff82169050919050565b612b7781612b56565b82525050565b6000602082019050612b926000830184612b6e565b92915050565b600060208284031215612bae57612bad61295a565b5b6000612bbc848285016129e3565b91505092915050565b600060208284031215612bdb57612bda61295a565b5b6000612be9848285016129ad565b91505092915050565b612bfb81612984565b82525050565b6000602082019050612c166000830184612bf2565b92915050565b600063ffffffff82169050919050565b612c3581612c1c565b82525050565b6000602082019050612c506000830184612c2c565b92915050565b612c5f81612b1f565b8114612c6a57600080fd5b50565b600081359050612c7c81612c56565b92915050565b612c8b81612aeb565b8114612c9657600080fd5b50565b600081359050612ca881612c82565b92915050565b60008060008060008060c08789031215612ccb57612cca61295a565b5b6000612cd989828a016129ad565b9650506020612cea89828a016129ad565b9550506040612cfb89828a016129e3565b9450506060612d0c89828a01612c6d565b9350506080612d1d89828a01612c99565b92505060a0612d2e89828a01612c99565b9150509295509295509295565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612d7d826128e4565b810181811067ffffffffffffffff82111715612d9c57612d9b612d45565b5b80604052505050565b6000612daf612950565b9050612dbb8282612d74565b919050565b600067ffffffffffffffff821115612ddb57612dda612d45565b5b612de4826128e4565b9050602081019050919050565b82818337600083830152505050565b6000612e13612e0e84612dc0565b612da5565b905082815260208101848484011115612e2f57612e2e612d40565b5b612e3a848285612df1565b509392505050565b600082601f830112612e5757612e56612d3b565b5b8135612e67848260208601612e00565b91505092915050565b600080600060608486031215612e8957612e8861295a565b5b6000612e97868287016129ad565b9350506020612ea8868287016129e3565b925050604084013567ffffffffffffffff811115612ec957612ec861295f565b5b612ed586828701612e42565b9150509250925092565b600080600080600080600060e0888a031215612efe57612efd61295a565b5b6000612f0c8a828b016129ad565b9750506020612f1d8a828b016129ad565b9650506040612f2e8a828b016129e3565b9550506060612f3f8a828b016129e3565b9450506080612f508a828b01612c6d565b93505060a0612f618a828b01612c99565b92505060c0612f728a828b01612c99565b91505092959891949750929550565b60008060408385031215612f9857612f9761295a565b5b6000612fa6858286016129ad565b9250506020612fb7858286016129ad565b9150509250929050565b612fca81612c1c565b8114612fd557600080fd5b50565b600081359050612fe781612fc1565b92915050565b600080604083850312156130045761300361295a565b5b6000613012858286016129ad565b925050602061302385828601612fd8565b9150509250929050565b61303681612c1c565b82525050565b61304581612b56565b82525050565b604082016000820151613061600085018261302d565b506020820151613074602085018261303c565b50505050565b600060408201905061308f600083018461304b565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806130dc57607f821691505b602082108114156130f0576130ef613095565b5b50919050565b7f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b60006131526021836128a0565b915061315d826130f6565b604082019050919050565b6000602082019050818103600083015261318181613145565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006131c2826129c2565b91506131cd836129c2565b9250828210156131e0576131df613188565b5b828203905092915050565b7f4d696e7420746f20746865207a65726f20616464726573730000000000000000600082015250565b60006132216018836128a0565b915061322c826131eb565b602082019050919050565b6000602082019050818103600083015261325081613214565b9050919050565b6000613262826129c2565b915061326d836129c2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156132a2576132a1613188565b5b828201905092915050565b7f4275726e20616d6f756e74206578636565647320616c6c6f77616e6365000000600082015250565b60006132e3601d836128a0565b91506132ee826132ad565b602082019050919050565b60006020820190508181036000830152613312816132d6565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f44656c65676174696f6e20657870697265640000000000000000000000000000600082015250565b600061337e6012836128a0565b915061338982613348565b602082019050919050565b600060208201905081810360008301526133ad81613371565b9050919050565b7f496e76616c6964207369676e6174757265202773272076616c75650000000000600082015250565b60006133ea601b836128a0565b91506133f5826133b4565b602082019050919050565b60006020820190508181036000830152613419816133dd565b9050919050565b7f496e76616c6964207369676e6174757265202776272076616c75650000000000600082015250565b6000613456601b836128a0565b915061346182613420565b602082019050919050565b6000602082019050818103600083015261348581613449565b9050919050565b6000613497826129c2565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156134ca576134c9613188565b5b600182019050919050565b60006080820190506134ea6000830187612af5565b6134f76020830186612bf2565b6135046040830185612a6e565b6135116060830184612a6e565b95945050505050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b600061355b60028361351a565b915061356682613525565b600282019050919050565b6000819050919050565b61358c61358782612aeb565b613571565b82525050565b600061359d8261354e565b91506135a9828561357b565b6020820191506135b9828461357b565b6020820191508190509392505050565b60006080820190506135de6000830187612af5565b6135eb6020830186612b2c565b6135f86040830185612af5565b6136056060830184612af5565b95945050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b60006136446011836128a0565b915061364f8261360e565b602082019050919050565b6000602082019050818103600083015261367381613637565b9050919050565b600081519050919050565b600082825260208201905092915050565b60006136a18261367a565b6136ab8185613685565b93506136bb8185602086016128b1565b6136c4816128e4565b840191505092915050565b60006080820190506136e46000830187612bf2565b6136f16020830186612a6e565b6136fe6040830185612bf2565b81810360608301526137108184613696565b905095945050505050565b7f5065726d697373696f6e20657870697265640000000000000000000000000000600082015250565b60006137516012836128a0565b915061375c8261371b565b602082019050919050565b6000602082019050818103600083015261378081613744565b9050919050565b600060c08201905061379c6000830189612af5565b6137a96020830188612bf2565b6137b66040830187612bf2565b6137c36060830186612a6e565b6137d06080830185612a6e565b6137dd60a0830184612a6e565b979650505050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006138446026836128a0565b915061384f826137e8565b604082019050919050565b6000602082019050818103600083015261387381613837565b9050919050565b7f417070726f76652066726f6d20746865207a65726f2061646472657373000000600082015250565b60006138b0601d836128a0565b91506138bb8261387a565b602082019050919050565b600060208201905081810360008301526138df816138a3565b9050919050565b7f417070726f766520746f20746865207a65726f20616464726573730000000000600082015250565b600061391c601b836128a0565b9150613927826138e6565b602082019050919050565b6000602082019050818103600083015261394b8161390f565b9050919050565b7f5472616e736665722066726f6d20746865207a65726f20616464726573730000600082015250565b6000613988601e836128a0565b915061399382613952565b602082019050919050565b600060208201905081810360008301526139b78161397b565b9050919050565b7f5472616e7366657220746f20746865207a65726f206164647265737300000000600082015250565b60006139f4601c836128a0565b91506139ff826139be565b602082019050919050565b60006020820190508181036000830152613a23816139e7565b9050919050565b7f5472616e7366657220746f2074686520746f6b656e2061646472657373000000600082015250565b6000613a60601d836128a0565b9150613a6b82613a2a565b602082019050919050565b60006020820190508181036000830152613a8f81613a53565b9050919050565b7f5472616e7366657220616d6f756e7420657863656564732062616c616e636500600082015250565b6000613acc601f836128a0565b9150613ad782613a96565b602082019050919050565b60006020820190508181036000830152613afb81613abf565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154613b2f816130c4565b613b398186613b02565b94506001821660008114613b545760018114613b6557613b98565b60ff19831686528186019350613b98565b613b6e85613b0d565b60005b83811015613b9057815481890152600182019150602081019050613b71565b838801955050505b50505092915050565b6000613bad8284613b22565b915081905092915050565b600060a082019050613bcd6000830188612af5565b613bda6020830187612af5565b613be76040830186612af5565b613bf46060830185612a6e565b613c016080830184612bf2565b9695505050505050565b7f426c6f636b206e6f74207965742064657465726d696e65640000000000000000600082015250565b6000613c416018836128a0565b9150613c4c82613c0b565b602082019050919050565b60006020820190508181036000830152613c7081613c34565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613cad6020836128a0565b9150613cb882613c77565b602082019050919050565b60006020820190508181036000830152613cdc81613ca0565b9050919050565b7f4d6178696d756d20746f74616c20737570706c79206578636565646564000000600082015250565b6000613d19601d836128a0565b9150613d2482613ce3565b602082019050919050565b60006020820190508181036000830152613d4881613d0c565b9050919050565b7f4275726e20616d6f756e7420657863656564732062616c616e63650000000000600082015250565b6000613d85601b836128a0565b9150613d9082613d4f565b602082019050919050565b60006020820190508181036000830152613db481613d78565b9050919050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203360008201527f3220626974730000000000000000000000000000000000000000000000000000602082015250565b6000613e176026836128a0565b9150613e2282613dbb565b604082019050919050565b60006020820190508181036000830152613e4681613e0a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613e87826129c2565b9150613e92836129c2565b925082613ea257613ea1613e4d565b5b828204905092915050565b6000604082019050613ec26000830185612a6e565b613ecf6020830184612a6e565b9392505050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203960008201527f3620626974730000000000000000000000000000000000000000000000000000602082015250565b6000613f326026836128a0565b9150613f3d82613ed6565b604082019050919050565b60006020820190508181036000830152613f6181613f25565b905091905056fea264697066735822122080c4ea65fe927ddc01a672c8707e7276fbf471d1a5c285c9638eb1806c347c3764736f6c63430008090033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101e55760003560e01c8063715018a61161010f578063b20d7fa9116100a2578063dd62ed3e11610071578063dd62ed3e146105ba578063e7a324dc146105ea578063f1127ed814610608578063f2fde38b14610638576101e5565b8063b20d7fa914610534578063b4f94b2e14610550578063cae9ca511461056e578063d505accf1461059e576101e5565b80638e539e8c116100de5780638e539e8c1461048657806395d89b41146104b65780639ab24eb0146104d4578063a9059cbb14610504576101e5565b8063715018a614610424578063771da5c51461042e57806379cc67901461044c5780638da5cb5b14610468576101e5565b80633a46b1a8116101875780635c19a95c116101565780635c19a95c146103785780636fcfff451461039457806370a08231146103c457806370ae92d2146103f4576101e5565b80633a46b1a8146102e057806340c10f191461031057806342966c681461032c578063587cde1e14610348576101e5565b806323b872dd116101c357806323b872dd1461025657806330adf81f14610286578063313ce567146102a45780633644e515146102c2576101e5565b806306fdde03146101ea578063095ea7b31461020857806318160ddd14610238575b600080fd5b6101f2610654565b6040516101ff919061292e565b60405180910390f35b610222600480360381019061021d91906129f8565b6106e2565b60405161022f9190612a53565b60405180910390f35b6102406106f9565b60405161024d9190612a7d565b60405180910390f35b610270600480360381019061026b9190612a98565b6106ff565b60405161027d9190612a53565b60405180910390f35b61028e610819565b60405161029b9190612b04565b60405180910390f35b6102ac61083d565b6040516102b99190612b3b565b60405180910390f35b6102ca610842565b6040516102d79190612b04565b60405180910390f35b6102fa60048036038101906102f591906129f8565b6108a2565b6040516103079190612b7d565b60405180910390f35b61032a600480360381019061032591906129f8565b6108f4565b005b61034660048036038101906103419190612b98565b610a51565b005b610362600480360381019061035d9190612bc5565b610a5e565b60405161036f9190612c01565b60405180910390f35b610392600480360381019061038d9190612bc5565b610ac7565b005b6103ae60048036038101906103a99190612bc5565b610ad4565b6040516103bb9190612c3b565b60405180910390f35b6103de60048036038101906103d99190612bc5565b610b28565b6040516103eb9190612a7d565b60405180910390f35b61040e60048036038101906104099190612bc5565b610b40565b60405161041b9190612a7d565b60405180910390f35b61042c610b58565b005b610436610b6c565b6040516104439190612a7d565b60405180910390f35b610466600480360381019061046191906129f8565b610b90565b005b610470610ca1565b60405161047d9190612c01565b60405180910390f35b6104a0600480360381019061049b9190612b98565b610cca565b6040516104ad9190612b7d565b60405180910390f35b6104be610cde565b6040516104cb919061292e565b60405180910390f35b6104ee60048036038101906104e99190612bc5565b610d6c565b6040516104fb9190612b7d565b60405180910390f35b61051e600480360381019061051991906129f8565b610e63565b60405161052b9190612a53565b60405180910390f35b61054e60048036038101906105499190612cae565b610e7a565b005b610558611158565b6040516105659190612b04565b60405180910390f35b61058860048036038101906105839190612e70565b61117c565b6040516105959190612a53565b60405180910390f35b6105b860048036038101906105b39190612edf565b611213565b005b6105d460048036038101906105cf9190612f81565b6114f7565b6040516105e19190612a7d565b60405180910390f35b6105f261151c565b6040516105ff9190612b04565b60405180910390f35b610622600480360381019061061d9190612fed565b611540565b60405161062f919061307a565b60405180910390f35b610652600480360381019061064d9190612bc5565b611613565b005b60058054610661906130c4565b80601f016020809104026020016040519081016040528092919081815260200182805461068d906130c4565b80156106da5780601f106106af576101008083540402835291602001916106da565b820191906000526020600020905b8154815290600101906020018083116106bd57829003601f168201915b505050505081565b60006106ef338484611697565b6001905092915050565b60045481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461080257828110156107eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e290613168565b60405180910390fd5b610801853385846107fc91906131b7565b611697565b5b61080d858585611862565b60019150509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60007f0000000000000000000000000000000000000000000000000000000000000000461415610894577f0000000000000000000000000000000000000000000000000000000000000000905061089f565b61089c611b53565b90505b90565b60006108ec600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002083611bfb565b905092915050565b6108fc611d52565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561096c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161096390613237565b60405180910390fd5b61097860008383611dd0565b806004600082825461098a9190613257565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546109e09190613257565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610a459190612a7d565b60405180910390a35050565b610a5b3382611ee1565b50565b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b610ad13382612047565b50565b6000610b21600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490506121ae565b9050919050565b60016020528060005260406000206000915090505481565b60036020528060005260406000206000915090505481565b610b60611d52565b610b6a6000612201565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610c925781811015610c7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c72906132f9565b60405180910390fd5b610c9183338484610c8c91906131b7565b611697565b5b610c9c8383611ee1565b505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000610cd7600983611bfb565b9050919050565b60068054610ceb906130c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610d17906130c4565b8015610d645780601f10610d3957610100808354040283529160200191610d64565b820191906000526020600020905b815481529060010190602001808311610d4757829003601f168201915b505050505081565b600080600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050905060008114610e5857610e53600860008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600183610e0b91906131b7565b81548110610e1c57610e1b613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b610e5b565b60005b915050919050565b6000610e70338484611862565b6001905092915050565b42841015610ebd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb490613394565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c1115610f23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1a90613400565b60405180910390fd5b601b8360ff161480610f385750601c8360ff16145b610f77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6e9061346c565b60405180910390fd5b6000610f81610842565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e287600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610ff39061348c565b919050558860405160200161100b94939291906134d5565b60405160208183030381529060405280519060200120604051602001611032929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161106f94939291906135c9565b6020604051602081039080840390855afa158015611091573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561110557508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611144576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113b9061365a565b60405180910390fd5b61114e8888612047565b5050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061118884846106e2565b15611207578373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b81526004016111cc94939291906136cf565b600060405180830381600087803b1580156111e657600080fd5b505af11580156111fa573d6000803e3d6000fd5b505050506001905061120c565b600090505b9392505050565b42841015611256576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124d90613767565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c11156112bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b390613400565b60405180910390fd5b601b8360ff1614806112d15750601c8360ff16145b611310576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113079061346c565b60405180910390fd5b600061131a610842565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9898989600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061138e9061348c565b919050558a6040516020016113a896959493929190613787565b604051602081830303815290604052805190602001206040516020016113cf929190613592565b60405160208183030381529060405280519060200120905060006001828686866040516000815260200160405260405161140c94939291906135c9565b6020604051602081039080840390855afa15801561142e573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156114a257508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b6114e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114d89061365a565b60405180910390fd5b6114ec898989611697565b505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b7f76995fe87be88484696cfd6792aeb71e0b61f81dfa3b641e5adffa38a0d3b8e281565b611548612867565b6000806115dc600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208563ffffffff16815481106115a5576115a4613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122cf565b9150915060405180604001604052808363ffffffff168152602001826bffffffffffffffffffffffff168152509250505092915050565b61161b611d52565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561168b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116829061385a565b60405180910390fd5b61169481612201565b50565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611707576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116fe906138c6565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176e90613932565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516118559190612a7d565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156118d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c99061399e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611942576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193990613a0a565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156119b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119a890613a76565b60405180910390fd5b6119bc838383611dd0565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611a43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a3a90613ae2565b60405180910390fd5b8181611a4f91906131b7565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611ae19190613257565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611b459190612a7d565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051611b859190613ba1565b60405180910390206040518060400160405280600181526020017f3100000000000000000000000000000000000000000000000000000000000000815250805190602001204630604051602001611be0959493929190613bb8565b60405160208183030381529060405280519060200120905090565b6000438210611c3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3690613c57565b60405180910390fd5b60008380549050905060005b81811015611cdf576000611c5f82846122ed565b90506000611cb0878381548110611c7957611c78613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050858163ffffffff161115611cc857819350611cd8565b600182611cd59190613257565b92505b5050611c4b565b60008214611d4557611d4085600184611cf891906131b7565b81548110611d0957611d08613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b611d48565b60005b9250505092915050565b611d5a612323565b73ffffffffffffffffffffffffffffffffffffffff16611d78610ca1565b73ffffffffffffffffffffffffffffffffffffffff1614611dce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dc590613cc3565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611e7b57611e0d61232b565b6bffffffffffffffffffffffff1681600454611e299190613257565b1115611e6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6190613d2f565b60405180910390fd5b611e78600961233f83612355565b50505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ec157611ebe600961256b83612355565b50505b611edc611ecd84610a5e565b611ed684610a5e565b83612581565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611f68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f5f90613d9b565b60405180910390fd5b611f7483600084611dd0565b8181611f8091906131b7565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160046000828254611fd591906131b7565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161203a9190612a7d565b60405180910390a3505050565b600061205283610a5e565b9050600061209e600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461277a565b905082600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f60405160405180910390a46121a88284836bffffffffffffffffffffffff16612581565b50505050565b600063ffffffff80168211156121f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121f090613e2d565b60405180910390fd5b819050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000819050919050565b6000806122db83612313565b91506122e6836122c5565b9050915091565b600060028284186122fe9190613e7c565b82841661230b9190613257565b905092915050565b60008160801b60e01c9050919050565b600033905090565b60006bffffffffffffffffffffffff905090565b6000818361234d9190613257565b905092915050565b600080600085805490509050600081146123c7576123c28660018361237a91906131b7565b8154811061238b5761238a613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff166122c5565b6123ca565b60005b6bffffffffffffffffffffffff1692506123e883858763ffffffff16565b915060008111156124e357600061244e8760018461240691906131b7565b8154811061241757612416613319565b5b90600052602060002090600291828204019190066010029054906101000a90046fffffffffffffffffffffffffffffffff16612313565b9050438163ffffffff1614156124e1576124708161246b856127d5565b612830565b8760018461247e91906131b7565b8154811061248f5761248e613319565b5b90600052602060002090600291828204019190066010026101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055505050612563565b505b856124fe6124f0436121ae565b6124f9856127d5565b612830565b90806001815401808255809150506001900390600052602060002090600291828204019190066010029091909190916101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff160217905550505b935093915050565b6000818361257991906131b7565b905092915050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141580156125bd5750600081115b1561277557600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161461269b57600080612644600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061256b85612355565b915091508473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612690929190613ead565b60405180910390a250505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146127745760008061271d600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061233f85612355565b915091508373ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a7248383604051612769929190613ead565b60405180910390a250505b5b505050565b60006bffffffffffffffffffffffff80168211156127cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127c490613f48565b60405180910390fd5b819050919050565b60006bffffffffffffffffffffffff8016821115612828576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281f90613f48565b60405180910390fd5b819050919050565b6000816bffffffffffffffffffffffff1660608463ffffffff166fffffffffffffffffffffffffffffffff16901b17905092915050565b6040518060400160405280600063ffffffff16815260200160006bffffffffffffffffffffffff1681525090565b600081519050919050565b600082825260208201905092915050565b60005b838110156128cf5780820151818401526020810190506128b4565b838111156128de576000848401525b50505050565b6000601f19601f8301169050919050565b600061290082612895565b61290a81856128a0565b935061291a8185602086016128b1565b612923816128e4565b840191505092915050565b6000602082019050818103600083015261294881846128f5565b905092915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061298f82612964565b9050919050565b61299f81612984565b81146129aa57600080fd5b50565b6000813590506129bc81612996565b92915050565b6000819050919050565b6129d5816129c2565b81146129e057600080fd5b50565b6000813590506129f2816129cc565b92915050565b60008060408385031215612a0f57612a0e61295a565b5b6000612a1d858286016129ad565b9250506020612a2e858286016129e3565b9150509250929050565b60008115159050919050565b612a4d81612a38565b82525050565b6000602082019050612a686000830184612a44565b92915050565b612a77816129c2565b82525050565b6000602082019050612a926000830184612a6e565b92915050565b600080600060608486031215612ab157612ab061295a565b5b6000612abf868287016129ad565b9350506020612ad0868287016129ad565b9250506040612ae1868287016129e3565b9150509250925092565b6000819050919050565b612afe81612aeb565b82525050565b6000602082019050612b196000830184612af5565b92915050565b600060ff82169050919050565b612b3581612b1f565b82525050565b6000602082019050612b506000830184612b2c565b92915050565b60006bffffffffffffffffffffffff82169050919050565b612b7781612b56565b82525050565b6000602082019050612b926000830184612b6e565b92915050565b600060208284031215612bae57612bad61295a565b5b6000612bbc848285016129e3565b91505092915050565b600060208284031215612bdb57612bda61295a565b5b6000612be9848285016129ad565b91505092915050565b612bfb81612984565b82525050565b6000602082019050612c166000830184612bf2565b92915050565b600063ffffffff82169050919050565b612c3581612c1c565b82525050565b6000602082019050612c506000830184612c2c565b92915050565b612c5f81612b1f565b8114612c6a57600080fd5b50565b600081359050612c7c81612c56565b92915050565b612c8b81612aeb565b8114612c9657600080fd5b50565b600081359050612ca881612c82565b92915050565b60008060008060008060c08789031215612ccb57612cca61295a565b5b6000612cd989828a016129ad565b9650506020612cea89828a016129ad565b9550506040612cfb89828a016129e3565b9450506060612d0c89828a01612c6d565b9350506080612d1d89828a01612c99565b92505060a0612d2e89828a01612c99565b9150509295509295509295565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612d7d826128e4565b810181811067ffffffffffffffff82111715612d9c57612d9b612d45565b5b80604052505050565b6000612daf612950565b9050612dbb8282612d74565b919050565b600067ffffffffffffffff821115612ddb57612dda612d45565b5b612de4826128e4565b9050602081019050919050565b82818337600083830152505050565b6000612e13612e0e84612dc0565b612da5565b905082815260208101848484011115612e2f57612e2e612d40565b5b612e3a848285612df1565b509392505050565b600082601f830112612e5757612e56612d3b565b5b8135612e67848260208601612e00565b91505092915050565b600080600060608486031215612e8957612e8861295a565b5b6000612e97868287016129ad565b9350506020612ea8868287016129e3565b925050604084013567ffffffffffffffff811115612ec957612ec861295f565b5b612ed586828701612e42565b9150509250925092565b600080600080600080600060e0888a031215612efe57612efd61295a565b5b6000612f0c8a828b016129ad565b9750506020612f1d8a828b016129ad565b9650506040612f2e8a828b016129e3565b9550506060612f3f8a828b016129e3565b9450506080612f508a828b01612c6d565b93505060a0612f618a828b01612c99565b92505060c0612f728a828b01612c99565b91505092959891949750929550565b60008060408385031215612f9857612f9761295a565b5b6000612fa6858286016129ad565b9250506020612fb7858286016129ad565b9150509250929050565b612fca81612c1c565b8114612fd557600080fd5b50565b600081359050612fe781612fc1565b92915050565b600080604083850312156130045761300361295a565b5b6000613012858286016129ad565b925050602061302385828601612fd8565b9150509250929050565b61303681612c1c565b82525050565b61304581612b56565b82525050565b604082016000820151613061600085018261302d565b506020820151613074602085018261303c565b50505050565b600060408201905061308f600083018461304b565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806130dc57607f821691505b602082108114156130f0576130ef613095565b5b50919050565b7f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b60006131526021836128a0565b915061315d826130f6565b604082019050919050565b6000602082019050818103600083015261318181613145565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006131c2826129c2565b91506131cd836129c2565b9250828210156131e0576131df613188565b5b828203905092915050565b7f4d696e7420746f20746865207a65726f20616464726573730000000000000000600082015250565b60006132216018836128a0565b915061322c826131eb565b602082019050919050565b6000602082019050818103600083015261325081613214565b9050919050565b6000613262826129c2565b915061326d836129c2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156132a2576132a1613188565b5b828201905092915050565b7f4275726e20616d6f756e74206578636565647320616c6c6f77616e6365000000600082015250565b60006132e3601d836128a0565b91506132ee826132ad565b602082019050919050565b60006020820190508181036000830152613312816132d6565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f44656c65676174696f6e20657870697265640000000000000000000000000000600082015250565b600061337e6012836128a0565b915061338982613348565b602082019050919050565b600060208201905081810360008301526133ad81613371565b9050919050565b7f496e76616c6964207369676e6174757265202773272076616c75650000000000600082015250565b60006133ea601b836128a0565b91506133f5826133b4565b602082019050919050565b60006020820190508181036000830152613419816133dd565b9050919050565b7f496e76616c6964207369676e6174757265202776272076616c75650000000000600082015250565b6000613456601b836128a0565b915061346182613420565b602082019050919050565b6000602082019050818103600083015261348581613449565b9050919050565b6000613497826129c2565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156134ca576134c9613188565b5b600182019050919050565b60006080820190506134ea6000830187612af5565b6134f76020830186612bf2565b6135046040830185612a6e565b6135116060830184612a6e565b95945050505050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b600061355b60028361351a565b915061356682613525565b600282019050919050565b6000819050919050565b61358c61358782612aeb565b613571565b82525050565b600061359d8261354e565b91506135a9828561357b565b6020820191506135b9828461357b565b6020820191508190509392505050565b60006080820190506135de6000830187612af5565b6135eb6020830186612b2c565b6135f86040830185612af5565b6136056060830184612af5565b95945050505050565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b60006136446011836128a0565b915061364f8261360e565b602082019050919050565b6000602082019050818103600083015261367381613637565b9050919050565b600081519050919050565b600082825260208201905092915050565b60006136a18261367a565b6136ab8185613685565b93506136bb8185602086016128b1565b6136c4816128e4565b840191505092915050565b60006080820190506136e46000830187612bf2565b6136f16020830186612a6e565b6136fe6040830185612bf2565b81810360608301526137108184613696565b905095945050505050565b7f5065726d697373696f6e20657870697265640000000000000000000000000000600082015250565b60006137516012836128a0565b915061375c8261371b565b602082019050919050565b6000602082019050818103600083015261378081613744565b9050919050565b600060c08201905061379c6000830189612af5565b6137a96020830188612bf2565b6137b66040830187612bf2565b6137c36060830186612a6e565b6137d06080830185612a6e565b6137dd60a0830184612a6e565b979650505050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b60006138446026836128a0565b915061384f826137e8565b604082019050919050565b6000602082019050818103600083015261387381613837565b9050919050565b7f417070726f76652066726f6d20746865207a65726f2061646472657373000000600082015250565b60006138b0601d836128a0565b91506138bb8261387a565b602082019050919050565b600060208201905081810360008301526138df816138a3565b9050919050565b7f417070726f766520746f20746865207a65726f20616464726573730000000000600082015250565b600061391c601b836128a0565b9150613927826138e6565b602082019050919050565b6000602082019050818103600083015261394b8161390f565b9050919050565b7f5472616e736665722066726f6d20746865207a65726f20616464726573730000600082015250565b6000613988601e836128a0565b915061399382613952565b602082019050919050565b600060208201905081810360008301526139b78161397b565b9050919050565b7f5472616e7366657220746f20746865207a65726f206164647265737300000000600082015250565b60006139f4601c836128a0565b91506139ff826139be565b602082019050919050565b60006020820190508181036000830152613a23816139e7565b9050919050565b7f5472616e7366657220746f2074686520746f6b656e2061646472657373000000600082015250565b6000613a60601d836128a0565b9150613a6b82613a2a565b602082019050919050565b60006020820190508181036000830152613a8f81613a53565b9050919050565b7f5472616e7366657220616d6f756e7420657863656564732062616c616e636500600082015250565b6000613acc601f836128a0565b9150613ad782613a96565b602082019050919050565b60006020820190508181036000830152613afb81613abf565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154613b2f816130c4565b613b398186613b02565b94506001821660008114613b545760018114613b6557613b98565b60ff19831686528186019350613b98565b613b6e85613b0d565b60005b83811015613b9057815481890152600182019150602081019050613b71565b838801955050505b50505092915050565b6000613bad8284613b22565b915081905092915050565b600060a082019050613bcd6000830188612af5565b613bda6020830187612af5565b613be76040830186612af5565b613bf46060830185612a6e565b613c016080830184612bf2565b9695505050505050565b7f426c6f636b206e6f74207965742064657465726d696e65640000000000000000600082015250565b6000613c416018836128a0565b9150613c4c82613c0b565b602082019050919050565b60006020820190508181036000830152613c7081613c34565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613cad6020836128a0565b9150613cb882613c77565b602082019050919050565b60006020820190508181036000830152613cdc81613ca0565b9050919050565b7f4d6178696d756d20746f74616c20737570706c79206578636565646564000000600082015250565b6000613d19601d836128a0565b9150613d2482613ce3565b602082019050919050565b60006020820190508181036000830152613d4881613d0c565b9050919050565b7f4275726e20616d6f756e7420657863656564732062616c616e63650000000000600082015250565b6000613d85601b836128a0565b9150613d9082613d4f565b602082019050919050565b60006020820190508181036000830152613db481613d78565b9050919050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203360008201527f3220626974730000000000000000000000000000000000000000000000000000602082015250565b6000613e176026836128a0565b9150613e2282613dbb565b604082019050919050565b60006020820190508181036000830152613e4681613e0a565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000613e87826129c2565b9150613e92836129c2565b925082613ea257613ea1613e4d565b5b828204905092915050565b6000604082019050613ec26000830185612a6e565b613ecf6020830184612a6e565b9392505050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e203960008201527f3620626974730000000000000000000000000000000000000000000000000000602082015250565b6000613f326026836128a0565b9150613f3d82613ed6565b604082019050919050565b60006020820190508181036000830152613f6181613f25565b905091905056fea264697066735822122080c4ea65fe927ddc01a672c8707e7276fbf471d1a5c285c9638eb1806c347c3764736f6c63430008090033", + "devdoc": { + "kind": "dev", + "methods": { + "approve(address,uint256)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729", + "returns": { + "_0": "True if the operation succeeded." + } + }, + "approveAndCall(address,uint256,bytes)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.", + "returns": { + "_0": "True if both approval and `receiveApproval` calls succeeded." + } + }, + "burn(uint256)": { + "details": "Requirements: - the caller must have a balance of at least `amount`." + }, + "burnFrom(address,uint256)": { + "details": "Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`." + }, + "delegate(address)": { + "params": { + "delegatee": "The address to delegate votes to" + } + }, + "delegateBySig(address,address,uint256,uint8,bytes32,bytes32)": { + "params": { + "deadline": "The time at which to expire the signature", + "delegatee": "The address to delegate votes to", + "r": "Half of the ECDSA signature pair", + "s": "Half of the ECDSA signature pair", + "v": "The recovery byte of the signature" + } + }, + "getPastTotalSupply(uint256)": { + "details": "`blockNumber` must have been already mined", + "params": { + "blockNumber": "The block number to get the total supply at" + } + }, + "getPastVotes(address,uint256)": { + "details": "Block number must be a finalized block or else this function will revert to prevent misinformation.", + "params": { + "account": "The address of the account to check", + "blockNumber": "The block number to get the vote balance at" + }, + "returns": { + "_0": "The number of votes the account had as of the given block" + } + }, + "getVotes(address)": { + "params": { + "account": "The address to get votes balance" + }, + "returns": { + "_0": "The number of current votes for `account`" + } + }, + "mint(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "details": "The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transfer(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferFrom(address,address,uint256)": { + "details": "Requirements: - `spender` and `recipient` cannot be the zero address, - `spender` must have a balance of at least `amount`, - the caller must have allowance for `spender`'s tokens of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "UnderwriterToken", + "version": 1 + }, + "userdoc": { + "events": { + "DelegateChanged(address,address,address)": { + "notice": "Emitted when an account changes their delegate." + }, + "DelegateVotesChanged(address,uint256,uint256)": { + "notice": "Emitted when a balance or delegate change results in changes to an account's voting power." + } + }, + "kind": "user", + "methods": { + "DELEGATION_TYPEHASH()": { + "notice": "The EIP-712 typehash for the delegation struct used by `delegateBySig`." + }, + "DOMAIN_SEPARATOR()": { + "notice": "Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function." + }, + "PERMIT_TYPEHASH()": { + "notice": "Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function." + }, + "allowance(address,address)": { + "notice": "The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default." + }, + "approve(address,uint256)": { + "notice": "Sets `amount` as the allowance of `spender` over the caller's tokens." + }, + "approveAndCall(address,uint256,bytes)": { + "notice": "Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted." + }, + "balanceOf(address)": { + "notice": "The amount of tokens owned by the given account." + }, + "burn(uint256)": { + "notice": "Destroys `amount` tokens from the caller." + }, + "burnFrom(address,uint256)": { + "notice": "Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + }, + "decimals()": { + "notice": "The decimals places of the token." + }, + "delegate(address)": { + "notice": "Delegate votes from `msg.sender` to `delegatee`." + }, + "delegateBySig(address,address,uint256,uint8,bytes32,bytes32)": { + "notice": "Delegates votes from signatory to `delegatee`" + }, + "delegates(address)": { + "notice": "Get the address `account` is currently delegating to." + }, + "getPastTotalSupply(uint256)": { + "notice": "Retrieve the `totalSupply` at the end of `blockNumber`. Note, this value is the sum of all balances, but it is NOT the sum of all the delegated votes!" + }, + "getPastVotes(address,uint256)": { + "notice": "Determine the prior number of votes for an account as of a block number." + }, + "getVotes(address)": { + "notice": "Gets the current votes balance for `account`." + }, + "mint(address,uint256)": { + "notice": "Creates `amount` tokens and assigns them to `account`, increasing the total supply." + }, + "name()": { + "notice": "The name of the token." + }, + "nonce(address)": { + "notice": "Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function." + }, + "numCheckpoints(address)": { + "notice": "Get number of checkpoints for `account`." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "notice": "EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction." + }, + "symbol()": { + "notice": "The symbol of the token." + }, + "totalSupply()": { + "notice": "The amount of tokens in existence." + }, + "transfer(address,uint256)": { + "notice": "Moves `amount` tokens from the caller's account to `recipient`." + }, + "transferFrom(address,address,uint256)": { + "notice": "Moves `amount` tokens from `spender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + } + }, + "notice": "Underwriter tokens represent an ownership share in the underlying collateral of the asset-specific pool. Underwriter tokens are minted when a user deposits ERC20 tokens into asset-specific pool and they are burned when a user exits the position. Underwriter tokens natively support meta transactions. Users can authorize a transfer of their underwriter tokens with a signature conforming EIP712 standard instead of an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, as specified in EIP2612 standard, paying gas fees, and possibly performing other actions in the same transaction.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 488, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 3955, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "balanceOf", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 3963, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "allowance", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 3969, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "nonce", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 3984, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "totalSupply", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 3988, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "name", + "offset": 0, + "slot": "5", + "type": "t_string_storage" + }, + { + "astId": 3992, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "symbol", + "offset": 0, + "slot": "6", + "type": "t_string_storage" + }, + { + "astId": 4788, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_delegates", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_address)" + }, + { + "astId": 4793, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_checkpoints", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_array(t_uint128)dyn_storage)" + }, + { + "astId": 4796, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "_totalSupplyCheckpoints", + "offset": 0, + "slot": "9", + "type": "t_array(t_uint128)dyn_storage" + }, + { + "astId": 4800, + "contract": "contracts/UnderwriterToken.sol:UnderwriterToken", + "label": "__gap", + "offset": 0, + "slot": "10", + "type": "t_array(t_uint256)47_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint128)dyn_storage": { + "base": "t_uint128", + "encoding": "dynamic_array", + "label": "uint128[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)47_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_mapping(t_address,t_address)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => address)", + "numberOfBytes": "32", + "value": "t_address" + }, + "t_mapping(t_address,t_array(t_uint128)dyn_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint128[])", + "numberOfBytes": "32", + "value": "t_array(t_uint128)dyn_storage" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint128": { + "encoding": "inplace", + "label": "uint128", + "numberOfBytes": "16" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json b/deployments/mainnet/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json new file mode 100644 index 00000000..8c3edbba --- /dev/null +++ b/deployments/mainnet/solcInputs/1f648bbc62fc09e530210f2d58cb219e.json @@ -0,0 +1,198 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.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 /**\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 / b + (a % b == 0 ? 0 : 1);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@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" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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 Context {\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" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.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 IERC165 {\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" + }, + "@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 // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `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" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/clone/CloneFactory.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.5;\n\n/*\nThe MIT License (MIT)\nCopyright (c) 2018 Murray Software, LLC.\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n/// @notice Implementation of [EIP-1167] based on [clone-factory]\n/// source code.\n///\n/// EIP 1167: https://eips.ethereum.org/EIPS/eip-1167\n// Original implementation: https://github.com/optionality/clone-factory\n// Modified to use ^0.8.5; instead of ^0.4.23 solidity version.\n/* solhint-disable no-inline-assembly */\nabstract contract CloneFactory {\n /// @notice Creates EIP-1167 clone of the contract under the provided\n /// `target` address. Returns address of the created clone.\n /// @dev In specific circumstances, such as the `target` contract destroyed,\n /// create opcode may return 0x0 address. The code calling this\n /// function should handle this corner case properly.\n function createClone(address target) internal returns (address result) {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000\n )\n mstore(add(clone, 0x14), targetBytes)\n mstore(\n add(clone, 0x28),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n result := create(0, clone, 0x37)\n }\n }\n\n /// @notice Checks if the contract under the `query` address is a EIP-1167\n /// clone of the contract under `target` address.\n function isClone(address target, address query)\n internal\n view\n returns (bool result)\n {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000\n )\n mstore(add(clone, 0xa), targetBytes)\n mstore(\n add(clone, 0x1e),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n\n let other := add(clone, 0x40)\n extcodecopy(query, other, 0, 0x2d)\n result := and(\n eq(mload(clone), mload(other)),\n eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))\n )\n }\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport \"./IERC20WithPermit.sol\";\nimport \"./IReceiveApproval.sol\";\n\n/// @title ERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\n /// @notice The amount of tokens owned by the given account.\n mapping(address => uint256) public override balanceOf;\n\n /// @notice The remaining number of tokens that spender will be\n /// allowed to spend on behalf of owner through `transferFrom` and\n /// `burnFrom`. This is zero by default.\n mapping(address => mapping(address => uint256)) public override allowance;\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n mapping(address => uint256) public override nonce;\n\n uint256 public immutable cachedChainId;\n bytes32 public immutable cachedDomainSeparator;\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n bytes32 public constant override PERMIT_TYPEHASH =\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n /// @notice The amount of tokens in existence.\n uint256 public override totalSupply;\n\n /// @notice The name of the token.\n string public override name;\n\n /// @notice The symbol of the token.\n string public override symbol;\n\n /// @notice The decimals places of the token.\n uint8 public constant override decimals = 18;\n\n constructor(string memory _name, string memory _symbol) {\n name = _name;\n symbol = _symbol;\n\n cachedChainId = block.chainid;\n cachedDomainSeparator = buildDomainSeparator();\n }\n\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address,\n /// - the caller must have a balance of at least `amount`.\n function transfer(address recipient, uint256 amount)\n external\n override\n returns (bool)\n {\n _transfer(msg.sender, recipient, amount);\n return true;\n }\n\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\n /// allowance mechanism. `amount` is then deducted from the caller's\n /// allowance unless the allowance was made for `type(uint256).max`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `spender` and `recipient` cannot be the zero address,\n /// - `spender` must have a balance of at least `amount`,\n /// - the caller must have allowance for `spender`'s tokens of at least\n /// `amount`.\n function transferFrom(\n address spender,\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n uint256 currentAllowance = allowance[spender][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Transfer amount exceeds allowance\"\n );\n _approve(spender, msg.sender, currentAllowance - amount);\n }\n _transfer(spender, recipient, amount);\n return true;\n }\n\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire. If the `amount` is set\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\n /// not reduce an allowance.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Permission expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n PERMIT_TYPEHASH,\n owner,\n spender,\n amount,\n nonce[owner]++,\n deadline\n )\n )\n )\n );\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == owner,\n \"Invalid signature\"\n );\n _approve(owner, spender, amount);\n }\n\n /// @notice Creates `amount` tokens and assigns them to `account`,\n /// increasing the total supply.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address.\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(recipient != address(0), \"Mint to the zero address\");\n\n beforeTokenTransfer(address(0), recipient, amount);\n\n totalSupply += amount;\n balanceOf[recipient] += amount;\n emit Transfer(address(0), recipient, amount);\n }\n\n /// @notice Destroys `amount` tokens from the caller.\n /// @dev Requirements:\n /// - the caller must have a balance of at least `amount`.\n function burn(uint256 amount) external override {\n _burn(msg.sender, amount);\n }\n\n /// @notice Destroys `amount` of tokens from `account` using the allowance\n /// mechanism. `amount` is then deducted from the caller's allowance\n /// unless the allowance was made for `type(uint256).max`.\n /// @dev Requirements:\n /// - `account` must have a balance of at least `amount`,\n /// - the caller must have allowance for `account`'s tokens of at least\n /// `amount`.\n function burnFrom(address account, uint256 amount) external override {\n uint256 currentAllowance = allowance[account][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Burn amount exceeds allowance\"\n );\n _approve(account, msg.sender, currentAllowance - amount);\n }\n _burn(account, amount);\n }\n\n /// @notice Calls `receiveApproval` function on spender previously approving\n /// the spender to withdraw from the caller multiple times, up to\n /// the `amount` amount. If this function is called again, it\n /// overwrites the current allowance with `amount`. Reverts if the\n /// approval reverted or if `receiveApproval` call on the spender\n /// reverted.\n /// @return True if both approval and `receiveApproval` calls succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external override returns (bool) {\n if (approve(spender, amount)) {\n IReceiveApproval(spender).receiveApproval(\n msg.sender,\n amount,\n address(this),\n extraData\n );\n return true;\n }\n return false;\n }\n\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\n /// tokens.\n /// @return True if the operation succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n /// Beware that changing an allowance with this method brings the risk\n /// that someone may use both the old and the new allowance by\n /// unfortunate transaction ordering. One possible solution to mitigate\n /// this race condition is to first reduce the spender's allowance to 0\n /// and set the desired value afterwards:\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n function approve(address spender, uint256 amount)\n public\n override\n returns (bool)\n {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\n // chainId and is defined at contract deployment instead of\n // reconstructed for every signature, there is a risk of possible replay\n // attacks between chains in the event of a future chain split.\n // To address this issue, we check the cached chain ID against the\n // current one and in case they are different, we build domain separator\n // from scratch.\n if (block.chainid == cachedChainId) {\n return cachedDomainSeparator;\n } else {\n return buildDomainSeparator();\n }\n }\n\n /// @dev Hook that is called before any transfer of tokens. This includes\n /// minting and burning.\n ///\n /// Calling conditions:\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\n /// will be to transferred to `to`.\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n /// - `from` and `to` are never both zero.\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _burn(address account, uint256 amount) internal {\n uint256 currentBalance = balanceOf[account];\n require(currentBalance >= amount, \"Burn amount exceeds balance\");\n\n beforeTokenTransfer(account, address(0), amount);\n\n balanceOf[account] = currentBalance - amount;\n totalSupply -= amount;\n emit Transfer(account, address(0), amount);\n }\n\n function _transfer(\n address spender,\n address recipient,\n uint256 amount\n ) private {\n require(spender != address(0), \"Transfer from the zero address\");\n require(recipient != address(0), \"Transfer to the zero address\");\n require(recipient != address(this), \"Transfer to the token address\");\n\n beforeTokenTransfer(spender, recipient, amount);\n\n uint256 spenderBalance = balanceOf[spender];\n require(spenderBalance >= amount, \"Transfer amount exceeds balance\");\n balanceOf[spender] = spenderBalance - amount;\n balanceOf[recipient] += amount;\n emit Transfer(spender, recipient, amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) private {\n require(owner != address(0), \"Approve from the zero address\");\n require(spender != address(0), \"Approve to the zero address\");\n allowance[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function buildDomainSeparator() private view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n ),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n block.chainid,\n address(this)\n )\n );\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by tokens supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IApproveAndCall {\n /// @notice Executes `receiveApproval` function on spender as specified in\n /// `IReceiveApproval` interface. Approves spender to withdraw from\n /// the caller multiple times, up to the `amount`. If this\n /// function is called again, it overwrites the current allowance\n /// with `amount`. Reverts if the approval reverted or if\n /// `receiveApproval` call on the spender reverted.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external returns (bool);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"./IApproveAndCall.sol\";\n\n/// @title IERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /// @notice Destroys `amount` tokens from the caller.\n function burn(uint256 amount) external;\n\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\n /// from caller's allowance.\n function burnFrom(address account, uint256 amount) external;\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n function nonce(address owner) external view returns (uint256);\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n /* solhint-disable-next-line func-name-mixedcase */\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by contracts supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IReceiveApproval {\n /// @notice Receives approval to spend tokens. Called as a result of\n /// `approveAndCall` call on the token.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external;\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title MisfundRecovery\n/// @notice Allows the owner of the token contract extending MisfundRecovery\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\n/// contract address.\ncontract MisfundRecovery is Ownable {\n using SafeERC20 for IERC20;\n\n function recoverERC20(\n IERC20 token,\n address recipient,\n uint256 amount\n ) external onlyOwner {\n token.safeTransfer(recipient, amount);\n }\n\n function recoverERC721(\n IERC721 token,\n address recipient,\n uint256 tokenId,\n bytes calldata data\n ) external onlyOwner {\n token.safeTransferFrom(address(this), recipient, tokenId, data);\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"./IVotesHistory.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\";\n\n/// @title Checkpoints\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\n/// delegation. This implementation supports token supply up to 2^96 - 1.\n/// This contract keeps a history (checkpoints) of each account's vote\n/// power. Vote power can be delegated either by calling the {delegate}\n/// function directly, or by providing a signature to be used with\n/// {delegateBySig}. Voting power can be publicly queried through\n/// {getVotes} and {getPastVotes}.\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\n/// @dev This contract is upgrade-safe.\nabstract contract Checkpoints is IVotesHistory {\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n // slither-disable-next-line uninitialized-state\n mapping(address => address) internal _delegates;\n mapping(address => uint128[]) internal _checkpoints;\n uint128[] internal _totalSupplyCheckpoints;\n\n // Reserved storage space in case we need to add more variables,\n // since there are upgradeable contracts that inherit from this one.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[47] private __gap;\n\n /// @notice Emitted when an account changes their delegate.\n event DelegateChanged(\n address indexed delegator,\n address indexed fromDelegate,\n address indexed toDelegate\n );\n\n /// @notice Emitted when a balance or delegate change results in changes\n /// to an account's voting power.\n event DelegateVotesChanged(\n address indexed delegate,\n uint256 previousBalance,\n uint256 newBalance\n );\n\n function checkpoints(address account, uint32 pos)\n public\n view\n virtual\n returns (Checkpoint memory checkpoint)\n {\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\n _checkpoints[account][pos]\n );\n checkpoint = Checkpoint(fromBlock, votes);\n }\n\n /// @notice Get number of checkpoints for `account`.\n function numCheckpoints(address account)\n public\n view\n virtual\n returns (uint32)\n {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /// @notice Get the address `account` is currently delegating to.\n function delegates(address account) public view virtual returns (address) {\n return _delegates[account];\n }\n\n /// @notice Gets the current votes balance for `account`.\n /// @param account The address to get votes balance\n /// @return The number of current votes for `account`\n function getVotes(address account) public view returns (uint96) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\n }\n\n /// @notice Determine the prior number of votes for an account as of\n /// a block number.\n /// @dev Block number must be a finalized block or else this function will\n /// revert to prevent misinformation.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_checkpoints[account], blockNumber);\n }\n\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\n /// Note, this value is the sum of all balances, but it is NOT the\n /// sum of all the delegated votes!\n /// @param blockNumber The block number to get the total supply at\n /// @dev `blockNumber` must have been already mined\n function getPastTotalSupply(uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\n }\n\n /// @notice Change delegation for `delegator` to `delegatee`.\n // slither-disable-next-line dead-code\n function delegate(address delegator, address delegatee) internal virtual;\n\n /// @notice Moves voting power from one delegate to another\n /// @param src Address of old delegate\n /// @param dst Address of new delegate\n /// @param amount Voting power amount to transfer between delegates\n function moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) internal {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n // https://github.com/crytic/slither/issues/960\n // slither-disable-next-line variable-scope\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[src],\n subtract,\n amount\n );\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n // https://github.com/crytic/slither/issues/959\n // slither-disable-next-line uninitialized-local\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[dst],\n add,\n amount\n );\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n /// @notice Writes a new checkpoint based on operating last stored value\n /// with a `delta`. Usually, said operation is the `add` or\n /// `subtract` functions from this contract, but more complex\n /// functions can be passed as parameters.\n /// @param ckpts The checkpoints array to use\n /// @param op The function to apply over the last value and the `delta`\n /// @param delta Variation with respect to last stored value to be used\n /// for new checkpoint\n function writeCheckpoint(\n uint128[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\n newWeight = op(oldWeight, delta);\n\n if (pos > 0) {\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\n // slither-disable-next-line incorrect-equality\n if (fromBlock == block.number) {\n ckpts[pos - 1] = encodeCheckpoint(\n fromBlock,\n SafeCastUpgradeable.toUint96(newWeight)\n );\n return (oldWeight, newWeight);\n }\n }\n\n ckpts.push(\n encodeCheckpoint(\n SafeCastUpgradeable.toUint32(block.number),\n SafeCastUpgradeable.toUint96(newWeight)\n )\n );\n }\n\n /// @notice Lookup a value in a list of (sorted) checkpoints.\n /// @param ckpts The checkpoints array to use\n /// @param blockNumber Block number when we want to get the checkpoint at\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\n internal\n view\n returns (uint96)\n {\n // We run a binary search to look for the earliest checkpoint taken\n // after `blockNumber`. During the loop, the index of the wanted\n // checkpoint remains in the range [low-1, high). With each iteration,\n // either `low` or `high` is moved towards the middle of the range to\n // maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`,\n // we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`,\n // we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the\n // right checkpoint at the index high-1, if not out of bounds (in that\n // case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for\n // `blockNumber`, we end up with an index that is past the end of the\n // array, so we technically don't find a checkpoint after\n // `blockNumber`, but it works out the same.\n require(blockNumber < block.number, \"Block not yet determined\");\n\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\n if (midBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\n }\n\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\n // slither-disable-next-line dead-code\n function maxSupply() internal view virtual returns (uint96) {\n return type(uint96).max;\n }\n\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\n /// checkpoint.\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\n /// remaining 96 bits.\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\n internal\n pure\n returns (uint128)\n {\n return (uint128(blockNumber) << 96) | uint128(value);\n }\n\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\n function decodeBlockNumber(uint128 checkpoint)\n internal\n pure\n returns (uint32)\n {\n return uint32(bytes4(bytes16(checkpoint)));\n }\n\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\n return uint96(checkpoint);\n }\n\n /// @notice Decodes a block number and voting value from a `uint128`\n /// `checkpoint`.\n function decodeCheckpoint(uint128 checkpoint)\n internal\n pure\n returns (uint32 blockNumber, uint96 value)\n {\n blockNumber = decodeBlockNumber(checkpoint);\n value = decodeValue(checkpoint);\n }\n\n // slither-disable-next-line dead-code\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n // slither-disable-next-line dead-code\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\ninterface IVotesHistory {\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n\n function getPastTotalSupply(uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"../governance/Checkpoints.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\";\n\n/// @title T token\n/// @notice Threshold Network T token\n/// @dev By default, token balance does not account for voting power.\n/// This makes transfers cheaper. The downside is that it requires users\n/// to delegate to themselves to activate checkpoints and have their\n/// voting power tracked.\ncontract T is ERC20WithPermit, MisfundRecovery, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor() ERC20WithPermit(\"Threshold Network Token\", \"T\") {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n uint96 safeAmount = SafeCast.toUint96(amount);\n\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, safeAmount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, safeAmount);\n }\n\n moveVotingPower(delegates(from), delegates(to), safeAmount);\n }\n\n function delegate(address delegator, address delegatee)\n internal\n virtual\n override\n {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/AssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPool.sol\";\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./RewardsPool.sol\";\nimport \"./UnderwriterToken.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Asset Pool\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\n/// accepts a single ERC20 token as collateral, and returns an\n/// underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\n/// as a deposit. It means that the total supply of the collateral token\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\n/// acceptable that not all tokens can be deposited into the pool.\ncontract AssetPool is Ownable, IAssetPool {\n using SafeERC20 for ICollateralToken;\n using SafeERC20 for UnderwriterToken;\n\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n RewardsPool public immutable rewardsPool;\n\n IAssetPoolUpgrade public newAssetPool;\n\n /// @notice The time it takes the underwriter to withdraw their collateral\n /// and rewards from the pool. This is the time that needs to pass\n /// between initiating and completing the withdrawal. During that\n /// time, underwriter is still earning rewards and their share of\n /// the pool is still a subject of a possible coverage claim.\n uint256 public withdrawalDelay = 21 days;\n uint256 public newWithdrawalDelay;\n uint256 public withdrawalDelayChangeInitiated;\n\n /// @notice The time the underwriter has after the withdrawal delay passed\n /// to complete the withdrawal. During that time, underwriter is\n /// still earning rewards and their share of the pool is still\n /// a subject of a possible coverage claim.\n /// After the withdrawal timeout elapses, tokens stay in the pool\n /// and the underwriter has to initiate the withdrawal again and\n /// wait for the full withdrawal delay to complete the withdrawal.\n uint256 public withdrawalTimeout = 2 days;\n uint256 public newWithdrawalTimeout;\n uint256 public withdrawalTimeoutChangeInitiated;\n\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\n mapping(address => uint256) public pendingWithdrawal;\n\n event Deposited(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount\n );\n\n event CoverageClaimed(\n address indexed recipient,\n uint256 amount,\n uint256 timestamp\n );\n\n event WithdrawalInitiated(\n address indexed underwriter,\n uint256 covAmount,\n uint256 timestamp\n );\n event WithdrawalCompleted(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event ApprovedAssetPoolUpgrade(address newAssetPool);\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\n event AssetPoolUpgraded(\n address indexed underwriter,\n uint256 collateralAmount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event WithdrawalDelayUpdateStarted(\n uint256 withdrawalDelay,\n uint256 timestamp\n );\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\n event WithdrawalTimeoutUpdateStarted(\n uint256 withdrawalTimeout,\n uint256 timestamp\n );\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\n\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\n /// if the change was not yet initiated.\n /// @param changeInitiatedTimestamp The timestamp at which the change has\n /// been initiated\n modifier onlyAfterWithdrawalGovernanceDelay(\n uint256 changeInitiatedTimestamp\n ) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >=\n withdrawalGovernanceDelay(),\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n constructor(\n ICollateralToken _collateralToken,\n UnderwriterToken _underwriterToken,\n address rewardsManager\n ) {\n collateralToken = _collateralToken;\n underwriterToken = _underwriterToken;\n\n rewardsPool = new RewardsPool(\n _collateralToken,\n address(this),\n rewardsManager\n );\n\n initGovernance(_collateralToken);\n }\n\n /// @dev Overwrite to empty if collateral token used by the AssetPool\n /// does not support DAO checkpoints. Used for tests with KEEP token.\n function initGovernance(ICollateralToken _collateralToken)\n internal\n virtual\n {\n _collateralToken.delegate(address(this));\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// Optional data in extraData may include a minimal amount of\n /// underwriter tokens expected to be minted for a depositor. There\n /// are cases when an amount of minted tokens matters for a\n /// depositor, as tokens might be used in third party exchanges.\n /// @dev This function is a shortcut for approve + deposit.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external {\n require(\n amount + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n require(msg.sender == token, \"Only token caller allowed\");\n require(\n token == address(collateralToken),\n \"Unsupported collateral token\"\n );\n\n uint256 toMint = _calculateTokensToMint(amount);\n if (extraData.length != 0) {\n require(extraData.length == 32, \"Unexpected data length\");\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n }\n\n _deposit(from, amount, toMint);\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal to\n /// 2^96-1\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amountToDeposit)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership. The amount locked in the pool after accepting\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\n /// function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal\n /// to 2^96-1\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\n /// expects to receive in exchange for the deposited\n /// collateral tokens\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Initiates the withdrawal of collateral and rewards from the\n /// pool. Must be followed with completeWithdrawal call after the\n /// withdrawal delay passes. Accepts the amount of underwriter\n /// tokens representing the share of the pool that should be\n /// withdrawn. Can be called multiple times increasing the pool share\n /// to withdraw and resetting the withdrawal initiated timestamp for\n /// each call. Can be called with 0 covAmount to reset the\n /// withdrawal initiated timestamp if the underwriter has a pending\n /// withdrawal. In practice 0 covAmount should be used only to\n /// initiate the withdrawal again in case one did not complete the\n /// withdrawal before the withdrawal timeout elapsed.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external override {\n uint256 pending = pendingWithdrawal[msg.sender];\n require(\n covAmount > 0 || pending > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n pending += covAmount;\n pendingWithdrawal[msg.sender] = pending;\n /* solhint-disable not-rely-on-time */\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\n\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\n /* solhint-enable not-rely-on-time */\n\n if (covAmount > 0) {\n underwriterToken.safeTransferFrom(\n msg.sender,\n address(this),\n covAmount\n );\n }\n }\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter. Anyone can complete the withdrawal for the\n /// underwriter. The withdrawal has to be completed before the\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\n /// be initiated again and the underwriter has to wait for the\n /// entire withdrawal delay again before being able to complete\n /// the withdrawal.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter)\n external\n override\n returns (uint256)\n {\n /* solhint-disable not-rely-on-time */\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\n require(initiatedAt > 0, \"No withdrawal initiated for the underwriter\");\n\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\n require(\n withdrawalDelayEndTimestamp < block.timestamp,\n \"Withdrawal delay has not elapsed\"\n );\n\n require(\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\n \"Withdrawal timeout elapsed\"\n );\n\n uint256 covAmount = pendingWithdrawal[underwriter];\n uint256 covSupply = underwriterToken.totalSupply();\n delete withdrawalInitiatedTimestamp[underwriter];\n delete pendingWithdrawal[underwriter];\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\n\n emit WithdrawalCompleted(\n underwriter,\n amountToWithdraw,\n covAmount,\n block.timestamp\n );\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\n\n /* solhint-enable not-rely-on-time */\n underwriterToken.burn(covAmount);\n\n return amountToWithdraw;\n }\n\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\n /// was approved by the governance. Upgrade does not have to obey\n /// withdrawal delay.\n /// Old underwriter tokens are burned in favor of new tokens minted\n /// in a new Asset Pool. New tokens are sent directly to the\n /// underwriter from a new Asset Pool.\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\n /// tokens which are transferred to a new asset pool\n /// @param _newAssetPool New Asset Pool address to check validity with the one\n /// that was approved by the governance\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\n external\n {\n /* solhint-disable not-rely-on-time */\n require(\n address(newAssetPool) != address(0),\n \"New asset pool must be assigned\"\n );\n\n require(\n address(newAssetPool) == _newAssetPool,\n \"Addresses of a new asset pool must match\"\n );\n\n require(\n covAmount > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n uint256 covSupply = underwriterToken.totalSupply();\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\n covSupply;\n\n collateralToken.safeApprove(\n address(newAssetPool),\n collateralToTransfer\n );\n // old underwriter tokens are burned in favor of new minted in a new\n // asset pool\n underwriterToken.burnFrom(msg.sender, covAmount);\n // collateralToTransfer will be sent to a new AssetPool and new\n // underwriter tokens will be minted and transferred back to the underwriter\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\n\n emit AssetPoolUpgraded(\n msg.sender,\n collateralToTransfer,\n covAmount,\n block.timestamp\n );\n }\n\n /// @notice Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n require(\n address(_newAssetPool) != address(0),\n \"New asset pool can't be zero address\"\n );\n\n newAssetPool = _newAssetPool;\n\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\n }\n\n /// @notice Allows governance to cancel already approved new asset pool\n /// in case of some misconfiguration.\n function cancelNewAssetPoolUpgrade() external onlyOwner {\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\n\n newAssetPool = IAssetPoolUpgrade(address(0));\n }\n\n /// @notice Allows the coverage pool to demand coverage from the asset hold\n /// by this pool and send it to the provided recipient address.\n function claim(address recipient, uint256 amount) external onlyOwner {\n emit CoverageClaimed(recipient, amount, block.timestamp);\n rewardsPool.withdraw();\n require(\n amount <= collateralToken.balanceOf(address(this)),\n \"Amount to seize exceeds the pool balance\"\n );\n collateralToken.safeTransfer(recipient, amount);\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param _newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\n external\n onlyOwner\n {\n newWithdrawalDelay = _newWithdrawalDelay;\n withdrawalDelayChangeInitiated = block.timestamp;\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\n {\n withdrawalDelay = newWithdrawalDelay;\n emit WithdrawalDelayUpdated(withdrawalDelay);\n newWithdrawalDelay = 0;\n withdrawalDelayChangeInitiated = 0;\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\n external\n onlyOwner\n {\n newWithdrawalTimeout = _newWithdrawalTimeout;\n withdrawalTimeoutChangeInitiated = block.timestamp;\n emit WithdrawalTimeoutUpdateStarted(\n _newWithdrawalTimeout,\n block.timestamp\n );\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\n {\n withdrawalTimeout = newWithdrawalTimeout;\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\n newWithdrawalTimeout = 0;\n withdrawalTimeoutChangeInitiated = 0;\n }\n\n /// @notice Grants pool shares by minting a given amount of the underwriter\n /// tokens for the recipient address. In result, the recipient\n /// obtains part of the pool ownership without depositing any\n /// collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by the contract owner.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantShares(address recipient, uint256 covAmount)\n external\n onlyOwner\n {\n rewardsPool.withdraw();\n underwriterToken.mint(recipient, covAmount);\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal delay update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal delay update can be finalized\n function getRemainingWithdrawalDelayUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalDelayChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal timeout update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal timeout update can be finalized\n function getRemainingWithdrawalTimeoutUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalTimeoutChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the current collateral token balance of the asset pool\n /// plus the reward amount (in collateral token) earned by the asset\n /// pool and not yet withdrawn to the asset pool.\n /// @return The total value of asset pool in collateral token.\n function totalValue() public view returns (uint256) {\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\n }\n\n /// @notice The time it takes to initiate and complete the withdrawal from\n /// the pool plus 2 days to make a decision. This governance delay\n /// should be used for all changes directly affecting underwriter\n /// positions. This time is a minimum and the governance may choose\n /// to wait longer before finalizing the update.\n /// @return The withdrawal governance delay in seconds\n function withdrawalGovernanceDelay() public view returns (uint256) {\n return withdrawalDelay + withdrawalTimeout + 2 days;\n }\n\n /// @dev Calculates underwriter tokens to mint.\n function _calculateTokensToMint(uint256 amountToDeposit)\n internal\n returns (uint256)\n {\n rewardsPool.withdraw();\n\n uint256 covSupply = underwriterToken.totalSupply();\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n if (covSupply == 0) {\n return amountToDeposit;\n }\n\n return (amountToDeposit * covSupply) / collateralBalance;\n }\n\n function _deposit(\n address depositor,\n uint256 amountToDeposit,\n uint256 amountToMint\n ) internal {\n require(depositor != address(this), \"Self-deposit not allowed\");\n\n require(\n amountToMint > 0,\n \"Minted tokens amount must be greater than 0\"\n );\n\n emit Deposited(depositor, amountToDeposit, amountToMint);\n\n underwriterToken.mint(depositor, amountToMint);\n collateralToken.safeTransferFrom(\n depositor,\n address(this),\n amountToDeposit\n );\n }\n}\n" + }, + "contracts/Auction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAuction.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title Auction\n/// @notice A contract to run a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\n/// pool. Auctions can be partially filled, and are meant to be amenable\n/// to flash loans and other atomic constructions to take advantage of\n/// arbitrage opportunities within a single block.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// Auction contracts are not meant to be deployed directly, and are\n/// instead cloned by an auction factory. Auction contracts clean up and\n/// self-destruct on close. An auction that has run the entire length will\n/// stay open, forever, or until priced fluctuate and it's eventually\n/// profitable to close.\ncontract Auction is IAuction {\n using SafeERC20 for IERC20;\n\n struct AuctionStorage {\n IERC20 tokenAccepted;\n Auctioneer auctioneer;\n // the auction price, denominated in tokenAccepted\n uint256 amountOutstanding;\n uint256 amountDesired;\n uint256 startTime;\n uint256 startTimeOffset;\n uint256 auctionLength;\n }\n\n AuctionStorage public self;\n address public immutable masterContract;\n\n /// @notice Throws if called by any account other than the auctioneer.\n modifier onlyAuctioneer() {\n //slither-disable-next-line incorrect-equality\n require(\n msg.sender == address(self.auctioneer),\n \"Caller is not the auctioneer\"\n );\n\n _;\n }\n\n constructor() {\n masterContract = address(this);\n }\n\n /// @notice Initializes auction\n /// @dev At the beginning of an auction, velocity pool depleting rate is\n /// always 1. It increases over time after a partial auction buy.\n /// @param _auctioneer the auctioneer contract responsible for seizing\n /// funds from the backing collateral pool\n /// @param _tokenAccepted the token with which the auction can be taken\n /// @param _amountDesired the amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param _auctionLength the amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function initialize(\n Auctioneer _auctioneer,\n IERC20 _tokenAccepted,\n uint256 _amountDesired,\n uint256 _auctionLength\n ) external {\n require(!isMasterContract(), \"Can not initialize master contract\");\n //slither-disable-next-line incorrect-equality\n require(self.startTime == 0, \"Auction already initialized\");\n require(_amountDesired > 0, \"Amount desired must be greater than zero\");\n require(_auctionLength > 0, \"Auction length must be greater than zero\");\n self.auctioneer = _auctioneer;\n self.tokenAccepted = _tokenAccepted;\n self.amountOutstanding = _amountDesired;\n self.amountDesired = _amountDesired;\n /* solhint-disable-next-line not-rely-on-time */\n self.startTime = block.timestamp;\n self.startTimeOffset = 0;\n self.auctionLength = _auctionLength;\n }\n\n /// @notice Takes an offer from an auction buyer.\n /// @dev There are two possible ways to take an offer from a buyer. The first\n /// one is to buy entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// WARNING: When calling this function directly, it might happen that\n /// the expected amount of tokens to seize from the coverage pool is\n /// different from the actual one. There are a couple of reasons for that\n /// such another bids taking this offer, claims or withdrawals on an\n /// Asset Pool that are executed in the same block. The recommended way\n /// for taking an offer is through 'AuctionBidder' contract with\n /// 'takeOfferWithMin' function, where a caller can specify the minimal\n /// value to receive from the coverage pool in exchange for its amount\n /// of tokenAccepted.\n /// @param amount the amount the taker is paying, denominated in tokenAccepted.\n /// In the scenario when amount exceeds the outstanding tokens\n /// for the auction to complete, only the amount outstanding will\n /// be taken from a caller.\n function takeOffer(uint256 amount) external override {\n require(amount > 0, \"Can't pay 0 tokens\");\n uint256 amountToTransfer = Math.min(amount, self.amountOutstanding);\n uint256 amountOnOffer = _onOffer();\n\n //slither-disable-next-line reentrancy-no-eth\n self.tokenAccepted.safeTransferFrom(\n msg.sender,\n address(self.auctioneer),\n amountToTransfer\n );\n\n uint256 portionToSeize = (amountOnOffer * amountToTransfer) /\n self.amountOutstanding;\n\n if (!isAuctionOver() && amountToTransfer != self.amountOutstanding) {\n // Time passed since the auction start or the last takeOffer call\n // with a partial fill.\n\n\n uint256 timePassed /* solhint-disable-next-line not-rely-on-time */\n = block.timestamp - self.startTime - self.startTimeOffset;\n\n // Ratio of the auction's amount included in this takeOffer call to\n // the whole outstanding auction amount.\n uint256 ratioAmountPaid = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * amountToTransfer) /\n self.amountOutstanding;\n // We will shift the start time offset and increase the velocity pool\n // depleting rate proportionally to the fraction of the outstanding\n // amount paid in this function call so that the auction can offer\n // no worse financial outcome for the next takers than the current\n // taker has.\n //\n //slither-disable-next-line divide-before-multiply\n self.startTimeOffset =\n self.startTimeOffset +\n ((timePassed * ratioAmountPaid) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n self.amountOutstanding -= amountToTransfer;\n\n //slither-disable-next-line incorrect-equality\n bool isFullyFilled = self.amountOutstanding == 0;\n\n // inform auctioneer of proceeds and winner. the auctioneer seizes funds\n // from the collateral pool in the name of the winner, and controls all\n // proceeds\n //\n //slither-disable-next-line reentrancy-no-eth\n self.auctioneer.offerTaken(\n msg.sender,\n self.tokenAccepted,\n amountToTransfer,\n portionToSeize,\n isFullyFilled\n );\n\n //slither-disable-next-line incorrect-equality\n if (isFullyFilled) {\n harikari();\n }\n }\n\n /// @notice Tears down the auction manually, before its entire amount\n /// is bought by takers.\n /// @dev Can be called only by the auctioneer which may decide to early\n // close the auction in case it is no longer needed.\n function earlyClose() external onlyAuctioneer {\n require(self.amountOutstanding > 0, \"Auction must be open\");\n\n harikari();\n }\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @dev _onOffer() / FLOATING_POINT_DIVISOR) returns a portion of the\n /// collateral pool. Ex. if 35% available of the collateral pool,\n /// then _onOffer() / FLOATING_POINT_DIVISOR) returns 0.35\n /// @return the ratio of the collateral pool currently on offer\n function onOffer() external view override returns (uint256, uint256) {\n return (_onOffer(), CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n function amountOutstanding() external view returns (uint256) {\n return self.amountOutstanding;\n }\n\n function amountTransferred() external view returns (uint256) {\n return self.amountDesired - self.amountOutstanding;\n }\n\n /// @dev Delete all storage and destroy the contract. Should only be called\n /// after an auction has closed.\n function harikari() internal {\n require(!isMasterContract(), \"Master contract can not harikari\");\n selfdestruct(payable(address(self.auctioneer)));\n }\n\n function _onOffer() internal view returns (uint256) {\n // when the auction is over, entire pool is on offer\n if (isAuctionOver()) {\n // Down the road, for determining a portion on offer, a value returned\n // by this function will be divided by FLOATING_POINT_DIVISOR. To\n // return the entire pool, we need to return just this divisor in order\n // to get 1.0 ie. FLOATING_POINT_DIVISOR / FLOATING_POINT_DIVISOR = 1.0\n return CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n\n // How fast portions of the collateral pool become available on offer.\n // It is needed to calculate the right portion value on offer at the\n // given moment before the auction is over.\n // Auction length once set is constant and what changes is the auction's\n // \"start time offset\" once the takeOffer() call has been processed for\n // partial fill. The auction's \"start time offset\" is updated every takeOffer().\n // velocityPoolDepletingRate = auctionLength / (auctionLength - startTimeOffset)\n // velocityPoolDepletingRate always starts at 1.0 and then can go up\n // depending on partial offer calls over auction life span to maintain\n // the right ratio between the remaining auction time and the remaining\n // portion of the collateral pool.\n //slither-disable-next-line divide-before-multiply\n uint256 velocityPoolDepletingRate = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * self.auctionLength) /\n (self.auctionLength - self.startTimeOffset);\n\n return\n /* solhint-disable-next-line not-rely-on-time */\n ((block.timestamp - (self.startTime + self.startTimeOffset)) *\n velocityPoolDepletingRate) / self.auctionLength;\n }\n\n function isAuctionOver() internal view returns (bool) {\n /* solhint-disable-next-line not-rely-on-time */\n return block.timestamp >= self.startTime + self.auctionLength;\n }\n\n function isMasterContract() internal view returns (bool) {\n return masterContract == address(this);\n }\n}\n" + }, + "contracts/AuctionBidder.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\n/// @title AuctionBidder\n/// @notice A contract for auction bidders for buying coverage pool auctions. This\n/// contract offers additional features for bidders to decide if their\n/// requirements for making a purchase are satisfied.\ncontract AuctionBidder {\n CoveragePool public immutable coveragePool;\n\n constructor(CoveragePool _coveragePool) {\n coveragePool = _coveragePool;\n }\n\n /// @notice Takes an offer from an auction buyer with a minimum required amount\n /// of tokens to seize from the coverage pool.\n /// @dev This contract is used only for KEEP coverage pool in v1 that was\n /// depricated. Going forward T coverage pool will be used for v2.\n /// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n ///\n /// 'minAmountToSeize' sets a minimum amount of tokens to seize in this\n /// transaction. A bidder can call `takeOffer` directly in the Auction\n /// contract but this function is a recommended way of taking coverage pool\n /// auctions. It might happen that the order of transactions might be changed\n /// for 'takeOffer' calls in the same block or claim and withdrawals from\n /// an AssetPool might occur. These reasons can affect a taker's expected\n /// amount of the coverage pool tokens to receive. Whereas if a minimum\n /// amount of tokens is specified but not satisfied, then the transaction\n /// will revert.\n /// @param auction coverage pool auction\n /// @param amount the amount a taker is paying, denominated in token accepted\n /// by the auction\n /// @param minAmountToSeize minimum amount of tokens to seize from the coverage\n /// pool\n function takeOfferWithMin(\n Auction auction,\n uint256 amount,\n uint256 minAmountToSeize\n ) external {\n uint256 auctionAmountOutstanding = auction.amountOutstanding();\n uint256 amountToPay = Math.min(amount, auctionAmountOutstanding);\n (uint256 amountOnOffer, ) = auction.onOffer();\n uint256 portionToSeize = (amountOnOffer * amountToPay) /\n auctionAmountOutstanding;\n\n uint256 amountToSeize = coveragePool.amountToSeize(portionToSeize);\n\n require(\n minAmountToSeize <= amountToSeize,\n \"Can't fulfill offer with a minimal amount to seize\"\n );\n\n auction.takeOffer(amount);\n }\n}\n" + }, + "contracts/Auctioneer.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\nimport \"@thesis/solidity-contracts/contracts/clone/CloneFactory.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Auctioneer\n/// @notice Factory for the creation of new auction clones and receiving proceeds.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// We avoid redeployment of auction contracts by using the clone factory.\n/// Proxy delegates calls to Auction and therefore does not affect auction state.\n/// This means that we only need to deploy the auction contracts once.\n/// The auctioneer provides clean state for every new auction clone.\ncontract Auctioneer is CloneFactory {\n // Holds the address of the auction contract\n // which will be used as a master contract for cloning.\n address public immutable masterAuction;\n mapping(address => bool) public openAuctions;\n uint256 public openAuctionsCount;\n\n CoveragePool public immutable coveragePool;\n\n event AuctionCreated(\n address indexed tokenAccepted,\n uint256 amount,\n address auctionAddress\n );\n event AuctionOfferTaken(\n address indexed auction,\n address indexed offerTaker,\n address tokenAccepted,\n uint256 amount,\n uint256 portionToSeize // This amount should be divided by FLOATING_POINT_DIVISOR\n );\n event AuctionClosed(address indexed auction);\n\n constructor(CoveragePool _coveragePool, address _masterAuction) {\n coveragePool = _coveragePool;\n // slither-disable-next-line missing-zero-check\n masterAuction = _masterAuction;\n }\n\n /// @notice Informs the auctioneer to seize funds and log appropriate events\n /// @dev This function is meant to be called from a cloned auction. It logs\n /// \"offer taken\" and \"auction closed\" events, seizes funds, and cleans\n /// up closed auctions.\n /// @param offerTaker The address of the taker of the auction offer,\n /// who will receive the pool's seized funds\n /// @param tokenPaid The token this auction is denominated in\n /// @param tokenAmountPaid The amount of the token the taker paid\n /// @param portionToSeize The portion of the pool the taker won at auction.\n /// This amount should be divided by FLOATING_POINT_DIVISOR\n /// to calculate how much of the pool should be set\n /// aside as the taker's winnings.\n /// @param fullyFilled Indicates whether the auction was taken fully or\n /// partially. If auction was fully filled, it is\n /// closed. If auction was partially filled, it is\n /// sill open and waiting for remaining bids.\n function offerTaken(\n address offerTaker,\n IERC20 tokenPaid,\n uint256 tokenAmountPaid,\n uint256 portionToSeize,\n bool fullyFilled\n ) external {\n require(openAuctions[msg.sender], \"Sender isn't an auction\");\n\n emit AuctionOfferTaken(\n msg.sender,\n offerTaker,\n address(tokenPaid),\n tokenAmountPaid,\n portionToSeize\n );\n\n // actually seize funds, setting them aside for the taker to withdraw\n // from the coverage pool.\n // `portionToSeize` will be divided by FLOATING_POINT_DIVISOR which is\n // defined in Auction.sol\n //\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n coveragePool.seizePortion(offerTaker, portionToSeize);\n\n Auction auction = Auction(msg.sender);\n if (fullyFilled) {\n onAuctionFullyFilled(auction);\n\n emit AuctionClosed(msg.sender);\n delete openAuctions[msg.sender];\n openAuctionsCount -= 1;\n } else {\n onAuctionPartiallyFilled(auction);\n }\n }\n\n /// @notice Opens a new auction against the coverage pool. The auction\n /// will remain open until filled.\n /// @dev Calls `Auction.initialize` to initialize the instance.\n /// @param tokenAccepted The token with which the auction can be taken\n /// @param amountDesired The amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param auctionLength The amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function createAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) internal returns (address) {\n address cloneAddress = createClone(masterAuction);\n require(cloneAddress != address(0), \"Cloned auction address is 0\");\n\n Auction auction = Auction(cloneAddress);\n //slither-disable-next-line reentrancy-benign,reentrancy-events\n auction.initialize(this, tokenAccepted, amountDesired, auctionLength);\n\n openAuctions[cloneAddress] = true;\n openAuctionsCount += 1;\n\n emit AuctionCreated(\n address(tokenAccepted),\n amountDesired,\n cloneAddress\n );\n\n return cloneAddress;\n }\n\n /// @notice Tears down an open auction with given address immediately.\n /// @dev Can be called by contract owner to early close an auction if it\n /// is no longer needed. Bear in mind that funds from the early closed\n /// auction last on the auctioneer contract. Calling code should take\n /// care of them.\n /// @return Amount of funds transferred to this contract by the Auction\n /// being early closed.\n function earlyCloseAuction(Auction auction) internal returns (uint256) {\n address auctionAddress = address(auction);\n\n require(openAuctions[auctionAddress], \"Address is not an open auction\");\n\n uint256 amountTransferred = auction.amountTransferred();\n\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n auction.earlyClose();\n\n emit AuctionClosed(auctionAddress);\n delete openAuctions[auctionAddress];\n openAuctionsCount -= 1;\n\n return amountTransferred;\n }\n\n /// @notice Auction lifecycle hook allowing to act on auction closed\n /// as fully filled. This function is not executed when an auction\n /// was partially filled. When this function is executed auction is\n /// already closed and funds from the coverage pool are seized.\n /// @dev Override this function to act on auction closed as fully filled.\n function onAuctionFullyFilled(Auction auction) internal virtual {}\n\n /// @notice Auction lifecycle hook allowing to act on auction partially\n /// filled. This function is not executed when an auction\n /// was fully filled.\n /// @dev Override this function to act on auction partially filled.\n function onAuctionPartiallyFilled(Auction auction) internal view virtual {}\n}\n" + }, + "contracts/BatchedPhasedEscrow.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Batched Phased Escrow Beneficiary\n/// @notice Interface expected from contracts receiving tokens from the\n/// BatchedPhasedEscrow.\ninterface IBeneficiaryContract {\n function __escrowSentTokens(uint256 amount) external;\n}\n\n/// @title BatchedPhasedEscrow\n/// @notice A token holder contract allowing contract owner to approve a set of\n/// beneficiaries of tokens held by the contract, to appoint a separate\n/// drawee role, and allowing that drawee to withdraw tokens to approved\n/// beneficiaries in phases.\ncontract BatchedPhasedEscrow is Ownable {\n using SafeERC20 for IERC20;\n\n event BeneficiaryApproved(address beneficiary);\n event TokensWithdrawn(address beneficiary, uint256 amount);\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\n\n IERC20 public token;\n address public drawee;\n mapping(address => bool) private approvedBeneficiaries;\n\n modifier onlyDrawee() {\n require(drawee == msg.sender, \"Caller is not the drawee\");\n _;\n }\n\n constructor(IERC20 _token) {\n token = _token;\n drawee = msg.sender;\n }\n\n /// @notice Approves the provided address as a beneficiary of tokens held by\n /// the escrow. Can be called only by escrow owner.\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\n external\n onlyOwner\n {\n address beneficiaryAddress = address(_beneficiary);\n require(\n beneficiaryAddress != address(0),\n \"Beneficiary can not be zero address\"\n );\n approvedBeneficiaries[beneficiaryAddress] = true;\n emit BeneficiaryApproved(beneficiaryAddress);\n }\n\n /// @notice Returns `true` if the given address has been approved as a\n /// beneficiary of the escrow, `false` otherwise.\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\n public\n view\n returns (bool)\n {\n return approvedBeneficiaries[address(_beneficiary)];\n }\n\n /// @notice Transfers the role of drawee to another address. Can be called\n /// only by the contract owner.\n function setDrawee(address newDrawee) external onlyOwner {\n require(newDrawee != address(0), \"New drawee can not be zero address\");\n emit DraweeRoleTransferred(drawee, newDrawee);\n drawee = newDrawee;\n }\n\n /// @notice Funds the escrow by transferring all of the approved tokens\n /// to the escrow.\n function receiveApproval(\n address _from,\n uint256 _value,\n address _token,\n bytes memory\n ) external {\n require(IERC20(_token) == token, \"Unsupported token\");\n token.safeTransferFrom(_from, address(this), _value);\n }\n\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\n /// transferring to each beneficiary the amount of tokens specified\n /// as a parameter. Only beneficiaries previously approved by escrow\n /// owner can receive funds.\n function batchedWithdraw(\n IBeneficiaryContract[] memory beneficiaries,\n uint256[] memory amounts\n ) external onlyDrawee {\n require(\n beneficiaries.length == amounts.length,\n \"Mismatched arrays length\"\n );\n\n for (uint256 i = 0; i < beneficiaries.length; i++) {\n IBeneficiaryContract beneficiary = beneficiaries[i];\n require(\n isBeneficiaryApproved(beneficiary),\n \"Beneficiary was not approved\"\n );\n withdraw(beneficiary, amounts[i]);\n }\n }\n\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\n private\n {\n emit TokensWithdrawn(address(beneficiary), amount);\n token.safeTransfer(address(beneficiary), amount);\n // slither-disable-next-line calls-loop\n beneficiary.__escrowSentTokens(amount);\n }\n}\n" + }, + "contracts/CoveragePool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./AssetPool.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Coverage Pool\n/// @notice A contract that manages a single asset pool. Handles approving and\n/// unapproving of risk managers and allows them to seize funds from the\n/// asset pool if they are approved.\n/// @dev Coverage pool contract is owned by the governance. Coverage pool is the\n/// owner of the asset pool contract.\ncontract CoveragePool is Ownable {\n AssetPool public immutable assetPool;\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n bool public firstRiskManagerApproved = false;\n\n // Currently approved risk managers\n mapping(address => bool) public approvedRiskManagers;\n // Timestamps of risk managers whose approvals have been initiated\n mapping(address => uint256) public riskManagerApprovalTimestamps;\n\n event RiskManagerApprovalStarted(address riskManager, uint256 timestamp);\n event RiskManagerApprovalCompleted(address riskManager, uint256 timestamp);\n event RiskManagerUnapproved(address riskManager, uint256 timestamp);\n\n /// @notice Reverts if called by a risk manager that is not approved\n modifier onlyApprovedRiskManager() {\n require(approvedRiskManagers[msg.sender], \"Risk manager not approved\");\n _;\n }\n\n constructor(AssetPool _assetPool) {\n assetPool = _assetPool;\n collateralToken = _assetPool.collateralToken();\n underwriterToken = _assetPool.underwriterToken();\n }\n\n /// @notice Approves the first risk manager\n /// @dev Can be called only by the contract owner. Can be called only once.\n /// Does not require any further calls to any functions.\n /// @param riskManager Risk manager that will be approved\n function approveFirstRiskManager(address riskManager) external onlyOwner {\n require(\n !firstRiskManagerApproved,\n \"The first risk manager was approved\"\n );\n approvedRiskManagers[riskManager] = true;\n firstRiskManagerApproved = true;\n }\n\n /// @notice Begins risk manager approval process.\n /// @dev Can be called only by the contract owner and only when the first\n /// risk manager is already approved. For a risk manager to be\n /// approved, a call to `finalizeRiskManagerApproval` must follow\n /// (after a governance delay).\n /// @param riskManager Risk manager that will be approved\n function beginRiskManagerApproval(address riskManager) external onlyOwner {\n require(\n firstRiskManagerApproved,\n \"The first risk manager is not yet approved; Please use \"\n \"approveFirstRiskManager instead\"\n );\n\n require(\n !approvedRiskManagers[riskManager],\n \"Risk manager already approved\"\n );\n\n /* solhint-disable-next-line not-rely-on-time */\n riskManagerApprovalTimestamps[riskManager] = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalStarted(riskManager, block.timestamp);\n }\n\n /// @notice Finalizes risk manager approval process.\n /// @dev Can be called only by the contract owner. Must be preceded with a\n /// call to beginRiskManagerApproval and a governance delay must elapse.\n /// @param riskManager Risk manager that will be approved\n function finalizeRiskManagerApproval(address riskManager)\n external\n onlyOwner\n {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0,\n \"Risk manager approval not initiated\"\n );\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - riskManagerApprovalTimestamps[riskManager] >=\n assetPool.withdrawalGovernanceDelay(),\n \"Risk manager governance delay has not elapsed\"\n );\n approvedRiskManagers[riskManager] = true;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalCompleted(riskManager, block.timestamp);\n delete riskManagerApprovalTimestamps[riskManager];\n }\n\n /// @notice Unapproves an already approved risk manager or cancels the\n /// approval process of a risk manager (the latter happens if called\n /// between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`).\n /// The change takes effect immediately.\n /// @dev Can be called only by the contract owner.\n /// @param riskManager Risk manager that will be unapproved\n function unapproveRiskManager(address riskManager) external onlyOwner {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0 ||\n approvedRiskManagers[riskManager],\n \"Risk manager is neither approved nor with a pending approval\"\n );\n delete riskManagerApprovalTimestamps[riskManager];\n delete approvedRiskManagers[riskManager];\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerUnapproved(riskManager, block.timestamp);\n }\n\n /// @notice Approves upgradeability to the new asset pool.\n /// Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n /// @param _newAssetPool New asset pool\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n assetPool.approveNewAssetPoolUpgrade(_newAssetPool);\n }\n\n /// @notice Lets the governance to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 newWithdrawalDelay)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalDelayUpdate(newWithdrawalDelay);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalDelayUpdate();\n }\n\n /// @notice Lets the governance to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 newWithdrawalTimeout)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalTimeoutUpdate(newWithdrawalTimeout);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalTimeoutUpdate();\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @dev `portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR`\n /// for calculation precision purposes. Further calculations in this\n /// function will need to take this divisor into account.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by `FLOATING_POINT_DIVISOR`\n function seizePortion(address recipient, uint256 portionToSeize)\n external\n onlyApprovedRiskManager\n {\n require(\n portionToSeize > 0 &&\n portionToSeize <= CoveragePoolConstants.FLOATING_POINT_DIVISOR,\n \"Portion to seize is not within the range (0, 1]\"\n );\n\n assetPool.claim(recipient, amountToSeize(portionToSeize));\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param amountToSeize Amount to be seized from the pool\n // slither-disable-next-line shadowing-local\n function seizeAmount(address recipient, uint256 amountToSeize)\n external\n onlyApprovedRiskManager\n {\n require(amountToSeize > 0, \"Amount to seize must be >0\");\n\n assetPool.claim(recipient, amountToSeize);\n }\n\n /// @notice Grants asset pool shares by minting a given amount of the\n /// underwriter tokens for the recipient address. In result, the\n /// recipient obtains part of the pool ownership without depositing\n /// any collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by an approved risk manager.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n onlyApprovedRiskManager\n {\n assetPool.grantShares(recipient, covAmount);\n }\n\n /// @notice Returns the time remaining until the risk manager approval\n /// process can be finalized\n /// @param riskManager Risk manager in the process of approval\n /// @return Remaining time in seconds.\n function getRemainingRiskManagerApprovalTime(address riskManager)\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n riskManagerApprovalTimestamps[riskManager],\n assetPool.withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Determine the prior number of DAO votes for the given coverage\n /// pool underwriter.\n /// @param account The underwriter address to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the underwriter had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96)\n {\n uint96 underwriterVotes = underwriterToken.getPastVotes(\n account,\n blockNumber\n );\n uint96 underwriterTokenSupply = underwriterToken.getPastTotalSupply(\n blockNumber\n );\n\n if (underwriterTokenSupply == 0) {\n return 0;\n }\n\n uint96 covPoolVotes = collateralToken.getPastVotes(\n address(assetPool),\n blockNumber\n );\n\n return\n uint96(\n (uint256(underwriterVotes) * covPoolVotes) /\n underwriterTokenSupply\n );\n }\n\n /// @notice Calculates amount of tokens to be seized from the coverage pool.\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by FLOATING_POINT_DIVISOR\n function amountToSeize(uint256 portionToSeize)\n public\n view\n returns (uint256)\n {\n return\n (collateralToken.balanceOf(address(assetPool)) * portionToSeize) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n}\n" + }, + "contracts/CoveragePoolBeneficiary.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./RewardsPool.sol\";\nimport \"./BatchedPhasedEscrow.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title CoveragePoolBeneficiary\n/// @notice A beneficiary contract that can receive a withdrawal phase from a\n/// BatchedPhasedEscrow contract.\n/// It immediately transfers the received tokens on a designated\n/// RewardsPool contract.\ncontract CoveragePoolBeneficiary is Ownable, IBeneficiaryContract {\n using SafeERC20 for IERC20;\n\n IERC20 public immutable token;\n RewardsPool public immutable rewards;\n\n constructor(IERC20 _token, RewardsPool _rewards) {\n token = _token;\n rewards = _rewards;\n }\n\n function __escrowSentTokens(uint256 amount) external override onlyOwner {\n token.safeApprove(address(rewards), amount);\n rewards.topUpReward(amount);\n }\n}\n" + }, + "contracts/CoveragePoolConstants.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary CoveragePoolConstants {\n // This divisor is for precision purposes only. We use this divisor around\n // auction related code to get the precise values without rounding it down\n // when dealing with floating numbers.\n uint256 public constant FLOATING_POINT_DIVISOR = 1e18;\n}\n" + }, + "contracts/GovernanceUtils.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary GovernanceUtils {\n /// @notice Gets the time remaining until the governable parameter update\n /// can be committed.\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\n /// @param delay Governance delay.\n /// @return Remaining time in seconds.\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\n internal\n view\n returns (uint256)\n {\n require(changeTimestamp > 0, \"Change not initiated\");\n /* solhint-disable-next-line not-rely-on-time */\n uint256 elapsed = block.timestamp - changeTimestamp;\n if (elapsed >= delay) {\n return 0;\n } else {\n return delay - elapsed;\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@threshold-network/solidity-contracts/contracts/token/T.sol';\n" + }, + "contracts/interfaces/IAssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool interface\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\n/// an underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool.\ninterface IAssetPool {\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amount) external returns (uint256);\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n returns (uint256);\n\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external;\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter) external returns (uint256);\n}\n" + }, + "contracts/interfaces/IAssetPoolUpgrade.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool upgrade interface\n/// @notice Interface that has to be implemented by an Asset Pool accepting\n/// upgrades from another asset pool.\ninterface IAssetPoolUpgrade {\n /// @notice Accepts the given underwriter with collateral tokens amount as a\n /// deposit. In exchange new underwriter tokens will be calculated,\n /// minted and then transferred back to the underwriter.\n function depositFor(address underwriter, uint256 amount) external;\n}\n" + }, + "contracts/interfaces/IAuction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Auction interface\n/// @notice Auction runs a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\ninterface IAuction {\n /// @notice Takes an offer from an auction buyer. There are two possible\n /// ways to take an offer from a buyer. The first one is to buy\n /// entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// @dev The implementation is not guaranteed to be protecting against\n /// frontrunning. See `AuctionBidder` for an example protection.\n function takeOffer(uint256 amount) external;\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @return The ratio of the collateral pool currently on offer and divisor\n /// for precision purposes.\n function onOffer() external view returns (uint256, uint256);\n}\n" + }, + "contracts/interfaces/ICollateralToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Collateral Token interface\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\n/// as a deposit token by underwriters. Collateral token positions of\n/// underwriters can be affected when the Risk Manager claims coverage.\n/// Collateral token needs to support DAO checkpoints and let to\n/// retrieve past number of votes for the given address so that\n/// Coverage Pool underwriters can participate in token holder DAO.\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\ninterface ICollateralToken is IERC20 {\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) external;\n\n /// @notice Determine the prior number of DAO votes for an account as of\n /// a block number.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "contracts/interfaces/IRiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Interface for tBTC v1 Risk Manager\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\ninterface IRiskManagerV1 {\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external;\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external;\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n /// @param amount Amount of signer bonds being withdrawn.\n function withdrawSignerBonds(uint256 amount) external;\n\n /// @notice Returns true if there are open auctions managed by the risk\n /// manager. Returns false otherwise.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n function hasOpenAuctions() external view returns (bool);\n}\n" + }, + "contracts/RewardsPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Rewards Pool\n/// @notice RewardsPool accepts a single reward token and releases it to the\n/// AssetPool over time in one week reward intervals. The owner of this\n/// contract is the reward distribution address funding it with reward\n/// tokens.\ncontract RewardsPool is Ownable {\n using SafeERC20 for IERC20;\n\n uint256 public constant DURATION = 7 days;\n\n IERC20 public immutable rewardToken;\n address public immutable assetPool;\n\n // timestamp of the current reward interval end or the timestamp of the\n // last interval end in case a new reward interval has not been allocated\n uint256 public intervalFinish = 0;\n // rate per second with which reward tokens are unlocked\n uint256 public rewardRate = 0;\n // amount of rewards accumulated and not yet withdrawn from the previous\n // reward interval(s)\n uint256 public rewardAccumulated = 0;\n // the last time information in this contract was updated\n uint256 public lastUpdateTime = 0;\n\n event RewardToppedUp(uint256 amount);\n event RewardWithdrawn(uint256 amount);\n\n constructor(\n IERC20 _rewardToken,\n address _assetPool,\n address owner\n ) {\n rewardToken = _rewardToken;\n // slither-disable-next-line missing-zero-check\n assetPool = _assetPool;\n transferOwnership(owner);\n }\n\n /// @notice Transfers the provided reward amount into RewardsPool and\n /// creates a new, one-week reward interval starting from now.\n /// Reward tokens from the previous reward interval that unlocked\n /// over the time will be available for withdrawal immediately.\n /// Reward tokens from the previous interval that has not been yet\n /// unlocked, are added to the new interval being created.\n /// @dev This function can be called only by the owner given that it creates\n /// a new interval with one week length, starting from now.\n function topUpReward(uint256 reward) external onlyOwner {\n rewardAccumulated = earned();\n\n /* solhint-disable not-rely-on-time */\n if (block.timestamp >= intervalFinish) {\n // see https://github.com/crytic/slither/issues/844\n // slither-disable-next-line divide-before-multiply\n rewardRate = reward / DURATION;\n } else {\n uint256 remaining = intervalFinish - block.timestamp;\n uint256 leftover = remaining * rewardRate;\n rewardRate = (reward + leftover) / DURATION;\n }\n intervalFinish = block.timestamp + DURATION;\n lastUpdateTime = block.timestamp;\n /* solhint-enable avoid-low-level-calls */\n\n emit RewardToppedUp(reward);\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\n }\n\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\n function withdraw() external {\n uint256 amount = earned();\n rewardAccumulated = 0;\n lastUpdateTime = lastTimeRewardApplicable();\n emit RewardWithdrawn(amount);\n rewardToken.safeTransfer(assetPool, amount);\n }\n\n /// @notice Returns the amount of earned and not yet withdrawn reward\n /// tokens.\n function earned() public view returns (uint256) {\n return\n rewardAccumulated +\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\n }\n\n /// @notice Returns the timestamp at which a reward was last time applicable.\n /// When reward interval is pending, returns current block's\n /// timestamp. If the last reward interval ended and no other reward\n /// interval had been allocated, returns the last reward interval's\n /// end timestamp.\n function lastTimeRewardApplicable() public view returns (uint256) {\n return Math.min(block.timestamp, intervalFinish);\n }\n}\n" + }, + "contracts/RiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./Auction.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title tBTC v1 Deposit contract interface\n/// @notice This is an interface with just a few function signatures of a main\n/// Deposit contract from tBTC. tBTC deposit contract functions declared in\n/// this interface are used by RiskManagerV1 contract to interact with tBTC\n/// v1 deposits. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface IDeposit {\n function withdrawFunds() external;\n\n function purchaseSignerBondsAtAuction() external;\n\n function currentState() external view returns (uint256);\n\n function lotSizeTbtc() external view returns (uint256);\n\n function withdrawableAmount() external view returns (uint256);\n\n function auctionValue() external view returns (uint256);\n}\n\n/// @title tBTC v1 deposit token (TDT) interface\n/// @notice This is an interface with just a few function signatures of a main\n/// contract from tBTC. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/system/TBTCDepositToken.sol\ninterface ITBTCDepositToken {\n function exists(uint256 _tokenId) external view returns (bool);\n}\n\n/// @title Signer bonds swap strategy\n/// @notice This interface is meant to abstract the underlying signer bonds\n/// swap strategy and make it interchangeable for the governance.\n/// Risk manager uses the strategy to swap ETH from tBTC deposit\n/// purchased signer bonds back into collateral token accepted by\n/// coverage pool.\ninterface ISignerBondsSwapStrategy {\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external;\n}\n\n/// @title Risk Manager for tBTC v1\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract RiskManagerV1 is IRiskManagerV1, Auctioneer, Ownable {\n using SafeERC20 for IERC20;\n using RiskManagerV1Rewards for RiskManagerV1Rewards.Storage;\n\n /// @notice Governance delay that needs to pass before any risk manager\n /// parameter change initiated by the governance takes effect.\n uint256 public constant GOVERNANCE_DELAY = 12 hours;\n\n // See https://github.com/keep-network/tbtc/blob/v1.1.0/solidity/contracts/deposit/DepositStates.sol\n uint256 public constant DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE = 9;\n uint256 public constant DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE = 10;\n uint256 public constant DEPOSIT_LIQUIDATED_STATE = 11;\n\n /// @notice Coverage pool auction will not be opened if the deposit's bond\n /// auction offers a bond percentage lower than this threshold.\n /// Risk manager should open a coverage pool auction for only those\n // tBTC deposits that nobody else is willing to purchase bonds\n /// from. The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public bondAuctionThreshold; // percentage\n uint256 public newBondAuctionThreshold;\n uint256 public bondAuctionThresholdChangeInitiated;\n\n /// @notice The length with which every new auction is opened. Auction length\n /// is the amount of time it takes for the auction to get to 100%\n /// of all collateral on offer, in seconds. This parameter value\n /// should be updated and kept up to date based on the coverage pool\n /// TVL and tBTC v1 minimum lot size allowed so that a new auction\n /// does not liquidate too much too early. Auction length is the\n /// same, no matter tBTC deposit lot size.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public auctionLength;\n uint256 public newAuctionLength;\n uint256 public auctionLengthChangeInitiated;\n\n /// @notice The strategy used to swap ETH from tBTC deposit purchased signer\n /// bonds into an asset accepted by coverage pool as collateral.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n ISignerBondsSwapStrategy public signerBondsSwapStrategy;\n ISignerBondsSwapStrategy public newSignerBondsSwapStrategy;\n uint256 public signerBondsSwapStrategyInitiated;\n\n IERC20 public immutable tbtcToken;\n ITBTCDepositToken public immutable tbtcDepositToken;\n\n /// @notice TBTC surplus collected from early closed auctions.\n /// When tBTC deposit gets liquidated outside of coverage pools and\n /// an auction was opened earlier by the risk manager for that\n /// deposit, it might happen that the auction was partially filled\n /// and some TBTC from that auction has accumulated. In such a case,\n /// TBTC surplus left on the risk manager can be used to purchase\n /// signer bonds from another liquidating tBTC deposit in the future\n /// assuming enough surplus will accumulate up to that point.\n uint256 public tbtcSurplus;\n\n /// @notice Keeps track of notifier rewards for those calling\n /// `notifyLiquidation` and `notifyLiquidated`.\n RiskManagerV1Rewards.Storage public rewards;\n\n // deposit in liquidation => opened coverage pool auction\n mapping(address => address) public depositToAuction;\n // opened coverage pool auction => deposit in liquidation\n mapping(address => address) public auctionToDeposit;\n\n event NotifiedLiquidated(address indexed deposit, address notifier);\n event NotifiedLiquidation(address indexed deposit, address notifier);\n\n event BondAuctionThresholdUpdateStarted(\n uint256 bondAuctionThreshold,\n uint256 timestamp\n );\n event BondAuctionThresholdUpdated(uint256 bondAuctionThreshold);\n\n event AuctionLengthUpdateStarted(uint256 auctionLength, uint256 timestamp);\n event AuctionLengthUpdated(uint256 auctionLength);\n\n event SignerBondsSwapStrategyUpdateStarted(\n address indexed signerBondsSwapStrategy,\n uint256 timestamp\n );\n event SignerBondsSwapStrategyUpdated(\n address indexed signerBondsSwapStrategy\n );\n\n event LiquidationNotifierRewardUpdateStarted(\n uint256 liquidationNotifierReward,\n uint256 timestamp\n );\n event LiquidationNotifierRewardUpdated(uint256 liquidationNotifierReward);\n\n event LiquidatedNotifierRewardUpdateStarted(\n uint256 liquidatedNotifierReward,\n uint256 timestamp\n );\n event LiquidatedNotifierRewardUpdated(uint256 liquidatedNotifierReward);\n\n /// @notice Reverts if called before the governance delay elapses.\n /// @param changeInitiatedTimestamp Timestamp indicating the beginning\n /// of the change.\n modifier onlyAfterGovernanceDelay(uint256 changeInitiatedTimestamp) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >= GOVERNANCE_DELAY,\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n /// @notice Reverts if called by any account other than the current signer\n /// bonds swap strategy.\n modifier onlySignerBondsSwapStrategy() {\n require(\n msg.sender == address(signerBondsSwapStrategy),\n \"Caller is not the signer bonds swap strategy\"\n );\n _;\n }\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n ) Auctioneer(_coveragePool, _masterAuction) {\n tbtcToken = _tbtcToken;\n tbtcDepositToken = _tbtcDepositToken;\n signerBondsSwapStrategy = _signerBondsSwapStrategy;\n auctionLength = _auctionLength;\n bondAuctionThreshold = _bondAuctionThreshold;\n }\n\n /// @notice Receives ETH from tBTC for purchasing and withdrawing deposit\n /// signer bonds.\n //slither-disable-next-line locked-ether\n receive() external payable {}\n\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external override {\n require(\n tbtcDepositToken.exists(uint256(uint160(depositAddress))),\n \"Address is not a deposit contract\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit is not in liquidation state\"\n );\n\n require(\n depositToAuction[depositAddress] == address(0),\n \"Already notified on the deposit in liquidation\"\n );\n\n require(\n deposit.auctionValue() >=\n (address(deposit).balance * bondAuctionThreshold) / 100,\n \"Deposit bond auction percentage is below the threshold level\"\n );\n\n uint256 lotSizeTbtc = deposit.lotSizeTbtc();\n\n emit NotifiedLiquidation(depositAddress, msg.sender);\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidationNotifierReward > 0) {\n // slither-disable-next-line reentrancy-benign\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidationNotifierReward\n );\n }\n\n // If the surplus can cover the deposit liquidation cost, liquidate\n // that deposit directly without the auction process.\n if (tbtcSurplus >= lotSizeTbtc) {\n tbtcSurplus -= lotSizeTbtc;\n liquidateDeposit(deposit);\n return;\n }\n\n // slither-disable-next-line reentrancy-no-eth\n address auctionAddress = createAuction(\n tbtcToken,\n lotSizeTbtc,\n auctionLength\n );\n depositToAuction[depositAddress] = auctionAddress;\n auctionToDeposit[auctionAddress] = depositAddress;\n }\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external override {\n require(\n depositToAuction[depositAddress] != address(0),\n \"No auction for given deposit\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n deposit.currentState() == DEPOSIT_LIQUIDATED_STATE,\n \"Deposit is not in liquidated state\"\n );\n emit NotifiedLiquidated(depositAddress, msg.sender);\n\n Auction auction = Auction(depositToAuction[depositAddress]);\n\n delete depositToAuction[depositAddress];\n delete auctionToDeposit[address(auction)];\n uint256 amountTransferred = earlyCloseAuction(auction);\n\n // Add auction's transferred amount to the surplus pool.\n // slither-disable-next-line reentrancy-benign\n tbtcSurplus += amountTransferred;\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidatedNotifierReward > 0) {\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidatedNotifierReward\n );\n }\n }\n\n /// @notice Begins the bond auction threshold update process. The value of\n /// the threshold must not be greater than 100. The threshold should\n /// be high enough so that the possibility of purchasing signer\n /// bonds outside of coverage pools after opening an auction is\n /// minimal.\n /// @dev Can be called only by the contract owner.\n /// @param _newBondAuctionThreshold New bond auction threshold in percent\n function beginBondAuctionThresholdUpdate(uint256 _newBondAuctionThreshold)\n external\n onlyOwner\n {\n require(\n _newBondAuctionThreshold <= 100,\n \"Bond auction threshold must be lower or equal to 100\"\n );\n newBondAuctionThreshold = _newBondAuctionThreshold;\n /* solhint-disable-next-line not-rely-on-time */\n bondAuctionThresholdChangeInitiated = block.timestamp;\n /* solhint-disable not-rely-on-time */\n emit BondAuctionThresholdUpdateStarted(\n _newBondAuctionThreshold,\n block.timestamp\n );\n }\n\n /// @notice Finalizes the bond auction threshold update process.\n /// @dev Can be called only by the contract owner, after the the\n /// governance delay elapses.\n function finalizeBondAuctionThresholdUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(bondAuctionThresholdChangeInitiated)\n {\n bondAuctionThreshold = newBondAuctionThreshold;\n emit BondAuctionThresholdUpdated(bondAuctionThreshold);\n bondAuctionThresholdChangeInitiated = 0;\n newBondAuctionThreshold = 0;\n }\n\n /// @notice Begins the auction length update process. The auction length\n /// should be adjusted very carefully. Total value locked of the\n /// coverage pool and minimum possible auction amount need to be\n /// taken into account. The goal is to find a \"sweet spot\" for\n /// auction length, not making it too short (which leads to big\n /// sums of coverage pool become available in a short time) and not\n /// making it too long (which leads to bidders waiting for too long\n /// until it will makes sense for them to bid on an auction).\n /// @dev Can be called only by the contract owner.\n /// @param _newAuctionLength New auction length in seconds\n function beginAuctionLengthUpdate(uint256 _newAuctionLength)\n external\n onlyOwner\n {\n newAuctionLength = _newAuctionLength;\n /* solhint-disable-next-line not-rely-on-time */\n auctionLengthChangeInitiated = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit AuctionLengthUpdateStarted(_newAuctionLength, block.timestamp);\n }\n\n /// @notice Finalizes the auction length update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeAuctionLengthUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(auctionLengthChangeInitiated)\n {\n auctionLength = newAuctionLength;\n emit AuctionLengthUpdated(newAuctionLength);\n newAuctionLength = 0;\n auctionLengthChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidation` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @dev Can be called only by the contract owner.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward\n function beginLiquidationNotifierRewardUpdate(\n uint256 _newLiquidationNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidationNotifierRewardUpdateStarted(\n _newLiquidationNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidationNotifierRewardUpdate(\n _newLiquidationNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeLiquidationNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidationNotifierRewardChangeInitiated\n )\n {\n emit LiquidationNotifierRewardUpdated(\n rewards.newLiquidationNotifierReward\n );\n\n rewards.finalizeLiquidationNotifierRewardUpdate();\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidated` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n uint256 _newLiquidatedNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidatedNotifierRewardUpdateStarted(\n _newLiquidatedNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidatedNotifierRewardUpdate(\n _newLiquidatedNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses\n function finalizeLiquidatedNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidatedNotifierRewardChangeInitiated\n )\n {\n emit LiquidatedNotifierRewardUpdated(\n rewards.newLiquidatedNotifierReward\n );\n\n rewards.finalizeLiquidatedNotifierRewardUpdate();\n }\n\n /// @notice Begins the signer bonds swap strategy update process.\n /// @dev Must be followed by a finalizeSignerBondsSwapStrategyUpdate after\n /// the governance delay elapses.\n /// @param _newSignerBondsSwapStrategy The new signer bonds swap strategy\n function beginSignerBondsSwapStrategyUpdate(\n ISignerBondsSwapStrategy _newSignerBondsSwapStrategy\n ) external onlyOwner {\n require(\n address(_newSignerBondsSwapStrategy) != address(0),\n \"Invalid signer bonds swap strategy address\"\n );\n newSignerBondsSwapStrategy = _newSignerBondsSwapStrategy;\n /* solhint-disable-next-line not-rely-on-time */\n signerBondsSwapStrategyInitiated = block.timestamp;\n emit SignerBondsSwapStrategyUpdateStarted(\n address(_newSignerBondsSwapStrategy),\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp\n );\n }\n\n /// @notice Finalizes the signer bonds swap strategy update.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeSignerBondsSwapStrategyUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(signerBondsSwapStrategyInitiated)\n {\n signerBondsSwapStrategy = newSignerBondsSwapStrategy;\n emit SignerBondsSwapStrategyUpdated(\n address(newSignerBondsSwapStrategy)\n );\n delete newSignerBondsSwapStrategy;\n signerBondsSwapStrategyInitiated = 0;\n }\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Can be called only by the signer bonds swap strategy itself.\n /// This method should typically be used as part of the swap logic.\n /// Third-party calls may block funds on the strategy contract in case\n /// that strategy is not able to perform the swap.\n /// @param amount Amount of signer bonds being withdrawn\n function withdrawSignerBonds(uint256 amount)\n external\n override\n onlySignerBondsSwapStrategy\n {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = address(signerBondsSwapStrategy).call{value: amount}(\n \"\"\n );\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n /// @notice Get the time remaining until the bond auction threshold\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingBondAuctionThresholdUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n bondAuctionThresholdChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the auction length parameter\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingAuctionLengthUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n auctionLengthChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidation notifier reward\n /// parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidationNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidationNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidated notifier reward\n /// amount parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidatedNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidatedNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the signer bonds swap strategy\n /// can be changed.\n /// @return Remaining time in seconds.\n function getRemainingSignerBondsSwapStrategyChangeTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n signerBondsSwapStrategyInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @return True if there are open auctions managed by the risk manager.\n /// Returns false otherwise.\n function hasOpenAuctions() external view override returns (bool) {\n return openAuctionsCount > 0;\n }\n\n /// @return Current value of the liquidation notifier reward.\n function liquidationNotifierReward() external view returns (uint256) {\n return rewards.liquidationNotifierReward;\n }\n\n /// @return Current value of the liquidated notifier reward.\n function liquidatedNotifierReward() external view returns (uint256) {\n return rewards.liquidatedNotifierReward;\n }\n\n /// @notice Cleans up auction and deposit data and executes deposit liquidation.\n /// @dev This function is invoked when Auctioneer determines that an auction\n /// is eligible to be closed. It cannot be called on-demand outside\n /// the Auctioneer contract. By the time this function is called, all\n /// the TBTC tokens for the coverage pool auction should be transferred\n /// to this contract in order to buy signer bonds.\n /// @param auction Coverage pool auction\n function onAuctionFullyFilled(Auction auction) internal override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n\n delete depositToAuction[address(deposit)];\n delete auctionToDeposit[address(auction)];\n\n liquidateDeposit(deposit);\n }\n\n /// @notice Purchases ETH from signer bonds and swaps obtained funds\n /// using the underlying signer bonds swap strategy.\n /// @dev By the time this function is called, TBTC token balance for this\n /// contract should be enough to buy signer bonds.\n /// @param deposit TBTC deposit which should be liquidated.\n function liquidateDeposit(IDeposit deposit) internal {\n uint256 approvedAmount = deposit.lotSizeTbtc();\n tbtcToken.safeApprove(address(deposit), approvedAmount);\n\n // Purchase signers bonds ETH with TBTC acquired from the auction or\n // taken from the surplus pool.\n deposit.purchaseSignerBondsAtAuction();\n\n uint256 withdrawableAmount = deposit.withdrawableAmount();\n deposit.withdrawFunds();\n\n signerBondsSwapStrategy.onSignerBondsPurchased(withdrawableAmount);\n }\n\n /// @notice Reverts if the deposit for which the auction was created is no\n /// longer in the liquidation state. This could happen if signer\n /// bonds were purchased from tBTC deposit directly, outside of\n /// coverage pool auction.\n /// @dev This function is invoked when the auctioneer is informed about the\n /// results of an auction and the auction was partially filled.\n /// @param auction Address of an auction whose deposit needs to be checked.\n function onAuctionPartiallyFilled(Auction auction) internal view override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n }\n\n function isDepositLiquidationInProgress(IDeposit deposit)\n internal\n view\n returns (bool)\n {\n uint256 state = deposit.currentState();\n\n return (state == DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE ||\n state == DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE);\n }\n}\n\n/// @title RiskManagerV1Rewards\n/// @notice Contains logic responsible for calculating notifier rewards for\n/// both deposit liquidation start and deposit liquidated events.\n/// All parameters can be updated using a two-phase process.\n/// @dev The client contract should take care of authorizations or governance\n/// delays according to their needs.\n/* solhint-disable-next-line ordering */\nlibrary RiskManagerV1Rewards {\n struct Storage {\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about the start of deposit liquidation process.\n uint256 liquidationNotifierReward;\n uint256 newLiquidationNotifierReward;\n uint256 liquidationNotifierRewardChangeInitiated;\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about a deposit being liquidated outside of the\n // coverage pool.\n uint256 liquidatedNotifierReward;\n uint256 newLiquidatedNotifierReward;\n uint256 liquidatedNotifierRewardChangeInitiated;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward.\n function beginLiquidationNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidationNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidationNotifierReward = _newLiquidationNotifierReward;\n self.liquidationNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n function finalizeLiquidationNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidationNotifierReward = self.newLiquidationNotifierReward;\n self.newLiquidationNotifierReward = 0;\n self.liquidationNotifierRewardChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidatedNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidatedNotifierReward = _newLiquidatedNotifierReward;\n self.liquidatedNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n function finalizeLiquidatedNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidatedNotifierReward = self.newLiquidatedNotifierReward;\n self.newLiquidatedNotifierReward = 0;\n self.liquidatedNotifierRewardChangeInitiated = 0;\n }\n}\n" + }, + "contracts/SignerBondsManualSwap.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title SignerBondsManualSwap\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsManualSwap strategy allows the governance to withdraw\n/// the bonds from the risk manager and do the swap manually.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsManualSwap is ISignerBondsSwapStrategy, Ownable {\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Withdraws collected bonds to the given target address.\n /// @dev Can be called by the governance only.\n /// @param recipient Arbitrary recipient address chosen by the governance\n /// that will be responsible for swapping ETH and depositing\n /// collateral to the coverage pool.\n function withdrawSignerBonds(\n IRiskManagerV1 riskManager,\n uint256 amount,\n address payable recipient\n ) external onlyOwner {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n require(recipient != address(0), \"Invalid recipient address\");\n\n riskManager.withdrawSignerBonds(amount);\n\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls,arbitrary-send\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n}\n" + }, + "contracts/SignerBondsUniswapV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\nimport \"./CoveragePool.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @notice Interface for the Uniswap v2 router.\n/// @dev This is an interface with just a few function signatures of the\n/// router contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/router02\ninterface IUniswapV2Router {\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function factory() external pure returns (address);\n\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure returns (address);\n}\n\n/// @notice Interface for the Uniswap v2 pair.\n/// @dev This is an interface with just a few function signatures of the\n/// pair contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/pair\ninterface IUniswapV2Pair {\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n}\n\n/// @title SignerBondsUniswapV2\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsUniswapV2 is a swap strategy implementation which\n/// can withdraw the given bonds amount from the risk manager, swap them\n/// on Uniswap v2 exchange and deposit as coverage pool collateral.\n/// The governance can set crucial swap parameters: max allowed\n/// percentage impact, slippage tolerance and swap deadline, to force\n/// reasonable swap outcomes. It is up to the governance to decide what\n/// these values should be.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsUniswapV2 is ISignerBondsSwapStrategy, Ownable {\n // One basis point is equivalent to 1/100th of a percent.\n uint256 public constant BASIS_POINTS_DIVISOR = 10000;\n\n IUniswapV2Router public immutable uniswapRouter;\n IUniswapV2Pair public immutable uniswapPair;\n address public immutable assetPool;\n address public immutable collateralToken;\n\n mapping(address => bool) public approvedSwappers;\n\n // Determines the maximum allowed price impact for the swap transaction.\n // If transaction's price impact is higher, transaction will be reverted.\n // Default value is 100 basis points (1%).\n uint256 public maxAllowedPriceImpact = 100;\n // Determines the slippage tolerance for the swap transaction.\n // If transaction's slippage is higher, transaction will be reverted.\n // Default value is 50 basis points (0.5%).\n uint256 public slippageTolerance = 50;\n // Determines the deadline in which the swap transaction has to be mined.\n // If that deadline is exceeded, transaction will be reverted.\n uint256 public swapDeadline = 20 minutes;\n // Determines if the swap should revert when open auctions exists. If true,\n // swaps cannot be performed if there is at least one open auction.\n // If false, open auctions are not taken into account.\n bool public revertIfAuctionOpen = true;\n\n event SignerBondsSwapperApproved(address swapper);\n event SignerBondsSwapperUnapproved(address swapper);\n event UniswapV2SwapExecuted(uint256[] amounts);\n\n /// @notice Reverts if called by a signer bonds swapper that is not approved\n modifier onlyApprovedSwapper() {\n require(\n approvedSwappers[msg.sender],\n \"Signer bonds swapper not approved\"\n );\n _;\n }\n\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool) {\n uniswapRouter = _uniswapRouter;\n assetPool = address(_coveragePool.assetPool());\n address _collateralToken = address(_coveragePool.collateralToken());\n collateralToken = _collateralToken;\n uniswapPair = IUniswapV2Pair(\n computePairAddress(\n _uniswapRouter.factory(),\n _uniswapRouter.WETH(),\n _collateralToken\n )\n );\n }\n\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n /// @dev Do not send arbitrary funds. They will be locked forever.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Sets the maximum price impact allowed for a swap transaction.\n /// @param _maxAllowedPriceImpact Maximum allowed price impact specified\n /// in basis points. Value of this parameter must be between\n /// 0 and 10000 (inclusive). It should be chosen carefully as\n /// high limit level will accept transactions with high volumes.\n /// Those transactions may result in poor execution prices. Very low\n /// limit will force low swap volumes. Limit equal to 0 will\n /// effectively make swaps impossible.\n function setMaxAllowedPriceImpact(uint256 _maxAllowedPriceImpact)\n external\n onlyOwner\n {\n require(\n _maxAllowedPriceImpact <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n maxAllowedPriceImpact = _maxAllowedPriceImpact;\n }\n\n /// @notice Sets the slippage tolerance for a swap transaction.\n /// @param _slippageTolerance Slippage tolerance in basis points. Value of\n /// this parameter must be between 0 and 10000 (inclusive). It\n /// should be chosen carefully as transactions with high slippage\n /// tolerance result in poor execution prices. On the other hand,\n /// very low slippage tolerance may cause transactions to be\n /// reverted frequently. Slippage tolerance equal to 0 is possible\n /// and disallows any slippage to happen on the swap at the cost\n /// of higher revert risk.\n function setSlippageTolerance(uint256 _slippageTolerance)\n external\n onlyOwner\n {\n require(\n _slippageTolerance <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n slippageTolerance = _slippageTolerance;\n }\n\n /// @notice Sets the deadline for a swap transaction.\n /// @param _swapDeadline Swap deadline in seconds. Value of this parameter\n /// should be equal or greater than 0. It should be chosen carefully\n /// as transactions with long deadlines may result in poor execution\n /// prices. On the other hand, very short deadlines may cause\n /// transactions to be reverted frequently, especially in a\n /// gas-expensive environment. Deadline equal to 0 will effectively\n // make swaps impossible.\n function setSwapDeadline(uint256 _swapDeadline) external onlyOwner {\n swapDeadline = _swapDeadline;\n }\n\n /// @notice Sets whether a swap should revert if at least one\n /// open auction exists.\n /// @param _revertIfAuctionOpen If true, revert the swap if there is at\n /// least one open auction. If false, open auctions won't be taken\n /// into account.\n function setRevertIfAuctionOpen(bool _revertIfAuctionOpen)\n external\n onlyOwner\n {\n revertIfAuctionOpen = _revertIfAuctionOpen;\n }\n\n /// @notice Swaps signer bonds on Uniswap v2 exchange.\n /// @dev Swaps the given ETH amount for the collateral token using the\n /// Uniswap exchange. The maximum ETH amount is capped by the\n /// contract balance. Some governance parameters are applied on the\n /// transaction. The swap's price impact must fit within the\n /// maximum allowed price impact and the transaction is constrained\n /// with the slippage tolerance and deadline. Acquired collateral\n /// tokens are sent to the asset pool address set during\n /// contract construction.\n /// @param riskManager Address of the risk manager which holds the bonds.\n /// @param amount Amount to swap.\n function swapSignerBondsOnUniswapV2(\n IRiskManagerV1 riskManager,\n uint256 amount\n ) external onlyApprovedSwapper {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n\n if (revertIfAuctionOpen) {\n require(!riskManager.hasOpenAuctions(), \"There are open auctions\");\n }\n\n riskManager.withdrawSignerBonds(amount);\n\n // Setup the swap path. WETH must be the first component.\n address[] memory path = new address[](2);\n path[0] = uniswapRouter.WETH();\n path[1] = collateralToken;\n\n // Calculate the maximum output token amount basing on pair reserves.\n // This value will be used as the minimum amount of output tokens that\n // must be received for the transaction not to revert.\n // This value includes liquidity fee equal to 0.3%.\n uint256 amountOutMin = uniswapRouter.getAmountsOut(amount, path)[1];\n\n require(\n isAllowedPriceImpact(amountOutMin),\n \"Price impact exceeds allowed limit\"\n );\n\n // Include slippage tolerance into the minimum amount of output tokens.\n amountOutMin =\n (amountOutMin * (BASIS_POINTS_DIVISOR - slippageTolerance)) /\n BASIS_POINTS_DIVISOR;\n\n // slither-disable-next-line arbitrary-send,reentrancy-events\n uint256[] memory amounts = uniswapRouter.swapExactETHForTokens{\n value: amount\n }(\n amountOutMin,\n path,\n assetPool,\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp + swapDeadline\n );\n\n emit UniswapV2SwapExecuted(amounts);\n }\n\n /// @notice Approves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be approved\n function approveSwapper(address swapper) external onlyOwner {\n require(\n !approvedSwappers[swapper],\n \"Signer bonds swapper has been already approved\"\n );\n emit SignerBondsSwapperApproved(swapper);\n approvedSwappers[swapper] = true;\n }\n\n /// @notice Unapproves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be unapproved\n function unapproveSwapper(address swapper) external onlyOwner {\n require(\n approvedSwappers[swapper],\n \"Signer bonds swapper is not approved\"\n );\n emit SignerBondsSwapperUnapproved(swapper);\n delete approvedSwappers[swapper];\n }\n\n /// @notice Checks the price impact of buying a given amount of tokens\n /// against the maximum allowed price impact limit.\n /// @param amount Amount of tokens.\n /// @return True if the price impact is allowed, false otherwise.\n function isAllowedPriceImpact(uint256 amount) public view returns (bool) {\n // Get reserve of the collateral token.\n address WETH = uniswapRouter.WETH();\n address token0 = WETH < collateralToken ? WETH : collateralToken;\n (uint256 reserve0, uint256 reserve1, ) = uniswapPair.getReserves();\n uint256 collateralTokenReserve = WETH == token0 ? reserve1 : reserve0;\n\n // Same as: priceImpact <= priceImpactLimit\n return\n amount * BASIS_POINTS_DIVISOR <=\n maxAllowedPriceImpact * collateralTokenReserve;\n }\n\n /// @notice Compute Uniswap v2 pair address.\n /// @param factory Address of the Uniswap v2 factory.\n /// @param tokenA Address of token A.\n /// @param tokenB Address of token B.\n /// @return Address of token pair.\n function computePairAddress(\n address factory,\n address tokenA,\n address tokenB\n ) internal pure returns (address) {\n (address token0, address token1) = tokenA < tokenB\n ? (tokenA, tokenB)\n : (tokenB, tokenA);\n\n return\n address(\n uint160(\n uint256(\n keccak256(\n abi.encodePacked(\n hex\"ff\",\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex\"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\"\n )\n )\n )\n )\n );\n }\n}\n" + }, + "contracts/test/AuctioneerStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../Auctioneer.sol\";\n\ncontract AuctioneerStub is Auctioneer {\n event AuctionEarlyClosed(uint256 transferredAmount);\n\n constructor(CoveragePool _coveragePool, address _masterAuction)\n Auctioneer(_coveragePool, _masterAuction)\n {}\n\n /// @dev This fallback function is needed by the `impersonateAccount`\n /// test helper function.\n receive() external payable {}\n\n function publicCreateAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) public {\n createAuction(tokenAccepted, amountDesired, auctionLength);\n }\n\n function publicEarlyCloseAuction(Auction auction) public {\n uint256 transferredAmount = earlyCloseAuction(auction);\n emit AuctionEarlyClosed(transferredAmount);\n }\n}\n" + }, + "contracts/test/AuctionStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAuction.sol\";\n\ncontract AuctionStub is IAuction {\n uint256 public divisor;\n uint256 public offer;\n uint256 public amountOutstanding;\n\n event TakeOffer(uint256 amount);\n\n /// @dev Simulates calling Auction.takeOffer(amount) from the\n /// AuctionBidder contract.\n function takeOffer(uint256 amount) external override {\n emit TakeOffer(amount);\n }\n\n function onOffer() external view override returns (uint256, uint256) {\n return (offer, divisor);\n }\n\n function setOnOffer(uint256 _onOffer) public {\n offer = _onOffer;\n }\n\n function setDivisor(uint256 _divisor) public {\n divisor = _divisor;\n }\n\n function setAmountOutstanding(uint256 _amountOutstanding) public {\n amountOutstanding = _amountOutstanding;\n }\n}\n" + }, + "contracts/test/CoveragePoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../CoveragePoolConstants.sol\";\n\ncontract CoveragePoolStub {\n uint256 public covTotalSupply;\n\n event PortionSeized(address indexed recipient, uint256 portionToSeize);\n event AssetPoolSharesGranted(address indexed recipient, uint256 covAmount);\n\n function seizePortion(address recipient, uint256 portionToSeize) external {\n emit PortionSeized(recipient, portionToSeize);\n }\n\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n {\n emit AssetPoolSharesGranted(recipient, covAmount);\n }\n}\n" + }, + "contracts/test/DepositStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../RiskManagerV1.sol\";\n\n/// @dev tBTC v1 deposit interface with a subset of functions used by unit and\n/// system tests. For more information about tBTC Deposit, please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface ITBTCDeposit is IDeposit {\n function notifyRedemptionSignatureTimedOut() external;\n}\n\n/// @dev Stub contract simulating - in a simplified way - behavior of tBTC v1\n/// deposit when it comes to purchasing signer bonds. This is _not_\n/// a complete tBTC v1 Deposit implementation.\ncontract DepositStub is ITBTCDeposit {\n using SafeERC20 for IERC20;\n\n enum States {\n // DOES NOT EXIST YET\n START,\n // FUNDING FLOW\n AWAITING_SIGNER_SETUP,\n AWAITING_BTC_FUNDING_PROOF,\n // FAILED SETUP\n FAILED_SETUP,\n // ACTIVE\n ACTIVE, // includes courtesy call\n // REDEMPTION FLOW\n AWAITING_WITHDRAWAL_SIGNATURE,\n AWAITING_WITHDRAWAL_PROOF,\n REDEEMED,\n // SIGNER LIQUIDATION FLOW\n COURTESY_CALL,\n FRAUD_LIQUIDATION_IN_PROGRESS,\n LIQUIDATION_IN_PROGRESS,\n LIQUIDATED\n }\n\n IERC20 public tbtcToken;\n uint256 public override lotSizeTbtc;\n uint256 public override currentState;\n uint256 public override auctionValue;\n\n address public buyer;\n\n constructor(IERC20 _tbtcToken, uint256 _lotSizeTbtc) {\n tbtcToken = _tbtcToken;\n lotSizeTbtc = _lotSizeTbtc;\n currentState = 4; // active by default\n }\n\n /// @dev Needed to receive ETH bonds at deposit setup.\n receive() external payable {}\n\n function withdrawFunds() external override {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = buyer.call{value: address(this).balance}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n function purchaseSignerBondsAtAuction() external override {\n require(\n currentState == uint256(States.LIQUIDATION_IN_PROGRESS),\n \"Not in liquidation\"\n );\n currentState = uint256(States.LIQUIDATED);\n buyer = msg.sender;\n tbtcToken.safeTransferFrom(buyer, address(this), lotSizeTbtc);\n }\n\n function notifyUndercollateralizedLiquidation() external {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n function notifyRedemptionSignatureTimedOut() external override {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function setAuctionValue(uint256 _auctionValue) external {\n auctionValue = _auctionValue;\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function notifyFraud() external {\n currentState = uint256(States.FRAUD_LIQUIDATION_IN_PROGRESS);\n }\n\n function withdrawableAmount() external view override returns (uint256) {\n return address(this).balance;\n }\n}\n" + }, + "contracts/test/KeepAssetPool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../AssetPool.sol\";\n\ncontract KeepAssetPool is AssetPool {\n constructor(\n ICollateralToken collateralToken,\n UnderwriterToken underwriterToken,\n address rewardsManager\n ) AssetPool(collateralToken, underwriterToken, rewardsManager) {}\n\n function initGovernance(ICollateralToken _collateralToken)\n internal\n override\n {\n // KEEP does not support DAO checkpoints\n }\n}\n" + }, + "contracts/test/NewAssetPoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAssetPool.sol\";\nimport \"../interfaces/IAssetPoolUpgrade.sol\";\nimport \"../UnderwriterToken.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract NewAssetPoolStub is IAssetPoolUpgrade {\n using SafeERC20 for IERC20;\n\n IERC20 public collateralToken;\n UnderwriterToken public newUnderwriterToken;\n\n constructor(IERC20 _collateralToken, UnderwriterToken _newUnderwriterToken)\n {\n collateralToken = _collateralToken;\n newUnderwriterToken = _newUnderwriterToken;\n }\n\n function depositFor(address underwriter, uint256 collateralAmount)\n external\n override\n {\n collateralToken.safeTransferFrom(\n msg.sender,\n address(this),\n collateralAmount\n );\n // In a real contract amount of new cov tokens will be calculated based\n // on certain rules.\n // For testing purposes, cov tokens amount = collateral tokens amount\n newUnderwriterToken.mint(underwriter, collateralAmount);\n }\n}\n" + }, + "contracts/test/RiskManagerV1Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract RiskManagerV1Stub is RiskManagerV1 {\n using SafeERC20 for IERC20;\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n )\n RiskManagerV1(\n _tbtcToken,\n _tbtcDepositToken,\n _coveragePool,\n _signerBondsSwapStrategy,\n _masterAuction,\n _auctionLength,\n _bondAuctionThreshold\n )\n {}\n\n function fundTbtcSurplus(uint256 amount) external {\n tbtcToken.safeTransferFrom(msg.sender, address(this), amount);\n tbtcSurplus = tbtcSurplus + amount;\n }\n}\n" + }, + "contracts/test/SignerBondsUniswapV2Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract SignerBondsUniswapV2Stub is SignerBondsUniswapV2 {\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool)\n SignerBondsUniswapV2(_uniswapRouter, _coveragePool)\n {}\n}\n" + }, + "contracts/test/TBTCDepositTokenStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract TBTCDepositTokenStub is ITBTCDepositToken {\n mapping(uint256 => bool) public tokenIds;\n\n function setExists(uint256 tokenId, bool _exists) external {\n tokenIds[tokenId] = _exists;\n }\n\n function exists(uint256 tokenId) external view override returns (bool) {\n return tokenIds[tokenId];\n }\n}\n" + }, + "contracts/test/TestSimpleBeneficiary.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n// Simple beneficiary that does nothing when notified that it has received\n// tokens.\ncontract TestSimpleBeneficiary {\n function __escrowSentTokens(uint256 amount) external {}\n}\n" + }, + "contracts/test/TestToken.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/ICollateralToken.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\n\n/// @title Test ERC-20 token\n/// @dev Token with unlimited minting capacity. It does implement DAO-related\n/// functions from ICollateralToken but with just a dummy code.\n/// Implementation of DAO checkpoints is complex. Even if we used\n/// `Checkpoints` contract from `threshold-network` here, it would require\n/// implementation for `delegate(address delegator, address delegatee)` and\n/// updating checkpoints in `beforeTokenTransfer(address from, address to, uint amount)`\n/// of TestToken. Every time DAO related functions need to be tested, please\n/// use real token with proper DAO implementation, such as `T`.\ncontract TestToken is ERC20WithPermit, ICollateralToken {\n mapping(address => address) public delegatee;\n\n /* solhint-disable-next-line no-empty-blocks */\n constructor() ERC20WithPermit(\"Test Token\", \"TT\") {}\n\n function delegate(address _delegatee) external virtual {\n delegatee[msg.sender] = _delegatee;\n }\n\n function getPastVotes(address, uint256) external pure returns (uint96) {\n return 0;\n }\n}\n" + }, + "contracts/test/UniswapV2RouterStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract UniswapV2RouterStub is IUniswapV2Router {\n // Settable fake exchange rate is defined here to avoid pair logic complexity.\n // It determines how much tokens can be received for 1 ETH.\n uint256 public exchangeRate = 1;\n\n event SwapExactETHForTokensExecuted(\n uint256 amountOutMin,\n address[] path,\n address to,\n uint256 deadline\n );\n\n function setExchangeRate(uint256 _exchangeRate) external {\n exchangeRate = _exchangeRate;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one. Emits an event with input parameters.\n /// Calculates returned amounts to behave like a real method.\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable override returns (uint256[] memory amounts) {\n require(msg.value > 0, \"Amount must be grater than zero\");\n\n emit SwapExactETHForTokensExecuted(amountOutMin, path, to, deadline);\n\n amounts = new uint256[](2);\n amounts[0] = msg.value;\n amounts[1] = (msg.value * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one.\n function getAmountsOut(uint256 amountIn, address[] calldata)\n external\n view\n override\n returns (uint256[] memory amounts)\n {\n amounts = new uint256[](2);\n amounts[0] = amountIn;\n amounts[1] = (amountIn * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n function factory() external pure override returns (address) {\n return 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure override returns (address) {\n return 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n }\n}\n" + }, + "contracts/UnderwriterToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\";\n\n/// @title UnderwriterToken\n/// @notice Underwriter tokens represent an ownership share in the underlying\n/// collateral of the asset-specific pool. Underwriter tokens are minted\n/// when a user deposits ERC20 tokens into asset-specific pool and they\n/// are burned when a user exits the position. Underwriter tokens\n/// natively support meta transactions. Users can authorize a transfer\n/// of their underwriter tokens with a signature conforming EIP712\n/// standard instead of an on-chain transaction from their address.\n/// Anyone can submit this signature on the user's behalf by calling the\n/// permit function, as specified in EIP2612 standard, paying gas fees,\n/// and possibly performing other actions in the same transaction.\n// slither-disable-next-line missing-inheritance\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor(string memory _name, string memory _symbol)\n ERC20WithPermit(_name, _symbol)\n {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n /// @notice Moves voting power when tokens are minted, burned or transferred.\n /// @dev Overrides the empty function from the parent contract.\n /// @param from The address that loses tokens and voting power\n /// @param to The address that gains tokens and voting power\n /// @param amount The amount of tokens and voting power that is transferred\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\n }\n\n moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /// @notice Delegate votes from `delegator` to `delegatee`.\n /// @param delegator The address to delegate votes from\n /// @param delegatee The address to delegate votes to\n function delegate(address delegator, address delegatee) internal override {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/v2/RewardsPoolV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title RewardTokenMinting\n/// @notice Implements minting of reward tokens for registered Asset Pools with\n/// a reward rate assigned individually for each Asset Pool.\n/// Each Asset Pool is assigned a relative rate establishing a way for\n/// Governance to incentivize different assets to target a particular\n/// Collateral Pool composition.\n/// @dev Contract is not meant to be deployed directly. It implements\n/// a specific part of the functionality of the RewardPool and should be\n/// used only as a RewardPool parent contract.\nabstract contract RewardTokenMinting {\n // Reward rate per Asset Pool address.\n // Reward rate is 1e18 precision number.\n mapping(address => uint256) public rewardRates;\n\n // The last time minting rates were updated.\n uint256 public lastUpdateTime;\n\n uint256 internal tokenPerRateUnitAccumulated;\n mapping(address => uint256) internal poolTokenPerRateUnitPaid;\n mapping(address => uint256) internal poolTokens;\n\n // TODO: should be internal and used by governance function with a delay\n function setRewardRate(address assetPool, uint256 rewardRate) external {\n updateReward(assetPool);\n rewardRates[assetPool] = rewardRate;\n }\n\n function earned(address assetPool) public view returns (uint256) {\n return\n rewardRates[assetPool] *\n (tokenPerRateUnit() - poolTokenPerRateUnitPaid[assetPool]) +\n poolTokens[assetPool];\n }\n\n function updateReward(address assetPool) internal {\n tokenPerRateUnitAccumulated = tokenPerRateUnit();\n /* solhint-disable-next-line not-rely-on-time */\n lastUpdateTime = block.timestamp;\n poolTokens[assetPool] = earned(assetPool);\n poolTokenPerRateUnitPaid[assetPool] = tokenPerRateUnitAccumulated;\n }\n\n function tokenPerRateUnit() internal view returns (uint256) {\n return\n tokenPerRateUnitAccumulated +\n (/* solhint-disable-next-line not-rely-on-time */\n block.timestamp - lastUpdateTime);\n }\n}\n\n/// @title RewardsPool\n/// @notice Rewards Pool is a contract that accepts arbitrary assets and mints\n/// a single reward token. Recipients of the reward token can at any\n/// time turn it in for a portion of the rewards in the pool.\n/// A rewards pool maintains a governable list of recipients and\n/// relative reward rates. For example, a rewards pool might have two\n/// recipients — a WETH Asset Pool, and a WBTC asset pool, with\n/// respective reward rates of 1 and 2. Rewards tokens are minted\n/// constantly over time and distributed according to the relative\n/// reward rates. Reward rates allows establishing a way for Governance\n/// to incentivize different assets to target a particular Collateral\n/// Pool composition.\ncontract RewardPoolV2 is RewardTokenMinting {\n // TODO: Add function to update reward rate with a governance delay.\n // TODO: Allow to withdraw rewards based on the amount of reward tokens.\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": false, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "storageLayout", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + }, + "libraries": {} + } +} \ No newline at end of file diff --git a/deployments/mainnet/solcInputs/b466ba551e3f54d5eed446f39b17a223.json b/deployments/mainnet/solcInputs/b466ba551e3f54d5eed446f39b17a223.json new file mode 100644 index 00000000..ee0a0e6e --- /dev/null +++ b/deployments/mainnet/solcInputs/b466ba551e3f54d5eed446f39b17a223.json @@ -0,0 +1,197 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.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 /**\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 / b + (a % b == 0 ? 0 : 1);\n }\n}\n" + }, + "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCastUpgradeable {\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128) {\n require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return int128(value);\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64) {\n require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return int64(value);\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32) {\n require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return int32(value);\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16) {\n require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return int16(value);\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits.\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8) {\n require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return int8(value);\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n" + }, + "@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" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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 Context {\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" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.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 IERC165 {\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" + }, + "@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 // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `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" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n require(value <= type(uint248).max, \"SafeCast: value doesn't fit in 248 bits\");\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n require(value <= type(uint240).max, \"SafeCast: value doesn't fit in 240 bits\");\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n require(value <= type(uint232).max, \"SafeCast: value doesn't fit in 232 bits\");\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.2._\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n require(value <= type(uint216).max, \"SafeCast: value doesn't fit in 216 bits\");\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n require(value <= type(uint208).max, \"SafeCast: value doesn't fit in 208 bits\");\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n require(value <= type(uint200).max, \"SafeCast: value doesn't fit in 200 bits\");\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n require(value <= type(uint192).max, \"SafeCast: value doesn't fit in 192 bits\");\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n require(value <= type(uint184).max, \"SafeCast: value doesn't fit in 184 bits\");\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n require(value <= type(uint176).max, \"SafeCast: value doesn't fit in 176 bits\");\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n require(value <= type(uint168).max, \"SafeCast: value doesn't fit in 168 bits\");\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n require(value <= type(uint160).max, \"SafeCast: value doesn't fit in 160 bits\");\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n require(value <= type(uint152).max, \"SafeCast: value doesn't fit in 152 bits\");\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n require(value <= type(uint144).max, \"SafeCast: value doesn't fit in 144 bits\");\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n require(value <= type(uint136).max, \"SafeCast: value doesn't fit in 136 bits\");\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v2.5._\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n require(value <= type(uint120).max, \"SafeCast: value doesn't fit in 120 bits\");\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n require(value <= type(uint112).max, \"SafeCast: value doesn't fit in 112 bits\");\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n require(value <= type(uint104).max, \"SafeCast: value doesn't fit in 104 bits\");\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.2._\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n require(value <= type(uint88).max, \"SafeCast: value doesn't fit in 88 bits\");\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n require(value <= type(uint80).max, \"SafeCast: value doesn't fit in 80 bits\");\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n require(value <= type(uint72).max, \"SafeCast: value doesn't fit in 72 bits\");\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v2.5._\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n require(value <= type(uint56).max, \"SafeCast: value doesn't fit in 56 bits\");\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n require(value <= type(uint48).max, \"SafeCast: value doesn't fit in 48 bits\");\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n require(value <= type(uint40).max, \"SafeCast: value doesn't fit in 40 bits\");\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v2.5._\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n require(value <= type(uint24).max, \"SafeCast: value doesn't fit in 24 bits\");\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v2.5._\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v2.5._\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n *\n * _Available since v3.0._\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n require(value >= 0, \"SafeCast: value must be positive\");\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n *\n * _Available since v4.7._\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 248 bits\");\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n *\n * _Available since v4.7._\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 240 bits\");\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n *\n * _Available since v4.7._\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 232 bits\");\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n *\n * _Available since v4.7._\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 224 bits\");\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n *\n * _Available since v4.7._\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 216 bits\");\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n *\n * _Available since v4.7._\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 208 bits\");\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n *\n * _Available since v4.7._\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 200 bits\");\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n *\n * _Available since v4.7._\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 192 bits\");\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n *\n * _Available since v4.7._\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 184 bits\");\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n *\n * _Available since v4.7._\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 176 bits\");\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n *\n * _Available since v4.7._\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 168 bits\");\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n *\n * _Available since v4.7._\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 160 bits\");\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n *\n * _Available since v4.7._\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 152 bits\");\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n *\n * _Available since v4.7._\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 144 bits\");\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n *\n * _Available since v4.7._\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 136 bits\");\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n *\n * _Available since v3.1._\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 128 bits\");\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n *\n * _Available since v4.7._\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 120 bits\");\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n *\n * _Available since v4.7._\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 112 bits\");\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n *\n * _Available since v4.7._\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 104 bits\");\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n *\n * _Available since v4.7._\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 96 bits\");\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n *\n * _Available since v4.7._\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 88 bits\");\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n *\n * _Available since v4.7._\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 80 bits\");\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n *\n * _Available since v4.7._\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 72 bits\");\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n *\n * _Available since v3.1._\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 64 bits\");\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n *\n * _Available since v4.7._\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 56 bits\");\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n *\n * _Available since v4.7._\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 48 bits\");\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n *\n * _Available since v4.7._\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 40 bits\");\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n *\n * _Available since v3.1._\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 32 bits\");\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n *\n * _Available since v4.7._\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 24 bits\");\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n *\n * _Available since v3.1._\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 16 bits\");\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n *\n * _Available since v3.1._\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n require(downcasted == value, \"SafeCast: value doesn't fit in 8 bits\");\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n *\n * _Available since v3.0._\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n return int256(value);\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/clone/CloneFactory.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.5;\n\n/*\nThe MIT License (MIT)\nCopyright (c) 2018 Murray Software, LLC.\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n/// @notice Implementation of [EIP-1167] based on [clone-factory]\n/// source code.\n///\n/// EIP 1167: https://eips.ethereum.org/EIPS/eip-1167\n// Original implementation: https://github.com/optionality/clone-factory\n// Modified to use ^0.8.5; instead of ^0.4.23 solidity version.\n/* solhint-disable no-inline-assembly */\nabstract contract CloneFactory {\n /// @notice Creates EIP-1167 clone of the contract under the provided\n /// `target` address. Returns address of the created clone.\n /// @dev In specific circumstances, such as the `target` contract destroyed,\n /// create opcode may return 0x0 address. The code calling this\n /// function should handle this corner case properly.\n function createClone(address target) internal returns (address result) {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000\n )\n mstore(add(clone, 0x14), targetBytes)\n mstore(\n add(clone, 0x28),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n result := create(0, clone, 0x37)\n }\n }\n\n /// @notice Checks if the contract under the `query` address is a EIP-1167\n /// clone of the contract under `target` address.\n function isClone(address target, address query)\n internal\n view\n returns (bool result)\n {\n bytes20 targetBytes = bytes20(target);\n assembly {\n let clone := mload(0x40)\n mstore(\n clone,\n 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000\n )\n mstore(add(clone, 0xa), targetBytes)\n mstore(\n add(clone, 0x1e),\n 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000\n )\n\n let other := add(clone, 0x40)\n extcodecopy(query, other, 0, 0x2d)\n result := and(\n eq(mload(clone), mload(other)),\n eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))\n )\n }\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport \"./IERC20WithPermit.sol\";\nimport \"./IReceiveApproval.sol\";\n\n/// @title ERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\n /// @notice The amount of tokens owned by the given account.\n mapping(address => uint256) public override balanceOf;\n\n /// @notice The remaining number of tokens that spender will be\n /// allowed to spend on behalf of owner through `transferFrom` and\n /// `burnFrom`. This is zero by default.\n mapping(address => mapping(address => uint256)) public override allowance;\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n mapping(address => uint256) public override nonce;\n\n uint256 public immutable cachedChainId;\n bytes32 public immutable cachedDomainSeparator;\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n bytes32 public constant override PERMIT_TYPEHASH =\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n );\n\n /// @notice The amount of tokens in existence.\n uint256 public override totalSupply;\n\n /// @notice The name of the token.\n string public override name;\n\n /// @notice The symbol of the token.\n string public override symbol;\n\n /// @notice The decimals places of the token.\n uint8 public constant override decimals = 18;\n\n constructor(string memory _name, string memory _symbol) {\n name = _name;\n symbol = _symbol;\n\n cachedChainId = block.chainid;\n cachedDomainSeparator = buildDomainSeparator();\n }\n\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address,\n /// - the caller must have a balance of at least `amount`.\n function transfer(address recipient, uint256 amount)\n external\n override\n returns (bool)\n {\n _transfer(msg.sender, recipient, amount);\n return true;\n }\n\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\n /// allowance mechanism. `amount` is then deducted from the caller's\n /// allowance unless the allowance was made for `type(uint256).max`.\n /// @return True if the operation succeeded, reverts otherwise.\n /// @dev Requirements:\n /// - `spender` and `recipient` cannot be the zero address,\n /// - `spender` must have a balance of at least `amount`,\n /// - the caller must have allowance for `spender`'s tokens of at least\n /// `amount`.\n function transferFrom(\n address spender,\n address recipient,\n uint256 amount\n ) external override returns (bool) {\n uint256 currentAllowance = allowance[spender][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Transfer amount exceeds allowance\"\n );\n _approve(spender, msg.sender, currentAllowance - amount);\n }\n _transfer(spender, recipient, amount);\n return true;\n }\n\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire. If the `amount` is set\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\n /// not reduce an allowance.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external override {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Permission expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n PERMIT_TYPEHASH,\n owner,\n spender,\n amount,\n nonce[owner]++,\n deadline\n )\n )\n )\n );\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == owner,\n \"Invalid signature\"\n );\n _approve(owner, spender, amount);\n }\n\n /// @notice Creates `amount` tokens and assigns them to `account`,\n /// increasing the total supply.\n /// @dev Requirements:\n /// - `recipient` cannot be the zero address.\n function mint(address recipient, uint256 amount) external onlyOwner {\n require(recipient != address(0), \"Mint to the zero address\");\n\n beforeTokenTransfer(address(0), recipient, amount);\n\n totalSupply += amount;\n balanceOf[recipient] += amount;\n emit Transfer(address(0), recipient, amount);\n }\n\n /// @notice Destroys `amount` tokens from the caller.\n /// @dev Requirements:\n /// - the caller must have a balance of at least `amount`.\n function burn(uint256 amount) external override {\n _burn(msg.sender, amount);\n }\n\n /// @notice Destroys `amount` of tokens from `account` using the allowance\n /// mechanism. `amount` is then deducted from the caller's allowance\n /// unless the allowance was made for `type(uint256).max`.\n /// @dev Requirements:\n /// - `account` must have a balance of at least `amount`,\n /// - the caller must have allowance for `account`'s tokens of at least\n /// `amount`.\n function burnFrom(address account, uint256 amount) external override {\n uint256 currentAllowance = allowance[account][msg.sender];\n if (currentAllowance != type(uint256).max) {\n require(\n currentAllowance >= amount,\n \"Burn amount exceeds allowance\"\n );\n _approve(account, msg.sender, currentAllowance - amount);\n }\n _burn(account, amount);\n }\n\n /// @notice Calls `receiveApproval` function on spender previously approving\n /// the spender to withdraw from the caller multiple times, up to\n /// the `amount` amount. If this function is called again, it\n /// overwrites the current allowance with `amount`. Reverts if the\n /// approval reverted or if `receiveApproval` call on the spender\n /// reverted.\n /// @return True if both approval and `receiveApproval` calls succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external override returns (bool) {\n if (approve(spender, amount)) {\n IReceiveApproval(spender).receiveApproval(\n msg.sender,\n amount,\n address(this),\n extraData\n );\n return true;\n }\n return false;\n }\n\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\n /// tokens.\n /// @return True if the operation succeeded.\n /// @dev If the `amount` is set to `type(uint256).max` then\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\n /// Beware that changing an allowance with this method brings the risk\n /// that someone may use both the old and the new allowance by\n /// unfortunate transaction ordering. One possible solution to mitigate\n /// this race condition is to first reduce the spender's allowance to 0\n /// and set the desired value afterwards:\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n function approve(address spender, uint256 amount)\n public\n override\n returns (bool)\n {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\n // chainId and is defined at contract deployment instead of\n // reconstructed for every signature, there is a risk of possible replay\n // attacks between chains in the event of a future chain split.\n // To address this issue, we check the cached chain ID against the\n // current one and in case they are different, we build domain separator\n // from scratch.\n if (block.chainid == cachedChainId) {\n return cachedDomainSeparator;\n } else {\n return buildDomainSeparator();\n }\n }\n\n /// @dev Hook that is called before any transfer of tokens. This includes\n /// minting and burning.\n ///\n /// Calling conditions:\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\n /// will be to transferred to `to`.\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n /// - `from` and `to` are never both zero.\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n function _burn(address account, uint256 amount) internal {\n uint256 currentBalance = balanceOf[account];\n require(currentBalance >= amount, \"Burn amount exceeds balance\");\n\n beforeTokenTransfer(account, address(0), amount);\n\n balanceOf[account] = currentBalance - amount;\n totalSupply -= amount;\n emit Transfer(account, address(0), amount);\n }\n\n function _transfer(\n address spender,\n address recipient,\n uint256 amount\n ) private {\n require(spender != address(0), \"Transfer from the zero address\");\n require(recipient != address(0), \"Transfer to the zero address\");\n require(recipient != address(this), \"Transfer to the token address\");\n\n beforeTokenTransfer(spender, recipient, amount);\n\n uint256 spenderBalance = balanceOf[spender];\n require(spenderBalance >= amount, \"Transfer amount exceeds balance\");\n balanceOf[spender] = spenderBalance - amount;\n balanceOf[recipient] += amount;\n emit Transfer(spender, recipient, amount);\n }\n\n function _approve(\n address owner,\n address spender,\n uint256 amount\n ) private {\n require(owner != address(0), \"Approve from the zero address\");\n require(spender != address(0), \"Approve to the zero address\");\n allowance[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n function buildDomainSeparator() private view returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n ),\n keccak256(bytes(name)),\n keccak256(bytes(\"1\")),\n block.chainid,\n address(this)\n )\n );\n }\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by tokens supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IApproveAndCall {\n /// @notice Executes `receiveApproval` function on spender as specified in\n /// `IReceiveApproval` interface. Approves spender to withdraw from\n /// the caller multiple times, up to the `amount`. If this\n /// function is called again, it overwrites the current allowance\n /// with `amount`. Reverts if the approval reverted or if\n /// `receiveApproval` call on the spender reverted.\n function approveAndCall(\n address spender,\n uint256 amount,\n bytes memory extraData\n ) external returns (bool);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\nimport \"./IApproveAndCall.sol\";\n\n/// @title IERC20WithPermit\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\n/// authorize a transfer of their token with a signature conforming\n/// EIP712 standard instead of an on-chain transaction from their\n/// address. Anyone can submit this signature on the user's behalf by\n/// calling the permit function, as specified in EIP2612 standard,\n/// paying gas fees, and possibly performing other actions in the same\n/// transaction.\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\n /// @notice EIP2612 approval made with secp256k1 signature.\n /// Users can authorize a transfer of their tokens with a signature\n /// conforming EIP712 standard, rather than an on-chain transaction\n /// from their address. Anyone can submit this signature on the\n /// user's behalf by calling the permit function, paying gas fees,\n /// and possibly performing other actions in the same transaction.\n /// @dev The deadline argument can be set to `type(uint256).max to create\n /// permits that effectively never expire.\n function permit(\n address owner,\n address spender,\n uint256 amount,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /// @notice Destroys `amount` tokens from the caller.\n function burn(uint256 amount) external;\n\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\n /// from caller's allowance.\n function burnFrom(address account, uint256 amount) external;\n\n /// @notice Returns hash of EIP712 Domain struct with the token name as\n /// a signing domain and token contract as a verifying contract.\n /// Used to construct EIP2612 signature provided to `permit`\n /// function.\n /* solhint-disable-next-line func-name-mixedcase */\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n /// @notice Returns the current nonce for EIP2612 permission for the\n /// provided token owner for a replay protection. Used to construct\n /// EIP2612 signature provided to `permit` function.\n function nonce(address owner) external view returns (uint256);\n\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\n /// signature provided to `permit` function.\n /* solhint-disable-next-line func-name-mixedcase */\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\n/// @notice An interface that should be implemented by contracts supporting\n/// `approveAndCall`/`receiveApproval` pattern.\ninterface IReceiveApproval {\n /// @notice Receives approval to spend tokens. Called as a result of\n /// `approveAndCall` call on the token.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external;\n}\n" + }, + "@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.4;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/// @title MisfundRecovery\n/// @notice Allows the owner of the token contract extending MisfundRecovery\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\n/// contract address.\ncontract MisfundRecovery is Ownable {\n using SafeERC20 for IERC20;\n\n function recoverERC20(\n IERC20 token,\n address recipient,\n uint256 amount\n ) external onlyOwner {\n token.safeTransfer(recipient, amount);\n }\n\n function recoverERC721(\n IERC721 token,\n address recipient,\n uint256 tokenId,\n bytes calldata data\n ) external onlyOwner {\n token.safeTransferFrom(address(this), recipient, tokenId, data);\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"./IVotesHistory.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\";\n\n/// @title Checkpoints\n/// @dev Abstract contract to support checkpoints for Compound-like voting and\n/// delegation. This implementation supports token supply up to 2^96 - 1.\n/// This contract keeps a history (checkpoints) of each account's vote\n/// power. Vote power can be delegated either by calling the {delegate}\n/// function directly, or by providing a signature to be used with\n/// {delegateBySig}. Voting power can be publicly queried through\n/// {getVotes} and {getPastVotes}.\n/// NOTE: Extracted from OpenZeppelin ERCVotes.sol.\n/// @dev This contract is upgrade-safe.\nabstract contract Checkpoints is IVotesHistory {\n struct Checkpoint {\n uint32 fromBlock;\n uint96 votes;\n }\n\n // slither-disable-next-line uninitialized-state\n mapping(address => address) internal _delegates;\n mapping(address => uint128[]) internal _checkpoints;\n uint128[] internal _totalSupplyCheckpoints;\n\n // Reserved storage space in case we need to add more variables,\n // since there are upgradeable contracts that inherit from this one.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[47] private __gap;\n\n /// @notice Emitted when an account changes their delegate.\n event DelegateChanged(\n address indexed delegator,\n address indexed fromDelegate,\n address indexed toDelegate\n );\n\n /// @notice Emitted when a balance or delegate change results in changes\n /// to an account's voting power.\n event DelegateVotesChanged(\n address indexed delegate,\n uint256 previousBalance,\n uint256 newBalance\n );\n\n function checkpoints(address account, uint32 pos)\n public\n view\n virtual\n returns (Checkpoint memory checkpoint)\n {\n (uint32 fromBlock, uint96 votes) = decodeCheckpoint(\n _checkpoints[account][pos]\n );\n checkpoint = Checkpoint(fromBlock, votes);\n }\n\n /// @notice Get number of checkpoints for `account`.\n function numCheckpoints(address account)\n public\n view\n virtual\n returns (uint32)\n {\n return SafeCastUpgradeable.toUint32(_checkpoints[account].length);\n }\n\n /// @notice Get the address `account` is currently delegating to.\n function delegates(address account) public view virtual returns (address) {\n return _delegates[account];\n }\n\n /// @notice Gets the current votes balance for `account`.\n /// @param account The address to get votes balance\n /// @return The number of current votes for `account`\n function getVotes(address account) public view returns (uint96) {\n uint256 pos = _checkpoints[account].length;\n return pos == 0 ? 0 : decodeValue(_checkpoints[account][pos - 1]);\n }\n\n /// @notice Determine the prior number of votes for an account as of\n /// a block number.\n /// @dev Block number must be a finalized block or else this function will\n /// revert to prevent misinformation.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_checkpoints[account], blockNumber);\n }\n\n /// @notice Retrieve the `totalSupply` at the end of `blockNumber`.\n /// Note, this value is the sum of all balances, but it is NOT the\n /// sum of all the delegated votes!\n /// @param blockNumber The block number to get the total supply at\n /// @dev `blockNumber` must have been already mined\n function getPastTotalSupply(uint256 blockNumber)\n public\n view\n returns (uint96)\n {\n return lookupCheckpoint(_totalSupplyCheckpoints, blockNumber);\n }\n\n /// @notice Change delegation for `delegator` to `delegatee`.\n // slither-disable-next-line dead-code\n function delegate(address delegator, address delegatee) internal virtual;\n\n /// @notice Moves voting power from one delegate to another\n /// @param src Address of old delegate\n /// @param dst Address of new delegate\n /// @param amount Voting power amount to transfer between delegates\n function moveVotingPower(\n address src,\n address dst,\n uint256 amount\n ) internal {\n if (src != dst && amount > 0) {\n if (src != address(0)) {\n // https://github.com/crytic/slither/issues/960\n // slither-disable-next-line variable-scope\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[src],\n subtract,\n amount\n );\n emit DelegateVotesChanged(src, oldWeight, newWeight);\n }\n\n if (dst != address(0)) {\n // https://github.com/crytic/slither/issues/959\n // slither-disable-next-line uninitialized-local\n (uint256 oldWeight, uint256 newWeight) = writeCheckpoint(\n _checkpoints[dst],\n add,\n amount\n );\n emit DelegateVotesChanged(dst, oldWeight, newWeight);\n }\n }\n }\n\n /// @notice Writes a new checkpoint based on operating last stored value\n /// with a `delta`. Usually, said operation is the `add` or\n /// `subtract` functions from this contract, but more complex\n /// functions can be passed as parameters.\n /// @param ckpts The checkpoints array to use\n /// @param op The function to apply over the last value and the `delta`\n /// @param delta Variation with respect to last stored value to be used\n /// for new checkpoint\n function writeCheckpoint(\n uint128[] storage ckpts,\n function(uint256, uint256) view returns (uint256) op,\n uint256 delta\n ) internal returns (uint256 oldWeight, uint256 newWeight) {\n uint256 pos = ckpts.length;\n oldWeight = pos == 0 ? 0 : decodeValue(ckpts[pos - 1]);\n newWeight = op(oldWeight, delta);\n\n if (pos > 0) {\n uint32 fromBlock = decodeBlockNumber(ckpts[pos - 1]);\n // slither-disable-next-line incorrect-equality\n if (fromBlock == block.number) {\n ckpts[pos - 1] = encodeCheckpoint(\n fromBlock,\n SafeCastUpgradeable.toUint96(newWeight)\n );\n return (oldWeight, newWeight);\n }\n }\n\n ckpts.push(\n encodeCheckpoint(\n SafeCastUpgradeable.toUint32(block.number),\n SafeCastUpgradeable.toUint96(newWeight)\n )\n );\n }\n\n /// @notice Lookup a value in a list of (sorted) checkpoints.\n /// @param ckpts The checkpoints array to use\n /// @param blockNumber Block number when we want to get the checkpoint at\n function lookupCheckpoint(uint128[] storage ckpts, uint256 blockNumber)\n internal\n view\n returns (uint96)\n {\n // We run a binary search to look for the earliest checkpoint taken\n // after `blockNumber`. During the loop, the index of the wanted\n // checkpoint remains in the range [low-1, high). With each iteration,\n // either `low` or `high` is moved towards the middle of the range to\n // maintain the invariant.\n // - If the middle checkpoint is after `blockNumber`,\n // we look in [low, mid)\n // - If the middle checkpoint is before or equal to `blockNumber`,\n // we look in [mid+1, high)\n // Once we reach a single value (when low == high), we've found the\n // right checkpoint at the index high-1, if not out of bounds (in that\n // case we're looking too far in the past and the result is 0).\n // Note that if the latest checkpoint available is exactly for\n // `blockNumber`, we end up with an index that is past the end of the\n // array, so we technically don't find a checkpoint after\n // `blockNumber`, but it works out the same.\n require(blockNumber < block.number, \"Block not yet determined\");\n\n uint256 high = ckpts.length;\n uint256 low = 0;\n while (low < high) {\n uint256 mid = MathUpgradeable.average(low, high);\n uint32 midBlock = decodeBlockNumber(ckpts[mid]);\n if (midBlock > blockNumber) {\n high = mid;\n } else {\n low = mid + 1;\n }\n }\n\n return high == 0 ? 0 : decodeValue(ckpts[high - 1]);\n }\n\n /// @notice Maximum token supply. Defaults to `type(uint96).max` (2^96 - 1)\n // slither-disable-next-line dead-code\n function maxSupply() internal view virtual returns (uint96) {\n return type(uint96).max;\n }\n\n /// @notice Encodes a `blockNumber` and `value` into a single `uint128`\n /// checkpoint.\n /// @dev `blockNumber` is stored in the first 32 bits, while `value` in the\n /// remaining 96 bits.\n function encodeCheckpoint(uint32 blockNumber, uint96 value)\n internal\n pure\n returns (uint128)\n {\n return (uint128(blockNumber) << 96) | uint128(value);\n }\n\n /// @notice Decodes a block number from a `uint128` `checkpoint`.\n function decodeBlockNumber(uint128 checkpoint)\n internal\n pure\n returns (uint32)\n {\n return uint32(bytes4(bytes16(checkpoint)));\n }\n\n /// @notice Decodes a voting value from a `uint128` `checkpoint`.\n function decodeValue(uint128 checkpoint) internal pure returns (uint96) {\n return uint96(checkpoint);\n }\n\n /// @notice Decodes a block number and voting value from a `uint128`\n /// `checkpoint`.\n function decodeCheckpoint(uint128 checkpoint)\n internal\n pure\n returns (uint32 blockNumber, uint96 value)\n {\n blockNumber = decodeBlockNumber(checkpoint);\n value = decodeValue(checkpoint);\n }\n\n // slither-disable-next-line dead-code\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n return a + b;\n }\n\n // slither-disable-next-line dead-code\n function subtract(uint256 a, uint256 b) internal pure returns (uint256) {\n return a - b;\n }\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/governance/IVotesHistory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\ninterface IVotesHistory {\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n\n function getPastTotalSupply(uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-or-later\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity 0.8.9;\n\nimport \"../governance/Checkpoints.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\";\n\n/// @title T token\n/// @notice Threshold Network T token\n/// @dev By default, token balance does not account for voting power.\n/// This makes transfers cheaper. The downside is that it requires users\n/// to delegate to themselves to activate checkpoints and have their\n/// voting power tracked.\ncontract T is ERC20WithPermit, MisfundRecovery, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor() ERC20WithPermit(\"Threshold Network Token\", \"T\") {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n uint96 safeAmount = SafeCast.toUint96(amount);\n\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, safeAmount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, safeAmount);\n }\n\n moveVotingPower(delegates(from), delegates(to), safeAmount);\n }\n\n function delegate(address delegator, address delegatee)\n internal\n virtual\n override\n {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/AssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPool.sol\";\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./RewardsPool.sol\";\nimport \"./UnderwriterToken.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Asset Pool\n/// @notice Asset pool is a component of a Coverage Pool. Asset Pool\n/// accepts a single ERC20 token as collateral, and returns an\n/// underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool. Asset Pool accepts no more than 2^96-1 collateral tokens\n/// as a deposit. It means that the total supply of the collateral token\n/// can not be greater than 2^96-1 or, if that supply is greater, it is\n/// acceptable that not all tokens can be deposited into the pool.\ncontract AssetPool is Ownable, IAssetPool {\n using SafeERC20 for ICollateralToken;\n using SafeERC20 for UnderwriterToken;\n\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n RewardsPool public immutable rewardsPool;\n\n IAssetPoolUpgrade public newAssetPool;\n\n /// @notice The time it takes the underwriter to withdraw their collateral\n /// and rewards from the pool. This is the time that needs to pass\n /// between initiating and completing the withdrawal. During that\n /// time, underwriter is still earning rewards and their share of\n /// the pool is still a subject of a possible coverage claim.\n uint256 public withdrawalDelay = 21 days;\n uint256 public newWithdrawalDelay;\n uint256 public withdrawalDelayChangeInitiated;\n\n /// @notice The time the underwriter has after the withdrawal delay passed\n /// to complete the withdrawal. During that time, underwriter is\n /// still earning rewards and their share of the pool is still\n /// a subject of a possible coverage claim.\n /// After the withdrawal timeout elapses, tokens stay in the pool\n /// and the underwriter has to initiate the withdrawal again and\n /// wait for the full withdrawal delay to complete the withdrawal.\n uint256 public withdrawalTimeout = 2 days;\n uint256 public newWithdrawalTimeout;\n uint256 public withdrawalTimeoutChangeInitiated;\n\n mapping(address => uint256) public withdrawalInitiatedTimestamp;\n mapping(address => uint256) public pendingWithdrawal;\n\n event Deposited(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount\n );\n\n event CoverageClaimed(\n address indexed recipient,\n uint256 amount,\n uint256 timestamp\n );\n\n event WithdrawalInitiated(\n address indexed underwriter,\n uint256 covAmount,\n uint256 timestamp\n );\n event WithdrawalCompleted(\n address indexed underwriter,\n uint256 amount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event ApprovedAssetPoolUpgrade(address newAssetPool);\n event CancelledAssetPoolUpgrade(address cancelledAssetPool);\n event AssetPoolUpgraded(\n address indexed underwriter,\n uint256 collateralAmount,\n uint256 covAmount,\n uint256 timestamp\n );\n\n event WithdrawalDelayUpdateStarted(\n uint256 withdrawalDelay,\n uint256 timestamp\n );\n event WithdrawalDelayUpdated(uint256 withdrawalDelay);\n event WithdrawalTimeoutUpdateStarted(\n uint256 withdrawalTimeout,\n uint256 timestamp\n );\n event WithdrawalTimeoutUpdated(uint256 withdrawalTimeout);\n\n /// @notice Reverts if the withdrawal governance delay has not passed yet or\n /// if the change was not yet initiated.\n /// @param changeInitiatedTimestamp The timestamp at which the change has\n /// been initiated\n modifier onlyAfterWithdrawalGovernanceDelay(\n uint256 changeInitiatedTimestamp\n ) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >=\n withdrawalGovernanceDelay(),\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n constructor(\n ICollateralToken _collateralToken,\n UnderwriterToken _underwriterToken,\n address rewardsManager\n ) {\n collateralToken = _collateralToken;\n underwriterToken = _underwriterToken;\n\n rewardsPool = new RewardsPool(\n _collateralToken,\n address(this),\n rewardsManager\n );\n\n initGovernance(_collateralToken);\n }\n\n /// @dev Overwrite to empty if collateral token used by the AssetPool\n /// does not support DAO checkpoints. Used for tests with KEEP token.\n function initGovernance(ICollateralToken _collateralToken)\n internal\n virtual\n {\n _collateralToken.delegate(address(this));\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// Optional data in extraData may include a minimal amount of\n /// underwriter tokens expected to be minted for a depositor. There\n /// are cases when an amount of minted tokens matters for a\n /// depositor, as tokens might be used in third party exchanges.\n /// @dev This function is a shortcut for approve + deposit.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata extraData\n ) external {\n require(\n amount + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n require(msg.sender == token, \"Only token caller allowed\");\n require(\n token == address(collateralToken),\n \"Unsupported collateral token\"\n );\n\n uint256 toMint = _calculateTokensToMint(amount);\n if (extraData.length != 0) {\n require(extraData.length == 32, \"Unexpected data length\");\n uint256 minAmountToMint = abi.decode(extraData, (uint256));\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n }\n\n _deposit(from, amount, toMint);\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership. The\n /// amount locked in the pool after accepting this deposit must\n /// be smaller or equal to 2^96-1; otherwise, the function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal to\n /// 2^96-1\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amountToDeposit)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership. The amount locked in the pool after accepting\n /// this deposit must be smaller or equal to 2^96-1; otherwise, the\n /// function reverts.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @param amountToDeposit Collateral tokens amount that a user deposits to\n /// the asset pool; must be smaller or equal\n /// to 2^96-1\n /// @param minAmountToMint Underwriter minimal tokens amount that a user\n /// expects to receive in exchange for the deposited\n /// collateral tokens\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n override\n returns (uint256)\n {\n require(\n amountToDeposit + totalValue() <= type(uint96).max,\n \"Pool capacity exceeded\"\n );\n uint256 toMint = _calculateTokensToMint(amountToDeposit);\n\n require(\n minAmountToMint <= toMint,\n \"Amount to mint is smaller than the required minimum\"\n );\n\n _deposit(msg.sender, amountToDeposit, toMint);\n return toMint;\n }\n\n /// @notice Initiates the withdrawal of collateral and rewards from the\n /// pool. Must be followed with completeWithdrawal call after the\n /// withdrawal delay passes. Accepts the amount of underwriter\n /// tokens representing the share of the pool that should be\n /// withdrawn. Can be called multiple times increasing the pool share\n /// to withdraw and resetting the withdrawal initiated timestamp for\n /// each call. Can be called with 0 covAmount to reset the\n /// withdrawal initiated timestamp if the underwriter has a pending\n /// withdrawal. In practice 0 covAmount should be used only to\n /// initiate the withdrawal again in case one did not complete the\n /// withdrawal before the withdrawal timeout elapsed.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external override {\n uint256 pending = pendingWithdrawal[msg.sender];\n require(\n covAmount > 0 || pending > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n pending += covAmount;\n pendingWithdrawal[msg.sender] = pending;\n /* solhint-disable not-rely-on-time */\n withdrawalInitiatedTimestamp[msg.sender] = block.timestamp;\n\n emit WithdrawalInitiated(msg.sender, pending, block.timestamp);\n /* solhint-enable not-rely-on-time */\n\n if (covAmount > 0) {\n underwriterToken.safeTransferFrom(\n msg.sender,\n address(this),\n covAmount\n );\n }\n }\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter. Anyone can complete the withdrawal for the\n /// underwriter. The withdrawal has to be completed before the\n /// withdrawal timeout elapses. Otherwise, the withdrawal has to\n /// be initiated again and the underwriter has to wait for the\n /// entire withdrawal delay again before being able to complete\n /// the withdrawal.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter)\n external\n override\n returns (uint256)\n {\n /* solhint-disable not-rely-on-time */\n uint256 initiatedAt = withdrawalInitiatedTimestamp[underwriter];\n require(initiatedAt > 0, \"No withdrawal initiated for the underwriter\");\n\n uint256 withdrawalDelayEndTimestamp = initiatedAt + withdrawalDelay;\n require(\n withdrawalDelayEndTimestamp < block.timestamp,\n \"Withdrawal delay has not elapsed\"\n );\n\n require(\n withdrawalDelayEndTimestamp + withdrawalTimeout >= block.timestamp,\n \"Withdrawal timeout elapsed\"\n );\n\n uint256 covAmount = pendingWithdrawal[underwriter];\n uint256 covSupply = underwriterToken.totalSupply();\n delete withdrawalInitiatedTimestamp[underwriter];\n delete pendingWithdrawal[underwriter];\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 amountToWithdraw = (covAmount * collateralBalance) / covSupply;\n\n emit WithdrawalCompleted(\n underwriter,\n amountToWithdraw,\n covAmount,\n block.timestamp\n );\n collateralToken.safeTransfer(underwriter, amountToWithdraw);\n\n /* solhint-enable not-rely-on-time */\n underwriterToken.burn(covAmount);\n\n return amountToWithdraw;\n }\n\n /// @notice Transfers collateral tokens to a new Asset Pool which previously\n /// was approved by the governance. Upgrade does not have to obey\n /// withdrawal delay.\n /// Old underwriter tokens are burned in favor of new tokens minted\n /// in a new Asset Pool. New tokens are sent directly to the\n /// underwriter from a new Asset Pool.\n /// @param covAmount Amount of underwriter tokens used to calculate collateral\n /// tokens which are transferred to a new asset pool\n /// @param _newAssetPool New Asset Pool address to check validity with the one\n /// that was approved by the governance\n function upgradeToNewAssetPool(uint256 covAmount, address _newAssetPool)\n external\n {\n /* solhint-disable not-rely-on-time */\n require(\n address(newAssetPool) != address(0),\n \"New asset pool must be assigned\"\n );\n\n require(\n address(newAssetPool) == _newAssetPool,\n \"Addresses of a new asset pool must match\"\n );\n\n require(\n covAmount > 0,\n \"Underwriter token amount must be greater than 0\"\n );\n\n uint256 covSupply = underwriterToken.totalSupply();\n\n // slither-disable-next-line reentrancy-events\n rewardsPool.withdraw();\n\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n uint256 collateralToTransfer = (covAmount * collateralBalance) /\n covSupply;\n\n collateralToken.safeApprove(\n address(newAssetPool),\n collateralToTransfer\n );\n // old underwriter tokens are burned in favor of new minted in a new\n // asset pool\n underwriterToken.burnFrom(msg.sender, covAmount);\n // collateralToTransfer will be sent to a new AssetPool and new\n // underwriter tokens will be minted and transferred back to the underwriter\n newAssetPool.depositFor(msg.sender, collateralToTransfer);\n\n emit AssetPoolUpgraded(\n msg.sender,\n collateralToTransfer,\n covAmount,\n block.timestamp\n );\n }\n\n /// @notice Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n require(\n address(_newAssetPool) != address(0),\n \"New asset pool can't be zero address\"\n );\n\n newAssetPool = _newAssetPool;\n\n emit ApprovedAssetPoolUpgrade(address(_newAssetPool));\n }\n\n /// @notice Allows governance to cancel already approved new asset pool\n /// in case of some misconfiguration.\n function cancelNewAssetPoolUpgrade() external onlyOwner {\n emit CancelledAssetPoolUpgrade(address(newAssetPool));\n\n newAssetPool = IAssetPoolUpgrade(address(0));\n }\n\n /// @notice Allows the coverage pool to demand coverage from the asset hold\n /// by this pool and send it to the provided recipient address.\n function claim(address recipient, uint256 amount) external onlyOwner {\n emit CoverageClaimed(recipient, amount, block.timestamp);\n rewardsPool.withdraw();\n require(\n amount <= collateralToken.balanceOf(address(this)),\n \"Amount to seize exceeds the pool balance\"\n );\n collateralToken.safeTransfer(recipient, amount);\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param _newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 _newWithdrawalDelay)\n external\n onlyOwner\n {\n newWithdrawalDelay = _newWithdrawalDelay;\n withdrawalDelayChangeInitiated = block.timestamp;\n emit WithdrawalDelayUpdateStarted(_newWithdrawalDelay, block.timestamp);\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalDelayChangeInitiated)\n {\n withdrawalDelay = newWithdrawalDelay;\n emit WithdrawalDelayUpdated(withdrawalDelay);\n newWithdrawalDelay = 0;\n withdrawalDelayChangeInitiated = 0;\n }\n\n /// @notice Lets the contract owner to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the contract owner to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param _newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 _newWithdrawalTimeout)\n external\n onlyOwner\n {\n newWithdrawalTimeout = _newWithdrawalTimeout;\n withdrawalTimeoutChangeInitiated = block.timestamp;\n emit WithdrawalTimeoutUpdateStarted(\n _newWithdrawalTimeout,\n block.timestamp\n );\n }\n\n /// @notice Lets the contract owner to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate()\n external\n onlyOwner\n onlyAfterWithdrawalGovernanceDelay(withdrawalTimeoutChangeInitiated)\n {\n withdrawalTimeout = newWithdrawalTimeout;\n emit WithdrawalTimeoutUpdated(withdrawalTimeout);\n newWithdrawalTimeout = 0;\n withdrawalTimeoutChangeInitiated = 0;\n }\n\n /// @notice Grants pool shares by minting a given amount of the underwriter\n /// tokens for the recipient address. In result, the recipient\n /// obtains part of the pool ownership without depositing any\n /// collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by the contract owner.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantShares(address recipient, uint256 covAmount)\n external\n onlyOwner\n {\n rewardsPool.withdraw();\n underwriterToken.mint(recipient, covAmount);\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal delay update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal delay update can be finalized\n function getRemainingWithdrawalDelayUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalDelayChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the remaining time that has to pass before the contract\n /// owner will be able to finalize withdrawal timeout update.\n /// Bear in mind the contract owner may decide to wait longer and\n /// this value is just an absolute minimum.\n /// @return The time left until withdrawal timeout update can be finalized\n function getRemainingWithdrawalTimeoutUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n withdrawalTimeoutChangeInitiated,\n withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Returns the current collateral token balance of the asset pool\n /// plus the reward amount (in collateral token) earned by the asset\n /// pool and not yet withdrawn to the asset pool.\n /// @return The total value of asset pool in collateral token.\n function totalValue() public view returns (uint256) {\n return collateralToken.balanceOf(address(this)) + rewardsPool.earned();\n }\n\n /// @notice The time it takes to initiate and complete the withdrawal from\n /// the pool plus 2 days to make a decision. This governance delay\n /// should be used for all changes directly affecting underwriter\n /// positions. This time is a minimum and the governance may choose\n /// to wait longer before finalizing the update.\n /// @return The withdrawal governance delay in seconds\n function withdrawalGovernanceDelay() public view returns (uint256) {\n return withdrawalDelay + withdrawalTimeout + 2 days;\n }\n\n /// @dev Calculates underwriter tokens to mint.\n function _calculateTokensToMint(uint256 amountToDeposit)\n internal\n returns (uint256)\n {\n rewardsPool.withdraw();\n\n uint256 covSupply = underwriterToken.totalSupply();\n uint256 collateralBalance = collateralToken.balanceOf(address(this));\n\n if (covSupply == 0) {\n return amountToDeposit;\n }\n\n return (amountToDeposit * covSupply) / collateralBalance;\n }\n\n function _deposit(\n address depositor,\n uint256 amountToDeposit,\n uint256 amountToMint\n ) internal {\n require(depositor != address(this), \"Self-deposit not allowed\");\n\n require(\n amountToMint > 0,\n \"Minted tokens amount must be greater than 0\"\n );\n\n emit Deposited(depositor, amountToDeposit, amountToMint);\n\n underwriterToken.mint(depositor, amountToMint);\n collateralToken.safeTransferFrom(\n depositor,\n address(this),\n amountToDeposit\n );\n }\n}\n" + }, + "contracts/Auction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAuction.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title Auction\n/// @notice A contract to run a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\n/// pool. Auctions can be partially filled, and are meant to be amenable\n/// to flash loans and other atomic constructions to take advantage of\n/// arbitrage opportunities within a single block.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// Auction contracts are not meant to be deployed directly, and are\n/// instead cloned by an auction factory. Auction contracts clean up and\n/// self-destruct on close. An auction that has run the entire length will\n/// stay open, forever, or until priced fluctuate and it's eventually\n/// profitable to close.\ncontract Auction is IAuction {\n using SafeERC20 for IERC20;\n\n struct AuctionStorage {\n IERC20 tokenAccepted;\n Auctioneer auctioneer;\n // the auction price, denominated in tokenAccepted\n uint256 amountOutstanding;\n uint256 amountDesired;\n uint256 startTime;\n uint256 startTimeOffset;\n uint256 auctionLength;\n }\n\n AuctionStorage public self;\n address public immutable masterContract;\n\n /// @notice Throws if called by any account other than the auctioneer.\n modifier onlyAuctioneer() {\n //slither-disable-next-line incorrect-equality\n require(\n msg.sender == address(self.auctioneer),\n \"Caller is not the auctioneer\"\n );\n\n _;\n }\n\n constructor() {\n masterContract = address(this);\n }\n\n /// @notice Initializes auction\n /// @dev At the beginning of an auction, velocity pool depleting rate is\n /// always 1. It increases over time after a partial auction buy.\n /// @param _auctioneer the auctioneer contract responsible for seizing\n /// funds from the backing collateral pool\n /// @param _tokenAccepted the token with which the auction can be taken\n /// @param _amountDesired the amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param _auctionLength the amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function initialize(\n Auctioneer _auctioneer,\n IERC20 _tokenAccepted,\n uint256 _amountDesired,\n uint256 _auctionLength\n ) external {\n require(!isMasterContract(), \"Can not initialize master contract\");\n //slither-disable-next-line incorrect-equality\n require(self.startTime == 0, \"Auction already initialized\");\n require(_amountDesired > 0, \"Amount desired must be greater than zero\");\n require(_auctionLength > 0, \"Auction length must be greater than zero\");\n self.auctioneer = _auctioneer;\n self.tokenAccepted = _tokenAccepted;\n self.amountOutstanding = _amountDesired;\n self.amountDesired = _amountDesired;\n /* solhint-disable-next-line not-rely-on-time */\n self.startTime = block.timestamp;\n self.startTimeOffset = 0;\n self.auctionLength = _auctionLength;\n }\n\n /// @notice Takes an offer from an auction buyer.\n /// @dev There are two possible ways to take an offer from a buyer. The first\n /// one is to buy entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// WARNING: When calling this function directly, it might happen that\n /// the expected amount of tokens to seize from the coverage pool is\n /// different from the actual one. There are a couple of reasons for that\n /// such another bids taking this offer, claims or withdrawals on an\n /// Asset Pool that are executed in the same block. The recommended way\n /// for taking an offer is through 'AuctionBidder' contract with\n /// 'takeOfferWithMin' function, where a caller can specify the minimal\n /// value to receive from the coverage pool in exchange for its amount\n /// of tokenAccepted.\n /// @param amount the amount the taker is paying, denominated in tokenAccepted.\n /// In the scenario when amount exceeds the outstanding tokens\n /// for the auction to complete, only the amount outstanding will\n /// be taken from a caller.\n function takeOffer(uint256 amount) external override {\n require(amount > 0, \"Can't pay 0 tokens\");\n uint256 amountToTransfer = Math.min(amount, self.amountOutstanding);\n uint256 amountOnOffer = _onOffer();\n\n //slither-disable-next-line reentrancy-no-eth\n self.tokenAccepted.safeTransferFrom(\n msg.sender,\n address(self.auctioneer),\n amountToTransfer\n );\n\n uint256 portionToSeize = (amountOnOffer * amountToTransfer) /\n self.amountOutstanding;\n\n if (!isAuctionOver() && amountToTransfer != self.amountOutstanding) {\n // Time passed since the auction start or the last takeOffer call\n // with a partial fill.\n\n\n uint256 timePassed /* solhint-disable-next-line not-rely-on-time */\n = block.timestamp - self.startTime - self.startTimeOffset;\n\n // Ratio of the auction's amount included in this takeOffer call to\n // the whole outstanding auction amount.\n uint256 ratioAmountPaid = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * amountToTransfer) /\n self.amountOutstanding;\n // We will shift the start time offset and increase the velocity pool\n // depleting rate proportionally to the fraction of the outstanding\n // amount paid in this function call so that the auction can offer\n // no worse financial outcome for the next takers than the current\n // taker has.\n //\n //slither-disable-next-line divide-before-multiply\n self.startTimeOffset =\n self.startTimeOffset +\n ((timePassed * ratioAmountPaid) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n self.amountOutstanding -= amountToTransfer;\n\n //slither-disable-next-line incorrect-equality\n bool isFullyFilled = self.amountOutstanding == 0;\n\n // inform auctioneer of proceeds and winner. the auctioneer seizes funds\n // from the collateral pool in the name of the winner, and controls all\n // proceeds\n //\n //slither-disable-next-line reentrancy-no-eth\n self.auctioneer.offerTaken(\n msg.sender,\n self.tokenAccepted,\n amountToTransfer,\n portionToSeize,\n isFullyFilled\n );\n\n //slither-disable-next-line incorrect-equality\n if (isFullyFilled) {\n harikari();\n }\n }\n\n /// @notice Tears down the auction manually, before its entire amount\n /// is bought by takers.\n /// @dev Can be called only by the auctioneer which may decide to early\n // close the auction in case it is no longer needed.\n function earlyClose() external onlyAuctioneer {\n require(self.amountOutstanding > 0, \"Auction must be open\");\n\n harikari();\n }\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @dev _onOffer() / FLOATING_POINT_DIVISOR) returns a portion of the\n /// collateral pool. Ex. if 35% available of the collateral pool,\n /// then _onOffer() / FLOATING_POINT_DIVISOR) returns 0.35\n /// @return the ratio of the collateral pool currently on offer\n function onOffer() external view override returns (uint256, uint256) {\n return (_onOffer(), CoveragePoolConstants.FLOATING_POINT_DIVISOR);\n }\n\n function amountOutstanding() external view returns (uint256) {\n return self.amountOutstanding;\n }\n\n function amountTransferred() external view returns (uint256) {\n return self.amountDesired - self.amountOutstanding;\n }\n\n /// @dev Delete all storage and destroy the contract. Should only be called\n /// after an auction has closed.\n function harikari() internal {\n require(!isMasterContract(), \"Master contract can not harikari\");\n selfdestruct(payable(address(self.auctioneer)));\n }\n\n function _onOffer() internal view returns (uint256) {\n // when the auction is over, entire pool is on offer\n if (isAuctionOver()) {\n // Down the road, for determining a portion on offer, a value returned\n // by this function will be divided by FLOATING_POINT_DIVISOR. To\n // return the entire pool, we need to return just this divisor in order\n // to get 1.0 ie. FLOATING_POINT_DIVISOR / FLOATING_POINT_DIVISOR = 1.0\n return CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n\n // How fast portions of the collateral pool become available on offer.\n // It is needed to calculate the right portion value on offer at the\n // given moment before the auction is over.\n // Auction length once set is constant and what changes is the auction's\n // \"start time offset\" once the takeOffer() call has been processed for\n // partial fill. The auction's \"start time offset\" is updated every takeOffer().\n // velocityPoolDepletingRate = auctionLength / (auctionLength - startTimeOffset)\n // velocityPoolDepletingRate always starts at 1.0 and then can go up\n // depending on partial offer calls over auction life span to maintain\n // the right ratio between the remaining auction time and the remaining\n // portion of the collateral pool.\n //slither-disable-next-line divide-before-multiply\n uint256 velocityPoolDepletingRate = (CoveragePoolConstants\n .FLOATING_POINT_DIVISOR * self.auctionLength) /\n (self.auctionLength - self.startTimeOffset);\n\n return\n /* solhint-disable-next-line not-rely-on-time */\n ((block.timestamp - (self.startTime + self.startTimeOffset)) *\n velocityPoolDepletingRate) / self.auctionLength;\n }\n\n function isAuctionOver() internal view returns (bool) {\n /* solhint-disable-next-line not-rely-on-time */\n return block.timestamp >= self.startTime + self.auctionLength;\n }\n\n function isMasterContract() internal view returns (bool) {\n return masterContract == address(this);\n }\n}\n" + }, + "contracts/AuctionBidder.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\n/// @title AuctionBidder\n/// @notice A contract for auction bidders for buying coverage pool auctions. This\n/// contract offers additional features for bidders to decide if their\n/// requirements for making a purchase are satisfied.\ncontract AuctionBidder {\n CoveragePool public immutable coveragePool;\n\n constructor(CoveragePool _coveragePool) {\n coveragePool = _coveragePool;\n }\n\n /// @notice Takes an offer from an auction buyer with a minimum required amount\n /// of tokens to seize from the coverage pool.\n /// @dev This contract is used only for KEEP coverage pool in v1 that was\n /// depricated. Going forward T coverage pool will be used for v2.\n /// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n ///\n /// 'minAmountToSeize' sets a minimum amount of tokens to seize in this\n /// transaction. A bidder can call `takeOffer` directly in the Auction\n /// contract but this function is a recommended way of taking coverage pool\n /// auctions. It might happen that the order of transactions might be changed\n /// for 'takeOffer' calls in the same block or claim and withdrawals from\n /// an AssetPool might occur. These reasons can affect a taker's expected\n /// amount of the coverage pool tokens to receive. Whereas if a minimum\n /// amount of tokens is specified but not satisfied, then the transaction\n /// will revert.\n /// @param auction coverage pool auction\n /// @param amount the amount a taker is paying, denominated in token accepted\n /// by the auction\n /// @param minAmountToSeize minimum amount of tokens to seize from the coverage\n /// pool\n function takeOfferWithMin(\n Auction auction,\n uint256 amount,\n uint256 minAmountToSeize\n ) external {\n uint256 auctionAmountOutstanding = auction.amountOutstanding();\n uint256 amountToPay = Math.min(amount, auctionAmountOutstanding);\n (uint256 amountOnOffer, ) = auction.onOffer();\n uint256 portionToSeize = (amountOnOffer * amountToPay) /\n auctionAmountOutstanding;\n\n uint256 amountToSeize = coveragePool.amountToSeize(portionToSeize);\n\n require(\n minAmountToSeize <= amountToSeize,\n \"Can't fulfill offer with a minimal amount to seize\"\n );\n\n auction.takeOffer(amount);\n }\n}\n" + }, + "contracts/Auctioneer.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./Auction.sol\";\nimport \"./CoveragePool.sol\";\n\nimport \"@thesis/solidity-contracts/contracts/clone/CloneFactory.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Auctioneer\n/// @notice Factory for the creation of new auction clones and receiving proceeds.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\n///\n/// We avoid redeployment of auction contracts by using the clone factory.\n/// Proxy delegates calls to Auction and therefore does not affect auction state.\n/// This means that we only need to deploy the auction contracts once.\n/// The auctioneer provides clean state for every new auction clone.\ncontract Auctioneer is CloneFactory {\n // Holds the address of the auction contract\n // which will be used as a master contract for cloning.\n address public immutable masterAuction;\n mapping(address => bool) public openAuctions;\n uint256 public openAuctionsCount;\n\n CoveragePool public immutable coveragePool;\n\n event AuctionCreated(\n address indexed tokenAccepted,\n uint256 amount,\n address auctionAddress\n );\n event AuctionOfferTaken(\n address indexed auction,\n address indexed offerTaker,\n address tokenAccepted,\n uint256 amount,\n uint256 portionToSeize // This amount should be divided by FLOATING_POINT_DIVISOR\n );\n event AuctionClosed(address indexed auction);\n\n constructor(CoveragePool _coveragePool, address _masterAuction) {\n coveragePool = _coveragePool;\n // slither-disable-next-line missing-zero-check\n masterAuction = _masterAuction;\n }\n\n /// @notice Informs the auctioneer to seize funds and log appropriate events\n /// @dev This function is meant to be called from a cloned auction. It logs\n /// \"offer taken\" and \"auction closed\" events, seizes funds, and cleans\n /// up closed auctions.\n /// @param offerTaker The address of the taker of the auction offer,\n /// who will receive the pool's seized funds\n /// @param tokenPaid The token this auction is denominated in\n /// @param tokenAmountPaid The amount of the token the taker paid\n /// @param portionToSeize The portion of the pool the taker won at auction.\n /// This amount should be divided by FLOATING_POINT_DIVISOR\n /// to calculate how much of the pool should be set\n /// aside as the taker's winnings.\n /// @param fullyFilled Indicates whether the auction was taken fully or\n /// partially. If auction was fully filled, it is\n /// closed. If auction was partially filled, it is\n /// sill open and waiting for remaining bids.\n function offerTaken(\n address offerTaker,\n IERC20 tokenPaid,\n uint256 tokenAmountPaid,\n uint256 portionToSeize,\n bool fullyFilled\n ) external {\n require(openAuctions[msg.sender], \"Sender isn't an auction\");\n\n emit AuctionOfferTaken(\n msg.sender,\n offerTaker,\n address(tokenPaid),\n tokenAmountPaid,\n portionToSeize\n );\n\n // actually seize funds, setting them aside for the taker to withdraw\n // from the coverage pool.\n // `portionToSeize` will be divided by FLOATING_POINT_DIVISOR which is\n // defined in Auction.sol\n //\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n coveragePool.seizePortion(offerTaker, portionToSeize);\n\n Auction auction = Auction(msg.sender);\n if (fullyFilled) {\n onAuctionFullyFilled(auction);\n\n emit AuctionClosed(msg.sender);\n delete openAuctions[msg.sender];\n openAuctionsCount -= 1;\n } else {\n onAuctionPartiallyFilled(auction);\n }\n }\n\n /// @notice Opens a new auction against the coverage pool. The auction\n /// will remain open until filled.\n /// @dev Calls `Auction.initialize` to initialize the instance.\n /// @param tokenAccepted The token with which the auction can be taken\n /// @param amountDesired The amount denominated in _tokenAccepted. After\n /// this amount is received, the auction can close.\n /// @param auctionLength The amount of time it takes for the auction to get\n /// to 100% of all collateral on offer, in seconds.\n function createAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) internal returns (address) {\n address cloneAddress = createClone(masterAuction);\n require(cloneAddress != address(0), \"Cloned auction address is 0\");\n\n Auction auction = Auction(cloneAddress);\n //slither-disable-next-line reentrancy-benign,reentrancy-events\n auction.initialize(this, tokenAccepted, amountDesired, auctionLength);\n\n openAuctions[cloneAddress] = true;\n openAuctionsCount += 1;\n\n emit AuctionCreated(\n address(tokenAccepted),\n amountDesired,\n cloneAddress\n );\n\n return cloneAddress;\n }\n\n /// @notice Tears down an open auction with given address immediately.\n /// @dev Can be called by contract owner to early close an auction if it\n /// is no longer needed. Bear in mind that funds from the early closed\n /// auction last on the auctioneer contract. Calling code should take\n /// care of them.\n /// @return Amount of funds transferred to this contract by the Auction\n /// being early closed.\n function earlyCloseAuction(Auction auction) internal returns (uint256) {\n address auctionAddress = address(auction);\n\n require(openAuctions[auctionAddress], \"Address is not an open auction\");\n\n uint256 amountTransferred = auction.amountTransferred();\n\n //slither-disable-next-line reentrancy-no-eth,reentrancy-events,reentrancy-benign\n auction.earlyClose();\n\n emit AuctionClosed(auctionAddress);\n delete openAuctions[auctionAddress];\n openAuctionsCount -= 1;\n\n return amountTransferred;\n }\n\n /// @notice Auction lifecycle hook allowing to act on auction closed\n /// as fully filled. This function is not executed when an auction\n /// was partially filled. When this function is executed auction is\n /// already closed and funds from the coverage pool are seized.\n /// @dev Override this function to act on auction closed as fully filled.\n function onAuctionFullyFilled(Auction auction) internal virtual {}\n\n /// @notice Auction lifecycle hook allowing to act on auction partially\n /// filled. This function is not executed when an auction\n /// was fully filled.\n /// @dev Override this function to act on auction partially filled.\n function onAuctionPartiallyFilled(Auction auction) internal view virtual {}\n}\n" + }, + "contracts/BatchedPhasedEscrow.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Batched Phased Escrow Beneficiary\n/// @notice Interface expected from contracts receiving tokens from the\n/// BatchedPhasedEscrow.\ninterface IBeneficiaryContract {\n function __escrowSentTokens(uint256 amount) external;\n}\n\n/// @title BatchedPhasedEscrow\n/// @notice A token holder contract allowing contract owner to approve a set of\n/// beneficiaries of tokens held by the contract, to appoint a separate\n/// drawee role, and allowing that drawee to withdraw tokens to approved\n/// beneficiaries in phases.\ncontract BatchedPhasedEscrow is Ownable {\n using SafeERC20 for IERC20;\n\n event BeneficiaryApproved(address beneficiary);\n event TokensWithdrawn(address beneficiary, uint256 amount);\n event DraweeRoleTransferred(address oldDrawee, address newDrawee);\n\n IERC20 public token;\n address public drawee;\n mapping(address => bool) private approvedBeneficiaries;\n\n modifier onlyDrawee() {\n require(drawee == msg.sender, \"Caller is not the drawee\");\n _;\n }\n\n constructor(IERC20 _token) {\n token = _token;\n drawee = msg.sender;\n }\n\n /// @notice Approves the provided address as a beneficiary of tokens held by\n /// the escrow. Can be called only by escrow owner.\n function approveBeneficiary(IBeneficiaryContract _beneficiary)\n external\n onlyOwner\n {\n address beneficiaryAddress = address(_beneficiary);\n require(\n beneficiaryAddress != address(0),\n \"Beneficiary can not be zero address\"\n );\n approvedBeneficiaries[beneficiaryAddress] = true;\n emit BeneficiaryApproved(beneficiaryAddress);\n }\n\n /// @notice Returns `true` if the given address has been approved as a\n /// beneficiary of the escrow, `false` otherwise.\n function isBeneficiaryApproved(IBeneficiaryContract _beneficiary)\n public\n view\n returns (bool)\n {\n return approvedBeneficiaries[address(_beneficiary)];\n }\n\n /// @notice Transfers the role of drawee to another address. Can be called\n /// only by the contract owner.\n function setDrawee(address newDrawee) external onlyOwner {\n require(newDrawee != address(0), \"New drawee can not be zero address\");\n emit DraweeRoleTransferred(drawee, newDrawee);\n drawee = newDrawee;\n }\n\n /// @notice Funds the escrow by transferring all of the approved tokens\n /// to the escrow.\n function receiveApproval(\n address _from,\n uint256 _value,\n address _token,\n bytes memory\n ) external {\n require(IERC20(_token) == token, \"Unsupported token\");\n token.safeTransferFrom(_from, address(this), _value);\n }\n\n /// @notice Withdraws tokens from escrow to selected beneficiaries,\n /// transferring to each beneficiary the amount of tokens specified\n /// as a parameter. Only beneficiaries previously approved by escrow\n /// owner can receive funds.\n function batchedWithdraw(\n IBeneficiaryContract[] memory beneficiaries,\n uint256[] memory amounts\n ) external onlyDrawee {\n require(\n beneficiaries.length == amounts.length,\n \"Mismatched arrays length\"\n );\n\n for (uint256 i = 0; i < beneficiaries.length; i++) {\n IBeneficiaryContract beneficiary = beneficiaries[i];\n require(\n isBeneficiaryApproved(beneficiary),\n \"Beneficiary was not approved\"\n );\n withdraw(beneficiary, amounts[i]);\n }\n }\n\n function withdraw(IBeneficiaryContract beneficiary, uint256 amount)\n private\n {\n emit TokensWithdrawn(address(beneficiary), amount);\n token.safeTransfer(address(beneficiary), amount);\n // slither-disable-next-line calls-loop\n beneficiary.__escrowSentTokens(amount);\n }\n}\n" + }, + "contracts/CoveragePool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IAssetPoolUpgrade.sol\";\nimport \"./interfaces/ICollateralToken.sol\";\nimport \"./AssetPool.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Coverage Pool\n/// @notice A contract that manages a single asset pool. Handles approving and\n/// unapproving of risk managers and allows them to seize funds from the\n/// asset pool if they are approved.\n/// @dev Coverage pool contract is owned by the governance. Coverage pool is the\n/// owner of the asset pool contract.\ncontract CoveragePool is Ownable {\n AssetPool public immutable assetPool;\n ICollateralToken public immutable collateralToken;\n UnderwriterToken public immutable underwriterToken;\n\n bool public firstRiskManagerApproved = false;\n\n // Currently approved risk managers\n mapping(address => bool) public approvedRiskManagers;\n // Timestamps of risk managers whose approvals have been initiated\n mapping(address => uint256) public riskManagerApprovalTimestamps;\n\n event RiskManagerApprovalStarted(address riskManager, uint256 timestamp);\n event RiskManagerApprovalCompleted(address riskManager, uint256 timestamp);\n event RiskManagerUnapproved(address riskManager, uint256 timestamp);\n\n /// @notice Reverts if called by a risk manager that is not approved\n modifier onlyApprovedRiskManager() {\n require(approvedRiskManagers[msg.sender], \"Risk manager not approved\");\n _;\n }\n\n constructor(AssetPool _assetPool) {\n assetPool = _assetPool;\n collateralToken = _assetPool.collateralToken();\n underwriterToken = _assetPool.underwriterToken();\n }\n\n /// @notice Approves the first risk manager\n /// @dev Can be called only by the contract owner. Can be called only once.\n /// Does not require any further calls to any functions.\n /// @param riskManager Risk manager that will be approved\n function approveFirstRiskManager(address riskManager) external onlyOwner {\n require(\n !firstRiskManagerApproved,\n \"The first risk manager was approved\"\n );\n approvedRiskManagers[riskManager] = true;\n firstRiskManagerApproved = true;\n }\n\n /// @notice Begins risk manager approval process.\n /// @dev Can be called only by the contract owner and only when the first\n /// risk manager is already approved. For a risk manager to be\n /// approved, a call to `finalizeRiskManagerApproval` must follow\n /// (after a governance delay).\n /// @param riskManager Risk manager that will be approved\n function beginRiskManagerApproval(address riskManager) external onlyOwner {\n require(\n firstRiskManagerApproved,\n \"The first risk manager is not yet approved; Please use \"\n \"approveFirstRiskManager instead\"\n );\n\n require(\n !approvedRiskManagers[riskManager],\n \"Risk manager already approved\"\n );\n\n /* solhint-disable-next-line not-rely-on-time */\n riskManagerApprovalTimestamps[riskManager] = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalStarted(riskManager, block.timestamp);\n }\n\n /// @notice Finalizes risk manager approval process.\n /// @dev Can be called only by the contract owner. Must be preceded with a\n /// call to beginRiskManagerApproval and a governance delay must elapse.\n /// @param riskManager Risk manager that will be approved\n function finalizeRiskManagerApproval(address riskManager)\n external\n onlyOwner\n {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0,\n \"Risk manager approval not initiated\"\n );\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - riskManagerApprovalTimestamps[riskManager] >=\n assetPool.withdrawalGovernanceDelay(),\n \"Risk manager governance delay has not elapsed\"\n );\n approvedRiskManagers[riskManager] = true;\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerApprovalCompleted(riskManager, block.timestamp);\n delete riskManagerApprovalTimestamps[riskManager];\n }\n\n /// @notice Unapproves an already approved risk manager or cancels the\n /// approval process of a risk manager (the latter happens if called\n /// between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`).\n /// The change takes effect immediately.\n /// @dev Can be called only by the contract owner.\n /// @param riskManager Risk manager that will be unapproved\n function unapproveRiskManager(address riskManager) external onlyOwner {\n require(\n riskManagerApprovalTimestamps[riskManager] > 0 ||\n approvedRiskManagers[riskManager],\n \"Risk manager is neither approved nor with a pending approval\"\n );\n delete riskManagerApprovalTimestamps[riskManager];\n delete approvedRiskManagers[riskManager];\n /* solhint-disable-next-line not-rely-on-time */\n emit RiskManagerUnapproved(riskManager, block.timestamp);\n }\n\n /// @notice Approves upgradeability to the new asset pool.\n /// Allows governance to set a new asset pool so the underwriters\n /// can move their collateral tokens to a new asset pool without\n /// having to wait for the withdrawal delay.\n /// @param _newAssetPool New asset pool\n function approveNewAssetPoolUpgrade(IAssetPoolUpgrade _newAssetPool)\n external\n onlyOwner\n {\n assetPool.approveNewAssetPoolUpgrade(_newAssetPool);\n }\n\n /// @notice Lets the governance to begin an update of withdrawal delay\n /// parameter value. Withdrawal delay is the time it takes the\n /// underwriter to withdraw their collateral and rewards from the\n /// pool. This is the time that needs to pass between initiating and\n /// completing the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalDelayUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal delay value should be but it should\n /// be long enough so that the possibility of having free-riding\n /// underwriters escaping from a potential coverage claim by\n /// withdrawing their positions from the pool is negligible.\n /// @param newWithdrawalDelay The new value of withdrawal delay\n function beginWithdrawalDelayUpdate(uint256 newWithdrawalDelay)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalDelayUpdate(newWithdrawalDelay);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// delay parameter value. This call has to be preceded with\n /// a call to beginWithdrawalDelayUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalDelayUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalDelayUpdate();\n }\n\n /// @notice Lets the governance to begin an update of withdrawal timeout\n /// parameter value. The withdrawal timeout is the time the\n /// underwriter has - after the withdrawal delay passed - to\n /// complete the withdrawal. The change needs to be finalized with\n /// a call to finalizeWithdrawalTimeoutUpdate after the required\n /// governance delay passes. It is up to the governance to\n /// decide what the withdrawal timeout value should be but it should\n /// be short enough so that the time of free-riding by being able to\n /// immediately escape from the claim is minimal and long enough so\n /// that honest underwriters have a possibility to finalize the\n /// withdrawal. It is all about the right proportions with\n /// a relation to withdrawal delay value.\n /// @param newWithdrawalTimeout The new value of the withdrawal timeout\n function beginWithdrawalTimeoutUpdate(uint256 newWithdrawalTimeout)\n external\n onlyOwner\n {\n assetPool.beginWithdrawalTimeoutUpdate(newWithdrawalTimeout);\n }\n\n /// @notice Lets the governance to finalize an update of withdrawal\n /// timeout parameter value. This call has to be preceded with\n /// a call to beginWithdrawalTimeoutUpdate and the governance delay\n /// has to pass.\n function finalizeWithdrawalTimeoutUpdate() external onlyOwner {\n assetPool.finalizeWithdrawalTimeoutUpdate();\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @dev `portionToSeize` value was multiplied by `FLOATING_POINT_DIVISOR`\n /// for calculation precision purposes. Further calculations in this\n /// function will need to take this divisor into account.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by `FLOATING_POINT_DIVISOR`\n function seizePortion(address recipient, uint256 portionToSeize)\n external\n onlyApprovedRiskManager\n {\n require(\n portionToSeize > 0 &&\n portionToSeize <= CoveragePoolConstants.FLOATING_POINT_DIVISOR,\n \"Portion to seize is not within the range (0, 1]\"\n );\n\n assetPool.claim(recipient, amountToSeize(portionToSeize));\n }\n\n /// @notice Seizes funds from the coverage pool and sends them to the\n /// `recipient`.\n /// @param recipient Address that will receive the pool's seized funds\n /// @param amountToSeize Amount to be seized from the pool\n // slither-disable-next-line shadowing-local\n function seizeAmount(address recipient, uint256 amountToSeize)\n external\n onlyApprovedRiskManager\n {\n require(amountToSeize > 0, \"Amount to seize must be >0\");\n\n assetPool.claim(recipient, amountToSeize);\n }\n\n /// @notice Grants asset pool shares by minting a given amount of the\n /// underwriter tokens for the recipient address. In result, the\n /// recipient obtains part of the pool ownership without depositing\n /// any collateral tokens. Shares are usually granted for notifiers\n /// reporting about various contract state changes.\n /// @dev Can be called only by an approved risk manager.\n /// @param recipient Address of the underwriter tokens recipient\n /// @param covAmount Amount of the underwriter tokens which should be minted\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n onlyApprovedRiskManager\n {\n assetPool.grantShares(recipient, covAmount);\n }\n\n /// @notice Returns the time remaining until the risk manager approval\n /// process can be finalized\n /// @param riskManager Risk manager in the process of approval\n /// @return Remaining time in seconds.\n function getRemainingRiskManagerApprovalTime(address riskManager)\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n riskManagerApprovalTimestamps[riskManager],\n assetPool.withdrawalGovernanceDelay()\n );\n }\n\n /// @notice Determine the prior number of DAO votes for the given coverage\n /// pool underwriter.\n /// @param account The underwriter address to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the underwriter had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96)\n {\n uint96 underwriterVotes = underwriterToken.getPastVotes(\n account,\n blockNumber\n );\n uint96 underwriterTokenSupply = underwriterToken.getPastTotalSupply(\n blockNumber\n );\n\n if (underwriterTokenSupply == 0) {\n return 0;\n }\n\n uint96 covPoolVotes = collateralToken.getPastVotes(\n address(assetPool),\n blockNumber\n );\n\n return\n uint96(\n (uint256(underwriterVotes) * covPoolVotes) /\n underwriterTokenSupply\n );\n }\n\n /// @notice Calculates amount of tokens to be seized from the coverage pool.\n /// @param portionToSeize Portion of the pool to seize in the range (0, 1]\n /// multiplied by FLOATING_POINT_DIVISOR\n function amountToSeize(uint256 portionToSeize)\n public\n view\n returns (uint256)\n {\n return\n (collateralToken.balanceOf(address(assetPool)) * portionToSeize) /\n CoveragePoolConstants.FLOATING_POINT_DIVISOR;\n }\n}\n" + }, + "contracts/CoveragePoolBeneficiary.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./RewardsPool.sol\";\nimport \"./BatchedPhasedEscrow.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/// @title CoveragePoolBeneficiary\n/// @notice A beneficiary contract that can receive a withdrawal phase from a\n/// BatchedPhasedEscrow contract.\n/// It immediately transfers the received tokens on a designated\n/// RewardsPool contract.\ncontract CoveragePoolBeneficiary is Ownable, IBeneficiaryContract {\n using SafeERC20 for IERC20;\n\n IERC20 public immutable token;\n RewardsPool public immutable rewards;\n\n constructor(IERC20 _token, RewardsPool _rewards) {\n token = _token;\n rewards = _rewards;\n }\n\n function __escrowSentTokens(uint256 amount) external override onlyOwner {\n token.safeApprove(address(rewards), amount);\n rewards.topUpReward(amount);\n }\n}\n" + }, + "contracts/CoveragePoolConstants.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary CoveragePoolConstants {\n // This divisor is for precision purposes only. We use this divisor around\n // auction related code to get the precise values without rounding it down\n // when dealing with floating numbers.\n uint256 public constant FLOATING_POINT_DIVISOR = 1e18;\n}\n" + }, + "contracts/GovernanceUtils.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nlibrary GovernanceUtils {\n /// @notice Gets the time remaining until the governable parameter update\n /// can be committed.\n /// @param changeTimestamp Timestamp indicating the beginning of the change.\n /// @param delay Governance delay.\n /// @return Remaining time in seconds.\n function getRemainingChangeTime(uint256 changeTimestamp, uint256 delay)\n internal\n view\n returns (uint256)\n {\n require(changeTimestamp > 0, \"Change not initiated\");\n /* solhint-disable-next-line not-rely-on-time */\n uint256 elapsed = block.timestamp - changeTimestamp;\n if (elapsed >= delay) {\n return 0;\n } else {\n return delay - elapsed;\n }\n }\n}\n" + }, + "contracts/hardhat-dependency-compiler/@threshold-network/solidity-contracts/contracts/token/T.sol": { + "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity >0.0.0;\nimport '@threshold-network/solidity-contracts/contracts/token/T.sol';\n" + }, + "contracts/interfaces/IAssetPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool interface\n/// @notice Asset Pool accepts a single ERC20 token as collateral, and returns\n/// an underwriter token. For example, an asset pool might accept deposits\n/// in KEEP in return for covKEEP underwriter tokens. Underwriter tokens\n/// represent an ownership share in the underlying collateral of the\n/// Asset Pool.\ninterface IAssetPool {\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints underwriter tokens representing pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function deposit(uint256 amount) external returns (uint256);\n\n /// @notice Accepts the given amount of collateral token as a deposit and\n /// mints at least a minAmountToMint underwriter tokens representing\n /// pool's ownership.\n /// @dev Before calling this function, collateral token needs to have the\n /// required amount accepted to transfer to the asset pool.\n /// @return The amount of minted underwriter tokens\n function depositWithMin(uint256 amountToDeposit, uint256 minAmountToMint)\n external\n returns (uint256);\n\n /// @notice Initiates the withdrawal of collateral and rewards from the pool.\n /// @dev Before calling this function, underwriter token needs to have the\n /// required amount accepted to transfer to the asset pool.\n function initiateWithdrawal(uint256 covAmount) external;\n\n /// @notice Completes the previously initiated withdrawal for the\n /// underwriter.\n /// @return The amount of collateral withdrawn\n function completeWithdrawal(address underwriter) external returns (uint256);\n}\n" + }, + "contracts/interfaces/IAssetPoolUpgrade.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Asset Pool upgrade interface\n/// @notice Interface that has to be implemented by an Asset Pool accepting\n/// upgrades from another asset pool.\ninterface IAssetPoolUpgrade {\n /// @notice Accepts the given underwriter with collateral tokens amount as a\n /// deposit. In exchange new underwriter tokens will be calculated,\n /// minted and then transferred back to the underwriter.\n function depositFor(address underwriter, uint256 amount) external;\n}\n" + }, + "contracts/interfaces/IAuction.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Auction interface\n/// @notice Auction runs a linear falling-price auction against a diverse\n/// basket of assets held in a collateral pool. Auctions are taken using\n/// a single asset. Over time, a larger and larger portion of the assets\n/// are on offer, eventually hitting 100% of the backing collateral\ninterface IAuction {\n /// @notice Takes an offer from an auction buyer. There are two possible\n /// ways to take an offer from a buyer. The first one is to buy\n /// entire auction with the amount desired for this auction.\n /// The other way is to buy a portion of an auction. In this case an\n /// auction depleting rate is increased.\n /// @dev The implementation is not guaranteed to be protecting against\n /// frontrunning. See `AuctionBidder` for an example protection.\n function takeOffer(uint256 amount) external;\n\n /// @notice How much of the collateral pool can currently be purchased at\n /// auction, across all assets.\n /// @return The ratio of the collateral pool currently on offer and divisor\n /// for precision purposes.\n function onOffer() external view returns (uint256, uint256);\n}\n" + }, + "contracts/interfaces/ICollateralToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/// @title Collateral Token interface\n/// @notice ERC-20 token which is accepted by the pool as collateral and used\n/// as a deposit token by underwriters. Collateral token positions of\n/// underwriters can be affected when the Risk Manager claims coverage.\n/// Collateral token needs to support DAO checkpoints and let to\n/// retrieve past number of votes for the given address so that\n/// Coverage Pool underwriters can participate in token holder DAO.\n/// @dev See @threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\ninterface ICollateralToken is IERC20 {\n /// @notice Delegate DAO votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) external;\n\n /// @notice Determine the prior number of DAO votes for an account as of\n /// a block number.\n /// @param account The address of the account to check\n /// @param blockNumber The block number to get the vote balance at\n /// @return The number of votes the account had as of the given block\n function getPastVotes(address account, uint256 blockNumber)\n external\n view\n returns (uint96);\n}\n" + }, + "contracts/interfaces/IRiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/// @title Interface for tBTC v1 Risk Manager\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\ninterface IRiskManagerV1 {\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external;\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external;\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n /// @param amount Amount of signer bonds being withdrawn.\n function withdrawSignerBonds(uint256 amount) external;\n\n /// @notice Returns true if there are open auctions managed by the risk\n /// manager. Returns false otherwise.\n /// @dev Usually used by `ISignerBondsSwapStrategy` implementations.\n function hasOpenAuctions() external view returns (bool);\n}\n" + }, + "contracts/RewardsPool.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Rewards Pool\n/// @notice RewardsPool accepts a single reward token and releases it to the\n/// AssetPool over time in one week reward intervals. The owner of this\n/// contract is the reward distribution address funding it with reward\n/// tokens.\ncontract RewardsPool is Ownable {\n using SafeERC20 for IERC20;\n\n uint256 public constant DURATION = 7 days;\n\n IERC20 public immutable rewardToken;\n address public immutable assetPool;\n\n // timestamp of the current reward interval end or the timestamp of the\n // last interval end in case a new reward interval has not been allocated\n uint256 public intervalFinish = 0;\n // rate per second with which reward tokens are unlocked\n uint256 public rewardRate = 0;\n // amount of rewards accumulated and not yet withdrawn from the previous\n // reward interval(s)\n uint256 public rewardAccumulated = 0;\n // the last time information in this contract was updated\n uint256 public lastUpdateTime = 0;\n\n event RewardToppedUp(uint256 amount);\n event RewardWithdrawn(uint256 amount);\n\n constructor(\n IERC20 _rewardToken,\n address _assetPool,\n address owner\n ) {\n rewardToken = _rewardToken;\n // slither-disable-next-line missing-zero-check\n assetPool = _assetPool;\n transferOwnership(owner);\n }\n\n /// @notice Transfers the provided reward amount into RewardsPool and\n /// creates a new, one-week reward interval starting from now.\n /// Reward tokens from the previous reward interval that unlocked\n /// over the time will be available for withdrawal immediately.\n /// Reward tokens from the previous interval that has not been yet\n /// unlocked, are added to the new interval being created.\n /// @dev This function can be called only by the owner given that it creates\n /// a new interval with one week length, starting from now.\n function topUpReward(uint256 reward) external onlyOwner {\n rewardAccumulated = earned();\n\n /* solhint-disable not-rely-on-time */\n if (block.timestamp >= intervalFinish) {\n // see https://github.com/crytic/slither/issues/844\n // slither-disable-next-line divide-before-multiply\n rewardRate = reward / DURATION;\n } else {\n uint256 remaining = intervalFinish - block.timestamp;\n uint256 leftover = remaining * rewardRate;\n rewardRate = (reward + leftover) / DURATION;\n }\n intervalFinish = block.timestamp + DURATION;\n lastUpdateTime = block.timestamp;\n /* solhint-enable avoid-low-level-calls */\n\n emit RewardToppedUp(reward);\n rewardToken.safeTransferFrom(msg.sender, address(this), reward);\n }\n\n /// @notice Withdraws all unlocked reward tokens to the AssetPool.\n function withdraw() external {\n uint256 amount = earned();\n rewardAccumulated = 0;\n lastUpdateTime = lastTimeRewardApplicable();\n emit RewardWithdrawn(amount);\n rewardToken.safeTransfer(assetPool, amount);\n }\n\n /// @notice Returns the amount of earned and not yet withdrawn reward\n /// tokens.\n function earned() public view returns (uint256) {\n return\n rewardAccumulated +\n ((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate);\n }\n\n /// @notice Returns the timestamp at which a reward was last time applicable.\n /// When reward interval is pending, returns current block's\n /// timestamp. If the last reward interval ended and no other reward\n /// interval had been allocated, returns the last reward interval's\n /// end timestamp.\n function lastTimeRewardApplicable() public view returns (uint256) {\n return Math.min(block.timestamp, intervalFinish);\n }\n}\n" + }, + "contracts/RiskManagerV1.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./Auctioneer.sol\";\nimport \"./Auction.sol\";\nimport \"./CoveragePoolConstants.sol\";\nimport \"./GovernanceUtils.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title tBTC v1 Deposit contract interface\n/// @notice This is an interface with just a few function signatures of a main\n/// Deposit contract from tBTC. tBTC deposit contract functions declared in\n/// this interface are used by RiskManagerV1 contract to interact with tBTC\n/// v1 deposits. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface IDeposit {\n function withdrawFunds() external;\n\n function purchaseSignerBondsAtAuction() external;\n\n function currentState() external view returns (uint256);\n\n function lotSizeTbtc() external view returns (uint256);\n\n function withdrawableAmount() external view returns (uint256);\n\n function auctionValue() external view returns (uint256);\n}\n\n/// @title tBTC v1 deposit token (TDT) interface\n/// @notice This is an interface with just a few function signatures of a main\n/// contract from tBTC. For more information about tBTC Deposit please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/system/TBTCDepositToken.sol\ninterface ITBTCDepositToken {\n function exists(uint256 _tokenId) external view returns (bool);\n}\n\n/// @title Signer bonds swap strategy\n/// @notice This interface is meant to abstract the underlying signer bonds\n/// swap strategy and make it interchangeable for the governance.\n/// Risk manager uses the strategy to swap ETH from tBTC deposit\n/// purchased signer bonds back into collateral token accepted by\n/// coverage pool.\ninterface ISignerBondsSwapStrategy {\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external;\n}\n\n/// @title Risk Manager for tBTC v1\n/// @notice Risk Manager is a smart contract with the exclusive right to claim\n/// coverage from the coverage pool. Demanding coverage is akin to\n/// filing a claim in traditional insurance and processing your own\n/// claim. The risk manager holds an incredibly privileged position,\n/// because the ability to claim coverage of an arbitrarily large\n/// position could bankrupt the coverage pool.\n/// tBTC v1 risk manager demands coverage by opening an auction for TBTC\n/// and liquidating portion of the coverage pool when tBTC v1 deposit is\n/// in liquidation and signer bonds on offer reached the specific\n/// threshold. In practice, it means no one is willing to purchase\n/// signer bonds for that deposit on tBTC side.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract RiskManagerV1 is IRiskManagerV1, Auctioneer, Ownable {\n using SafeERC20 for IERC20;\n using RiskManagerV1Rewards for RiskManagerV1Rewards.Storage;\n\n /// @notice Governance delay that needs to pass before any risk manager\n /// parameter change initiated by the governance takes effect.\n uint256 public constant GOVERNANCE_DELAY = 12 hours;\n\n // See https://github.com/keep-network/tbtc/blob/v1.1.0/solidity/contracts/deposit/DepositStates.sol\n uint256 public constant DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE = 9;\n uint256 public constant DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE = 10;\n uint256 public constant DEPOSIT_LIQUIDATED_STATE = 11;\n\n /// @notice Coverage pool auction will not be opened if the deposit's bond\n /// auction offers a bond percentage lower than this threshold.\n /// Risk manager should open a coverage pool auction for only those\n // tBTC deposits that nobody else is willing to purchase bonds\n /// from. The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public bondAuctionThreshold; // percentage\n uint256 public newBondAuctionThreshold;\n uint256 public bondAuctionThresholdChangeInitiated;\n\n /// @notice The length with which every new auction is opened. Auction length\n /// is the amount of time it takes for the auction to get to 100%\n /// of all collateral on offer, in seconds. This parameter value\n /// should be updated and kept up to date based on the coverage pool\n /// TVL and tBTC v1 minimum lot size allowed so that a new auction\n /// does not liquidate too much too early. Auction length is the\n /// same, no matter tBTC deposit lot size.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n uint256 public auctionLength;\n uint256 public newAuctionLength;\n uint256 public auctionLengthChangeInitiated;\n\n /// @notice The strategy used to swap ETH from tBTC deposit purchased signer\n /// bonds into an asset accepted by coverage pool as collateral.\n /// The value can be updated by the governance in two steps.\n /// First step is to begin the update process with the new value\n /// and the second step is to finalize it after\n /// `GOVERNANCE_DELAY` has passed.\n ISignerBondsSwapStrategy public signerBondsSwapStrategy;\n ISignerBondsSwapStrategy public newSignerBondsSwapStrategy;\n uint256 public signerBondsSwapStrategyInitiated;\n\n IERC20 public immutable tbtcToken;\n ITBTCDepositToken public immutable tbtcDepositToken;\n\n /// @notice TBTC surplus collected from early closed auctions.\n /// When tBTC deposit gets liquidated outside of coverage pools and\n /// an auction was opened earlier by the risk manager for that\n /// deposit, it might happen that the auction was partially filled\n /// and some TBTC from that auction has accumulated. In such a case,\n /// TBTC surplus left on the risk manager can be used to purchase\n /// signer bonds from another liquidating tBTC deposit in the future\n /// assuming enough surplus will accumulate up to that point.\n uint256 public tbtcSurplus;\n\n /// @notice Keeps track of notifier rewards for those calling\n /// `notifyLiquidation` and `notifyLiquidated`.\n RiskManagerV1Rewards.Storage public rewards;\n\n // deposit in liquidation => opened coverage pool auction\n mapping(address => address) public depositToAuction;\n // opened coverage pool auction => deposit in liquidation\n mapping(address => address) public auctionToDeposit;\n\n event NotifiedLiquidated(address indexed deposit, address notifier);\n event NotifiedLiquidation(address indexed deposit, address notifier);\n\n event BondAuctionThresholdUpdateStarted(\n uint256 bondAuctionThreshold,\n uint256 timestamp\n );\n event BondAuctionThresholdUpdated(uint256 bondAuctionThreshold);\n\n event AuctionLengthUpdateStarted(uint256 auctionLength, uint256 timestamp);\n event AuctionLengthUpdated(uint256 auctionLength);\n\n event SignerBondsSwapStrategyUpdateStarted(\n address indexed signerBondsSwapStrategy,\n uint256 timestamp\n );\n event SignerBondsSwapStrategyUpdated(\n address indexed signerBondsSwapStrategy\n );\n\n event LiquidationNotifierRewardUpdateStarted(\n uint256 liquidationNotifierReward,\n uint256 timestamp\n );\n event LiquidationNotifierRewardUpdated(uint256 liquidationNotifierReward);\n\n event LiquidatedNotifierRewardUpdateStarted(\n uint256 liquidatedNotifierReward,\n uint256 timestamp\n );\n event LiquidatedNotifierRewardUpdated(uint256 liquidatedNotifierReward);\n\n /// @notice Reverts if called before the governance delay elapses.\n /// @param changeInitiatedTimestamp Timestamp indicating the beginning\n /// of the change.\n modifier onlyAfterGovernanceDelay(uint256 changeInitiatedTimestamp) {\n require(changeInitiatedTimestamp > 0, \"Change not initiated\");\n require(\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp - changeInitiatedTimestamp >= GOVERNANCE_DELAY,\n \"Governance delay has not elapsed\"\n );\n _;\n }\n\n /// @notice Reverts if called by any account other than the current signer\n /// bonds swap strategy.\n modifier onlySignerBondsSwapStrategy() {\n require(\n msg.sender == address(signerBondsSwapStrategy),\n \"Caller is not the signer bonds swap strategy\"\n );\n _;\n }\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n ) Auctioneer(_coveragePool, _masterAuction) {\n tbtcToken = _tbtcToken;\n tbtcDepositToken = _tbtcDepositToken;\n signerBondsSwapStrategy = _signerBondsSwapStrategy;\n auctionLength = _auctionLength;\n bondAuctionThreshold = _bondAuctionThreshold;\n }\n\n /// @notice Receives ETH from tBTC for purchasing and withdrawing deposit\n /// signer bonds.\n //slither-disable-next-line locked-ether\n receive() external payable {}\n\n /// @notice Notifies the risk manager about tBTC deposit in liquidation\n /// state for which signer bonds on offer passed the threshold\n /// expected by the risk manager. In practice, it means no one else\n /// is willing to purchase signer bonds from that deposit so the\n /// risk manager should open an auction to collect TBTC and purchase\n /// those bonds liquidating part of the coverage pool. If there is\n /// enough TBTC surplus from earlier auctions accumulated by the\n /// risk manager, bonds are purchased right away without opening an\n /// auction. Notifier calling this function receives a share in the\n /// coverage pool as a reward - underwriter tokens are transferred\n /// to the notifier's address.\n /// @param depositAddress liquidating tBTC deposit address\n function notifyLiquidation(address depositAddress) external override {\n require(\n tbtcDepositToken.exists(uint256(uint160(depositAddress))),\n \"Address is not a deposit contract\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit is not in liquidation state\"\n );\n\n require(\n depositToAuction[depositAddress] == address(0),\n \"Already notified on the deposit in liquidation\"\n );\n\n require(\n deposit.auctionValue() >=\n (address(deposit).balance * bondAuctionThreshold) / 100,\n \"Deposit bond auction percentage is below the threshold level\"\n );\n\n uint256 lotSizeTbtc = deposit.lotSizeTbtc();\n\n emit NotifiedLiquidation(depositAddress, msg.sender);\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidationNotifierReward > 0) {\n // slither-disable-next-line reentrancy-benign\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidationNotifierReward\n );\n }\n\n // If the surplus can cover the deposit liquidation cost, liquidate\n // that deposit directly without the auction process.\n if (tbtcSurplus >= lotSizeTbtc) {\n tbtcSurplus -= lotSizeTbtc;\n liquidateDeposit(deposit);\n return;\n }\n\n // slither-disable-next-line reentrancy-no-eth\n address auctionAddress = createAuction(\n tbtcToken,\n lotSizeTbtc,\n auctionLength\n );\n depositToAuction[depositAddress] = auctionAddress;\n auctionToDeposit[auctionAddress] = depositAddress;\n }\n\n /// @notice Notifies the risk manager about tBTC deposit liquidated outside\n /// the coverage pool for which the risk manager opened an auction\n /// earlier (as a result of `notifyLiquidation` call). Function\n /// closes the auction early and collects TBTC surplus from the\n /// auction in case the auction was partially taken before the\n /// deposit got liquidated. Notifier calling this function receives\n /// a share in the coverage pool as a reward - underwriter tokens\n /// are transferred to the notifier's address.\n /// @param depositAddress liquidated tBTC Deposit address\n function notifyLiquidated(address depositAddress) external override {\n require(\n depositToAuction[depositAddress] != address(0),\n \"No auction for given deposit\"\n );\n\n IDeposit deposit = IDeposit(depositAddress);\n require(\n deposit.currentState() == DEPOSIT_LIQUIDATED_STATE,\n \"Deposit is not in liquidated state\"\n );\n emit NotifiedLiquidated(depositAddress, msg.sender);\n\n Auction auction = Auction(depositToAuction[depositAddress]);\n\n delete depositToAuction[depositAddress];\n delete auctionToDeposit[address(auction)];\n uint256 amountTransferred = earlyCloseAuction(auction);\n\n // Add auction's transferred amount to the surplus pool.\n // slither-disable-next-line reentrancy-benign\n tbtcSurplus += amountTransferred;\n\n // Reward the notifier by giving them some share of the pool.\n if (rewards.liquidatedNotifierReward > 0) {\n coveragePool.grantAssetPoolShares(\n msg.sender,\n rewards.liquidatedNotifierReward\n );\n }\n }\n\n /// @notice Begins the bond auction threshold update process. The value of\n /// the threshold must not be greater than 100. The threshold should\n /// be high enough so that the possibility of purchasing signer\n /// bonds outside of coverage pools after opening an auction is\n /// minimal.\n /// @dev Can be called only by the contract owner.\n /// @param _newBondAuctionThreshold New bond auction threshold in percent\n function beginBondAuctionThresholdUpdate(uint256 _newBondAuctionThreshold)\n external\n onlyOwner\n {\n require(\n _newBondAuctionThreshold <= 100,\n \"Bond auction threshold must be lower or equal to 100\"\n );\n newBondAuctionThreshold = _newBondAuctionThreshold;\n /* solhint-disable-next-line not-rely-on-time */\n bondAuctionThresholdChangeInitiated = block.timestamp;\n /* solhint-disable not-rely-on-time */\n emit BondAuctionThresholdUpdateStarted(\n _newBondAuctionThreshold,\n block.timestamp\n );\n }\n\n /// @notice Finalizes the bond auction threshold update process.\n /// @dev Can be called only by the contract owner, after the the\n /// governance delay elapses.\n function finalizeBondAuctionThresholdUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(bondAuctionThresholdChangeInitiated)\n {\n bondAuctionThreshold = newBondAuctionThreshold;\n emit BondAuctionThresholdUpdated(bondAuctionThreshold);\n bondAuctionThresholdChangeInitiated = 0;\n newBondAuctionThreshold = 0;\n }\n\n /// @notice Begins the auction length update process. The auction length\n /// should be adjusted very carefully. Total value locked of the\n /// coverage pool and minimum possible auction amount need to be\n /// taken into account. The goal is to find a \"sweet spot\" for\n /// auction length, not making it too short (which leads to big\n /// sums of coverage pool become available in a short time) and not\n /// making it too long (which leads to bidders waiting for too long\n /// until it will makes sense for them to bid on an auction).\n /// @dev Can be called only by the contract owner.\n /// @param _newAuctionLength New auction length in seconds\n function beginAuctionLengthUpdate(uint256 _newAuctionLength)\n external\n onlyOwner\n {\n newAuctionLength = _newAuctionLength;\n /* solhint-disable-next-line not-rely-on-time */\n auctionLengthChangeInitiated = block.timestamp;\n /* solhint-disable-next-line not-rely-on-time */\n emit AuctionLengthUpdateStarted(_newAuctionLength, block.timestamp);\n }\n\n /// @notice Finalizes the auction length update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeAuctionLengthUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(auctionLengthChangeInitiated)\n {\n auctionLength = newAuctionLength;\n emit AuctionLengthUpdated(newAuctionLength);\n newAuctionLength = 0;\n auctionLengthChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidation` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @dev Can be called only by the contract owner.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward\n function beginLiquidationNotifierRewardUpdate(\n uint256 _newLiquidationNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidationNotifierRewardUpdateStarted(\n _newLiquidationNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidationNotifierRewardUpdate(\n _newLiquidationNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeLiquidationNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidationNotifierRewardChangeInitiated\n )\n {\n emit LiquidationNotifierRewardUpdated(\n rewards.newLiquidationNotifierReward\n );\n\n rewards.finalizeLiquidationNotifierRewardUpdate();\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// Total value locked of the coverage pool and the cost of calling\n /// `notifyLiquidated` needs to be taken into account so that the\n /// call incentive is attractive enough and at the same time it does\n /// not offer to much value held the coverage pool.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n uint256 _newLiquidatedNotifierReward\n ) external onlyOwner {\n /* solhint-disable-next-line not-rely-on-time */\n emit LiquidatedNotifierRewardUpdateStarted(\n _newLiquidatedNotifierReward,\n block.timestamp\n );\n\n rewards.beginLiquidatedNotifierRewardUpdate(\n _newLiquidatedNotifierReward\n );\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses\n function finalizeLiquidatedNotifierRewardUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(\n rewards.liquidatedNotifierRewardChangeInitiated\n )\n {\n emit LiquidatedNotifierRewardUpdated(\n rewards.newLiquidatedNotifierReward\n );\n\n rewards.finalizeLiquidatedNotifierRewardUpdate();\n }\n\n /// @notice Begins the signer bonds swap strategy update process.\n /// @dev Must be followed by a finalizeSignerBondsSwapStrategyUpdate after\n /// the governance delay elapses.\n /// @param _newSignerBondsSwapStrategy The new signer bonds swap strategy\n function beginSignerBondsSwapStrategyUpdate(\n ISignerBondsSwapStrategy _newSignerBondsSwapStrategy\n ) external onlyOwner {\n require(\n address(_newSignerBondsSwapStrategy) != address(0),\n \"Invalid signer bonds swap strategy address\"\n );\n newSignerBondsSwapStrategy = _newSignerBondsSwapStrategy;\n /* solhint-disable-next-line not-rely-on-time */\n signerBondsSwapStrategyInitiated = block.timestamp;\n emit SignerBondsSwapStrategyUpdateStarted(\n address(_newSignerBondsSwapStrategy),\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp\n );\n }\n\n /// @notice Finalizes the signer bonds swap strategy update.\n /// @dev Can be called only by the contract owner, after the governance\n /// delay elapses.\n function finalizeSignerBondsSwapStrategyUpdate()\n external\n onlyOwner\n onlyAfterGovernanceDelay(signerBondsSwapStrategyInitiated)\n {\n signerBondsSwapStrategy = newSignerBondsSwapStrategy;\n emit SignerBondsSwapStrategyUpdated(\n address(newSignerBondsSwapStrategy)\n );\n delete newSignerBondsSwapStrategy;\n signerBondsSwapStrategyInitiated = 0;\n }\n\n /// @notice Withdraws the given amount of accumulated signer bonds.\n /// @dev Can be called only by the signer bonds swap strategy itself.\n /// This method should typically be used as part of the swap logic.\n /// Third-party calls may block funds on the strategy contract in case\n /// that strategy is not able to perform the swap.\n /// @param amount Amount of signer bonds being withdrawn\n function withdrawSignerBonds(uint256 amount)\n external\n override\n onlySignerBondsSwapStrategy\n {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = address(signerBondsSwapStrategy).call{value: amount}(\n \"\"\n );\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n /// @notice Get the time remaining until the bond auction threshold\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingBondAuctionThresholdUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n bondAuctionThresholdChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the auction length parameter\n /// can be updated.\n /// @return Remaining time in seconds.\n function getRemainingAuctionLengthUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n auctionLengthChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidation notifier reward\n /// parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidationNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidationNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the liquidated notifier reward\n /// amount parameter can be updated.\n /// @return Remaining time in seconds.\n function getRemainingLiquidatedNotifierRewardUpdateTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n rewards.liquidatedNotifierRewardChangeInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @notice Get the time remaining until the signer bonds swap strategy\n /// can be changed.\n /// @return Remaining time in seconds.\n function getRemainingSignerBondsSwapStrategyChangeTime()\n external\n view\n returns (uint256)\n {\n return\n GovernanceUtils.getRemainingChangeTime(\n signerBondsSwapStrategyInitiated,\n GOVERNANCE_DELAY\n );\n }\n\n /// @return True if there are open auctions managed by the risk manager.\n /// Returns false otherwise.\n function hasOpenAuctions() external view override returns (bool) {\n return openAuctionsCount > 0;\n }\n\n /// @return Current value of the liquidation notifier reward.\n function liquidationNotifierReward() external view returns (uint256) {\n return rewards.liquidationNotifierReward;\n }\n\n /// @return Current value of the liquidated notifier reward.\n function liquidatedNotifierReward() external view returns (uint256) {\n return rewards.liquidatedNotifierReward;\n }\n\n /// @notice Cleans up auction and deposit data and executes deposit liquidation.\n /// @dev This function is invoked when Auctioneer determines that an auction\n /// is eligible to be closed. It cannot be called on-demand outside\n /// the Auctioneer contract. By the time this function is called, all\n /// the TBTC tokens for the coverage pool auction should be transferred\n /// to this contract in order to buy signer bonds.\n /// @param auction Coverage pool auction\n function onAuctionFullyFilled(Auction auction) internal override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n\n delete depositToAuction[address(deposit)];\n delete auctionToDeposit[address(auction)];\n\n liquidateDeposit(deposit);\n }\n\n /// @notice Purchases ETH from signer bonds and swaps obtained funds\n /// using the underlying signer bonds swap strategy.\n /// @dev By the time this function is called, TBTC token balance for this\n /// contract should be enough to buy signer bonds.\n /// @param deposit TBTC deposit which should be liquidated.\n function liquidateDeposit(IDeposit deposit) internal {\n uint256 approvedAmount = deposit.lotSizeTbtc();\n tbtcToken.safeApprove(address(deposit), approvedAmount);\n\n // Purchase signers bonds ETH with TBTC acquired from the auction or\n // taken from the surplus pool.\n deposit.purchaseSignerBondsAtAuction();\n\n uint256 withdrawableAmount = deposit.withdrawableAmount();\n deposit.withdrawFunds();\n\n signerBondsSwapStrategy.onSignerBondsPurchased(withdrawableAmount);\n }\n\n /// @notice Reverts if the deposit for which the auction was created is no\n /// longer in the liquidation state. This could happen if signer\n /// bonds were purchased from tBTC deposit directly, outside of\n /// coverage pool auction.\n /// @dev This function is invoked when the auctioneer is informed about the\n /// results of an auction and the auction was partially filled.\n /// @param auction Address of an auction whose deposit needs to be checked.\n function onAuctionPartiallyFilled(Auction auction) internal view override {\n IDeposit deposit = IDeposit(auctionToDeposit[address(auction)]);\n // Make sure the deposit was not liquidated outside of Coverage Pool\n require(\n isDepositLiquidationInProgress(deposit),\n \"Deposit liquidation is not in progress\"\n );\n }\n\n function isDepositLiquidationInProgress(IDeposit deposit)\n internal\n view\n returns (bool)\n {\n uint256 state = deposit.currentState();\n\n return (state == DEPOSIT_LIQUIDATION_IN_PROGRESS_STATE ||\n state == DEPOSIT_FRAUD_LIQUIDATION_IN_PROGRESS_STATE);\n }\n}\n\n/// @title RiskManagerV1Rewards\n/// @notice Contains logic responsible for calculating notifier rewards for\n/// both deposit liquidation start and deposit liquidated events.\n/// All parameters can be updated using a two-phase process.\n/// @dev The client contract should take care of authorizations or governance\n/// delays according to their needs.\n/* solhint-disable-next-line ordering */\nlibrary RiskManagerV1Rewards {\n struct Storage {\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about the start of deposit liquidation process.\n uint256 liquidationNotifierReward;\n uint256 newLiquidationNotifierReward;\n uint256 liquidationNotifierRewardChangeInitiated;\n // Amount of COV tokens which should be given as reward for the\n // notifier reporting about a deposit being liquidated outside of the\n // coverage pool.\n uint256 liquidatedNotifierReward;\n uint256 newLiquidatedNotifierReward;\n uint256 liquidatedNotifierRewardChangeInitiated;\n }\n\n /// @notice Begins the liquidation notifier reward update process.\n /// @param _newLiquidationNotifierReward New liquidation notifier reward.\n function beginLiquidationNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidationNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidationNotifierReward = _newLiquidationNotifierReward;\n self.liquidationNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidation notifier reward update process.\n function finalizeLiquidationNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidationNotifierReward = self.newLiquidationNotifierReward;\n self.newLiquidationNotifierReward = 0;\n self.liquidationNotifierRewardChangeInitiated = 0;\n }\n\n /// @notice Begins the liquidated notifier reward update process.\n /// @param _newLiquidatedNotifierReward New liquidated notifier reward\n function beginLiquidatedNotifierRewardUpdate(\n Storage storage self,\n uint256 _newLiquidatedNotifierReward\n ) internal {\n /* solhint-disable not-rely-on-time */\n self.newLiquidatedNotifierReward = _newLiquidatedNotifierReward;\n self.liquidatedNotifierRewardChangeInitiated = block.timestamp;\n /* solhint-enable not-rely-on-time */\n }\n\n /// @notice Finalizes the liquidated notifier reward update process.\n function finalizeLiquidatedNotifierRewardUpdate(Storage storage self)\n internal\n {\n self.liquidatedNotifierReward = self.newLiquidatedNotifierReward;\n self.newLiquidatedNotifierReward = 0;\n self.liquidatedNotifierRewardChangeInitiated = 0;\n }\n}\n" + }, + "contracts/SignerBondsManualSwap.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title SignerBondsManualSwap\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsManualSwap strategy allows the governance to withdraw\n/// the bonds from the risk manager and do the swap manually.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsManualSwap is ISignerBondsSwapStrategy, Ownable {\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Withdraws collected bonds to the given target address.\n /// @dev Can be called by the governance only.\n /// @param recipient Arbitrary recipient address chosen by the governance\n /// that will be responsible for swapping ETH and depositing\n /// collateral to the coverage pool.\n function withdrawSignerBonds(\n IRiskManagerV1 riskManager,\n uint256 amount,\n address payable recipient\n ) external onlyOwner {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n require(recipient != address(0), \"Invalid recipient address\");\n\n riskManager.withdrawSignerBonds(amount);\n\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls,arbitrary-send\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n}\n" + }, + "contracts/SignerBondsUniswapV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./interfaces/IRiskManagerV1.sol\";\nimport \"./RiskManagerV1.sol\";\nimport \"./CoveragePool.sol\";\nimport \"./CoveragePoolConstants.sol\";\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @notice Interface for the Uniswap v2 router.\n/// @dev This is an interface with just a few function signatures of the\n/// router contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/router02\ninterface IUniswapV2Router {\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function factory() external pure returns (address);\n\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure returns (address);\n}\n\n/// @notice Interface for the Uniswap v2 pair.\n/// @dev This is an interface with just a few function signatures of the\n/// pair contract. For more info and function description please see:\n/// https://uniswap.org/docs/v2/smart-contracts/pair\ninterface IUniswapV2Pair {\n function getReserves()\n external\n view\n returns (\n uint112 reserve0,\n uint112 reserve1,\n uint32 blockTimestampLast\n );\n}\n\n/// @title SignerBondsUniswapV2\n/// @notice ETH purchased by the risk manager from tBTC signer bonds needs to be\n/// swapped and deposited back to the coverage pool as collateral.\n/// SignerBondsUniswapV2 is a swap strategy implementation which\n/// can withdraw the given bonds amount from the risk manager, swap them\n/// on Uniswap v2 exchange and deposit as coverage pool collateral.\n/// The governance can set crucial swap parameters: max allowed\n/// percentage impact, slippage tolerance and swap deadline, to force\n/// reasonable swap outcomes. It is up to the governance to decide what\n/// these values should be.\n/// @dev This contract is used only for KEEP coverage pool in v1 that was\n/// depricated. Going forward T coverage pool will be used for v2.\n/// Please see: https://forum.threshold.network/t/tip-043-coverage-pool-migration/465\ncontract SignerBondsUniswapV2 is ISignerBondsSwapStrategy, Ownable {\n // One basis point is equivalent to 1/100th of a percent.\n uint256 public constant BASIS_POINTS_DIVISOR = 10000;\n\n IUniswapV2Router public immutable uniswapRouter;\n IUniswapV2Pair public immutable uniswapPair;\n address public immutable assetPool;\n address public immutable collateralToken;\n\n mapping(address => bool) public approvedSwappers;\n\n // Determines the maximum allowed price impact for the swap transaction.\n // If transaction's price impact is higher, transaction will be reverted.\n // Default value is 100 basis points (1%).\n uint256 public maxAllowedPriceImpact = 100;\n // Determines the slippage tolerance for the swap transaction.\n // If transaction's slippage is higher, transaction will be reverted.\n // Default value is 50 basis points (0.5%).\n uint256 public slippageTolerance = 50;\n // Determines the deadline in which the swap transaction has to be mined.\n // If that deadline is exceeded, transaction will be reverted.\n uint256 public swapDeadline = 20 minutes;\n // Determines if the swap should revert when open auctions exists. If true,\n // swaps cannot be performed if there is at least one open auction.\n // If false, open auctions are not taken into account.\n bool public revertIfAuctionOpen = true;\n\n event SignerBondsSwapperApproved(address swapper);\n event SignerBondsSwapperUnapproved(address swapper);\n event UniswapV2SwapExecuted(uint256[] amounts);\n\n /// @notice Reverts if called by a signer bonds swapper that is not approved\n modifier onlyApprovedSwapper() {\n require(\n approvedSwappers[msg.sender],\n \"Signer bonds swapper not approved\"\n );\n _;\n }\n\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool) {\n uniswapRouter = _uniswapRouter;\n assetPool = address(_coveragePool.assetPool());\n address _collateralToken = address(_coveragePool.collateralToken());\n collateralToken = _collateralToken;\n uniswapPair = IUniswapV2Pair(\n computePairAddress(\n _uniswapRouter.factory(),\n _uniswapRouter.WETH(),\n _collateralToken\n )\n );\n }\n\n /// @notice Receive ETH upon withdrawal of risk manager's signer bonds.\n /// @dev Do not send arbitrary funds. They will be locked forever.\n receive() external payable {}\n\n /// @notice Notifies the strategy about signer bonds purchase.\n /// @param amount Amount of purchased signer bonds.\n function onSignerBondsPurchased(uint256 amount) external override {}\n\n /// @notice Sets the maximum price impact allowed for a swap transaction.\n /// @param _maxAllowedPriceImpact Maximum allowed price impact specified\n /// in basis points. Value of this parameter must be between\n /// 0 and 10000 (inclusive). It should be chosen carefully as\n /// high limit level will accept transactions with high volumes.\n /// Those transactions may result in poor execution prices. Very low\n /// limit will force low swap volumes. Limit equal to 0 will\n /// effectively make swaps impossible.\n function setMaxAllowedPriceImpact(uint256 _maxAllowedPriceImpact)\n external\n onlyOwner\n {\n require(\n _maxAllowedPriceImpact <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n maxAllowedPriceImpact = _maxAllowedPriceImpact;\n }\n\n /// @notice Sets the slippage tolerance for a swap transaction.\n /// @param _slippageTolerance Slippage tolerance in basis points. Value of\n /// this parameter must be between 0 and 10000 (inclusive). It\n /// should be chosen carefully as transactions with high slippage\n /// tolerance result in poor execution prices. On the other hand,\n /// very low slippage tolerance may cause transactions to be\n /// reverted frequently. Slippage tolerance equal to 0 is possible\n /// and disallows any slippage to happen on the swap at the cost\n /// of higher revert risk.\n function setSlippageTolerance(uint256 _slippageTolerance)\n external\n onlyOwner\n {\n require(\n _slippageTolerance <= BASIS_POINTS_DIVISOR,\n \"Maximum value is 10000 basis points\"\n );\n slippageTolerance = _slippageTolerance;\n }\n\n /// @notice Sets the deadline for a swap transaction.\n /// @param _swapDeadline Swap deadline in seconds. Value of this parameter\n /// should be equal or greater than 0. It should be chosen carefully\n /// as transactions with long deadlines may result in poor execution\n /// prices. On the other hand, very short deadlines may cause\n /// transactions to be reverted frequently, especially in a\n /// gas-expensive environment. Deadline equal to 0 will effectively\n // make swaps impossible.\n function setSwapDeadline(uint256 _swapDeadline) external onlyOwner {\n swapDeadline = _swapDeadline;\n }\n\n /// @notice Sets whether a swap should revert if at least one\n /// open auction exists.\n /// @param _revertIfAuctionOpen If true, revert the swap if there is at\n /// least one open auction. If false, open auctions won't be taken\n /// into account.\n function setRevertIfAuctionOpen(bool _revertIfAuctionOpen)\n external\n onlyOwner\n {\n revertIfAuctionOpen = _revertIfAuctionOpen;\n }\n\n /// @notice Swaps signer bonds on Uniswap v2 exchange.\n /// @dev Swaps the given ETH amount for the collateral token using the\n /// Uniswap exchange. The maximum ETH amount is capped by the\n /// contract balance. Some governance parameters are applied on the\n /// transaction. The swap's price impact must fit within the\n /// maximum allowed price impact and the transaction is constrained\n /// with the slippage tolerance and deadline. Acquired collateral\n /// tokens are sent to the asset pool address set during\n /// contract construction.\n /// @param riskManager Address of the risk manager which holds the bonds.\n /// @param amount Amount to swap.\n function swapSignerBondsOnUniswapV2(\n IRiskManagerV1 riskManager,\n uint256 amount\n ) external onlyApprovedSwapper {\n require(amount > 0, \"Amount must be greater than 0\");\n require(\n amount <= address(riskManager).balance,\n \"Amount exceeds risk manager balance\"\n );\n\n if (revertIfAuctionOpen) {\n require(!riskManager.hasOpenAuctions(), \"There are open auctions\");\n }\n\n riskManager.withdrawSignerBonds(amount);\n\n // Setup the swap path. WETH must be the first component.\n address[] memory path = new address[](2);\n path[0] = uniswapRouter.WETH();\n path[1] = collateralToken;\n\n // Calculate the maximum output token amount basing on pair reserves.\n // This value will be used as the minimum amount of output tokens that\n // must be received for the transaction not to revert.\n // This value includes liquidity fee equal to 0.3%.\n uint256 amountOutMin = uniswapRouter.getAmountsOut(amount, path)[1];\n\n require(\n isAllowedPriceImpact(amountOutMin),\n \"Price impact exceeds allowed limit\"\n );\n\n // Include slippage tolerance into the minimum amount of output tokens.\n amountOutMin =\n (amountOutMin * (BASIS_POINTS_DIVISOR - slippageTolerance)) /\n BASIS_POINTS_DIVISOR;\n\n // slither-disable-next-line arbitrary-send,reentrancy-events\n uint256[] memory amounts = uniswapRouter.swapExactETHForTokens{\n value: amount\n }(\n amountOutMin,\n path,\n assetPool,\n /* solhint-disable-next-line not-rely-on-time */\n block.timestamp + swapDeadline\n );\n\n emit UniswapV2SwapExecuted(amounts);\n }\n\n /// @notice Approves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be approved\n function approveSwapper(address swapper) external onlyOwner {\n require(\n !approvedSwappers[swapper],\n \"Signer bonds swapper has been already approved\"\n );\n emit SignerBondsSwapperApproved(swapper);\n approvedSwappers[swapper] = true;\n }\n\n /// @notice Unapproves the signer bonds swapper. The change takes effect\n /// immediately.\n /// @dev Can be called only by the contract owner.\n /// @param swapper Swapper that will be unapproved\n function unapproveSwapper(address swapper) external onlyOwner {\n require(\n approvedSwappers[swapper],\n \"Signer bonds swapper is not approved\"\n );\n emit SignerBondsSwapperUnapproved(swapper);\n delete approvedSwappers[swapper];\n }\n\n /// @notice Checks the price impact of buying a given amount of tokens\n /// against the maximum allowed price impact limit.\n /// @param amount Amount of tokens.\n /// @return True if the price impact is allowed, false otherwise.\n function isAllowedPriceImpact(uint256 amount) public view returns (bool) {\n // Get reserve of the collateral token.\n address WETH = uniswapRouter.WETH();\n address token0 = WETH < collateralToken ? WETH : collateralToken;\n (uint256 reserve0, uint256 reserve1, ) = uniswapPair.getReserves();\n uint256 collateralTokenReserve = WETH == token0 ? reserve1 : reserve0;\n\n // Same as: priceImpact <= priceImpactLimit\n return\n amount * BASIS_POINTS_DIVISOR <=\n maxAllowedPriceImpact * collateralTokenReserve;\n }\n\n /// @notice Compute Uniswap v2 pair address.\n /// @param factory Address of the Uniswap v2 factory.\n /// @param tokenA Address of token A.\n /// @param tokenB Address of token B.\n /// @return Address of token pair.\n function computePairAddress(\n address factory,\n address tokenA,\n address tokenB\n ) internal pure returns (address) {\n (address token0, address token1) = tokenA < tokenB\n ? (tokenA, tokenB)\n : (tokenB, tokenA);\n\n return\n address(\n uint160(\n uint256(\n keccak256(\n abi.encodePacked(\n hex\"ff\",\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex\"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\"\n )\n )\n )\n )\n );\n }\n}\n" + }, + "contracts/test/AuctioneerStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../Auctioneer.sol\";\n\ncontract AuctioneerStub is Auctioneer {\n event AuctionEarlyClosed(uint256 transferredAmount);\n\n constructor(CoveragePool _coveragePool, address _masterAuction)\n Auctioneer(_coveragePool, _masterAuction)\n {}\n\n /// @dev This fallback function is needed by the `impersonateAccount`\n /// test helper function.\n receive() external payable {}\n\n function publicCreateAuction(\n IERC20 tokenAccepted,\n uint256 amountDesired,\n uint256 auctionLength\n ) public {\n createAuction(tokenAccepted, amountDesired, auctionLength);\n }\n\n function publicEarlyCloseAuction(Auction auction) public {\n uint256 transferredAmount = earlyCloseAuction(auction);\n emit AuctionEarlyClosed(transferredAmount);\n }\n}\n" + }, + "contracts/test/AuctionStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAuction.sol\";\n\ncontract AuctionStub is IAuction {\n uint256 public divisor;\n uint256 public offer;\n uint256 public amountOutstanding;\n\n event TakeOffer(uint256 amount);\n\n /// @dev Simulates calling Auction.takeOffer(amount) from the\n /// AuctionBidder contract.\n function takeOffer(uint256 amount) external override {\n emit TakeOffer(amount);\n }\n\n function onOffer() external view override returns (uint256, uint256) {\n return (offer, divisor);\n }\n\n function setOnOffer(uint256 _onOffer) public {\n offer = _onOffer;\n }\n\n function setDivisor(uint256 _divisor) public {\n divisor = _divisor;\n }\n\n function setAmountOutstanding(uint256 _amountOutstanding) public {\n amountOutstanding = _amountOutstanding;\n }\n}\n" + }, + "contracts/test/CoveragePoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../CoveragePoolConstants.sol\";\n\ncontract CoveragePoolStub {\n uint256 public covTotalSupply;\n\n event PortionSeized(address indexed recipient, uint256 portionToSeize);\n event AssetPoolSharesGranted(address indexed recipient, uint256 covAmount);\n\n function seizePortion(address recipient, uint256 portionToSeize) external {\n emit PortionSeized(recipient, portionToSeize);\n }\n\n function grantAssetPoolShares(address recipient, uint256 covAmount)\n external\n {\n emit AssetPoolSharesGranted(recipient, covAmount);\n }\n}\n" + }, + "contracts/test/DepositStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../RiskManagerV1.sol\";\n\n/// @dev tBTC v1 deposit interface with a subset of functions used by unit and\n/// system tests. For more information about tBTC Deposit, please see:\n/// https://github.com/keep-network/tbtc/blob/solidity/v1.1.0/solidity/contracts/deposit/Deposit.sol\ninterface ITBTCDeposit is IDeposit {\n function notifyRedemptionSignatureTimedOut() external;\n}\n\n/// @dev Stub contract simulating - in a simplified way - behavior of tBTC v1\n/// deposit when it comes to purchasing signer bonds. This is _not_\n/// a complete tBTC v1 Deposit implementation.\ncontract DepositStub is ITBTCDeposit {\n using SafeERC20 for IERC20;\n\n enum States {\n // DOES NOT EXIST YET\n START,\n // FUNDING FLOW\n AWAITING_SIGNER_SETUP,\n AWAITING_BTC_FUNDING_PROOF,\n // FAILED SETUP\n FAILED_SETUP,\n // ACTIVE\n ACTIVE, // includes courtesy call\n // REDEMPTION FLOW\n AWAITING_WITHDRAWAL_SIGNATURE,\n AWAITING_WITHDRAWAL_PROOF,\n REDEEMED,\n // SIGNER LIQUIDATION FLOW\n COURTESY_CALL,\n FRAUD_LIQUIDATION_IN_PROGRESS,\n LIQUIDATION_IN_PROGRESS,\n LIQUIDATED\n }\n\n IERC20 public tbtcToken;\n uint256 public override lotSizeTbtc;\n uint256 public override currentState;\n uint256 public override auctionValue;\n\n address public buyer;\n\n constructor(IERC20 _tbtcToken, uint256 _lotSizeTbtc) {\n tbtcToken = _tbtcToken;\n lotSizeTbtc = _lotSizeTbtc;\n currentState = 4; // active by default\n }\n\n /// @dev Needed to receive ETH bonds at deposit setup.\n receive() external payable {}\n\n function withdrawFunds() external override {\n /* solhint-disable avoid-low-level-calls */\n // slither-disable-next-line low-level-calls\n (bool success, ) = buyer.call{value: address(this).balance}(\"\");\n require(success, \"Failed to send Ether\");\n /* solhint-enable avoid-low-level-calls */\n }\n\n function purchaseSignerBondsAtAuction() external override {\n require(\n currentState == uint256(States.LIQUIDATION_IN_PROGRESS),\n \"Not in liquidation\"\n );\n currentState = uint256(States.LIQUIDATED);\n buyer = msg.sender;\n tbtcToken.safeTransferFrom(buyer, address(this), lotSizeTbtc);\n }\n\n function notifyUndercollateralizedLiquidation() external {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n function notifyRedemptionSignatureTimedOut() external override {\n currentState = uint256(States.LIQUIDATION_IN_PROGRESS);\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function setAuctionValue(uint256 _auctionValue) external {\n auctionValue = _auctionValue;\n }\n\n ///\n /// Not in tBTC deposit interface, added just for tests.\n ///\n function notifyFraud() external {\n currentState = uint256(States.FRAUD_LIQUIDATION_IN_PROGRESS);\n }\n\n function withdrawableAmount() external view override returns (uint256) {\n return address(this).balance;\n }\n}\n" + }, + "contracts/test/KeepAssetPool.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../AssetPool.sol\";\n\ncontract KeepAssetPool is AssetPool {\n constructor(\n ICollateralToken collateralToken,\n UnderwriterToken underwriterToken,\n address rewardsManager\n ) AssetPool(collateralToken, underwriterToken, rewardsManager) {}\n\n function initGovernance(ICollateralToken _collateralToken)\n internal\n override\n {\n // KEEP does not support DAO checkpoints\n }\n}\n" + }, + "contracts/test/NewAssetPoolStub.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.9;\n\nimport \"../interfaces/IAssetPool.sol\";\nimport \"../interfaces/IAssetPoolUpgrade.sol\";\nimport \"../UnderwriterToken.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract NewAssetPoolStub is IAssetPoolUpgrade {\n using SafeERC20 for IERC20;\n\n IERC20 public collateralToken;\n UnderwriterToken public newUnderwriterToken;\n\n constructor(IERC20 _collateralToken, UnderwriterToken _newUnderwriterToken)\n {\n collateralToken = _collateralToken;\n newUnderwriterToken = _newUnderwriterToken;\n }\n\n function depositFor(address underwriter, uint256 collateralAmount)\n external\n override\n {\n collateralToken.safeTransferFrom(\n msg.sender,\n address(this),\n collateralAmount\n );\n // In a real contract amount of new cov tokens will be calculated based\n // on certain rules.\n // For testing purposes, cov tokens amount = collateral tokens amount\n newUnderwriterToken.mint(underwriter, collateralAmount);\n }\n}\n" + }, + "contracts/test/RiskManagerV1Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract RiskManagerV1Stub is RiskManagerV1 {\n using SafeERC20 for IERC20;\n\n constructor(\n IERC20 _tbtcToken,\n ITBTCDepositToken _tbtcDepositToken,\n CoveragePool _coveragePool,\n ISignerBondsSwapStrategy _signerBondsSwapStrategy,\n address _masterAuction,\n uint256 _auctionLength,\n uint256 _bondAuctionThreshold\n )\n RiskManagerV1(\n _tbtcToken,\n _tbtcDepositToken,\n _coveragePool,\n _signerBondsSwapStrategy,\n _masterAuction,\n _auctionLength,\n _bondAuctionThreshold\n )\n {}\n\n function fundTbtcSurplus(uint256 amount) external {\n tbtcToken.safeTransferFrom(msg.sender, address(this), amount);\n tbtcSurplus = tbtcSurplus + amount;\n }\n}\n" + }, + "contracts/test/SignerBondsUniswapV2Stub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract SignerBondsUniswapV2Stub is SignerBondsUniswapV2 {\n constructor(IUniswapV2Router _uniswapRouter, CoveragePool _coveragePool)\n SignerBondsUniswapV2(_uniswapRouter, _coveragePool)\n {}\n}\n" + }, + "contracts/test/TBTCDepositTokenStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../RiskManagerV1.sol\";\n\ncontract TBTCDepositTokenStub is ITBTCDepositToken {\n mapping(uint256 => bool) public tokenIds;\n\n function setExists(uint256 tokenId, bool _exists) external {\n tokenIds[tokenId] = _exists;\n }\n\n function exists(uint256 tokenId) external view override returns (bool) {\n return tokenIds[tokenId];\n }\n}\n" + }, + "contracts/test/TestSimpleBeneficiary.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n// Simple beneficiary that does nothing when notified that it has received\n// tokens.\ncontract TestSimpleBeneficiary {\n function __escrowSentTokens(uint256 amount) external {}\n}\n" + }, + "contracts/test/TestToken.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/ICollateralToken.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\n\n/// @title Test ERC-20 token\n/// @dev Token with unlimited minting capacity. It does implement DAO-related\n/// functions from ICollateralToken but with just a dummy code.\n/// Implementation of DAO checkpoints is complex. Even if we used\n/// `Checkpoints` contract from `threshold-network` here, it would require\n/// implementation for `delegate(address delegator, address delegatee)` and\n/// updating checkpoints in `beforeTokenTransfer(address from, address to, uint amount)`\n/// of TestToken. Every time DAO related functions need to be tested, please\n/// use real token with proper DAO implementation, such as `T`.\ncontract TestToken is ERC20WithPermit, ICollateralToken {\n mapping(address => address) public delegatee;\n\n /* solhint-disable-next-line no-empty-blocks */\n constructor() ERC20WithPermit(\"Test Token\", \"TT\") {}\n\n function delegate(address _delegatee) external virtual {\n delegatee[msg.sender] = _delegatee;\n }\n\n function getPastVotes(address, uint256) external pure returns (uint96) {\n return 0;\n }\n}\n" + }, + "contracts/test/UniswapV2RouterStub.sol": { + "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../SignerBondsUniswapV2.sol\";\n\ncontract UniswapV2RouterStub is IUniswapV2Router {\n // Settable fake exchange rate is defined here to avoid pair logic complexity.\n // It determines how much tokens can be received for 1 ETH.\n uint256 public exchangeRate = 1;\n\n event SwapExactETHForTokensExecuted(\n uint256 amountOutMin,\n address[] path,\n address to,\n uint256 deadline\n );\n\n function setExchangeRate(uint256 _exchangeRate) external {\n exchangeRate = _exchangeRate;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one. Emits an event with input parameters.\n /// Calculates returned amounts to behave like a real method.\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable override returns (uint256[] memory amounts) {\n require(msg.value > 0, \"Amount must be grater than zero\");\n\n emit SwapExactETHForTokensExecuted(amountOutMin, path, to, deadline);\n\n amounts = new uint256[](2);\n amounts[0] = msg.value;\n amounts[1] = (msg.value * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Always assumes there are two elements in the path and\n /// WETH is the first one.\n function getAmountsOut(uint256 amountIn, address[] calldata)\n external\n view\n override\n returns (uint256[] memory amounts)\n {\n amounts = new uint256[](2);\n amounts[0] = amountIn;\n amounts[1] = (amountIn * exchangeRate * 997) / 1000; // simulate 0.3% fee\n\n return amounts;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n function factory() external pure override returns (address) {\n return 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;\n }\n\n /// @dev Returns mainnet address in order to get verifiable pair addresses.\n /* solhint-disable-next-line func-name-mixedcase */\n function WETH() external pure override returns (address) {\n return 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;\n }\n}\n" + }, + "contracts/UnderwriterToken.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\";\nimport \"@threshold-network/solidity-contracts/contracts/governance/Checkpoints.sol\";\n\n/// @title UnderwriterToken\n/// @notice Underwriter tokens represent an ownership share in the underlying\n/// collateral of the asset-specific pool. Underwriter tokens are minted\n/// when a user deposits ERC20 tokens into asset-specific pool and they\n/// are burned when a user exits the position. Underwriter tokens\n/// natively support meta transactions. Users can authorize a transfer\n/// of their underwriter tokens with a signature conforming EIP712\n/// standard instead of an on-chain transaction from their address.\n/// Anyone can submit this signature on the user's behalf by calling the\n/// permit function, as specified in EIP2612 standard, paying gas fees,\n/// and possibly performing other actions in the same transaction.\n// slither-disable-next-line missing-inheritance\ncontract UnderwriterToken is ERC20WithPermit, Checkpoints {\n /// @notice The EIP-712 typehash for the delegation struct used by\n /// `delegateBySig`.\n bytes32 public constant DELEGATION_TYPEHASH =\n keccak256(\n \"Delegation(address delegatee,uint256 nonce,uint256 deadline)\"\n );\n\n constructor(string memory _name, string memory _symbol)\n ERC20WithPermit(_name, _symbol)\n {}\n\n /// @notice Delegates votes from signatory to `delegatee`\n /// @param delegatee The address to delegate votes to\n /// @param deadline The time at which to expire the signature\n /// @param v The recovery byte of the signature\n /// @param r Half of the ECDSA signature pair\n /// @param s Half of the ECDSA signature pair\n function delegateBySig(\n address signatory,\n address delegatee,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external {\n /* solhint-disable-next-line not-rely-on-time */\n require(deadline >= block.timestamp, \"Delegation expired\");\n\n // Validate `s` and `v` values for a malleability concern described in EIP2.\n // Only signatures with `s` value in the lower half of the secp256k1\n // curve's order and `v` value of 27 or 28 are considered valid.\n require(\n uint256(s) <=\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n \"Invalid signature 's' value\"\n );\n require(v == 27 || v == 28, \"Invalid signature 'v' value\");\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n DELEGATION_TYPEHASH,\n delegatee,\n nonce[signatory]++,\n deadline\n )\n )\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n require(\n recoveredAddress != address(0) && recoveredAddress == signatory,\n \"Invalid signature\"\n );\n\n return delegate(signatory, delegatee);\n }\n\n /// @notice Delegate votes from `msg.sender` to `delegatee`.\n /// @param delegatee The address to delegate votes to\n function delegate(address delegatee) public virtual {\n return delegate(msg.sender, delegatee);\n }\n\n /// @notice Moves voting power when tokens are minted, burned or transferred.\n /// @dev Overrides the empty function from the parent contract.\n /// @param from The address that loses tokens and voting power\n /// @param to The address that gains tokens and voting power\n /// @param amount The amount of tokens and voting power that is transferred\n // slither-disable-next-line dead-code\n function beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal override {\n // When minting:\n if (from == address(0)) {\n // Does not allow to mint more than uint96 can fit. Otherwise, the\n // Checkpoint might not fit the balance.\n require(\n totalSupply + amount <= maxSupply(),\n \"Maximum total supply exceeded\"\n );\n writeCheckpoint(_totalSupplyCheckpoints, add, amount);\n }\n\n // When burning:\n if (to == address(0)) {\n writeCheckpoint(_totalSupplyCheckpoints, subtract, amount);\n }\n\n moveVotingPower(delegates(from), delegates(to), amount);\n }\n\n /// @notice Delegate votes from `delegator` to `delegatee`.\n /// @param delegator The address to delegate votes from\n /// @param delegatee The address to delegate votes to\n function delegate(address delegator, address delegatee) internal override {\n address currentDelegate = delegates(delegator);\n uint96 delegatorBalance = SafeCast.toUint96(balanceOf[delegator]);\n _delegates[delegator] = delegatee;\n\n emit DelegateChanged(delegator, currentDelegate, delegatee);\n\n moveVotingPower(currentDelegate, delegatee, delegatorBalance);\n }\n}\n" + }, + "contracts/v2/RewardsPoolV2.sol": { + "content": "// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\n// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title RewardTokenMinting\n/// @notice Implements minting of reward tokens for registered Asset Pools with\n/// a reward rate assigned individually for each Asset Pool.\n/// Each Asset Pool is assigned a relative rate establishing a way for\n/// Governance to incentivize different assets to target a particular\n/// Collateral Pool composition.\n/// @dev Contract is not meant to be deployed directly. It implements\n/// a specific part of the functionality of the RewardPool and should be\n/// used only as a RewardPool parent contract.\nabstract contract RewardTokenMinting {\n // Reward rate per Asset Pool address.\n // Reward rate is 1e18 precision number.\n mapping(address => uint256) public rewardRates;\n\n // The last time minting rates were updated.\n uint256 public lastUpdateTime;\n\n uint256 internal tokenPerRateUnitAccumulated;\n mapping(address => uint256) internal poolTokenPerRateUnitPaid;\n mapping(address => uint256) internal poolTokens;\n\n // TODO: should be internal and used by governance function with a delay\n function setRewardRate(address assetPool, uint256 rewardRate) external {\n updateReward(assetPool);\n rewardRates[assetPool] = rewardRate;\n }\n\n function earned(address assetPool) public view returns (uint256) {\n return\n rewardRates[assetPool] *\n (tokenPerRateUnit() - poolTokenPerRateUnitPaid[assetPool]) +\n poolTokens[assetPool];\n }\n\n function updateReward(address assetPool) internal {\n tokenPerRateUnitAccumulated = tokenPerRateUnit();\n /* solhint-disable-next-line not-rely-on-time */\n lastUpdateTime = block.timestamp;\n poolTokens[assetPool] = earned(assetPool);\n poolTokenPerRateUnitPaid[assetPool] = tokenPerRateUnitAccumulated;\n }\n\n function tokenPerRateUnit() internal view returns (uint256) {\n return\n tokenPerRateUnitAccumulated +\n (/* solhint-disable-next-line not-rely-on-time */\n block.timestamp - lastUpdateTime);\n }\n}\n\n/// @title RewardsPool\n/// @notice Rewards Pool is a contract that accepts arbitrary assets and mints\n/// a single reward token. Recipients of the reward token can at any\n/// time turn it in for a portion of the rewards in the pool.\n/// A rewards pool maintains a governable list of recipients and\n/// relative reward rates. For example, a rewards pool might have two\n/// recipients — a WETH Asset Pool, and a WBTC asset pool, with\n/// respective reward rates of 1 and 2. Rewards tokens are minted\n/// constantly over time and distributed according to the relative\n/// reward rates. Reward rates allows establishing a way for Governance\n/// to incentivize different assets to target a particular Collateral\n/// Pool composition.\ncontract RewardPoolV2 is RewardTokenMinting {\n // TODO: Add function to update reward rate with a governance delay.\n // TODO: Allow to withdraw rewards based on the amount of reward tokens.\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": false, + "runs": 200 + }, + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "storageLayout", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/export.json b/export.json new file mode 100644 index 00000000..f28033d1 --- /dev/null +++ b/export.json @@ -0,0 +1,3287 @@ +{ + "name": "mainnet", + "chainId": "1", + "contracts": { + "T": { + "address": "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cachedChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cachedDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32", + "name": "pos", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "fromBlock", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct Checkpoints.Checkpoint", + "name": "checkpoint", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signatory", + "type": "address" + }, + { + "internalType": "address", + "name": "delegatee", + "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" + } + ], + "name": "delegateBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastTotalSupply", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "UnderwriterToken": { + "address": "0x007854FdCC9c6F748b435e63745599fb1A0dF843", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "fromDelegate", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "toDelegate", + "type": "address" + } + ], + "name": "DelegateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "delegate", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "previousBalance", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newBalance", + "type": "uint256" + } + ], + "name": "DelegateVotesChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cachedChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cachedDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint32", + "name": "pos", + "type": "uint32" + } + ], + "name": "checkpoints", + "outputs": [ + { + "components": [ + { + "internalType": "uint32", + "name": "fromBlock", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "votes", + "type": "uint96" + } + ], + "internalType": "struct Checkpoints.Checkpoint", + "name": "checkpoint", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "delegatee", + "type": "address" + } + ], + "name": "delegate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "signatory", + "type": "address" + }, + { + "internalType": "address", + "name": "delegatee", + "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" + } + ], + "name": "delegateBySig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "delegates", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastTotalSupply", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "numCheckpoints", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "AssetPool": { + "address": "0x21b86FDC93F23fD52022A283828dF8E808D28D5D", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ICollateralToken", + "name": "_collateralToken", + "type": "address" + }, + { + "internalType": "contract UnderwriterToken", + "name": "_underwriterToken", + "type": "address" + }, + { + "internalType": "address", + "name": "rewardsManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newAssetPool", + "type": "address" + } + ], + "name": "ApprovedAssetPoolUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "collateralAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "AssetPoolUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "cancelledAssetPool", + "type": "address" + } + ], + "name": "CancelledAssetPoolUpgrade", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "CoverageClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "Deposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalDelay", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalDelayUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalDelay", + "type": "uint256" + } + ], + "name": "WithdrawalDelayUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "underwriter", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalTimeout", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "WithdrawalTimeoutUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawalTimeout", + "type": "uint256" + } + ], + "name": "WithdrawalTimeoutUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "approveNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newWithdrawalDelay", + "type": "uint256" + } + ], + "name": "beginWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newWithdrawalTimeout", + "type": "uint256" + } + ], + "name": "beginWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cancelNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "claim", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "contract ICollateralToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "underwriter", + "type": "address" + } + ], + "name": "completeWithdrawal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToDeposit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minAmountToMint", + "type": "uint256" + } + ], + "name": "depositWithMin", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getRemainingWithdrawalDelayUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRemainingWithdrawalTimeoutUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "grantShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "initiateWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "newAssetPool", + "outputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newWithdrawalDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newWithdrawalTimeout", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingWithdrawal", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardsPool", + "outputs": [ + { + "internalType": "contract RewardsPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underwriterToken", + "outputs": [ + { + "internalType": "contract UnderwriterToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "upgradeToNewAssetPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalDelayChangeInitiated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalGovernanceDelay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "withdrawalInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalTimeout", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalTimeoutChangeInitiated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "RewardsPool": { + "address": "0xD4FD81D7a16320Ca029389a728327918bdc086b6", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_assetPool", + "type": "address" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardToppedUp", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "RewardWithdrawn", + "type": "event" + }, + { + "inputs": [], + "name": "DURATION", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "assetPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "earned", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "intervalFinish", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastTimeRewardApplicable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastUpdateTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardAccumulated", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "name": "topUpReward", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "CoveragePool": { + "address": "0x7D7B622C07f216d99eFc3EfB9Cf71872F46D811A", + "abi": [ + { + "inputs": [ + { + "internalType": "contract AssetPool", + "name": "_assetPool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerApprovalCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerApprovalStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "riskManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "RiskManagerUnapproved", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "portionToSeize", + "type": "uint256" + } + ], + "name": "amountToSeize", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "approveFirstRiskManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IAssetPoolUpgrade", + "name": "_newAssetPool", + "type": "address" + } + ], + "name": "approveNewAssetPoolUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "approvedRiskManagers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "assetPool", + "outputs": [ + { + "internalType": "contract AssetPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "beginRiskManagerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newWithdrawalDelay", + "type": "uint256" + } + ], + "name": "beginWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newWithdrawalTimeout", + "type": "uint256" + } + ], + "name": "beginWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "contract ICollateralToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "finalizeRiskManagerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeWithdrawalTimeoutUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "firstRiskManagerApproved", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getPastVotes", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "getRemainingRiskManagerApprovalTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "covAmount", + "type": "uint256" + } + ], + "name": "grantAssetPoolShares", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "riskManagerApprovalTimestamps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountToSeize", + "type": "uint256" + } + ], + "name": "seizeAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "portionToSeize", + "type": "uint256" + } + ], + "name": "seizePortion", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "riskManager", + "type": "address" + } + ], + "name": "unapproveRiskManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "underwriterToken", + "outputs": [ + { + "internalType": "contract UnderwriterToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ] + }, + "BatchedPhasedEscrow": { + "address": "0xa96AD7889ef29D4978e00B0cB31cD41F77bFD8A6", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "beneficiary", + "type": "address" + } + ], + "name": "BeneficiaryApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldDrawee", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newDrawee", + "type": "address" + } + ], + "name": "DraweeRoleTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "beneficiary", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "TokensWithdrawn", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract", + "name": "_beneficiary", + "type": "address" + } + ], + "name": "approveBeneficiary", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract[]", + "name": "beneficiaries", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "name": "batchedWithdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "drawee", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IBeneficiaryContract", + "name": "_beneficiary", + "type": "address" + } + ], + "name": "isBeneficiaryApproved", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newDrawee", + "type": "address" + } + ], + "name": "setDrawee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + }, + "CoveragePoolBeneficiary": { + "address": "0xE8372cab8d06a607E374cC549d8F68648ef67263", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + }, + { + "internalType": "contract RewardsPool", + "name": "_rewards", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "__escrowSentTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewards", + "outputs": [ + { + "internalType": "contract RewardsPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] + } + } +} \ No newline at end of file